Skip to content

Commit

Permalink
Set correct parsing to gdb_get_location_from_symbol (#1037)
Browse files Browse the repository at this point in the history
## Description

As stated in the comments `info symbol` returns "`<symbol_name> +
<offset>`" with spaces around the `+`. The current split leaves a space
in front of the offset which makes .isdigit() return False.
  • Loading branch information
Angelo942 committed Jan 4, 2024
1 parent d4b849e commit deeab2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gef.py
Expand Up @@ -2021,8 +2021,8 @@ def gdb_get_location_from_symbol(address: int) -> Optional[Tuple[str, int]]:
# gdb outputs symbols with format: "<symbol_name> + <offset> in section <section_name> of <file>",
# here, we are only interested in symbol name and offset.
i = sym.find(" in section ")
sym = sym[:i].split("+")
name, offset = sym[0].strip(), 0
sym = sym[:i].split(" + ")
name, offset = sym[0], 0
if len(sym) == 2 and sym[1].isdigit():
offset = int(sym[1])
return name, offset
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/xinfo.py
Expand Up @@ -20,8 +20,8 @@ def test_cmd_xinfo(self):
self.assertTrue(len(res.splitlines()) >= 7)

def test_cmd_xinfo_on_class(self):
cmd = "xinfo $pc"
cmd = "xinfo $pc+4"
target = debug_target("class")
res = gdb_run_silent_cmd(cmd, target=target, before=["b B<TraitA, TraitB>::Run()"])
res = gdb_run_silent_cmd(cmd, target=target, before=["b *'B<TraitA, TraitB>::Run'"])
self.assertNoException(res)
self.assertIn("Symbol: B<TraitA, TraitB>::Run", res)
self.assertIn("Symbol: B<TraitA, TraitB>::Run()+4", res)

0 comments on commit deeab2f

Please sign in to comment.