Doubts with GDB and GDBSERVER

John Martin jmartin@larraioz.com
Mon Dec 10 15:00:00 GMT 2012


Hello Jan,

Great, it works.
Without binary in host computer, I can read symbol table from remote target.


By other hand, I am using GDB with interpreter  MI (Machine Interface).
It works fine but there is a bit problem.
I have tried to send commands from C program to GDB using libmigdb library.

Example code:

//************************************************************************************
void InitGDBmi ()
{
     mi_set_gdb_exe(nameGDB);
     h = mi_connect_local();
     if (!h)
         printf("Connect failed\n");

//    mi_set_console_cb(h,cb_console,NULL);
//    mi_set_target_cb(h,cb_target,NULL);
//    mi_set_log_cb(h,cb_log,NULL);
//    mi_set_async_cb(h,cb_async,NULL);
//    mi_set_to_gdb_cb(h,cb_to,NULL);
     mi_set_from_gdb_cb(h,cb_from,NULL);

     gmi_set_exec(h, "LINMOT_TEST", "-qws");
}

int CallWhatis(char *data)
{
     memset(&mensaje[0], 0, sizeof(mensaje));
     strcpy(mensaje, "whatis ");
     strcat(mensaje, data);
     mi_send(h,"%s\n",mensaje);
     return mi_res_simple_done(h);
}

int CallPtype(char *data)
{
     memset(&mensaje[0], 0, sizeof(mensaje));
     strcpy(mensaje, "ptype ");
     strcat(mensaje, data);
     mi_send(h,"%s\n",mensaje);
     return mi_res_simple_done(h);
}

int CallSizeOf(char *data)
{
     memset(&mensaje[0], 0, sizeof(mensaje));
     strcpy(mensaje, "p sizeof(");
     strcat(mensaje, data);
     strcat(mensaje, ")");
     mi_send(h,"%s\n",mensaje);
     return mi_res_simple_done(h);
}

int CallAddr(char *data)
{
     memset(&mensaje[0], 0, sizeof(mensaje));
     strcpy(mensaje, "p &");
     strcat(mensaje, data);
     mi_send(h,"%s\n",mensaje);
     return mi_res_simple_done(h);
}

//************************************************************************************

In other part of the programm, I call all functions:

void VarInfo (void)
{
         CallWhatis(nameVar);
         CallPtype(nameVar);
         CallAddr(nameVar);
         CallSizeOf(nameVar);
}

And after it, gdb give  a response:

<< &"whatis PCISRAM_FD\n"
<< ~"type = INT\n"
<< ^done
<< (gdb)
<< &"ptype PCISRAM_FD\n"
<< ~"type = short int\n"
<< ^done
<< (gdb)
<< &"p &PCISRAM_FD\n"
<< ~"$1 = (INT *) 0x8670296 <PCISRAM_FD>\n"
<< ^done
<< (gdb)

But gdb does not send me response about size of variable. But if I call 
again VarInfo function, gdb return me .....


<< &"p sizeof(PCISRAM_FD)\n"
<< ~"$2 = 2"
<< ~"\n"
<< ^done
<< (gdb)
<< &"whatis panel_access_code\n"
<< ~"type = INT\n"
<< ^done
<< (gdb) Fwd: Fwd: Fwd: Re:
<< &"ptype panel_access_code\n"
<< ~"type = short int\n"
<< ^done
<< (gdb)
<< &"p &panel_access_code\n"
<< ~"$3 = (INT *) 0x8670324 <panel_access_code>\n"
<< ^done
<< (gdb)

I have received the size of var last request and receive new infromation 
of new var less sizeof.

Could somebody known gdb does not return me all request at the same time???

Best regards.



More information about the Gdb mailing list