Salut,

Nu am inteles f. bine, daca vrei sa faci din acelasi program sau din altul,
dar merge folosing gdb, si atasind-ul la programul la care vrei sa vezi
stiva.
Poti folosi codul de mai jos, vezi sa pui informatiile de debug in
executabil (-g) :

void debug_stack(int up_frames, int show_stack, int show_calling_function,
        int show_source_info, int show_functions,
        char * show_types, char * show_expressions)
{
    char s[2000];
    char * GDB_CONFIG_FILE;
    char executable[10000];
    for (int i=0; i<10000; i++)
        executable[i]=0;

    #ifdef __linux__
        readlink("/proc/self/exe", executable, 10000);
    #elif __CYGWIN__
        sprintf(executable,"my_app.exe");
    #else
        #error Implement this  ....
    #endif

    GDB_CONFIG_FILE="/tmp/DEBUG_CRASH_FILE";
    FILE * fout;
    fout = fopen(GDB_CONFIG_FILE,"wt");
    fprintf(fout,"set verbose off\nset confirm off\nset pagination off\n");

    if (show_stack)
                fprintf(fout,"bt\n");
    if (show_calling_function)
    {
                sprintf(s,"frame %d\nlist -\nlist +\n",3+up_frames);
                fprintf(fout,s);
    }
    if (show_functions)
                fprintf(fout,"info functions\n");
    if (show_source_info)
                fprintf(fout,"info source\n");

    if (show_types)
    {
                char * token;
                char * kk;
                kk = strdup(show_types);
                token = strtok(kk," ");
                while (token)
                {
                        fprintf(fout,"echo Type of [%s] : \n",token);
                        fprintf(fout,"ptype %s\n",token);
                        token = strtok(NULL," ");
                };
                free(kk);
    }

    if (show_expressions)
    {
                char * token;
                char * kk;
                kk = strdup(show_expressions);
                token = strtok(kk," ");

                fprintf(fout,"frame 4\n");
                while (token)
                {
                        fprintf(fout,"echo Value of [%s] : \n",token);
                        fprintf(fout,"print %s\n",token);
                        token = strtok(NULL," ");
                };
                free(kk);
    }

    fprintf(fout,"detach\n");
    fclose(fout);
    sprintf(s, "gdb %s %d --batch --quiet -x %s 2>/dev/null", executable,
getpid(), GDB_CONFIG_FILE);
    system(s);
    return;
}

> Cum pot face dump la stiva unui program
>  dintr-ul program scris in C ?

---
Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to 
unsubscribe from this list.

Raspunde prin e-mail lui