Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert to order register logic #987

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading