6

I've tried running valgrind (memcheck and massif) on an app I wrote, but all I get back are addresses for the functions that executed.

--------------------------------- Context accounted for 0.6% of measured spacetime 0x805F29A: (within prog_name) 0x8141740: (within prog_name) Called from: 0.6% : 0x812E077: (within prog_name) --------------------------------- Context accounted for 0.5% of measured spacetime 0x805F29A: (within prog_name) 0x81418FB: (within prog_name) Called from: 0.5% : 0x812E077: (within prog_name) 

I compiled my app with the -g flag to put the debugging symbols in. Is there any other reason why valgrind wouldn't show the source line?

EDIT: valgrind version 3.2.1-Debian; g++ 4.3.1

4
  • 1
    Not sure, but if you gdb prog_name your app and try something like break 0x812E077, does gdb show line numbers? (You shouldn't need to even run the program, just have gdb load it.) Commented Oct 25, 2010 at 21:48
  • @aschepler - Tried it. Whenever I try to do that, gdb can't find the function named "0x812E077" and asks if it is in a library that it will load later... so that didn't work. Commented Oct 25, 2010 at 22:23
  • 1
    Whoops, that should have been break *0x812E077. But glad you found a fix. Commented Oct 26, 2010 at 18:32
  • Didn't realize I could do that in gdb though. Thanks for your tip! Commented Oct 26, 2010 at 18:52

4 Answers 4

8

I discovered that I passed in both the -g and -ggdb flags to g++ at compile time. Omitting the -g flag caused this issue to go away.

Sign up to request clarification or add additional context in comments.

Comments

3

There are a couple of possible reasons:

  • you may have inadvertently stripped your executable (most likely explanation),
  • you may be executing JITted code (though the address doesn't look like that's the case).

What does file prog_name say? If it says "stripped", that's a problem. You might also want to check whether other tools, e.g. GDB know what symbol is at address 0x805F29A:

gdb prog_name (gdb) info symbol 0x805F29A 

3 Comments

I never got a stripped message. I don't know for sure, but I suspect mixing the '-g' and '-ggdb' flags messed it up.
@sheepsimulator You can suspect all you want, but if you want us to help you, please provide the info that we ask for: what exactly does 'file prog_name' say? what exactly does GDB 'info symbol' say?
I appreciate your show of support, but this problem went away when I omitted the -g flag at compile time. I consider my question answered.
1

I guess, you are not mentioning right flags, and going with default flags.

--show-reachable is one such flag which should be enabled, please look at other flags and enable them.

--Cheers

Comments

1

For other readers with similar problem (i had the same but my compiler options where ok): It turns out that valgrind needs the path to the executable, if you dont give this then it will run ok but it won't give you the line numbers. In my case the executable was in a different directory, which was in my PATH, but to get the line information i had to run

valgrind --leak-check=full path_to_myprogram/myprogram

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.