From 5ac497d07d44d7ff6b01220b7dfbc3867e140548 Mon Sep 17 00:00:00 2001 From: yuki Date: Fri, 15 Mar 2024 18:24:13 +0800 Subject: [PATCH 1/4] wrap flag_register_to_human with try:except, some ISA does not imple this --- gef.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gef.py b/gef.py index f9c6f7e4e..93fc1dcb4 100644 --- a/gef.py +++ b/gef.py @@ -7586,7 +7586,10 @@ def context_regs(self) -> None: if line: gef_print(line) - gef_print(f"Flags: {gef.arch.flag_register_to_human()}") + try: + gef_print(f"Flags: {gef.arch.flag_register_to_human()}") + except: + pass return def context_stack(self) -> None: From adb8ac4340b4f4e6dd4ac0e85bfd5e0b117fa242 Mon Sep 17 00:00:00 2001 From: yuki Date: Fri, 22 Mar 2024 15:47:58 +0800 Subject: [PATCH 2/4] suppress flag_register_to_human in RISCV --- gef.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gef.py b/gef.py index 93fc1dcb4..cffdf3d0d 100644 --- a/gef.py +++ b/gef.py @@ -7586,10 +7586,9 @@ def context_regs(self) -> None: if line: gef_print(line) - try: + if gef.arch.flag_register: gef_print(f"Flags: {gef.arch.flag_register_to_human()}") - except: - pass + return def context_stack(self) -> None: From f7ff1a0a36b93daa6bc4bda9f6ce9782483a9a8f Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 7 Apr 2024 21:35:54 -0700 Subject: [PATCH 3/4] add missing `flag_register_to_human` for RISCV --- gef.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gef.py b/gef.py index cffdf3d0d..3e5e4384a 100644 --- a/gef.py +++ b/gef.py @@ -2547,6 +2547,10 @@ def get_ra(self, insn: Instruction, frame: "gdb.Frame") -> Optional[int]: ra = to_unsigned_long(older.pc()) return ra + def flag_register_to_human(self, val: Optional[int] = None) -> str: + # RISC-V has no flags registers, return an empty string to + # preserve the Architecture API + return "" class ARM(Architecture): aliases = ("ARM", Elf.Abi.ARM) @@ -7586,9 +7590,7 @@ def context_regs(self) -> None: if line: gef_print(line) - if gef.arch.flag_register: - gef_print(f"Flags: {gef.arch.flag_register_to_human()}") - + gef_print(f"Flags: {gef.arch.flag_register_to_human()}") return def context_stack(self) -> None: From 06fdfe777d7f2607b84cdd776b698415fe0b15da Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 7 Apr 2024 21:38:17 -0700 Subject: [PATCH 4/4] linting --- gef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gef.py b/gef.py index 3e5e4384a..1982f2420 100644 --- a/gef.py +++ b/gef.py @@ -2548,7 +2548,7 @@ def get_ra(self, insn: Instruction, frame: "gdb.Frame") -> Optional[int]: return ra def flag_register_to_human(self, val: Optional[int] = None) -> str: - # RISC-V has no flags registers, return an empty string to + # RISC-V has no flags registers, return an empty string to # preserve the Architecture API return ""