이유는 잘못된 답을 얻고있다 :gdb python : gdb.value에서 산술 연산을 수행하는 방법은 무엇입니까? 산술 연산을하는 동안
(gdb) python address = gdb.parse_and_eval('&(((struct my_struct *)next->priv).wait_list)')
(gdb) python print address
0x410027a00728
(gdb) python offset = gdb.parse_and_eval('&((struct wait_list_t *)0)->list')
(gdb) python print offset
0x0
(gdb) python diff = address - offset
gdb) python print diff
0x410027a0072
출력 0x410027a00728
을해야합니다 동안. 나는
(gdb) python y = hex(long(address))
(gdb) python print y
0x410027A14FF0L
(gdb) python z = hex(long(offset))
(gdb) python print z
0x0L
(gdb) python diff = y - z
Traceback (most recent call last):
File "<string>", line 1, in ?
TypeError: unsupported operand type(s) for -: 'str' and 'str'
Error while executing Python code.
이 작업을 수행하기 위해 어떤 대안이 있는가 또한이 시도 주소의 유형을 확인하고
(gdb) python print address.type
struct list_head *
(gdb) python print offset.type
struct list_head *
에 의해 상쇄?
'python diff = long (주소) - 긴 (오프셋)'이 작동합니까? – user4815162342
고마워. :-) 그것은 내가 원한 정확하게 작동했다. –