Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function name displayed in .pdb files #39

Closed
HongThatCong opened this issue Aug 13, 2023 · 7 comments
Closed

Function name displayed in .pdb files #39

HongThatCong opened this issue Aug 13, 2023 · 7 comments

Comments

@HongThatCong
Copy link
Contributor

HongThatCong commented Aug 13, 2023

Pin v3.28, tiny_tracer v2.6
I don't know if this is new code of tiny_tracer or new feature of Pin v3.28.
When the environment variable _NT_SYMBOL_PATH is set, and I have long since set it, the tiny_tracer (or Pin v3.28) will path and display the function name according to the debug symbol files (.pdb/.xxx).
So the functions I define in params.txt don't match.
I was forced to delete (temporarily rename) this _NT_SYMBOL_PATH environment variable.
Previous versions of Pin and tiny_tracer do not have this problem.
Below is a screenshot of an example.
image
And after turn off _NT_SYMBOL_PATH, it run OK
image

@hasherezade
Copy link
Owner

hasherezade commented Aug 13, 2023

hi @HongThatCong !
Thanks for reporting. I didn't change anything related with the name resolutions in TinyTracer, so I believe this is a change introduced in Pin platform itself.
I will investigate it in details soon, and make some workaround.
I guess this is the change in Pin that caused it:

   o RTN_Name()/SYM_Name() on Windows OS are now returning public mangled routine/symbol name (e.g. ?foo@ccc@@QAEPADH@Z) if exists.
     Use PIN_UndecorateSymbolName() when comparing routine names rather than direct comparison 
     (e.g. PIN_UndecorateSymbolName(RTN_Name(rtn), UNDECORATION_NAME_ONLY) == "RaiseX87OverflowException").

@hasherezade
Copy link
Owner

@HongThatCong - please check if my latest commit helps. For now I disabled using Debug symbols at all, only export symbols (so it should work like if the _NT_SYMBOL_PATH was not available).
Later I am gonna implement a version with demangling.

@hasherezade
Copy link
Owner

@HongThatCong - I also implemented name unmangling in a new branch: https://github.com/hasherezade/tiny_tracer/tree/unmangle
Please try both options and let me know if they help.

@HongThatCong
Copy link
Contributor Author

HongThatCong commented Aug 14, 2023

Yes, change to PIN_InitSymbolsAlt(EXPORT_SYMBOL) works fine for my needs now.
But new branch unmangling is even better, when we need to monitor C++/Rust... export functions with name mangling.
I will testing with new unmangling branch

Tks and brgs.
TQN
image

@HongThatCong
Copy link
Contributor Author

Somethings still wrong with unmangling branch.

  1. An underscore in front of the output name has been removed (by PIN_UndecorateSymbolName func?)
    image

  2. Function name still get from debug symbol name (pdb).
    image

  3. But C++ export demangled is OK
    image

@hasherezade
Copy link
Owner

@HongThatCong - thanks for checking.
Unfortunately, when some functions are represented by different names in the Debug symbol vs Exports, it is gonna be difficult to solve. Pin doesn't offer any way of using both versions simultaneously. And there is no one way to normalize them.
What I can do is making it configurable via INI file, whether or not you want the Debug symbols to be used.

@hasherezade
Copy link
Owner

@HongThatCong - please check the update to the unmangle branch.
Now you can select if from the INI file if you want to use the debug symbols: https://github.com/hasherezade/tiny_tracer/blob/unmangle/install32_64/TinyTracer.ini#L2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants