-
Notifications
You must be signed in to change notification settings - Fork 49
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
Added test locals printing command to GDB #28
Conversation
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.
Delete test/a.out
, maybe run black
formatter, and LGTM!
Tested with file:
#include <iostream>
struct P {
int b;
};
struct Q {
int a;
P* p;
P q;
};
struct C {
C* c;
};
int main() {
Q q;
q.a = 1;
q.p = new P();
q.p->b = 2;
q.q.b = 3;
int i = 0;
C a;
C b;
a.c = &b;
b.c = &a;
std::cout << *static_cast<char*>(nullptr) << std::endl;
}
PS: Instead of a max-recursion parameter, maybe we could keep a list of already printed/visited variable within a certain scope, and just stop when visiting again?
def __init__(self): | ||
gdb.Command.__init__(self, "wzd", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL, True) | ||
|
||
def invoke(self, arg, from_tty): |
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.
Seems like arg
contains the entire string after the command, we should be able to parse options this way. (I like argparse
personally).
We could use this to add timeout, llm, and other options, provided LLDB has similar functionality.
addresses = {} | ||
for symbol in block: | ||
if symbol.is_argument or symbol.is_variable: | ||
variable = {} # Create python dictionary for each variable |
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.
variable = {} # Create python dictionary for each variable |
Removed test field Co-authored-by: Nicolas van Kempen <[email protected]>
Updated command name Co-authored-by: Nicolas van Kempen <[email protected]>
Removed self from super() args
Added experimental locals printing command to GDB. Command "print-test [recursion-depth]" currently prints a dictionary of found local variables mapped to memory locations, and JSON list of these variables, with fields "name", "type", "value"