LLDB icon indicating copy to clipboard operation
LLDB copied to clipboard

ivars not working.

Open CodeLife2012 opened this issue 5 years ago • 5 comments

image

CodeLife2012 avatar Apr 19 '19 04:04 CodeLife2012

I'll need a bit more context: Is self Swift or ObjC? Do you have the source to this program you are debugging? Is this iOS or a different platform?

ivars currently only works with iOS since it's calling a private UIKit(Core) method. MacOS doesn't have it. One day I'll rewrite it with my own, but I don't see that happening for at least a month

DerekSelander avatar Apr 19 '19 13:04 DerekSelander

Oh,it's on Mac OS.

CodeLife2012 avatar Apr 21 '19 11:04 CodeLife2012

Ah, ok, I'll keep this open then until I've got a replacement for MacOS. In the time being you can run dclass self to obtain all the Objective-C values ivars from the class and manually jump to the interesting offsets. For example, picking on Finder:

(lldb) search NSObject -m Finder
<TWindowHistoryEntry: 0x600003c49260>

# Other results removed for brevity

# query instance for info using dclass 
(lldb) dclass 0x600003c49260

@interface TWindowHistoryEntry : NSObject
{
 {TFENodeVector="__begin_"^{TFENode}"__end_"^{TFENode}"__end_cap_"{__compressed_pair<TFENode *, std::__1::allocator<TFENode> >="__value_"^{TFENode}}} _targetPath                   ; offset 0x8, 0x18
      @"NSDictionary" _windowState                  ; offset 0x20, 0x8
      @"NSDictionary" _searchState                  ; offset 0x28, 0x8
}

@property T{TFENodeVector=^{TFENode}^{TFENode}{__compressed_pair<TFENode *, std::__1::allocator<TFENode> >=^{TFENode}}},N,V_targetPath *targetPath
@property T@"NSDictionary",&,N,V_windowState *windowState
@property T@"NSDictionary",&,N,V_searchState *searchState

 -                           .cxx_destruct  0x101f94f78
 -                                 dealloc  0x101f94f20
 -                                 isValid  0x101fa8e37
 -                              targetPath  0x101f6d4d6
 -                         setSearchState:  0x101f6d4b7
 -                          setTargetPath:  0x101f6d485
 -                             searchState  0x101f6f026
 -                          .cxx_construct  0x101f6d459
 -                             windowState  0x101fa92c4
 -                         setWindowState:  0x101f6d4a5
 +  historyEntryForTargetPath:windowState:  0x101f6d387

@end

# Let's say we are interested in the _windowState property at offset 0x20 
po *(id *)(0x600003c49260 + 0x20)
{
    BrowserViewState =     {
        IconViewScrollOrigin = "{0, 0}";
    };
    ContainerShowSidebar = 1;
    SearchViewState =     {
        EmptyStringAbortsSearch = 1;
        PropertyList = "";
        TypingScope = 9223372036854775806;
        UseTokens = 1;
    };
.... 

DerekSelander avatar Apr 21 '19 15:04 DerekSelander

I also ran a (lldb) cpo @import ObjectiveCbefore this example to fix LLDBs module headers, a problem that is constantly changing for every LLDB release

DerekSelander avatar Apr 21 '19 15:04 DerekSelander

that is great. Thanks @DerekSelander . I haven't see the cpo command before. gulp!

rustymagnet3000 avatar May 08 '19 14:05 rustymagnet3000