Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stepping into MACRO in VC++

I am debugging a source code that has a lot of big #define'd MACRO routines. I am interesting in stepping into them, but I guess, VC++ does not allow step-in functionality ... so,

  • I am converting them into functions, but this is becoming hard for me

Is there a way to step into MACRO routines? especially in VC++?

PS: I can port the whole code into gcc, if gcc compiler supports stepping into MACRO

like image 233
Alphaneo Avatar asked Sep 30 '09 05:09

Alphaneo


1 Answers

In addition to all correct answers above: what I usually do is to show mixed display (C+assembly). This shows what really happens. Even if you are no expert in the underlying assembly, it gives an idea what happens (i.e. is it a trivial replacement or a complex loop). Also it will provide additional opportunities to step into functions. For instance, if your macro is

#define foo(a) i++;foo_func(a,i)

your debugger will show something like looping and what kind of variables are used). You can use the macro definition as a reference to understand it.

00411454  mov         dword ptr [j],eax 
00411457  cmp         dword ptr [j],0Ah 
0041145B  jge         wmain+58h (411478h) 
    {
        foo(j);
0041145D  mov         eax,dword ptr [i] 
00411460  add         eax,1 
00411463  mov         dword ptr [i],eax 
00411466  mov         eax,dword ptr [i] 
00411469  push        eax  
0041146A  mov         ecx,dword ptr [j] 
0041146D  push        ecx  
0041146E  call        foo_func (411028h) 
00411473  add         esp,8 
    }

This gives a clue that variables i and j are used to call function foo_func.

If you use Visual C++, it will allow you to step into functions called from a macro (F11); not individual statements though.

like image 175
Adriaan Avatar answered Oct 20 '22 18:10

Adriaan