forked from nuttx/nuttx-update
get g_tcbinfo just use elf memory
g_tcbinfo is const data, thus elf memmory is more reliable than other method in case of corruption etc. Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
c5276f4244
commit
6554ed4d66
1 changed files with 10 additions and 5 deletions
|
@ -763,8 +763,9 @@ class GDBStub:
|
||||||
|
|
||||||
self.put_gdb_packet(b"OK")
|
self.put_gdb_packet(b"OK")
|
||||||
|
|
||||||
def get_mem_region(self, addr):
|
def get_mem_region(self, addr, mem_regions=None):
|
||||||
for mem in self.mem_regions:
|
mem_regions = mem_regions or self.mem_regions
|
||||||
|
for mem in mem_regions:
|
||||||
if mem["start"] <= addr < mem["end"]:
|
if mem["start"] <= addr < mem["end"]:
|
||||||
return mem
|
return mem
|
||||||
|
|
||||||
|
@ -821,7 +822,10 @@ class GDBStub:
|
||||||
self.put_gdb_packet(b"OK")
|
self.put_gdb_packet(b"OK")
|
||||||
|
|
||||||
def parse_thread(self):
|
def parse_thread(self):
|
||||||
def unpack_data(addr, fmt):
|
def unpack_data(addr, fmt, from_elf=False):
|
||||||
|
if from_elf:
|
||||||
|
r = self.get_mem_region(addr, self.elffile.get_memories())
|
||||||
|
else:
|
||||||
r = self.get_mem_region(addr)
|
r = self.get_mem_region(addr)
|
||||||
offset = addr - r["start"]
|
offset = addr - r["start"]
|
||||||
data = r["data"]
|
data = r["data"]
|
||||||
|
@ -846,6 +850,7 @@ class GDBStub:
|
||||||
unpacked_data = unpack_data(
|
unpacked_data = unpack_data(
|
||||||
self.elffile.symbol["g_tcbinfo"]["st_value"],
|
self.elffile.symbol["g_tcbinfo"]["st_value"],
|
||||||
TCBINFO_FMT,
|
TCBINFO_FMT,
|
||||||
|
True,
|
||||||
)
|
)
|
||||||
tcbinfo = {
|
tcbinfo = {
|
||||||
"pid_off": int(unpacked_data[0]),
|
"pid_off": int(unpacked_data[0]),
|
||||||
|
@ -907,7 +912,7 @@ class GDBStub:
|
||||||
def parse_regs_to_gdb(regs):
|
def parse_regs_to_gdb(regs):
|
||||||
gdb_regs = []
|
gdb_regs = []
|
||||||
for i in range(0, tcbinfo["regs_num"]):
|
for i in range(0, tcbinfo["regs_num"]):
|
||||||
reg_off = int(unpack_data(tcbinfo["reg_off"] + i * 2, "<H")[0])
|
reg_off = int(unpack_data(tcbinfo["reg_off"] + i * 2, "<H", True)[0])
|
||||||
if reg_off == UINT16_MAX:
|
if reg_off == UINT16_MAX:
|
||||||
gdb_regs.append(b"x")
|
gdb_regs.append(b"x")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue