[LLVMbugs] [Bug 12283] New: clang doesn't produce dbghelp-friendly debug info

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 16 06:03:42 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12283

             Bug #: 12283
           Summary: clang doesn't produce dbghelp-friendly debug info
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: timurrrr at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


$ 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 <no info>
 #01 <no info>
 #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;

    DWORD64 addr = (DWORD64)stacktrace[n];

    symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
    symbol->MaxNameLen = MAX_SYM_NAME;
    got_objname = SymFromAddr(proc, addr, &offset, symbol);
    info.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
    got_fileline = SymGetLineFromAddr64(proc, addr, &unused, &info);
    if (got_fileline) {
      printf(" #%02d %s %s:%ld\n", n, symbol->Name, info.FileName,
info.LineNumber);
    } else if (got_objname) {
      printf(" #%02d %s+0x%p\n", n, symbol->Name, (void*)offset);
    } else {
      printf(" #%02d <no info>\n", n);
    }
  }
  printf("Done\n");
  return 0;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list