Issue |
143149
|
Summary |
A few of lldb's frame formatting function options do not work on Windows
|
Labels |
lldb,
platform:windows
|
Assignees |
|
Reporter |
DavidSpickett
|
Found while fixing https://github.com/llvm/llvm-project/pull/142952, but really this has been going on for a while.
`function.name` and `function.name-without-args` don't work on Windows because it thinks that the function's "name" is like `void fn(void)`.
For example:
```
C:\Users\tcwg>cat test.cpp
void fn0() {}
void fn1() { fn0();}
int main() { fn1(); return 0; }
```
This is the default backtrace:
```
lldb.exe test.exe
(lldb) target create "test.exe"
Current executable set to 'C:\Users\tcwg\test.exe' (aarch64).
(lldb) b fn0
Breakpoint 1: where = test.exe`void __cdecl fn0(void) at test.cpp:1, address = 0x00000001400148c0
(lldb) run
Process 5632 launched: 'C:\Users\tcwg\test.exe' (aarch64)
Process 5632 stopped
* thread #1, stop reason = breakpoint 1.1
frame #0: 0x00007ff6483248c0 test.exe`void __cdecl fn0(void) at test.cpp:1
-> 1 void fn0() {}
2 void fn1() { fn0();}
3 int main() { fn1(); return 0; }
4
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* frame #0: 0x00007ff6483248c0 test.exe`void __cdecl fn0(void) at test.cpp:1
frame #1: 0x00007ff6483248d4 test.exe`void __cdecl fn1(void) at test.cpp:2
frame #2: 0x00007ff6483248ec test.exe`main at test.cpp:3
frame #3: 0x00007ff648324838 test.exe`static int __scrt_common_main_seh() at exe_common.inl:288
frame #4: 0x00007ff648324d3c test.exe`mainCRTStartup(__formal=<unavailable>) at exe_main.cpp:16
frame #5: 0x00007ff9efe52310 kernel32.dll`BaseThreadInitThunk + 48
frame #6: 0x00007ff9f3a15aec ntdll.dll`RtlUserThreadStart + 60
```
Note that some functions lack arguments, I don't know why.
`function.name` does not remove the return type or parameters for some functions:
```
(lldb) settings set frame-format "'${function.name}'\n"
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* 'void __cdecl fn0(void)'
'void __cdecl fn1(void)'
'main'
'static int __scrt_common_main_seh()'
'mainCRTStartup'
'BaseThreadInitThunk'
'RtlUserThreadStart'
```
`function.mangled-name` works:
```
(lldb) settings set frame-format "'${function.mangled-name}'\n"
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* '?fn0@@YAXXZ'
'?fn1@@YAXXZ'
'main'
'static int __scrt_common_main_seh()'
'mainCRTStartup'
'BaseThreadInitThunk'
'RtlUserThreadStart'
```
`function.name-with-args` still includes the return type:
```
(lldb) settings set frame-format "'${function.name-with-args}'\n"
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* 'void __cdecl fn0(void)'
'void __cdecl fn1(void)'
'main'
'static int __scrt_common_main_seh()'
'mainCRTStartup(__formal=<unavailable>)'
'BaseThreadInitThunk'
'RtlUserThreadStart'
```
`function.name-without-args` also does not work:
```
(lldb) settings set frame-format "'${function.name-without-args}'\n"
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* 'void __cdecl fn0(void)'
'void __cdecl fn1(void)'
'main'
'static int __scrt_common_main_seh()'
'mainCRTStartup'
'BaseThreadInitThunk'
'RtlUserThreadStart'
```
That was with PDB debug info, I tried DWARF too but the only difference was that we got some extra functions before main that are unrecognised, and the calling convention goes away:
```
(lldb) settings set frame-format "'${function.name}'\n"
(lldb) bt
* thread #1, stop reason = breakpoint 1.1
* 'void fn0(void)'
'void fn1(void)'
'main'
frame #3: 0x00007ff6955721a0 test.exe`test.exe[0x00000001400021a0]
frame #4: 0x00007ff69557225c test.exe`test.exe[0x000000014000225c]
'BaseThreadInitThunk'
'RtlUserThreadStart'
```
The basic problem here is that on Windows we think `name` is `<return type> <calling convention> <actual name>(<parameters>)`.
It doesn't seem like a thing that would be decided by the platform, but it looks like it is because it happens for DWARF and PDB.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs