i tried this a couple of weeks ago with no success no
after more expermentation i think
i have something that works.
first on the host machine i downloaded and compiled
gdb version 6.0.
then i created a do nothing project that would
illustrate what i was looking for.
there is a main the opens a file and writes to it.
initall i wanted to write something to console
but it seems gdb server was eating the stderr
output. but opening a file and writting data
to it would show that program was be controlled
remotely.
------------------------------ main.c ---------------------
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include "foo.h"
int main(int argc, char * argv[])
{
int i = 0;
FILE *pFile;
pFile = fopen("/tmp/out.txt","w");
for(;;)
{
i++;
fprintf(pFile,"%d\n",foo(i));
fflush(pFile);
}
return 0;
}
----------------------------------------------
i wanted to see of the insight debugger
could automatically load source that
was being remotely debugged.
----------------------- foo.c ----------------
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include "foo.h"
int foo(int i)
{
return i-1;
}
-----------------------------------------------
procedure.
1) compile and link the program then tar
all of it and ftp it to the remote machine.
untar this and run gdbserver as follows:
./gdbserver 192.168.0.10:1234 ./stubs
the name of program executeable is stubs
the ip of this remote machine 192.168.0.10
i selected a port address of 1234.
2) on the host side start the insight debugger
and open the console window and type
file /path/to/stubs
then
target extended-remote 192.168.0.10:1234
the following should echo back
0x40000c90 in ?? ()
3) start debugging or should start debugging.
b main should put a breakpoint at main.
then
c or continute will run till main and stop
execute here
after that i started type s and as came to line
fprintf(pFile,"%d\n",foo(i));
the source file for foo.c was load automatically.
i telneted over to the remote machine and examined
the file /tmp/out.txt and the output was
0
1
2
3
as it should be.
No comments:
Post a Comment