Skip to content

latest commit : function get_arch() return 386:x86-64 instead of "i386:x86-64" #831

@Giles-one

Description

@Giles-one

Hello

gef➤  set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
gef➤  gef-remote --qemu-mode localhost:1234
[!] Command 'gef-remote' failed to execute properly, reason: unsupported architecture: 386:x86-64

I found '386:x86-64' kind of odd ,then checked the source code.

# $ sed -n "2062,2082p" ./gef.py 
def get_arch() -> str:
    """Return the binary's architecture."""
    if is_alive():
        arch = gdb.selected_frame().architecture()
        return arch.name()

    arch_str = gdb.execute("show architecture", to_string=True).strip()
    if "The target architecture is set automatically (currently " in arch_str:
        arch_str = arch_str.lstrip("(currently ").rstrip(")")
    elif "The target architecture is assumed to be " in arch_str:
-----------------------------------here-------------------------------------
        arch_str = arch_str.lstrip("The target architecture is assumed to be ")
-----------------------------------here-------------------------------------
    elif "The target architecture is set to " in arch_str:
        # GDB version >= 10.1
        if '"auto"' in arch_str:
            arch_str = re.findall(r"currently \"(.+)\"", arch_str)[0]
        else:
            arch_str = re.findall(r"\"(.+)\"", arch_str)[0]
    else:
        # Unknown, we throw an exception to be safe
        raise RuntimeError(f"Unknown architecture: {arch_str}")
    return arch_str

Then I test it in python.

$ gdb
gef➤  show architecture 
The target architecture is assumed to be i386:x86-64
$ python3
>>> arch_str = "The target architecture is assumed to be i386:x86-64"
>>> arch_str.lstrip("The target architecture is assumed to be ")
'386:x86-64'

Maybe problem lies in。I hope this can help。

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions