From: John Martin <jmartin@larraioz.com>
To: jan.kratochvil@redhat.com
Cc: gdb@sourceware.org
Subject: Doubts with GDB and GDBSERVER
Date: Mon, 10 Dec 2012 15:00:00 -0000 [thread overview]
Message-ID: <50C5F90B.90204@larraioz.com> (raw)
In-Reply-To: <50C5F681.8050505@larraioz.com>
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.
next parent reply other threads:[~2012-12-10 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <50C5F681.8050505@larraioz.com>
2012-12-10 15:00 ` John Martin [this message]
2012-12-13 21:19 ` Tom Tromey
[not found] <50C5D99A.8040708@larraioz.com>
2012-12-10 12:57 ` John Martin
2012-12-10 13:38 ` Luis Machado
2012-12-10 13:46 ` John Martin
2012-12-10 13:51 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50C5F90B.90204@larraioz.com \
--to=jmartin@larraioz.com \
--cc=gdb@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox