-
Notifications
You must be signed in to change notification settings - Fork 804
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
Add evalfile command #248
base: main
Are you sure you want to change the base?
Add evalfile command #248
Conversation
evalfile support args
|
||
ret = fb.evaluate(source) | ||
# if ret is not an address then print it directly | ||
if ret[0:2] != '0x': |
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.
you could do not ret.startswith('0x')
print ret | ||
else: | ||
command = 'po {}'.format(ret) | ||
lldb.debugger.HandleCommand(command) |
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.
you could do print fb.evaluateExpressionValue(ret).GetObjectDescription()
ret = process.ReadCStringFromMemory(int(ret.GetValue(), 16), 2**20, error) | ||
if not error.Success(): | ||
print error | ||
return None |
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.
what are these changes about?
Thanks for the pull request. I did something similar recently, but without the arguments. Have you tried wrapping the code in a function? Or alternatively, a class method or a category? For example: @import ObjectiveC.runtime;
@implementation NSObject (ObjectProperties)
+ (NSArray *)propertyNames {
NSMutableArray *result = (id)[NSMutableArray array];
unsigned int count;
objc_property_t *props = (objc_property_t *)class_copyPropertyList(self, &count);
for (int i = 0; i < count; i++) {
char *name = (char *)property_getName(props[i]);
[result addObject:(id)[NSString stringWithUTF8String:name]];
}
return result;
}
@end And then from lldb:
|
evalfile command can evaluate a multiline source code from a file. You can also supply a argument after the file parameter.