<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>On Aug 28, 2013, at 2:31 PM, Jakob Leben <<a href="mailto:jakob.leben@gmail.com">jakob.leben@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Wed, Aug 28, 2013 at 2:15 PM, Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a>> wrote:<br><blockquote type="cite">I think such a visualization would be highly inconvenient for most users<br>most of the time, much as you do not want to see a char* so much as an array<br>of chars but rather as a logical “string”, the same is true of std::string<br>Also, if you know the layout of the string class, you can directly access<br>the data buffer and read the individual bytes out of memory, which is also a<br>discouraging argument from going down the synthetic children route: the<br>added value compared to the actual type layout is quite low.<br>This is why LLDB vends a summary instead of synthetic children.<br></blockquote><br>I see you point.<br><br>I am approaching the issue from another perspective though: I am<br>building an application with the concept of "programming-model-aware<br>debugging", specifically data-flow programming model. I found the LLDB<br>C++ API valuable, because it allows me to easily build an application<br>that attaches to another process which performs processing of a<br>data-flow graph (think multimedia processing) and displays the<br>processing behavior in a graphical way. So I consider the LLDB C++ API<br>as a convenient utility and abstraction on top of<br>operating-system-provided debugging facilities, but for other purpose<br>than implementing a classical command-line debugger. Instead, it is<br>used as a utility to examine another program's state and data in a<br>convenient way.<br><br>Therefore, in my use case I need to access the *actual* data to<br>display it to the end-user in any arbitrary way that LLDB API should<br>never need to assume in itself. Providing a summary/value of a data<br>structure's contents as a string (returned by GetSummary() or<br>GetValue()) is an example of such an assumption.<br></blockquote><div><br></div><div>This is what data formatters are for.</div><div>There is an underlying ground truth which is what the DWARF type information vends.</div><div>On top of that, the data formatters enable you to vend a different reality of your own making. Whether that reality is that a vector is a container of items, or a string is a container of bytes, that is up to you.</div><div>The debugger vends two things in this area:</div><div>a) the data formatters subsystem (SBType*.h at the API level and the DataFormatters/ folder in the internals)</div><div>b) data formatters for types of interest</div><div><br></div><div>The second item is obviously tailored to common expectations and driven by what a user debugging an app expects to see</div><div>These formatters are pretty much constrained to live within this space of convenience and usability, or people would complain fairly loudly about it</div><div><br></div><div>This is where the first item comes into the picture. We cannot (or do not want) to vend any possible data view through the builtin formatters, but we vend a formatters model through which you can vend whatever formatting suits your needs</div><div>Yes, unfortunately that means that you need to know a little more about your types, but somebody needs to “bake the knowledge” in LLDB [1], whether it’s me writing a builtin formatter, or you writing your own </div><div><br></div><div>[1] DWARF is still the source of ground truth, anything else you see is custom knowledge that someone implemented on top of the ground truth</div><div><br></div><div>What you are trying to access is really not “raw data”. Raw data for a string looks like this:</div><div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">(std::__1::string) X = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">  __r_ = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">    std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, std::__1::allocator<char> > = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">      __first_ = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">         = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          __l = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            __cap_ = 139639644119302</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            __size_ = 4294967296</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            __data_ = 0x00007fff5fbffb70</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          __s = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">             = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              __size_ = '\x06'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              __lx = '\x06'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            __data_ = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [0] = 'a'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [1] = 'b'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [2] = 'c'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [3] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [4] = '\x7f'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [5] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [6] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [7] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [8] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [9] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [10] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [11] = '\x01'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [12] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [13] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [14] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [15] = 'p'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [16] = '?'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [17] = '?'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [18] = '_'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [19] = '?'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [20] = '\x7f'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [21] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [22] = '\0'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          __r = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            __words = {</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [0] = 139639644119302</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [1] = 4294967296</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">              [2] = 140734799805296</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">            }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">          }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">        }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">      }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">    }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">  }</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">}</div></div><div><br></div><div>Your desired view of the world is:</div><div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">(std::__1::string) X = {</div></div><div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">  [0] = 'a'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">  [1] = 'b'</div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">  [2] = 'c'</div></div><div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0); position: static; z-index: auto;"><div style="margin: 0px;">  [3] = '\0'</div></div><div style="margin: 0px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">}</div></div><div><br></div><div>This is far from raw data. And to get anything other than raw data, you need a formatter.</div><div><br></div><div>
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style=" orphans: 2; widows: 2; border-collapse: separate; border-spacing: 0px;"><span style="font-size: 12px; orphans: auto; widows: auto;">Enrico Granata</span><br style="font-size: 12px; orphans: auto; widows: auto;"><span style="font-size: 12px; orphans: auto; widows: auto;">📩 egranata@</span><font color="#ff2600" style="font-size: 12px; orphans: auto; widows: auto;"></font><span style="font-size: 12px; orphans: auto; widows: auto;">.com</span><br style="font-size: 12px; orphans: auto; widows: auto;"><span style="font-size: 12px; orphans: auto; widows: auto;">☎️ 27683</span></div></div></div>
</div>
<br><div><div><br></div></div></body></html>