Skip to content

Commit b59818f

Browse files
committed
Comments and other minor changes
1 parent 2079f9f commit b59818f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

qiling/extensions/trace.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
# More info, please refer to https://github.com/qilingframework/qiling/pull/765
44

5-
65
from collections import deque
76
from typing import Deque, Iterable, Iterator, Mapping, Tuple
87

9-
from capstone import Cs, CsInsn, CS_OP_IMM, CS_OP_MEM, CS_OP_REG
8+
from capstone import Cs, CsInsn, CS_ARCH_X86, CS_OP_IMM, CS_OP_MEM, CS_OP_REG
109
from capstone.x86 import X86Op
1110
from capstone.x86_const import X86_INS_LEA, X86_REG_INVALID, X86_REG_RIP
1211

@@ -16,7 +15,7 @@
1615

1716
# <WORKAROUND>
1817
def __uc2_workaround() -> Mapping[int, int]:
19-
"""Starting from Unicron2, Unicron and Capstone Intel registers definitions are
18+
"""Starting from Unicorn2, Unicorn and Capstone Intel registers definitions are
2019
no longer aligned and cannot be used interchangebly. This temporary workaround
2120
maps capstone x86 registers definitions to unicorn x86 registers definitions.
2221
@@ -47,6 +46,7 @@ def __get_trace_records(ql: Qiling, address: int, size: int, md: Cs) -> Iterator
4746
# unicorn denotes unsupported instructions by a magic size value. though these instructions
4847
# are not emulated, capstone can still parse them.
4948
if size == 0xf1f1f1f1:
49+
# note that invalid instructions will generate a StopIteration exception here
5050
yield next(__get_trace_records(ql, address, 16, md))
5151
return
5252

@@ -162,8 +162,8 @@ def enable_full_trace(ql: Qiling):
162162

163163
# show trace lines in a darker color so they would be easily distinguished from
164164
# ordinary log records
165-
DarkGray = "\x1b[90m"
166-
Default = "\x1b[39m"
165+
faded_color = "\033[2m"
166+
reset_color = "\033[0m"
167167

168168
def __trace_hook(ql: Qiling, address: int, size: int):
169169
"""[internal] Trace hook callback.
@@ -172,7 +172,7 @@ def __trace_hook(ql: Qiling, address: int, size: int):
172172
for record in __get_trace_records(ql, address, size, md):
173173
line = __to_trace_line(record, symsmap)
174174

175-
ql.log.debug(f'{DarkGray}{line}{Default}')
175+
ql.log.debug(f'{faded_color}{line}{reset_color}')
176176

177177
ql.hook_code(__trace_hook)
178178

0 commit comments

Comments
 (0)