* Fixed the "qOffsets" return value. At least how I understand the

documentation the segment offsets it shall return are relative to the
  address specified in the program header.
* Added "qSupported".
* Added the mandatory commands and some additional ones. Partially implemented
  only.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30038 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-04-08 16:54:57 +00:00
parent 7be389053f
commit 90d46a5c43
+44 -31
View File
@@ -18,6 +18,8 @@
#include <arch/debug_console.h> #include <arch/debug_console.h>
#include <debug.h> #include <debug.h>
#include <elf.h>
#include <elf_priv.h>
#include <smp.h> #include <smp.h>
#include <vm.h> #include <vm.h>
@@ -183,6 +185,14 @@ gdb_parse_command(void)
gdb_ack(); gdb_ack();
switch (sCommand[0]) { switch (sCommand[0]) {
case '?':
// command '?' is used for retrieving the signal
// that stopped the program. Fully implemeting
// this command requires help from the debugger,
// by now we just fake a SIGKILL
gdb_reply("S09"); /* SIGKILL = 9 */
break;
case 'H': case 'H':
// Command H (actually Hct) is used to select // Command H (actually Hct) is used to select
// the current thread (-1 meaning all threads) // the current thread (-1 meaning all threads)
@@ -193,42 +203,28 @@ gdb_parse_command(void)
case 'q': case 'q':
{ {
extern unsigned __data_start; // query commands
extern unsigned __bss_start;
// There are several q commands: if (strcmp(sCommand + 1, "Supported") == 0) {
// // get the supported features
// qXXXX Request info about XXXX. gdb_reply("");
// QXXXX=yyyy Set value of XXXX to yyyy. } else if (strcmp(sCommand + 1, "Offsets") == 0) {
// qOffsets Get segment offsets // get the segment offsets
// elf_image_info* kernelImage = elf_get_kernel_image();
// Currently we only support the 'qOffsets' gdb_reply("Text=%lx;Data=%lx;Bss=%lx",
// form. kernelImage->text_region.delta,
// kernelImage->data_region.delta,
// *Note* that we actually have to lie, kernelImage->data_region.delta);
// At first thought looks like we should
// return '_start', '__data_start' &
// '__bss_start', however gdb gets
// confused because the kernel link script
// pre-links at 0x80000000. To keep gdb
// gdb happy we just substract that amount.
if (strcmp(sCommand + 1, "Offsets") == 0) {
gdb_reply("Text=%x;Data=%x;Bss=%x", 0,
((unsigned)(&__data_start)) - 0x80000000,
((unsigned)(&__bss_start)) - 0x80000000);
} else } else
gdb_reply("ENS"); gdb_reply("");
break; break;
} }
case '?': case 'c':
// command '?' is used for retrieving the signal // continue at address
// that stopped the program. Fully implemeting // TODO: Parse the address and resume there!
// this command requires help from the debugger, return QUIT;
// by now we just fake a SIGKILL
gdb_reply("S09"); /* SIGKILL = 9 */
break;
case 'g': case 'g':
{ {
@@ -255,6 +251,13 @@ gdb_parse_command(void)
break; break;
} }
case 'G':
// write registers
// TODO: Implement!
gdb_reply("E01");
break;
case 'm': case 'm':
{ {
char* ptr; char* ptr;
@@ -296,6 +299,10 @@ gdb_parse_command(void)
break; break;
} }
case 'D':
// detach
return QUIT;
case 'k': case 'k':
// Command 'k' actual semantics is 'kill the damn thing'. // Command 'k' actual semantics is 'kill the damn thing'.
// However gdb sends that command when you disconnect // However gdb sends that command when you disconnect
@@ -306,9 +313,15 @@ gdb_parse_command(void)
// kernel debugger command prompt. // kernel debugger command prompt.
return QUIT; return QUIT;
default: case 's':
// "step" -- resume (?) at address
// TODO: Implement!
gdb_reply("E01"); gdb_reply("E01");
break; break;
default:
gdb_reply("");
break;
} }
return WAITACK; return WAITACK;