llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.99k stars 11.06k forks source link

LLDB hangs at O0 #94574

Open YangYibiao opened 1 month ago

YangYibiao commented 1 month ago

$ clang --version

Ubuntu clang version 19.0.0 (++20240301064251+dd426fa5f931-1~exp1~20240301184412.1845) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-19/bin

$ lldb --version

lldb version 19.0.0

$ cat small.c

typedef struct { int baddr; } mstruct_t;

static struct { unsigned int mapnum; mstruct_t unused; } mtab;

static mstruct_t *mactab = &mtab.unused;

int main(void) { int i; int addr;

for (i=1; i <= mtab.mapnum; i++) if (addr < mactab[i].baddr) break; return 0; }

$ clang -O0 -g small.c; lldb a.out

(lldb) target create "a.out" Current executable set to '/root/a.out' (x86_64). (lldb) b main Breakpoint 1: where = a.out`main + 11 at small.c:20:9, address = 0x000000000000113b (lldb) r Process 26442 launched: '/root/a.out' (x86_64) [1344/3230] Manually indexing DWARF: libc.so.6...

The code you provided is causing LLDB to hang after setting a breakpoint at main and attempting to run the program.

llvmbot commented 1 month ago

@llvm/issue-subscribers-lldb

Author: Alex (HelloAlexy)

`$ clang --version` > Ubuntu clang version 19.0.0 (++20240301064251+dd426fa5f931-1~exp1~20240301184412.1845) > Target: x86_64-pc-linux-gnu > Thread model: posix > InstalledDir: /usr/lib/llvm-19/bin `$ lldb --version` > lldb version 19.0.0 `$ cat small.c` > typedef struct > { > int baddr; > } mstruct_t; > > static struct > { > unsigned int mapnum; > mstruct_t unused; > } mtab; > > static mstruct_t *mactab = &mtab.unused; > > int > main(void) > { > int i; > int addr; > > for (i=1; i <= mtab.mapnum; i++) > if (addr < mactab[i].baddr) > break; > return 0; > } `$ clang -O0 -g small.c; lldb a.out` > (lldb) target create "a.out" > Current executable set to '/root/a.out' (x86_64). > (lldb) b main > Breakpoint 1: where = a.out`main + 11 at small.c:20:9, address = 0x000000000000113b > (lldb) r > Process 26442 launched: '/root/a.out' (x86_64) > [1344/3230] Manually indexing DWARF: libc.so.6... The code you provided is causing LLDB to hang after setting a breakpoint at main and attempting to run the program.
bulbazord commented 1 month ago

I tried to reproduce this on macOS with top-of-tree LLDB and Clang. I wasn't able to hit the same issue, so it's possible the issue is specific to Linux (or even Ubuntu since you're using Ubuntu clang and Ubuntu lldb).

xgupta commented 1 month ago

Does not reproduce on arch linux with latest trunk of LLDB and Clang.

jimingham commented 1 month ago

This is happening during manual indexing. I'm surprised we're doing that anymore on up to date toolchains. Now that the index tables are part of standard DWARF, it is much better to use that...

Anyway, to reproduce this you're going to have to turn off emission of the DWARF index tables.