mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
minidumpserver.py:support rawfile load
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
+37
-3
@@ -430,13 +430,39 @@ class DumpLogFile:
|
|||||||
return self.__memories
|
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:
|
class GDBStub:
|
||||||
def __init__(self, logfile: DumpLogFile, elffile: DumpELFFile):
|
def __init__(
|
||||||
|
self, logfile: DumpLogFile, elffile: DumpELFFile, rawfile: RawMemoryFile
|
||||||
|
):
|
||||||
self.logfile = logfile
|
self.logfile = logfile
|
||||||
self.elffile = elffile
|
self.elffile = elffile
|
||||||
self.socket = None
|
self.socket = None
|
||||||
self.gdb_signal = GDB_SIGNAL_DEFAULT
|
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_digits = elffile.xlen() // 4
|
||||||
self.reg_fmt = "<I" if elffile.xlen() <= 32 else "<Q"
|
self.reg_fmt = "<I" if elffile.xlen() <= 32 else "<Q"
|
||||||
|
|
||||||
@@ -674,6 +700,12 @@ def arg_parser():
|
|||||||
help="provided a custom GDB init command, automatically start GDB sessions and input what you provide. "
|
help="provided a custom GDB init command, automatically start GDB sessions and input what you provide. "
|
||||||
f"if you don't provide any command, it will use default command [{DEFAULT_GDB_INIT_CMD}]. ",
|
f"if you don't provide any command, it will use default command [{DEFAULT_GDB_INIT_CMD}]. ",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-r",
|
||||||
|
"--rawfile",
|
||||||
|
nargs="*",
|
||||||
|
help="rawfile is a binary file, args format like ram.bin:0x10000 ...",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--debug",
|
"--debug",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@@ -771,7 +803,9 @@ def main(args):
|
|||||||
logger.error("Architecture unknown, exiting...")
|
logger.error("Architecture unknown, exiting...")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
gdb_stub = GDBStub(log, elf)
|
raw = RawMemoryFile(args.rawfile)
|
||||||
|
|
||||||
|
gdb_stub = GDBStub(log, elf, raw)
|
||||||
|
|
||||||
gdbserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
gdbserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user