-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Description
Hello, I am working on WinDRBD (GitHub - LINBIT/windrbd: DRBD driver for windows) which is a Windows port of the Linux DRBD driver. We used to compile it with MS VC earlier (in the 1.1 branch) but then switched to gcc in the 1.2 branch because there are lots of Linux driver codes therein. The drawback is no PDB support in gcc (as I understand it). So we came to clang / llvm.
After some experiments I was able to successfully create a windrbd.pdb file alongside the windrbd.sys file (driver binary). The versions are:
clang version 20.1.8 (Fedora 20.1.8-4.fc42)
LLD 19.1.7 (compatible with GNU linkers)
As I understand it the PDB is generated by the LLD.
When enforcing a blue screen (BSOD) to make the system dump memory, loading the dump into windbg and produce a stack trace I get:
00 ffff8c8c`8ecb1598 fffff800`26a46c55 nt!KeBugCheckEx
01 ffff8c8c`8ecb15a0 00000000`deaddead windrbd!intentionally_bsod+0x45
02 ffff8c8c`8ecb15a8 00000000`0000002a 0xdeaddead
03 ffff8c8c`8ecb15b0 00000000`00000043 0x2a
04 ffff8c8c`8ecb15b8 00000000`0000001c 0x43
05 ffff8c8c`8ecb15c0 00000000`00000007 0x1c
06 ffff8c8c`8ecb15c8 ffff8d89`7c0fd150 0x7
07 ffff8c8c`8ecb15d0 00000001`7d596460 0xffff8d89`7c0fd150
08 ffff8c8c`8ecb15d8 fffff800`26a45782 0x00000001`7d596460
09 ffff8c8c`8ecb15e0 ffff8d89`7cd4a6b0 windrbd!test_main+0x4f2 [/home/johannes/Linbit/windrbd-build-with-clang/windrbd/src/windrbd_test.c @ 1985]
0a ffff8c8c`8ecb15e8 00ff8d89`7a725080 0xffff8d89`7cd4a6b0
0b ffff8c8c`8ecb15f0 fffff800`26bd12c0 0x00ff8d89`7a725080
0c ffff8c8c`8ecb15f8 fffff800`26a48a7a windrbd!thread_list_lock
0d ffff8c8c`8ecb1600 00000060`00120101 windrbd!windrbd_find_thread+0x8a [/home/johannes/Linbit/windrbd-build-with-clang/windrbd/src/windrbd_threads.c @ 63]
0e ffff8c8c`8ecb1608 0000f800`00000040 0x00000060`00120101
0f ffff8c8c`8ecb1610 00000001`00000001 0x0000f800`00000040
10 ffff8c8c`8ecb1618 ffff8d89`7c0fd150 0x00000001`00000001
11 ffff8c8c`8ecb1620 ffff8d89`7d596472 0xffff8d89`7c0fd150
12 ffff8c8c`8ecb1628 ffff8d89`7d596460 0xffff8d89`7d596472
13 ffff8c8c`8ecb1630 ffff8d89`70256100 0xffff8d89`7d596460
14 ffff8c8c`8ecb1638 fffff800`26a3f2df 0xffff8d89`70256100
15 ffff8c8c`8ecb1640 ffff8d89`7b4959a0 windrbd!windrbd_root_device_control+0x63f [/home/johannes/Linbit/windrbd-build-with-clang/windrbd/src/windrbd_device.c @ 387]
16 ffff8c8c`8ecb1648 00000000`00000000 0xffff8d89`7b4959a0
which is already quite good. However as you can see the sizes of the stack frames are interpreted incorrectly (it shows a frame every 8 bytes). Is this a known bug? Do I have to enable something in windbg? Can I work around somehow?
Note that this was cross compiled on Linux, does this make a difference? I used following flags:
CFLAGS_FOR_DRIVERS=-fvisibility=hidden -ffunction-sections -fdata-sections -fno-builtin -ffreestanding -fno-stack-protector -fno-strict-aliasing -Wno-pragma-pack -Wno-missing-declarations -g -gcodeview
LDFLAGS_FOR_DRIVERS=-fuse-ld=lld-19 -shared -Wl,--subsystem,native -Wl,--image-base,0x140000000 -Wl,--dynamicbase -Wl,--nxcompat -Wl,--stack,0x100000 -Wl,--gc-sections -Wl,--entry,$(DRIVER_ENTRY) -nostartfiles -nodefaultlibs -nostdlib -g -gcodeview -Wl,--pdb=windrbd.pdb
plus
--target=x86_64-pc-mingw32-w64
Do I miss a CFLAG/LDFLAG? It looks a bit like the stack sizes (unwind info, is it that?) are not generated by the clang compiler.
I’d be happy to run more test and contribute as a tester, if that helps.
Thanks a lot and best regards,
- Johannes