I'm trying to get line numbers of address I collected in a stackwalk by using symgetlinefromaddr64, but I can't seem to get addresses of simple commands or their lines.
for example, if i'm looking at the method:
void Test(int g)
{
g++;
DoSomething(g);
g--;
}
I'll get only the line number of "DoSomething", but I want the line numbers of "g++" etc. I suppose it is doable because debuggers do it. how can I do it myself in c++ on windows?
A stack walk will only retrieve addresses that are stored on the stack, which pretty much means function calls. If you want the address of your
g++org--, you'll need to use something other than a stack walk to get them (e.g.,SymGetFileLineOffsets64). If you're starting from a stackwalk and have info fromSymGetLineFromAddr64, you can useSymGetLineNext64andSymGetLinePrev64to get information about the surrounding lines.