GLBasic forum

Main forum => Bug Reports => Topic started by: bigsofty on 2019-May-21

Title: Profiler broken?
Post by: bigsofty on 2019-May-21
I get a compile failed when I turn on the profiler option...

Code: GLBasic [Select]
linking:
g++.exe: error: resource.o-lGLBProfiler: No such file or directory
*** FATAL ERROR - Please post this output in the forum
Title: Re: Profiler broken?
Post by: dreamerman on 2019-May-21
Yes it's an error, surely with passing arguments to GCC (g++.exe) during link stage, GLB just doesn't add space before '-lGLBProfiler' command. Checked and 'GLBProfiler' library is in proper directory directory. File: 'resource.o' is from what I remember icon file, as now it's linked/added to project in different way than in previous GLB versions.
But another thing should be fixed too (also easy-to-fix), 'resource.rc' that's VERSIONINFO file, it contains little bug;
BLOCK "StringFileInfo" and BLOCK "VarFileInfo" should contain translation in same language code, now GLB sets StringFileInfo to '0809' code - UK English, but VarFileInfo has only translation for '0x409' - US English, this way file doesn't show proper description (author, copyright, version) in file-properties-details in system.
Just set both block's to same language, best US English so it would be:
Code: GLBasic [Select]
BLOCK "040904E4"
[...]
VALUE "Translation", 0x409, 1252
 
Info about VERSIONINFO resource file (https://docs.microsoft.com/en-us/windows/desktop/menurc/versioninfo-resource)
Title: Re: Profiler broken?
Post by: bigsofty on 2019-May-22
Had a quick look, via a recursive text search in the GLBasic compiler  but no luck finding a editable text file to fix it. Which is a pity since most of the GCC compiler and linker command line params are editable this way.

I was going to try GPROF (-pg on the project options GCC and Linker command line params) as a stand in but no luck, maybe because the symbols are stripped when creating an executable in GLB? This would actually have suited me better since I use quite a bit of inline C but oh well.
Title: Re: Profiler broken?
Post by: dreamerman on 2019-May-22
That command is surely added by GLB Editor during compilation, so rather no way to fix this in that way. One workaround is to compile from cmd, You can grab whole compilation/link command passed to gcc using this (https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer)
Start compile in GLB with profiler, switch to ProcessExplorer when GLB comes to 'link' part, hit space (on ProcessExplorer - pause refreshing) search for g++ entry and copy whole cmd, fix that wrongly placed ' ', save that to .bat file. Use it after GLB 'compile' stage to get your app (it would be something like output.obj in %TEMP%\glbasic folder).

On other hand just checked GLB v15 and I have some issues with profiler.. Didn't use it from a long time, yet I remember that it worked, now it produces empty csv file, maybe I'm doing something wrong...

ps. to avoid symbols stripping just comment (';') one line in proper platform.ini file:
Code: GLBasic [Select]
strip="%GLBASIC%Compiler\platform\Win32\bin\strip.exe" --strip-all
Title: Re: Profiler broken?
Post by: bigsofty on 2019-May-22
Thanks for the tips Dreamerman. Yeah, I was kinda hoping that the command line was read from somewhere, same as platform.ini but no luck. Strangely I can't seem to get "-pg" to work, even with stripping off.  :S

Simplest solution would be to use an old version of GLB, I know I had it working a couple of months back. It's not great though, kinda grinds my game to a halt when it is working, considering your profiling execution speed I worry about the accuracy of the profiler, when the profiler is affecting performance in such a way. Hence trying to get the GCC profiler to work on the raw C++.
Title: Re: Profiler broken?
Post by: dreamerman on 2019-May-23
Just tried and -pg is working ok (tested on small project), comment strip command, add '-pg' in project options in cmp & link, compile your app normally (no profiler).
Run your app for some time, so You will have something to measure, end/exit it, now it should create 'gmon.out' file, create .bat file or launch cmd, assuming that You will launch gprof.exe from app directory command should like this:
"GLBasic_SDK\Compiler\platform\Win32\bin\gprof.exe" youapp.exe gmon.out > profiler.txt
And here you have it. Only thing that those result's are basic and maybe could be better with other profiler/debugger - I will need to check some of them as nice graphs and better info/details would be handy :)

ps. I've checked some other profilers but all have some problems, either are vendor specific (AMD, Nvidia, Intel) or work only with VS projects (need *pdb file) and so on.. Basic gprof output may be sufficient, but I would like to compare it to GLB profiler (yet still can get it work even with previous versions hm..).
Title: Re: Profiler broken?
Post by: bigsofty on 2019-May-24
Still no luck for me I'm afraid, I'm pretty sure I tried this earlier but I went though the steps again here just in case and still no "gmon.out". Hmm...

BTW there are a couple of Windows utils that will produce a profile graph based on gmon.out...

http://www.graphviz.org and https://github.com/jrfonseca/gprof2dot

You'll need to make sure python is install first though.

EDIT: OK, I got it working. The main problem was the project command line options. I chose Win64 as my target, so I added "-pg" to the linker and GCC for that platform(Each platform has its own set of command line options). BUT there seems to be a bug with the project options even if you choose Win64 the GLB compiler ONLY uses Win32 projects command line options. Changing the Win32 ones(even though I'm not compiling Win32) seemed to add the "-pg" to the compile process.

Thanks for your help Dreamerman.  :booze:
Title: Re: Profiler broken?
Post by: dreamerman on 2019-May-24
I saw gprof2dot and tried it, little messing around with all that python, PATH setting stuff but it worked. Checked it on simple demo and produced image graph isn't something spectacular, at least it shows some connections between functions, but not all :/
There are some active profilers like tracy (https://bitbucket.org/wolfpld/tracy/src/master/) with more features but they require including additional functions/source in project, this particular profiler should be compatible with GCC & OpenGL.
Title: Re: Profiler broken?
Post by: bigsofty on 2019-May-24
I had a quick look at Tracy, yeah seems like a very good profiler. Not sure it would work out of the box with GLBasic though, as it needs OpenGL 3. I did a quick tutorial on installing OpenGL 3 support but that was on a per project basis.
Title: Re: Profiler broken?
Post by: Kitty Hello on 2019-May-30
Fixed in next update.