mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
Merge remote-tracking branch
'origin/GP-5120_d-millar_inferior_thread--SQUASHED' (Closes #7176)
This commit is contained in:
commit
c9a51029bb
@ -98,11 +98,11 @@ class InferiorState(object):
|
|||||||
frame, util.get_register_descs(frame.architecture(), 'general'))
|
frame, util.get_register_descs(frame.architecture(), 'general'))
|
||||||
try:
|
try:
|
||||||
commands.putmem("$pc", "1", from_tty=False)
|
commands.putmem("$pc", "1", from_tty=False)
|
||||||
except MemoryError as e:
|
except gdb.MemoryError as e:
|
||||||
print(f"Couldn't record page with PC: {e}")
|
print(f"Couldn't record page with PC: {e}")
|
||||||
try:
|
try:
|
||||||
commands.putmem("$sp", "1", from_tty=False)
|
commands.putmem("$sp", "1", from_tty=False)
|
||||||
except MemoryError as e:
|
except gdb.MemoryError as e:
|
||||||
print(f"Couldn't record page with SP: {e}")
|
print(f"Couldn't record page with SP: {e}")
|
||||||
self.visited.add(hashable_frame)
|
self.visited.add(hashable_frame)
|
||||||
# NB: These commands (put_modules/put_regions) will fail if the process is running
|
# NB: These commands (put_modules/put_regions) will fail if the process is running
|
||||||
@ -281,6 +281,11 @@ def on_register_changed(event):
|
|||||||
|
|
||||||
@log_errors
|
@log_errors
|
||||||
def on_cont(event):
|
def on_cont(event):
|
||||||
|
if event.inferior_thread is None:
|
||||||
|
# thread-based state computed in record_continued will
|
||||||
|
# fail in some versions of gdb because the current_thread is None
|
||||||
|
# and gdb fails to test for None before switching
|
||||||
|
return
|
||||||
if (HOOK_STATE.check_skip_continue()):
|
if (HOOK_STATE.check_skip_continue()):
|
||||||
return
|
return
|
||||||
inf = gdb.selected_inferior()
|
inf = gdb.selected_inferior()
|
||||||
|
@ -196,18 +196,12 @@ MODULE_INFO_READER = _choose_module_info_reader()
|
|||||||
|
|
||||||
|
|
||||||
REGIONS_CMD = 'info proc mappings'
|
REGIONS_CMD = 'info proc mappings'
|
||||||
REGION_PATTERN_V8 = re.compile("\\s*" +
|
REGION_PATTERN = re.compile("\\s*" +
|
||||||
"0x(?P<start>[0-9,A-F,a-f]+)\\s+" +
|
|
||||||
"0x(?P<end>[0-9,A-F,a-f]+)\\s+" +
|
|
||||||
"0x(?P<size>[0-9,A-F,a-f]+)\\s+" +
|
|
||||||
"0x(?P<offset>[0-9,A-F,a-f]+)\\s+" +
|
|
||||||
"(?P<objfile>.*)")
|
|
||||||
REGION_PATTERN_V12 = re.compile("\\s*" +
|
|
||||||
"0x(?P<start>[0-9,A-F,a-f]+)\\s+" +
|
"0x(?P<start>[0-9,A-F,a-f]+)\\s+" +
|
||||||
"0x(?P<end>[0-9,A-F,a-f]+)\\s+" +
|
"0x(?P<end>[0-9,A-F,a-f]+)\\s+" +
|
||||||
"0x(?P<size>[0-9,A-F,a-f]+)\\s+" +
|
"0x(?P<size>[0-9,A-F,a-f]+)\\s+" +
|
||||||
"0x(?P<offset>[0-9,A-F,a-f]+)\\s+" +
|
"0x(?P<offset>[0-9,A-F,a-f]+)\\s+" +
|
||||||
"(?P<perms>[rwsxp\\-]+)\\s+" +
|
"((?P<perms>[rwsxp\\-]+)?\\s+)?" +
|
||||||
"(?P<objfile>.*)")
|
"(?P<objfile>.*)")
|
||||||
|
|
||||||
|
|
||||||
@ -216,6 +210,9 @@ class Region(namedtuple('BaseRegion', ['start', 'end', 'offset', 'perms', 'objfi
|
|||||||
|
|
||||||
|
|
||||||
class RegionInfoReader(object):
|
class RegionInfoReader(object):
|
||||||
|
cmd = REGIONS_CMD
|
||||||
|
region_pattern = REGION_PATTERN
|
||||||
|
|
||||||
def region_from_line(self, line):
|
def region_from_line(self, line):
|
||||||
mat = self.region_pattern.fullmatch(line)
|
mat = self.region_pattern.fullmatch(line)
|
||||||
if mat is None:
|
if mat is None:
|
||||||
@ -253,28 +250,13 @@ class RegionInfoReader(object):
|
|||||||
return False, None
|
return False, None
|
||||||
return True, new_regions
|
return True, new_regions
|
||||||
|
|
||||||
|
|
||||||
class RegionInfoReaderV8(RegionInfoReader):
|
|
||||||
cmd = REGIONS_CMD
|
|
||||||
region_pattern = REGION_PATTERN_V8
|
|
||||||
|
|
||||||
def get_region_perms(self, mat):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class RegionInfoReaderV12(RegionInfoReader):
|
|
||||||
cmd = REGIONS_CMD
|
|
||||||
region_pattern = REGION_PATTERN_V12
|
|
||||||
|
|
||||||
def get_region_perms(self, mat):
|
def get_region_perms(self, mat):
|
||||||
return mat['perms']
|
return mat['perms']
|
||||||
|
|
||||||
|
|
||||||
def _choose_region_info_reader():
|
def _choose_region_info_reader():
|
||||||
if 8 <= GDB_VERSION.major < 12:
|
if 8 <= GDB_VERSION.major:
|
||||||
return RegionInfoReaderV8()
|
return RegionInfoReader()
|
||||||
elif GDB_VERSION.major >= 12:
|
|
||||||
return RegionInfoReaderV12()
|
|
||||||
else:
|
else:
|
||||||
raise gdb.GdbError(
|
raise gdb.GdbError(
|
||||||
"GDB version not recognized by ghidragdb: " + GDB_VERSION.full)
|
"GDB version not recognized by ghidragdb: " + GDB_VERSION.full)
|
||||||
|
Loading…
Reference in New Issue
Block a user