diff options
author | sotech117 <26747948+sotech117@users.noreply.github.com> | 2024-04-25 03:45:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 03:45:32 -0400 |
commit | c9f4da6024393310e254a2cba679b1f1cc67607a (patch) | |
tree | 6f7a61225676b9578c0e0c46cdd54a10bad9c9e3 /python/weenix | |
parent | a17999858ddaada83071d953d920e3c2a2b390c8 (diff) | |
parent | fb4b8fbec69f50c7386017896f0add4d46314a1d (diff) |
Merge branch 'brown-cs1690:master' into master
Diffstat (limited to 'python/weenix')
-rw-r--r-- | python/weenix/userland_new.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/python/weenix/userland_new.py b/python/weenix/userland_new.py new file mode 100644 index 0000000..7d4ff55 --- /dev/null +++ b/python/weenix/userland_new.py @@ -0,0 +1,41 @@ +import subprocess +from os import path + +# Define the command and arguments +command = [ + "objdump", + "--headers", + "--section=.text", + "user/usr/bin/s5fstest.exec" +] + + +class NewUserland(gdb.Command): + def __init__(self): + super(NewUserland, self).__init__("new-userland", gdb.COMMAND_USER) + + def invoke(self, arg, from_tty): + directory = 'user/usr/bin/' + filename = directory + arg + '.exec' + if not path.exists(filename): + filename = 'user/bin/' + arg + '.exec' + if arg == 'init': + filename = 'user/sbin/init.exec' + + + command = f"objdump --headers --section='.text' {filename} | grep .text | awk '{{print $4}}'" + + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) + + if result.returncode == 0: + print("VMA of the .text section:") + text_section = result.stdout.strip() + + gdb.execute(f"add-symbol-file {filename} 0x{text_section}") + gdb.execute(f"break main") + else: + print("Command failed with error:") + print(result.stderr) + + +NewUserland() |