News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Profiling a library

Started by tigerbeard, September 22, 2018, 07:58:42 PM

Previous topic - Next topic

tigerbeard

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


oBFusCATed

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!]

tigerbeard

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)

BlueHazzard

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...

tigerbeard

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.

tigerbeard

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

BlueHazzard

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...

tigerbeard

Tried that but it made no difference, same result.


stahta01

Quote from: tigerbeard on September 23, 2018, 11:32:19 PM
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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

tigerbeard

#9
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?


oBFusCATed

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!]

tigerbeard

of course, typo. Corrected it.
Thanks

stahta01

And, you made sure there was no "-s" that strips the debug symbols.

Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

BlueHazzard

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 ;)

tigerbeard

Quote from: stahta01 on September 24, 2018, 06:12:26 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

Quote from: BlueHazzard on September 24, 2018, 07:08:00 PMother 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?