drmemory icon indicating copy to clipboard operation
drmemory copied to clipboard

No line numbers with -ggdb or -g flag in MinGW

Open archdyn opened this issue 3 years ago • 1 comments

This is probably more an Info than a bug but I found the documentation a little bit misleadingI had the problem that DrMemory didnt show the line numbers in the following simple test.cpp.

#include <cstdlib>

int main(int argc, char *argv[]) {
  int *p1 = (int*)malloc(4*sizeof(int));
  if(p1) {
    for(int n=0; n<4; ++n)
      p1[n] = n*n;
  }
  return 0;
}

The test.cpp was compiled in MSYS MinGW64 with gcc version 11.2.0: g++ -static-libgcc -static-libstdc++ -ggdb test.cpp DrMemory call was: drmemory.exe -leaks_only -- a.exe

The results showed me this with no line numbers in main

Dr. Memory version 2.5.0 build 0 built on Oct 18 2021 03:01:22
Windows version: WinVer=105;Rel=2009;Build=19044;Edition=Enterprise
Dr. Memory results for pid 6120: "a.exe"
Application cmdline: "a.exe"
Recorded 124 suppression(s) from default C:\Projekte\DrMemory\bin64\suppress-default.txt

Error #1: LEAK 16 direct bytes 0x0000023cbb8902c0-0x0000023cbb8902d0 + 0 indirect bytes
# 0 replace_malloc               [d:\a\drmemory\drmemory\common\alloc_replace.c:2580]
# 1 msvcrt.dll!onexit           +0xf5     (0x00007ffc4a79aa86 <msvcrt.dll+0x2aa86>)
# 2 main 

===========================================================================
FINAL SUMMARY:

DUPLICATE ERROR COUNTS:

SUPPRESSIONS USED:

ERRORS FOUND:
      0 unique,     0 total invalid heap argument(s)
      0 unique,     0 total warning(s)
      1 unique,     1 total,     16 byte(s) of leak(s)
      0 unique,     0 total,      0 byte(s) of possible leak(s)
ERRORS IGNORED:
      1 potential leak(s) (suspected false positives)
         (details: C:\Projekte\DrMemory\drmemory\logs\DrMemory-a.exe.6120.000\potential_errors.txt)
      3 unique,     3 total,     38 byte(s) of still-reachable allocation(s)
         (re-run with "-show_reachable" for details)

I could only get line numbers if I explicitly compiled with -gdwarf-2 g++ -static-libgcc -static-libstdc++ -gdwarf-2 test.cpp DrMemory call was: drmemory.exe -leaks_only -- a.exe

The results from DrMemory now showed me the line numbers.

Dr. Memory version 2.5.0 build 0 built on Oct 18 2021 03:01:22
Windows version: WinVer=105;Rel=2009;Build=19044;Edition=Enterprise
Dr. Memory results for pid 12008: "a.exe"
Application cmdline: "a.exe"
Recorded 124 suppression(s) from default C:\Projekte\DrMemory\bin64\suppress-default.txt

Error #1: LEAK 16 direct bytes 0x0000024f861f02c0-0x0000024f861f02d0 + 0 indirect bytes
# 0 replace_malloc               [d:\a\drmemory\drmemory\common\alloc_replace.c:2580]
# 1 msvcrt.dll!onexit           +0xf5     (0x00007ffc4a79aa86 <msvcrt.dll+0x2aa86>)
# 2 main                         [C:\Projekte\Test/test.cpp:4]

===========================================================================
FINAL SUMMARY:

DUPLICATE ERROR COUNTS:

SUPPRESSIONS USED:

ERRORS FOUND:
      0 unique,     0 total invalid heap argument(s)
      0 unique,     0 total warning(s)
      1 unique,     1 total,     16 byte(s) of leak(s)
      0 unique,     0 total,      0 byte(s) of possible leak(s)
ERRORS IGNORED:
      1 potential leak(s) (suspected false positives)
         (details: C:\Projekte\DrMemory\drmemory\logs\DrMemory-a.exe.12008.000\potential_errors.txt)
      3 unique,     3 total,     38 byte(s) of still-reachable allocation(s)
         (re-run with "-show_reachable" for details)

archdyn avatar Apr 12 '22 17:04 archdyn

funny was trying to figure this out earlier

this is stinky looking but this is what I added to get it to include the lines numbers

CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -O0 -ggdb -fno-omit-frame-pointer -gdwarf-4 -pipe -fPIC -MMD -MP -static-libgcc -static-libstdc++

-O0 and -g was not good enough apparently... something to do with -fno-omit-frame-pointer -gdwarf-4 -static-libgcc -static-libstdc++

tbh idk what -gdwarf-4 does saw on stack overflow some dude going on about it for osx and gave it a shot.

now if only i could figure out what the stupid missing system calls is about

boardkeystown avatar Jun 13 '24 05:06 boardkeystown