<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/104712>104712</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lldb] lldb can't invoke function when param or return value with anonymous namespaces class.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
GithubXxz
</td>
</tr>
</table>
<pre>
I found that if a function definition with anonymous namespaces class in the parameter or return value.
While debugging with lldb, these functions can't be invoked.
See the following example:
```cpp
namespace {
class A {
int a;
public:
explicit A(int a) : a{a} {}
int func() { return a + 1; }
};
} // namespace
void *param(A /*a*/) { return nullptr; }
A *returnvalue() { return nullptr; }
int main() {
A a = A{1};
// avoid eliminated by compiler
(void)a.func();
(void)param(a);
(void)returnvalue();
return 0;
}
```
Debug above program by cli `lldb -- bin/lldbAnonymousVariable`
``` shell
(lldb) target create "bin/lldbAnonymousVariable"
Current executable set to '/Users/zhiqiangz/llvm/llvm-demo/bin/lldbAnonymousVariable' (arm64).
(lldb) b 23
Breakpoint 1: where = lldbAnonymousVariable`main + 76 at lldbAnonymousVariable.cpp:23:3, address = 0x0000000100003efc
(lldb) r
Process 33550 launched: '/Users/zhiqiangz/llvm/llvm-demo/bin/lldbAnonymousVariable' (arm64)
Process 33550 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003efc lldbAnonymousVariable`main at lldbAnonymousVariable.cpp:23:3
20 (void)param(a);
21 (void)returnvalue();
22
-> 23 return 0;
24 }
(lldb) e param(a)
error: error: function 'param' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage
<user expression 0>:1:1: used here
1 | param(a)
| ^
(lldb) e returnvalue()
error: error: function 'returnvalue' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage
<user expression 1>:1:1: used here
1 | returnvalue()
| ^
```
definitely the exec program contain corresponding symbols, verified by follow command.
``` shell
nm bin/lldbAnonymousVariable | c++filt | rg "param"
0000000100003f58 t param((anonymous namespace)::A)
```
- machine info
```shell
uname -a
Darwin zhiqiangz-mlt 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030 arm64
```
- llvm version
```shell
llvm-config --version
19.0.0git
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV09v2zoS_zT0ZWCBoizLPvggx8lisbtA0XbbvRWUNLK4pUiVpJykh_fZH0jK_-I0zeUdntEqEmc4nN-P84fk1oq9QtyQfEvy3YyPrtNm8w_hurH639PPWaWb580_odWjasB13IFogUM7qtoJraDBVigRXh-F64ArrZ57PVpQvEc78Bot1JJbC0KB6xAGbniPDg1oAwbdaBQcuBwxIXRHaPm1ExKhwWrc74XaR7NSNhVhd96AxdPqFmquCCscVAhCHfR3bCYrnxDDaq2WUj96O_jE-0EiycqoQZY0_quHIY6cPAZSbONQ9Lw8DwAI5YCTbPqOz2GspKhPpgGfBilq4aAkbBUnsDWQrAROii0nxS5YLHaXRj0qwlZBs9geqeFA2BZSkm3hpO9frh0IFtkDYQ9n3i_lBy0aIKwM5BO2KqN2yQkrw9vVmmqUcnDmak0_o4zysFu3nr42Kz49up4LdZ5zxF16fNkOSlJs01tYcATFAwCUoheKO2ygeoZa94OQaM6qK69F2JonZy5PFi_kRxb4lfxC4QbnjV8TZnoWXEN-EWPxc-eDGnilDwiD0XvD-wBECiBL6mMc5nOoPFEP_qs8JtMXbgSvJJ4snQyD7VDKaZCtYp6swXGzRwe1Qe4QCGNvGWUszr8bjUHlAJ-wHp0XgUUHTgNhBWEP_7VoLGEPPzvxQ3C1_xksHvrpz7zBXhP28OZShWeZm365IGyd3PhdAcvi4NYg_z5oHzqpT5zHDg2GWPkVMz7CQrIUS-DudbXEJ3tWsoxkZeYLCm8ag9YGw_SJxl_qHxm29Y1_U7B9MLr2s7IszylIPq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