* [PATCH] scripts/qemugdb/mtree.py: fix error of treating decimal as hexadecimal
@ 2024-07-21 6:50 Hawkins Jiawei
0 siblings, 0 replies; only message in thread
From: Hawkins Jiawei @ 2024-07-21 6:50 UTC (permalink / raw)
To: open list:All patches CC here
Cc: alex.bennee, Hawkins Jiawei, open list:All patches CC here
The mtree command throws the following exception:
Python Exception <class 'OverflowError'>: int too big to convert
Error occurred in Python: int too big to convert
The mtree command first converts `ptr['size']` to a python integer
using int128(), then calculates the memory end address by
`int(addr + (size - 1))`. Considering that `addr` is of type
gdb.TYPE_CODE_INT and `size` is a python integer, python tries to
convert `size` from a python integer to gdb.TYPE_CODE_INT
in order to calculate the address.
Yet the problem is that int128() incorrectly treating the deciaml
as hexadecimal, resulting in `ptr['size']` with
18446744073709551616 vlaue being treated as 0x18446744073709551616,
which is too big to convert.
This patch solves the problem by fixing the incorrect treatment
in int128(). As a result, gdb can display the output correctly
as follows:
0000000000000000-ffffffffffffffff system (I/O) (@ 0x555557273400)
00000000fee00000-00000000feefffff kvm-apic-msi (I/O) (@ 0x555557354ca0)
...
Fixes: 8037fa55ac ("scripts/qemugdb/mtree.py: fix up mtree dump")
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
scripts/qemugdb/mtree.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/qemugdb/mtree.py b/scripts/qemugdb/mtree.py
index 8fe42c3c12..c1557d44fa 100644
--- a/scripts/qemugdb/mtree.py
+++ b/scripts/qemugdb/mtree.py
@@ -25,7 +25,7 @@ def int128(p):
if p.type.code == gdb.TYPE_CODE_STRUCT:
return int(p['lo']) + (int(p['hi']) << 64)
else:
- return int(("%s" % p), 16)
+ return int("%s" % p)
class MtreeCommand(gdb.Command):
'''Display the memory tree hierarchy'''
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-07-21 6:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21 6:50 [PATCH] scripts/qemugdb/mtree.py: fix error of treating decimal as hexadecimal Hawkins Jiawei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).