Elena Laskavaia
|
Re: Profiling in QNX / or From QNX Momentics
|
Elena Laskavaia
09/01/2017 11:19 AM
post118009
|
Re: Profiling in QNX / or From QNX Momentics
It really depends on what qnx version you have, how you exec/spawn, and how you launch it
Without knowing it general notes
1) If you launch from IDE uncheck Remove on exit in profile prefs in IDE if you want to preserve .ptrace files,
otherwise IDE will delete it
2) Stop profiling singnal is actually to PAUSE profiling not to kill the process, if process died means handler is not
installed which can happen for few reasons, see below
3) Depending how you exec you may or not may not get children be profiled, a) child has to be also instrumented for
profiling b) you have to pass same env to trigger profiling, except QPROF_FILE, it has to be modified otherwise child
will re-open and wipe parent session. Secondary files have to be Imported in IDE after the session using profiling
import
4) If you fork and not exec trace file will be shared creating a mess
This is my example than works
qnxexehello.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
void fun(char * mess) {
puts(mess);
sleep(5);
}
void fun2(char * mess) {
puts(mess);
}
int main(int argc, char * argv[]) {
fun2("start");
int count = 0;
if (argc >= 2)
count = atoi(argv[1]);
char* var = getenv("QPROF_FILE");
printf("Hello World!!! %d %d\n", count, getpid()); /* prints Hello World!!! */
if (var != NULL) {
printf("QPROF_FILE=%s\n", var);
} else {
printf("QPROF_FILE is not set\n");
}
fun("continue");
if (count <= 0) {
fun2("sending stop");
fun("the end");
exit(0);
}
count--;
int pid = fork();
if (pid==0) {
fun("foo1");
fun2("foo2");
char scount[10];
char * xargv[] = { "/tmp/qnxexehello", scount, NULL };
sprintf(scount, "%d", count);
if (var != NULL) {
char * p = strstr(var, "prof");
if (p != NULL) {
sprintf(p, "prof%d.ptrace", getpid());
}
}
int rc = execv(xargv[0], xargv);
printf("went wrong rc=%d\n", rc);
} else {
fun("boo1");
fun("boo2");
}
return EXIT_SUCCESS;
}
|
|
|