[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] scripts/qemugdb/mtree.py: fix error of treating decimal as hexad
From: |
Hawkins Jiawei |
Subject: |
[PATCH] scripts/qemugdb/mtree.py: fix error of treating decimal as hexadecimal |
Date: |
Sun, 21 Jul 2024 14:50:47 +0800 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] scripts/qemugdb/mtree.py: fix error of treating decimal as hexadecimal,
Hawkins Jiawei <=