Celtoys / Remotery

Single C file, Realtime CPU/GPU Profiler with Remote Web Viewer
Apache License 2.0
3.11k stars 264 forks source link

How to use in Sample? #243

Closed TyeolRik closed 1 year ago

TyeolRik commented 2 years ago

Hello, I am newbie here. I found this repository via searching boost asio solution in my project.

I cannot understand how can I run this and, how to solve this error Error launching Remotery 5.

My PC (Environment)

What is did

I just run compile and run sample as README said.

$ cd ~
$ git clone https://github.com/Celtoys/Remotery.git
$ cd Remotery/
$ cc lib/Remotery.c sample/sample.c -I lib -pthread -lm
$ ./a.out
Error launching Remotery 5
$ cc lib/Remotery.c sample/thread.c -I lib -pthread -lm
$ ./a.out
Creating remotery instance
Error launching Remotery 5: No error message
$ cc lib/Remotery.c sample/dump.c -I lib -pthread -lm
$ ./a.out
Error launching Remotery 5

GCC version information

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC)
dwilliamson commented 2 years ago

5 maps to RMT_ERROR_RESOURCE_ACCESS_FAIL.

Can you modify this line: https://github.com/Celtoys/Remotery/blob/cc32849f1075154c087fccdfff829662be69a23f/sample/sample.c#L51

So that it's:

printf("Error launching Remotery %d (%s)\n", error, rmt_GetLastErrorMessage());
TyeolRik commented 2 years ago

I can't understand why editing printf solve the problem, but it works! Thank you.

dwilliamson commented 2 years ago

It was meant to print the actual error message, not solve your problem :)

I'm guessing it was a port open failure which your machine can now do. For some reason...

TyeolRik commented 2 years ago

I am so sorry but, I can't re-produce the error :(

I don't know why this didn't work before, and do work now.. (Same source code, Same GCC, Same OS, Same Computer etc..)

And also I think port is not problem because my firewall-cmd is stopped a long long time ago. (Right after I installing CentOS)

[root@dev-desktop Remotery]# firewall-cmd --list-ports
FirewallD is not running

When the error occurs, I will report you right away. Thank you for making good profiler 👍

TyeolRik commented 2 years ago

Sorry but I got a same error message

[root@dev-desktop Remotery]# cc lib/Remotery.c sample/sample.c -I lib -pthread -lm
[root@dev-desktop Remotery]# ./a.out 
Error launching Remotery 5 (No error message)

[root@dev-desktop Remotery]# cc lib/Remotery.c sample/thread.c -I lib -pthread -lm
[root@dev-desktop Remotery]# ./a.out 
Creating remotery instance
Error launching Remotery 5: No error message

And also I already did, the printf the error message

int main( ) {
    Remotery *rmt;
    rmtError error;

    signal(SIGINT, sigintHandler);

    error = rmt_CreateGlobalInstance(&rmt);
    if( RMT_ERROR_NONE != error) {
        printf("Error launching Remotery %d (%s)\n", error, rmt_GetLastErrorMessage());
        return -1;
    }

    while (sig == 0) {
        rmt_LogText("start profiling");
        delay();
        rmt_LogText("end profiling");
    }

    rmt_DestroyGlobalInstance(rmt);
    printf("Cleaned up and quit\n");
    return 0;
}

It said No error message. Is there any more thing that I can do?

dwilliamson commented 2 years ago

Unless you can get me a call stack I can't really diagnose what's going on here.

All of the errors that return RMT_ERROR_RESOURCE_ACCESS_FAIL at least set the error message, so what you're seeing suggests even the TLS code isn't working.

TyeolRik commented 1 year ago

Thanks. I will reopen this issue when I found the same error and (my estimated) reason :)