From f3e2b532e1d29af8b2840bf0d29e7772d93270c1 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 30 Jul 2024 18:06:31 +0800 Subject: [PATCH] minidumpserver.py:support rawfile load Signed-off-by: anjiahao --- tools/minidumpserver.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/tools/minidumpserver.py b/tools/minidumpserver.py index db89a07cef..e2c404c4b9 100755 --- a/tools/minidumpserver.py +++ b/tools/minidumpserver.py @@ -430,13 +430,39 @@ class DumpLogFile: return self.__memories +class RawMemoryFile: + def __init__(self, rawfile): + self.__memories = list() + + if rawfile is None: + return + + for raw in rawfile: + file, start = raw.split(":") + start = int(start, 0) + + size = os.path.getsize(file) + with open(file, "rb") as f: + data = f.read(size) + self.__memories.append(pack_memory(start, start + len(data), data)) + + def get_memories(self): + return self.__memories + + class GDBStub: - def __init__(self, logfile: DumpLogFile, elffile: DumpELFFile): + def __init__( + self, logfile: DumpLogFile, elffile: DumpELFFile, rawfile: RawMemoryFile + ): self.logfile = logfile self.elffile = elffile self.socket = None self.gdb_signal = GDB_SIGNAL_DEFAULT - self.mem_regions = self.elffile.get_memories() + self.logfile.get_memories() + self.mem_regions = ( + self.elffile.get_memories() + + self.logfile.get_memories() + + rawfile.get_memories() + ) self.reg_digits = elffile.xlen() // 4 self.reg_fmt = "