-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port aglib.symbol + aglib.kernel + aglib.godbg #2605
Conversation
9829eed
to
988fffa
Compare
13a8170
to
91f6b1d
Compare
@@ -99,8 +97,6 @@ def update() -> None: | |||
else: | |||
raise Exception("Pointer size not supported") | |||
|
|||
module.null = pwndbg.dbg.selected_inferior().evaluate_expression("0").cast(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not used anywhere, but it cause a lot of trouble in lldb - soo I removed it
pwndbg/arguments.py
Outdated
try: | ||
n_args_default = len(sym[0].type.fields()) | ||
n_args_default = len(sym.type.fields()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(sym.type.fields())
returns 0 if functions is found, but no debug info...
How should we fallback? Maybe we should create another method for that?
sym.type.func_arguments() -> List[Type] | None
and detect no symbols and raise exception? or return None
Only for gdb:
In [26]: sym.type
Out[26]: <gdb.Type code=TYPE_CODE_FUNC name=<text variable, no debug info>>
In [28]: sym.type.name
Out[28]: '<text variable, no debug info>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in previous version gdb.lookup_symbol
returns None when function don't have debug info.
And in new version with aglib.symbol.lookup_frame_symbol
we returns *function
address, but some data is missing like function argument (due to missing debug info - when debugging binary without debug info)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
4c04601
to
4b4fd97
Compare
# Conflicts: # pwndbg/aglib/kernel/rbtree.py # pwndbg/aglib/tls.py # pwndbg/commands/start.py # pwndbg/dbg/lldb/__init__.py
pwndbg/aglib/kernel/rbtree.py
Outdated
rb_root_type = gdb.lookup_type("struct rb_root") | ||
rb_node_type = gdb.lookup_type("struct rb_node") | ||
rb_root_type = pwndbg.aglib.typeinfo.load("struct rb_root") | ||
rb_node_type = pwndbg.aglib.typeinfo.load("struct rb_node") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, there is no exception here that can be thrown
In [1]: gdb.lookup_type('asdf')
---------------------------------------------------------------------------
error Traceback (most recent call last)
Cell In[1], line 1
----> 1 gdb.lookup_type('asdf')
error: No type named asdf.
In [2]: pwndbg.aglib.typeinfo.load('asdf')
In [3]:
so the try: ... except: ..
can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this was wrong before as failure to fetch struct, should set the types to None
while it could keep an old/previous value I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wonder if NEW_MODULE
is ever valid in the context of kernel debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably NEW_MODULE
is invalid in kernel context
pwndbg.dbg_mod.SymbolLookupType.ANY: Domain.ANY, | ||
pwndbg.dbg_mod.SymbolLookupType.VARIABLE: Domain.VARIABLE, | ||
pwndbg.dbg_mod.SymbolLookupType.FUNCTION: Domain.FUNCTION, | ||
}[type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this mapping?
If it is really needed, can we do if/elif/elif/else
Trying to address issues:
__libc_start_main
#2540Changes:
Todo: