-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[meta] Add support for CodeView, the MSVC-compatible debug information format #12655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
btw, clang+link build has at least some info: $ clang.exe -c -g debug_info.c && link /nologo /debug debug_info.o dbghelp.lib libcmt.lib && debug_info.exe |
Does dbghelp support DWARF-based debug info? I'd bet - not. clang + link just provide you the debug info present in MS CRT libs / objects. |
I changed the title of the PR. Maybe someone someday will implement emission of debug info in VC format. |
Kai posted a patch with CodeView debug information emission, which would be a very good first step to fix this bug. |
This is actually getting implemented, and I'd like to make this the meta-tracking bug for the support. Please file CodeView issues and mark them as blocking this meta bug so we can track them. The current status is that using 'clang -g -gcodeview' (TODO: make -gcodeview imply -g) or 'clang-cl /Zi' or 'clang-cl /Z7' will emit CodeView into COFF objects. We describe local variables, globals, and functions, but there are major gaps. /Zi-style emission of type info into PDBs is not on the immediate roadmap. |
Some of the original reporters and commenters may not want to receive updates, so I'm going to open a new meta bug and then mark everything blocked on that. The original intent of this bug was just to get backtraces, and we got that long ago. You can get more updates over at https://llvm.org/bugs/show_bug.cgi?id=28154. |
mentioned in issue llvm/llvm-bugzilla-archive#13707 |
Extended Description
$ clang.exe -v
clang version 3.1 (trunk 152788)
Target: i686-pc-win32
Thread model: posix
$ cl /nologo /Zi debug_info.c dbghelp.lib && debug_info.exe
debug_info.c
#00 main debug_info.c:12
#01 __tmainCRTStartup f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:266
#02 BaseThreadInitThunk+0x00000012
#03 RtlInitializeExceptionChain+0x00000063
#04 RtlInitializeExceptionChain+0x00000036
Done
$ clang.exe -g debug_info.c "C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\dbghelp.lib" && a.out
#00
#01
#02 BaseThreadInitThunk+0x00000012
#03 RtlInitializeExceptionChain+0x00000063
#04 RtlInitializeExceptionChain+0x00000036
Done
$ more debug_info.c
#include <windows.h>
#include <dbghelp.h>
#include <stdio.h>
#pragma comment(lib, "dbghelp.lib")
#define CHECK(x) do { if (!(x)) { printf("%s failed\n", #x); abort(); } } while(0)
int main(void) {
void *stacktrace[16];
size_t n, count = CaptureStackBackTrace(0, 16, stacktrace, NULL);
HANDLE proc = GetCurrentProcess();
CHECK(SymInitialize(proc, NULL, TRUE));
for (n = 0; n < 16 && n < count; ++n) {
// See http://msdn.microsoft.com/en-us/library/ms680578(VS.85).aspx
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(CHAR)];
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
IMAGEHLP_LINE64 info;
DWORD64 offset = 0;
DWORD unused;
BOOL got_objname, got_fileline;
}
printf("Done\n");
return 0;
}
The text was updated successfully, but these errors were encountered: