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

    <tr>
        <th>Summary</th>
        <td>
            [lldb] Setting breakpoint by basename on template instantiations with template types fails
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lldb
      </td>
    </tr>

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

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

<pre>
    Tried with top-of-tree as of `4ba360d499f6169d62a9535438b3cf34337ffc67`. But works with `lldb-14`.

```
$ cat nested.cpp 
template<typename T>
struct C {};

template<typename T>
struct S {
    template<typename U>
    void method() {}
};

template<typename T>
void free_function() {}

int main() {
    free_function<C<int>>();
    free_function<double>();

    S<float> s;
    s.method<C<int>>();
    s.method<double>();
}

$ ./bin/lldb  a.out -o "br se -n method<C<int>>" -o "br se -n \"method<C<int> >\"" -o "br se -n \"free_function<C<int> >\"" -o "q"
(lldb) target create "a.out"
Current executable set to 'a.out' (arm64).
(lldb) br se -n method<C<int>>
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) br se -n "method<C<int> >"
Breakpoint 2: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) br se -n "free_function<C<int> >"
Breakpoint 3: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) q

```

With lldb-14:
```
$ lldb a.out -o "br se -n method<C<int>>" -o "br se -n \"method<C<int> >\"" -o "br se -n \"free_function<C<int> >\"" -o "q"
(lldb) target create "a.out"
Current executable set to 'a.out' (arm64).
(lldb) br se -n method<C<int>>
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) br se -n "method<C<int> >"
Breakpoint 2: where = a.out`void S<float>::method<C<int> >() + 8 at nested.cpp:7:20, address = 0x0000000100003f60
(lldb) br se -n "free_function<C<int> >"
Breakpoint 3: where = a.out`void free_function<C<int> >() at nested.cpp:11:23, address = 0x0000000100003f50
(lldb) q
```

**Details**

The symbol name that we read out of dwarf contains a space between the angle brackets (i.e., `func<Foo<int> >`), which makes sense because that’s how it’s spelled out in `DW_AT_name`. So when a user sets breakpoint on `func<Foo<int>>`, we don’t find it in the `DWARFMappedHash::MemoryTable` anywhere because it doesn’t match the `DW_AT_name`.

However, when the user adds the space and we fish it out of the DWARF index, we fail to match (in `ProcessFunctionDIE`) against the demangled string because it doesn’t contain the space.

Will need to bisect but potentially related to https://github.com/llvm/llvm-project/issues/58360
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV0tv4zYQ_jXyhbAgkXrYBx_8WHf3kEWxyWKPASWOLDW0qIhUHP_7Din5tbGTFi3QAq0hK5E4nPlm5pvhOFNiP3toKxBkV5mSGNWMVTE2LQDhmqiCeEkQZZwlgYim0yIJk6lIKJ_GLI7YJGN5wSLG0qLIkxRFfbLoDNmp9kn3CvGdlCIbh5Fd9YKVF8yHexIMV_9II5JzQ2rQBoSfNw3pFwxsG8kNeGxp9g3UfAvkwWOf-lVt2i43ZEm8dOGlK48tzm38ob33bq97Q_Bzbc_34x4r8aIqQbZgSiU8OvHo9GC8t_wnUThtBQb8sejq3FSqvqbU3avakC2vzgWOoC41sOUSvyhvzeDlNhxhXZMXqsskvJU97bhHqUIqbnUSfaFM-0M4PrZ7JnrT5KXXlhm-R9eZdXxt2UQI9xXybKyIR2nWEg1kXJNbGOjPgl68xMcr4sTKu8Wbu27H-drmZ_s0eDGx0G3eDG83YEjeApLCSjlvjpLLrm0BMw2vkHeGY4gQgMHSRNF0EE3x_wlvt0mECv03Fj4KiZNfoP2nRllShR6bk1oRqbAE0S9t1SNTRVVvTgZ-zL99_fL1FytLvtcOGIJqQSv5AmjzqA7f8npPeG46Lk9K38H5TjoOYTmDS_8FcD_gwRXU7B9C_fxe1-1t2k59aNPsdn92tfd_6f3nS29XQovRY6ueDMgRd4idHxCWR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