Skip to content

Commit

Permalink
Fix pwndbg#429 - osabi check for non-English GDB version
Browse files Browse the repository at this point in the history
Detailed info is within the issue, but TLDR:

```
(gdb) show osabi
El actual SO ABI es «auto» (actualmente «GNU/Linux»).
El SO ABI predeterminado es «GNU/Linux».
```
  • Loading branch information
disconnect3d committed Mar 20, 2018
1 parent f595ba3 commit f139174
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pwndbg/abi.py
Expand Up @@ -125,17 +125,23 @@ def update():
global linux

# Detect current ABI of client side by 'show osabi'
osabi_string = gdb.execute('show osabi', to_string=True)

# The return string will be:
# The current OS ABI is "auto" (currently "GNU/Linux").
match = re.search('currently "([^"]+)"', osabi_string)
if match:
# 'GNU/Linux': linux
# 'none': bare metal
abi = match.group(1)

linux = 'Linux' in abi
#
# Examples of strings returned by `show osabi`:
# 'The current OS ABI is "auto" (currently "GNU/Linux").\nThe default OS ABI is "GNU/Linux".\n'
# 'The current OS ABI is "GNU/Linux".\nThe default OS ABI is "GNU/Linux".\n'
# 'El actual SO ABI es «auto» (actualmente «GNU/Linux»).\nEl SO ABI predeterminado es «GNU/Linux».\n'
# 'The current OS ABI is "auto" (currently "none")'
#
# As you can see, there might be GDBs with different language versions
# and so we have to support it there too.
# Lets assume and hope that `current osabi` is returned in first line in all languages...
current_osabi = gdb.execute('show osabi', to_string=True).split('\n')[0]

# Currently we support those osabis:
# 'GNU/Linux': linux
# 'none': bare metal

linux = 'GNU/Linux' in current_osabi

if not linux:
msg = M.warn(
Expand Down

0 comments on commit f139174

Please sign in to comment.