Skip to content

Commit

Permalink
revert reg and th order fix #986
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdreg committed Aug 15, 2023
1 parent d27efd3 commit 4a93900
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -6440,7 +6440,7 @@ def do_invoke(self, argv: List[str]) -> None:
if "all" in argv:
tids = [t.num for t in threads]
else:
tids = self.check_thread_ids([int(a) for a in argv])
tids = self.check_thread_ids(argv)
else:
tids = [current_thread.num]

Expand Down Expand Up @@ -6523,9 +6523,21 @@ def find_tcache() -> int:

@staticmethod
def check_thread_ids(tids: List[int]) -> List[int]:
"""Return the subset of tids that are currently valid."""
existing_tids = set(t.num for t in gdb.selected_inferior().threads())
return list(set(tids) & existing_tids)
"""Check the validity, dedup, and return all valid tids."""
existing_tids = [t.num for t in gdb.selected_inferior().threads()]
valid_tids = set()
for tid in tids:
try:
tid = int(tid)
except ValueError:
err(f"Invalid thread id {tid:d}")
continue
if tid in existing_tids:
valid_tids.add(tid)
else:
err(f"Unknown thread {tid}")

return list(valid_tids)

@staticmethod
def tcachebin(tcache_base: int, i: int) -> Tuple[Optional[GlibcTcacheChunk], int]:
Expand Down Expand Up @@ -6772,11 +6784,11 @@ def do_invoke(self, _: List[str], **kwargs: Any) -> None:

args : argparse.Namespace = kwargs["arguments"]
if args.registers and args.registers[0]:
requested_regs = set(args.registers)
valid_regs = set(gef.arch.all_registers) & requested_regs
required_regs = set(args.registers)
valid_regs = [reg for reg in gef.arch.all_registers if reg in required_regs]
if valid_regs:
regs = valid_regs
invalid_regs = requested_regs - valid_regs
invalid_regs = [reg for reg in required_regs if reg not in valid_regs]
if invalid_regs:
err(f"invalid registers for architecture: {', '.join(invalid_regs)}")

Expand Down Expand Up @@ -7358,7 +7370,7 @@ def context_regs(self) -> None:

if self["show_registers_raw"] is False:
regs = set(gef.arch.all_registers)
printable_registers = " ".join(regs - ignored_registers)
printable_registers = " ".join(list(regs - ignored_registers))
gdb.execute(f"registers {printable_registers}")
return

Expand Down

0 comments on commit 4a93900

Please sign in to comment.