Skip to content

[Bug] - Custom command not registering correclty with @register #955

@GamrayW

Description

@GamrayW

GEF+GDB version

GEF: rev:0fd751ec151952c4efbdcb5b2107b19b49256239 (Git - dirty)
SHA256(/opt/gef/gef.py): 6ce67338f7dfc572534023e3e11d267743fbfe6f225a7f5c212d6ae100ea1f29
GDB: 13.1
GDB-Python: 3.11

Operating System

Manjaro Linux

Describe the issue you encountered

Creating a custom command following the documentation works but gives us a register_external_command' is deprecated and will be removed in a feature release. Use register(), and inherit from GenericCommand instead warning.

Trying to use register() does not seems to works properly.

Do you read the docs and look at previously closed issues/PRs for similar cases?

Yes

Architecture impacted

  • X86
  • X64
  • ARM
  • ARM64
  • MIPS
  • MIPS64
  • PPC
  • PPC64
  • RISCV

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

Add this to gef.py:

@register
class Test(GenericCommand):
    """Test cmd."""
    _cmdline_ = "test"
    _syntax_  = f"{_cmdline_}"

    @only_if_gdb_running
    def do_invoke(self, argv):
        print("plop")
        return

Start gdb and try the new test command:

gef➤  test
Undefined command: "test".  Try "help".
gef➤  test
Undefined command: "test".  Try "help".
gef➤  pi Test()
<__main__.Test object at 0x7fc2f7f74780>
gef➤  test
plop

The expected behavior would be that test returns plop on the first instance

Minimalist test case

No response

Additional context?

Using register(Test) gives the same behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions