Merge pull request #22 from saelo/auxv_fix

Improved auxv entry parsing
pull/23/merge
Zach Riggle 10 years ago
commit 4711a50bfe

@ -1,4 +1,5 @@
import os import os
import re
import sys import sys
import gdb import gdb
@ -106,19 +107,14 @@ def use_info_auxv():
auxv = AUXV() auxv = AUXV()
for line in lines: for line in lines:
tokens = line.split() match = re.match('([0-9]+) .* (0x[0-9a-f]+|[0-9]+)', line)
const = int(tokens[0]) if not match:
print("Warning: Skipping auxv entry '{}'".format(line))
continue
# GDB will attempt to read strings for us, we dont want this const, value = int(match.group(1)), int(match.group(2), 0)
if '"' in tokens[-1]: tokens.pop(-1)
# If there' a memory read error, there will be some trash at the end.
# 31 AT_EXECFN File name of executable 0xffffdfef <error: Cannot access memory at address 0xffffdfef>
# So we just need to strip the trailing '>'
tokens[-1] = tokens[-1].rstrip('>')
value = eval(tokens[-1])
auxv.set(const, value) auxv.set(const, value)
return auxv return auxv

Loading…
Cancel
Save