chisel icon indicating copy to clipboard operation
chisel copied to clipboard

Add pivars command to FBClassDump.py

Open longv2go opened this issue 8 years ago • 5 comments

pivars command call the class_copyIvarList to get all ivars of an Class and print them out. It would show the offset, type, name and value if need.

(lldb) pivars -r -n child
NSObject:
    [0x0] Class isa

father:
    [0x4] NSString * father_var
    [0x8] NSString * faterh_var2

child:
    [0xc] {teststr="a"i"b"l} straaa
    [0x14] NSString * c_var1
    [0x18] NSString * _c_var2

longv2go avatar Nov 08 '16 03:11 longv2go

Thanks, and sorry for the late reply. This looks good, but I'm also wondering if we should consolidate pinternals and pivar? Should we discuss that now, or leave that for another time.

kastiglione avatar Nov 25 '16 19:11 kastiglione

@kastiglione I notice that too. pinternals can not show the ivar`s offset, so I wrote this command. Sometimes I need the offset to inspect the object`s memory layout, and pivar need the ivar`s name, no name no working.

longv2go avatar Nov 29 '16 02:11 longv2go

Related, a command I came across last week is:

language objc class-table dump -v <regular-expression>

This prints ivars and their offsets, but it also prints methods too, which adds noise if you just want structure information.

kastiglione avatar Nov 30 '16 04:11 kastiglione

@kastiglione I think we should to merge the pivars, pmethods, pproperties to one command.

class-dump <options> <arg>

if the arg is an instance of some class, it can show the ivar`s value of that instance. But there is more work to decode the struct infomation.

longv2go avatar Nov 30 '16 12:11 longv2go

@longv2go I'm following up on outstanding pull requests. Sorry for the long silence. Note that since this time, a -a flag was added to pinternals which calls the debugging helper _ivarDescription.

kastiglione avatar Nov 14 '17 23:11 kastiglione