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

Profile dump file not being produced; no errors #190

Open
Zylatis opened this issue Dec 25, 2020 · 7 comments
Open

Profile dump file not being produced; no errors #190

Zylatis opened this issue Dec 25, 2020 · 7 comments

Comments

@Zylatis
Copy link

Zylatis commented Dec 25, 2020

Hi,

I have what is probably a dumb question: the output file isn't being produced when dumping to disk.

I'm on ubuntu 16.04 and the project builds fine (i can open the GUI editor and all that) and I can compile a simple code (below) fine and it runs but the .prof file isn't produced anywhere. I've tried giving absolute paths and searching my whole drive but it simply doesn't exist - any ideas?

#include <easy/profiler.h>

void foo() {
    EASY_FUNCTION(profiler::colors::Magenta); // Magenta block with name "foo"

    EASY_BLOCK("Calculating sum"); // Begin block with default color == Amber100
    int sum = 0;
    for (int i = 0; i < 10; ++i) {
        EASY_BLOCK("Addition", profiler::colors::Red); // Scoped red block (no EASY_END_BLOCK needed)
        sum += i;
    }
    EASY_END_BLOCK; // End of "Calculating sum" block

    EASY_BLOCK("Calculating multiplication", profiler::colors::Blue500); // Blue block
    int mul = 1;
    for (int i = 1; i < 11; ++i)
        mul *= i;
    //EASY_END_BLOCK; // This is not needed because all blocks are ended on destructor when closing braces met
}


int main() {
    EASY_PROFILER_ENABLE;
    /* do work */
    foo();
    profiler::dumpBlocksToFile("test_profile.prof");
    return 0;
}
@yse
Copy link
Owner

yse commented Dec 25, 2020

Hello! Thanks for feedback. Let's debug together!

Try add EASY_OPTION_LOG=1 when cmake generating process:

cmake -DEASY_OPTION_LOG=1 ..

This option enable some diagnostics logs. May be program cannot open file for writing. I tried to write a file in place where I haven't permissionw (for example /). I get following logs (in stdout and stderr):

EasyProfiler INFO: Enabled profiling
EasyProfiler INFO: dumpBlocksToFile("/test_profile.prof")...
EasyProfiler ERROR: Can not open "/test_profile.prof" for writing

@Zylatis
Copy link
Author

Zylatis commented Dec 26, 2020

Hey, thanks for the speedy reply!

I am doing the following

 cmake -DCMAKE_BUILD_TYPE="Release"  -DEASY_OPTION_LOG=1 ..
-- 
-- EASY_PROFILER.Core version = 2.1.0
-- 
-- -------- EASY_PROFILER OPTIONS: --------
--   Use rtdsc as a timer
--   Default listening port = 28077
--   Auto-start listening = OFF
--   Profile self = OFF
--   Profile self blocks initial status = OFF
--   Truncate block dynamic names = OFF (may cause crash if using dynamic block names of length >2816 symbols)
--   Check maximum EASY_VALUE data size = OFF (may cause crash if using EASY_VALUE arrays of total data size >2816 bytes)
--   Implicit thread registration = ON
--   Log messages = 1
--   Function names pretty-print = OFF
--   Use EasyProfiler colors palette = ON
--   Shared library: ON
-- ------ END EASY_PROFILER OPTIONS -------
-- 
-- Using Qt v5.5.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/XXX/easy_profiler-develop/build

I then rerun 'make' and compile the test with

g++ -o test test.cpp -I /home/XXX/easy_profiler-develop/easy_profiler_core/include --std=c++14

which compiles fine. I then run it, it outputs nothing but the result of the calculation, and no file :/ No diagnostic or anything :sadcat:

I also tried with just

cmake -DEASY_OPTION_LOG=1 ..

instead of the release option, reran make etc etc, same result. I feel like i'm missing something dumb and obvious...

@yse
Copy link
Owner

yse commented Dec 26, 2020

I understand.
Try add BUILD_WITH_EASY_PROFILER definition for g++. See docs. You also need an info for linker - path with builded easy_profiler. If you are using CMake - the definition will be added by cmake in your project.

May be necessity of the definition is ugly design but...I don't know, it was from firsts steps and we kept it for backward compatibility.

@marcinp686
Copy link

It happens when you do not have BUILD_WITH_EASY_PROFILER macro defined. No errors or warnings and no output as well.
I think this issue should be closed.

@qlibp
Copy link

qlibp commented Jan 13, 2023

It happens when you do not have BUILD_WITH_EASY_PROFILER macro defined. No errors or warnings and no output as well. I think this issue should be closed.

I encounter the same problem too, the wiki don't really discuss this problem in details.

I find in easy_profiler_core/CMakeLists.txt that -DBUILD_WITH_EASY_PROFILER=1 is already defined, so why would I need to add an argument again when invoking cmake?

@marcinp686
Copy link

It depends on your usage of CMake and it's variable scope resolution. If you want to set a variable from child project you need to define it with PARENT_SCOPE option, like this: set(BUILD_WITH_EASY_PROFILER "1" PARENT_SCOPE) . Otherwise you need to define it in your parent project.

@VMorHSE
Copy link

VMorHSE commented Mar 4, 2024

I had the same problem on my Windows. Finally I've realized that I just needed to add full path to my libeasy_profiler.dll to the Path system variable. My exe just couldn't find the needed dll and crashed at startup.
So it seems to me that you need to somehow give your executable access to all needed shared libs.

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

5 participants