Author Topic: Dr. Memory  (Read 21828 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Dr. Memory
« Reply #15 on: February 28, 2012, 10:30:19 am »
Does TDM's g++ 4.5.x produce dwarf2 symbols?
I don't know about TDM's g++ 4.5.x, but TDM's g++ 4.6.x do (of course, you'll need to d/l the DWARF version).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Dr. Memory
« Reply #16 on: February 28, 2012, 10:35:32 am »
I think that I'm using the dw2 version of 4.5.x.
« Last Edit: February 28, 2012, 10:39:47 am by oBFusCATed »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Dr. Memory
« Reply #17 on: March 29, 2012, 07:54:49 am »
I think that I'm using the dw2 version of 4.5.x.
OK - the final DrMemory release with official MinGW support is out. I did a small sample:
Code
#include <cstdlib> // malloc
#include <iostream>

void func2(int* the_old_i, int the_new_i)
{
  std::cout << "Now in func2!" << std::endl;
  *the_old_i = the_new_i;

  std::cout << "Now leaking " << sizeof(double) << " bytes w/ malloc..." << std::endl;
  double* d = static_cast<double*>( malloc(sizeof(double)) );
}

void func1(int* i)
{
  std::cout << "Calling func2()" << std::endl;
  func2(i, 42);

  std::cout << "Now leaking 42 bytes w/ malloc..." << std::endl;
  void* v = malloc(42);
}

int main(int argc, char **argv)
{
  std::cout << "Calling func1()" << std::endl;
  int* i = new int;
  func1(i);

  std::cout << "Now leaking " << sizeof(int) << " bytes w/ new..." << std::endl;

  return 0;
}
And that's the report I am getting:
Dr. Memory version 1.4.6 build 2 built on Mar  7 2012 10:14:04
Application cmdline: ""C:\Devel\DrMemory\bin\drmemory_test.exe""
Recorded 62 suppression(s) from default C:\Devel\DrMemory/bin/suppress-default.txt

Error #1: POSSIBLE LEAK 58 direct bytes 0x003f2cd0-0x003f2d0a + 0 indirect bytes
# 0 msvcrt.dll!lock     
# 1 msvcrt.dll!_getmainargs
# 2 __mingw_CRTStartup                     [../mingw/init.c:60]
# 3 mainCRTStartup                         [../mingw/crt1.c:264]
# 4 KERNEL32.dll!RegisterWaitForInputIdle

Error #2: LEAK 4 direct bytes 0x003f2e28-0x003f2e2c + 0 indirect bytes
# 0 operator new()   
# 1 main                         [C:\Devel\DevPacks\DrMemory\bin/drmemory_test.cpp:25]

Error #3: LEAK 8 direct bytes 0x003f2e58-0x003f2e60 + 0 indirect bytes
# 0 func2()                   [C:\Devel\DrMemory\bin/drmemory_test.cpp:10]
# 1 std::ws<>()     
# 2 func1()                   [C:\Devel\DrMemory\bin/drmemory_test.cpp:16]
# 3 main                      [C:\Devel\DrMemory\bin/drmemory_test.cpp:26]

Error #4: LEAK 42 direct bytes 0x003f2e88-0x003f2eb2 + 0 indirect bytes
# 0 func1()                   [C:\Devel\DrMemory\bin/drmemory_test.cpp:19]
# 1 std::ws<>()     
# 2 main                      [C:\Devel\DrMemory\bin/drmemory_test.cpp:26]

DUPLICATE ERROR COUNTS:

SUPPRESSIONS USED:

ERRORS FOUND:
      0 unique,     0 total unaddressable access(es)
      0 unique,     0 total uninitialized access(es)
      0 unique,     0 total invalid heap argument(s)
      0 unique,     0 total warning(s)
      3 unique,     3 total,     54 byte(s) of leak(s)
      1 unique,     1 total,     58 byte(s) of possible leak(s)
ERRORS IGNORED:
    202 still-reachable allocation(s)
         (re-run with "-show_reachable" for details)
Details: C:\Devel\DrMemory/drmemory/logs/DrMemory-drmemory_test.exe.6988.000/results.txt

Nice, isn't it???
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Dr. Memory
« Reply #18 on: March 29, 2012, 08:21:17 am »
I think that I'm using the dw2 version of 4.5.x.
OK - the final DrMemory release with official MinGW support is out. I did a small sample:
Nice, isn't it???
VERY nice! I have never used it, I will try to download one from http://drmemory.googlecode.com/files/DrMemory-Windows-1.4.6-2.zip and test it.  :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.