Skip to content

Commit c762be5

Browse files
committed
CMD: add option to stats to show opcode distribution
1 parent b3fec98 commit c762be5

File tree

13 files changed

+94
-8
lines changed

13 files changed

+94
-8
lines changed

chb/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chbversion: str = "0.3.0-20250403"
1+
chbversion: str = "0.3.0-20250404"

chb/arm/ARMInstruction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def xdata(self) -> InstrXData:
106106

107107
@property
108108
def mnemonic_stem(self) -> str:
109-
return self.opcode.mnemonic
109+
return self.opcode.mnemonic_stem
110110

111111
@property
112112
def mnemonic(self) -> str:

chb/arm/ARMOpcode.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ def __init__(
241241
def mnemonic(self) -> str:
242242
return self.tags[0]
243243

244+
@property
245+
def mnemonic_stem(self) -> str:
246+
return self.mnemonic
247+
244248
def annotation(self, xdata: InstrXData) -> str:
245249
return self.__str__()
246250

chb/arm/opcodes/ARMLogicalShiftLeft.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def mnemonic_extension(self) -> str:
135135
def opargs(self) -> List[ARMOperand]:
136136
return [self.armd.arm_operand(i) for i in self.args[1:-1]]
137137

138+
@property
139+
def mnemonic_stem(self) -> str:
140+
return self.tags[0]
141+
138142
@property
139143
def mnemonic(self) -> str:
140144
mnem = self.tags[0]

chb/arm/opcodes/ARMLogicalShiftRight.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def operands(self) -> List[ARMOperand]:
127127
def opargs(self) -> List[ARMOperand]:
128128
return [self.armd.arm_operand(i) for i in self.args[1:-1]]
129129

130+
@property
131+
def mnemonic_stem(self) -> str:
132+
return self.tags[0]
133+
130134
@property
131135
def mnemonic(self) -> str:
132136
mnem = self.tags[0]

chb/arm/opcodes/ARMMove.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ def __init__(self, d: "ARMDictionary", ixval: IndexedTableValue) -> None:
124124
ARMOpcode.__init__(self, d, ixval)
125125
self.check_key(2, 5, "Move")
126126

127+
@property
128+
def mnemonic_stem(self) -> str:
129+
return self.tags[0]
130+
127131
@property
128132
def mnemonic(self) -> str:
129133
return (

chb/arm/opcodes/ARMReverseSubtract.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def operands(self) -> List[ARMOperand]:
158158
def opargs(self) -> List[ARMOperand]:
159159
return [self.armd.arm_operand(i) for i in self.args[1: -1]]
160160

161+
@property
162+
def mnemonic_stem(self) -> str:
163+
return self.tags[0]
164+
161165
@property
162166
def mnemonic(self) -> str:
163167
mnem = self.tags[0]

chb/arm/opcodes/ARMSwapByte.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(
5656
d: "ARMDictionary",
5757
ixval: IndexedTableValue) -> None:
5858
ARMOpcode.__init__(self, d, ixval)
59-
self.check_key(2, 3, "SwapByte")
59+
self.check_key(2, 4, "SwapByte")
6060

6161
@property
6262
def operands(self) -> List[ARMOperand]:

chb/arm/opcodes/opcodes_covered.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"legend": {
33
"AST": "ast support",
4+
"ASTC": "support for lifting to C code",
45
"D": "disassembled",
56
"DA": "destination abstracted",
67
"E": "encoding in bits",
@@ -162,6 +163,7 @@
162163
]
163164
},
164165
"AST": "Y",
166+
"ASTC": "Y",
165167
"TC": "Y",
166168
"A": "Y"
167169
},
@@ -195,6 +197,7 @@
195197
}
196198
]
197199
},
200+
"ASTC": "Y",
198201
"TC": "Y",
199202
"A": "Y"
200203
},
@@ -314,6 +317,7 @@
314317
]
315318
},
316319
"AST": "Y",
320+
"ASTC": "Y",
317321
"TC": "Y",
318322
"A": "Y"
319323
},
@@ -357,6 +361,7 @@
357361
]
358362
},
359363
"AST": "Y",
364+
"ASTC": "Y",
360365
"TC": "Y",
361366
"A": "Y"
362367
},
@@ -397,6 +402,7 @@
397402
]
398403
},
399404
"AST": "Y",
405+
"ASTC": "Y",
400406
"TC": "Y"
401407
},
402408
"BFC": {
@@ -477,6 +483,7 @@
477483
]
478484
},
479485
"A": "Y",
486+
"ASTC": "Y",
480487
"TC": "DA"
481488
},
482489
"BKPT": {
@@ -511,6 +518,7 @@
511518
]
512519
},
513520
"AST": "Y",
521+
"ASTC": "Y",
514522
"TC": "Y",
515523
"A": "Y"
516524
},
@@ -545,6 +553,7 @@
545553
]
546554
},
547555
"AST": "Y",
556+
"ASTC": "Y",
548557
"TC": "Y",
549558
"A": "Y"
550559
},
@@ -565,6 +574,7 @@
565574
}
566575
]
567576
},
577+
"ASTC": "Y",
568578
"TC": "Y",
569579
"A": "Y"
570580
},
@@ -710,6 +720,7 @@
710720
]
711721
},
712722
"AST": "Y",
723+
"ASTC": "Y",
713724
"TC": "Y",
714725
"A": "Y"
715726
},
@@ -794,6 +805,7 @@
794805
}
795806
]
796807
},
808+
"ASTC": "Y",
797809
"TC": "DA"
798810
},
799811
"FLDMIAX": {
@@ -926,6 +938,7 @@
926938
}
927939
]
928940
},
941+
"ASTC": "Y",
929942
"TC": "Y"
930943
},
931944
"LDMDA": {
@@ -1038,6 +1051,7 @@
10381051
]
10391052
},
10401053
"AST": "Y",
1054+
"ASTC": "Y",
10411055
"TC": "Y"
10421056
},
10431057
"LDRB": {
@@ -1186,6 +1200,7 @@
11861200
]
11871201
},
11881202
"AST": "Y",
1203+
"ASTC":" Y",
11891204
"TC": "Y"
11901205
},
11911206
"LDRSB": {
@@ -1464,6 +1479,7 @@
14641479
]
14651480
},
14661481
"AST": "Y",
1482+
"ASTC": "Y",
14671483
"TC": "Y"
14681484
},
14691485
"MOVT": {
@@ -1588,6 +1604,7 @@
15881604
}
15891605
]
15901606
},
1607+
"ASTC": "Y",
15911608
"TC": "Y"
15921609
},
15931610
"MVN": {
@@ -1723,6 +1740,7 @@
17231740
}
17241741
]
17251742
},
1743+
"ASTC": "Y",
17261744
"TC": "DA",
17271745
"A": "Y"
17281746
},
@@ -1805,6 +1823,7 @@
18051823
]
18061824
},
18071825
"AST": "Y",
1826+
"ASTC": "Y",
18081827
"TC": "Y"
18091828
},
18101829
"PUSH": {
@@ -2067,6 +2086,7 @@
20672086
]
20682087
},
20692088
"AST": "Y",
2089+
"ASTC": "Y",
20702090
"TC": "Y"
20712091
},
20722092
"RSC": {
@@ -2707,6 +2727,7 @@
27072727
}
27082728
]
27092729
},
2730+
"ASTC": "Y",
27102731
"TC": "Y"
27112732
},
27122733
"STMDA": {
@@ -2809,6 +2830,7 @@
28092830
]
28102831
},
28112832
"AST": "Y",
2833+
"ASTC": "Y",
28122834
"TC": "Y"
28132835
},
28142836
"STRB": {
@@ -2855,6 +2877,7 @@
28552877
]
28562878
},
28572879
"AST": "Y",
2880+
"ASTC": "Y",
28582881
"TC": "Y"
28592882
},
28602883
"STRD": {
@@ -2949,6 +2972,7 @@
29492972
]
29502973
},
29512974
"AST": "Y",
2975+
"ASTC": "Y",
29522976
"TC": "Y"
29532977
},
29542978
"SUB": {
@@ -3028,6 +3052,7 @@
30283052
]
30293053
},
30303054
"AST": "Y",
3055+
"ASTC": "Y",
30313056
"TC": "Y"
30323057
},
30333058
"SVC": {

chb/cmdline/chkx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def parse() -> argparse.Namespace:
619619
"--hide",
620620
help="name(s) of columns to hide",
621621
nargs="*",
622-
choices=["time", "esp","reads","writes", "unrc"],
622+
choices=["time", "esp","reads","writes", "unrc", "blocks", "instrs"],
623623
default=[])
624624
resultsstats.add_argument(
625625
"--loglevel", "-log",

0 commit comments

Comments
 (0)