<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/155691>155691</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Xcode and Android lldb don't find correct formatter if type is in C++ struct/class
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alecazam
      </td>
    </tr>
</table>

<pre>
    I'm using Xcode 16.3/.4 with lldb-1700l.  And also Android studio with clang-19.0.  I have no idea why lldb makes it so hard to write and debug formatters.  But the sample string formatter was way too complex and crashed all the time.   The second one worked which basically does a "p text.c_str()", but not that only works if the type is local, and not if it's in a class/struct.  The debugger and variable views of structs display (None).  Only a local string or ref of the struct value prints using the formatter.  This used to work.  

```
def CustomStringSummary(valobj, internal_dict):
    frame = valobj.GetFrame()
    name = valobj.GetName()

    # equivalent of expr var.c_str()
    # GetSummary() returns the string, GetValue() returns raw ptr address
    summary = frame.EvaluateExpression('{0}.c_str()'.format(name)).GetSummary()

 return summary

def __lldb_init_module(debugger, internal_dict):
 namespaceStr = os.path.splitext(os.path.basename(__file__))[0]

 debugger.HandleCommand("type summary add CustomString -F %s.CustomStringSummary" % namespaceStr)
```

```
struct TestString
{
        std::string text;
};
struct TestCustomString
{
        CustomString text;  // This is our custom std::string with a custom allocator
};

void TestStringFormatter()
{
        static TestString str1;
        static TestCustomString str2;
        static CustomString str3; 
        
        // can set a breakpoint here
        fprintf( stdout, "%s %s %s", str1.text.c_str(), str2.text.c_str(), str3.c_str() );
}
```

This is what lldb produces at the breakpiont of the fprintf.

```
(lldb) p str1
(TestString)  (text = "")

(lldb) p str2
(TestCustomString)  (text = None) <- this is wrong

(lldb) p str2.text
(TgcString) ""

(lldb) p str3
(CustomString) ""
```



</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8Vk-T4rgP_TTmoupUc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