patch-2.4.6 linux/arch/mips/kernel/gdb-stub.c
Next file: linux/arch/mips/kernel/head.S
Previous file: linux/arch/mips/kernel/entry.S
Back to the patch index
Back to the overall index
- Lines: 161
- Date:
Mon Jul 2 13:56:40 2001
- Orig file:
v2.4.5/linux/arch/mips/kernel/gdb-stub.c
- Orig date:
Sun Oct 1 20:35:15 2000
diff -u --recursive --new-file v2.4.5/linux/arch/mips/kernel/gdb-stub.c linux/arch/mips/kernel/gdb-stub.c
@@ -64,6 +64,61 @@
* Host: Reply:
* $m0,10#2a +$00010203040506070809101112131415#42
*
+ *
+ * ==============
+ * MORE EXAMPLES:
+ * ==============
+ *
+ * For reference -- the following are the steps that one
+ * company took (RidgeRun Inc) to get remote gdb debugging
+ * going. In this scenario the host machine was a PC and the
+ * target platform was a Galileo EVB64120A MIPS evaluation
+ * board.
+ *
+ * Step 1:
+ * First download gdb-5.0.tar.gz from the internet.
+ * and then build/install the package.
+ *
+ * Example:
+ * $ tar zxf gdb-5.0.tar.gz
+ * $ cd gdb-5.0
+ * $ ./configure --target=mips-linux-elf
+ * $ make
+ * $ install
+ * $ which mips-linux-elf-gdb
+ * /usr/local/bin/mips-linux-elf-gdb
+ *
+ * Step 2:
+ * Configure linux for remote debugging and build it.
+ *
+ * Example:
+ * $ cd ~/linux
+ * $ make menuconfig <go to "Kernel Hacking" and turn on remote debugging>
+ * $ make dep; make vmlinux
+ *
+ * Step 3:
+ * Download the kernel to the remote target and start
+ * the kernel running. It will promptly halt and wait
+ * for the host gdb session to connect. It does this
+ * since the "Kernel Hacking" option has defined
+ * CONFIG_REMOTE_DEBUG which in turn enables your calls
+ * to:
+ * set_debug_traps();
+ * breakpoint();
+ *
+ * Step 4:
+ * Start the gdb session on the host.
+ *
+ * Example:
+ * $ mips-linux-elf-gdb vmlinux
+ * (gdb) set remotebaud 115200
+ * (gdb) target remote /dev/ttyS1
+ * ...at this point you are connected to
+ * the remote target and can use gdb
+ * in the normal fasion. Setting
+ * breakpoints, single stepping,
+ * printing variables, etc.
+ *
*/
#include <linux/string.h>
@@ -71,6 +126,8 @@
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/mm.h>
+#include <linux/console.h>
+#include <linux/init.h>
#include <asm/asm.h>
#include <asm/mipsregs.h>
@@ -315,13 +372,10 @@
* signals, which are primarily what GDB understands. It also indicates
* which hardware traps we need to commandeer when initializing the stub.
*/
-static struct hard_trap_info
-{
+static struct hard_trap_info {
unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
unsigned char signo; /* Signal that we map this trap into */
} hard_trap_info[] = {
- { 4, SIGBUS }, /* address error (load) */
- { 5, SIGBUS }, /* address error (store) */
{ 6, SIGBUS }, /* instruction bus error */
{ 7, SIGBUS }, /* data bus error */
{ 9, SIGTRAP }, /* break */
@@ -350,6 +404,7 @@
for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
set_except_vector(ht->tt, trap_low);
+ putDebugChar('+'); /* 'hello world' */
/*
* In case GDB is started before us, ack any packets
* (presumably "$?#xx") sitting there.
@@ -373,7 +428,7 @@
*/
extern void fltr_set_mem_err(void)
{
- /* FIXME: Needs to be written... */
+ /* FIXME: Needs to be written... */
}
/*
@@ -401,8 +456,7 @@
*intValue = 0;
- while (**ptr)
- {
+ while (**ptr) {
hexValue = hex(**ptr);
if (hexValue < 0)
break;
@@ -904,3 +958,47 @@
lw $9,0($8)
");
}
+
+#ifdef CONFIG_GDB_CONSOLE
+
+void gdb_puts(const char *str)
+{
+ int l = strlen(str);
+ char outbuf[18];
+
+ outbuf[0]='O';
+
+ while(l) {
+ int i = (l>8)?8:l;
+ mem2hex((char *)str, &outbuf[1], i, 0);
+ outbuf[(i*2)+1]=0;
+ putpacket(outbuf);
+ str += i;
+ l -= i;
+ }
+}
+
+static kdev_t gdb_console_dev(struct console *con)
+{
+ return MKDEV(1, 3); /* /dev/null */
+}
+
+static void gdb_console_write(struct console *con, const char *s, unsigned n)
+{
+ gdb_puts(s);
+}
+
+static struct console gdb_console = {
+ name: "gdb",
+ write: gdb_console_write,
+ device: gdb_console_dev,
+ flags: CON_PRINTBUFFER,
+ index: -1
+};
+
+__init void register_gdb_console(void)
+{
+ register_console(&gdb_console);
+}
+
+#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)