Author Topic: Profiling a library  (Read 2326 times)

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Profiling a library
« on: September 22, 2018, 07:58:42 pm »
I have a library plugin (DLL) with performance issues. I'd like to profile that, but do not have access to the source of the target application. I can debug it in the target, but I do not know how to use the profiler plugin with a library.

For a executable I set the profiling compiler flag and it reads the executable after execution.

With the lib I comile with the flag and open the profiler plugin and it says
 Error: The target is not executable


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12006
    • Travis build status
Re: Profiling a library
« Reply #1 on: September 22, 2018, 08:59:43 pm »
Just use perf and flamegraphs, don't bother with gprof. There is a hotspot UI for perf which is nice...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #2 on: September 22, 2018, 11:05:12 pm »
Thanks great tip. Flame graphs made by that tool are really looking good to quickly get to the beef. I guess perf would fill in for missing stuff like hit counts etc. 
Only one tiny thing I forgot to mention: that libray in question is a windows DLL. Running in a Windows only environment (graphics, so no VM possible)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2493
Re: Profiling a library
« Reply #3 on: September 22, 2018, 11:52:00 pm »
Profiling on windows is a pain in the a*** with open source tools... I had some success with "Very Sleepy" http://www.codersnotes.com/sleepy/ I don't know if you can profile dlls with it...

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #4 on: September 23, 2018, 12:32:42 am »
From the description is can connect to a live PID, which is good.
Wether it runs with a process which was not compiled for profiling, but is calling a DLL compiled for profiing is to be found out.

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #5 on: September 23, 2018, 06:27:56 pm »
Tried to profile the DLL with VerySleepy.  I compiles the DLL with the profile compile switch enabled. in release mode.

The started the Base application from wxSleepy, giving the Apps working directory.
VerySleepy does record stuff while the application runs and after its closed it shows results.
But there are no data except Baseapplcation OS calls and OS module call, nothing specific to the DLL. No link to any function names etc.

So I would conclude you can not use VerySleepy for that purpose

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2493
Re: Profiling a library
« Reply #6 on: September 23, 2018, 07:57:36 pm »
You have to compile the dll with debug symbols, not with profiler settings enabled. Any profiler needs debug symbols in the binary to give you function names ecc...

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #7 on: September 23, 2018, 11:32:19 pm »
Tried that but it made no difference, same result.


Online stahta01

  • Lives here!
  • ****
  • Posts: 6636
    • My Best Post
Re: Profiling a library
« Reply #8 on: September 24, 2018, 01:33:39 am »
Tried that but it made no difference, same result.

So, you compiled the DLL with debug symbols; but, failed to get more information, correct?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #9 on: September 24, 2018, 11:08:52 am »
Right. I did compile the DLL with -g compiler switch and with/without -pg switch and run its executable with VerySleepy.
I did not see a single list entry with a function from the DLL, even though I could verifiy it was definitely executed.

Did you manage to profile a DLL with VerySleepy before?

« Last Edit: September 24, 2018, 11:27:59 am by tigerbeard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12006
    • Travis build status
Re: Profiling a library
« Reply #10 on: September 24, 2018, 11:26:47 am »
The flag for symbols is -g not -G...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #11 on: September 24, 2018, 11:28:27 am »
of course, typo. Corrected it.
Thanks

Online stahta01

  • Lives here!
  • ****
  • Posts: 6636
    • My Best Post
Re: Profiling a library
« Reply #12 on: September 24, 2018, 06:12:26 pm »
And, you made sure there was no "-s" that strips the debug symbols.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2493
Re: Profiling a library
« Reply #13 on: September 24, 2018, 07:08:00 pm »
I see this also some times: For example i can not profile the code completion plugin dll of codeblocks. The symbols are simply not found, but i have them activated, because other core plugins and the wxWidgets dll work fine... Just the code completion plugin won't show me any call stack or function names...

I tried to find the reason, but was not successful. If someone is able to do it, please let me know ;)

Offline tigerbeard

  • Multiple posting newcomer
  • *
  • Posts: 89
Re: Profiling a library
« Reply #14 on: September 24, 2018, 07:16:28 pm »
And, you made sure there was no "-s" that strips the debug symbols.
Yes, also the huge filesize showed that the symbols were is. Optimazion was off as well

other core plugins and the wxWidgets dll work fine...
Do you mean you could profile one (or more) of those non-code-completion-plugins while there were running in  Codeblocks?