locked
How to get method name and signature from _penter ? RRS feed

  • Question

  • Lets say I have a Visual C program like below

    int main()
    {
    	method1(10);
    	method2(8.34,8.98,6.21);
    	method3(34, 56);
    	method4();
    return 0;
    }

    I used /Gh argument and instrumented like this,

    extern "C" void __declspec(naked) _cdecl _penter( void ) {
       _asm {
          push eax
          push ebx
          push ecx
          push edx
          push ebp
          push edi
          push esi
        }
    
       printf_s("\nEnter ");
    
       _asm {
          pop esi
          pop edi
          pop ebp
          pop edx
          pop ecx
          pop ebx
          pop eax
          ret
        }

    This code instruments all the methods and prints "Enter" when a function invoked. Now how do I get the method Name, signature, parameter values and File name from this _penter method ? Thank you.

    Saturday, January 30, 2016 4:17 AM

Answers

  • This information can be obtained from the .pdb file of the program, using debugger library provided by Micorosoft.

    See for example this or this. Or, again, look for profiling tools that have this capability.

    -- pa


    • Edited by Pavel A Saturday, January 30, 2016 5:38 PM
    • Proposed as answer by May Wang - MSFT Tuesday, February 9, 2016 9:06 AM
    • Marked as answer by May Wang - MSFT Tuesday, February 9, 2016 9:06 AM
    Saturday, January 30, 2016 5:36 PM

All replies

  • This information can be obtained from the .pdb file of the program, using debugger library provided by Micorosoft.

    See for example this or this. Or, again, look for profiling tools that have this capability.

    -- pa


    • Edited by Pavel A Saturday, January 30, 2016 5:38 PM
    • Proposed as answer by May Wang - MSFT Tuesday, February 9, 2016 9:06 AM
    • Marked as answer by May Wang - MSFT Tuesday, February 9, 2016 9:06 AM
    Saturday, January 30, 2016 5:36 PM
  • Hi,

    Here has demo can get the method name signature . You can try to do . the demo can get function name from the IDiaSymbol object using the get_name method .it also needs to load the PDB file from the module file path using the loadDataForExe method of IDiaDataSource.

    For more information please look the link:

    http://www.codeproject.com/Articles/47532/A-Simple-Profiler-using-the-Visual-Studio-C-C-Comp

    Best Regards,

    Hart

    Monday, February 1, 2016 5:37 AM