PERFORCE change 30508 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat May 3 20:29:02 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=30508
Change 30508 by marcel at marcel_nfs on 2003/05/03 20:28:47
Round of fixes:
o Make sure the sio_dbgport softc points at the right softc
and avoid a NULL pointer dereference.
o Announce for the sio device if it's the console or the
debug port or both. Note that both console and debug port
is only allowed if GDB_REMOTE_CHAT is defined.
o Implement the MD GDB functions for i386 and provide stubs
for ia64.
o Remove references to the GDB option that I wanted to
introduce, but didn't after all.
o Warn the user if remote GDB is invoked without there
being a debug port.
More to come...
Affected files ...
.. //depot/projects/sio/sys/ddb/db_command.c#3 edit
.. //depot/projects/sio/sys/ddb/db_gdb.c#3 edit
.. //depot/projects/sio/sys/ddb/ddb.h#3 edit
.. //depot/projects/sio/sys/dev/sio/sio.c#5 edit
.. //depot/projects/sio/sys/dev/sio/sio_cons.c#4 edit
.. //depot/projects/sio/sys/dev/sio/sio_dbg.c#2 edit
.. //depot/projects/sio/sys/i386/include/db_machdep.h#4 edit
.. //depot/projects/sio/sys/ia64/ia64/db_interface.c#3 edit
.. //depot/projects/sio/sys/ia64/include/db_machdep.h#2 edit
Differences ...
==== //depot/projects/sio/sys/ddb/db_command.c#3 (text+ko) ====
@@ -69,10 +69,6 @@
static db_cmdfcn_t db_kill;
static db_cmdfcn_t db_reset;
-#ifdef GDB
-static db_cmdfcn_t db_gdb;
-#endif
-
/* XXX this is actually forward-static. */
extern struct command db_show_cmds[];
@@ -420,9 +416,7 @@
{ "call", db_fncall, CS_OWN, 0 },
{ "show", 0, 0, db_show_cmds },
{ "ps", db_ps, 0, 0 },
-#ifdef GDB
{ "gdb", db_gdb, 0, 0 },
-#endif
{ "reset", db_reset, 0, 0 },
{ "kill", db_kill, CS_OWN, 0 },
{ (char *)0, }
==== //depot/projects/sio/sys/ddb/db_gdb.c#3 (text+ko) ====
@@ -180,7 +180,7 @@
}
void
-db_gdb_cmd(db_expr_t a1 __unused, boolean_t a2 __unused, db_expr_t a3 __unused,
+db_gdb(db_expr_t a1 __unused, boolean_t a2 __unused, db_expr_t a3 __unused,
char *a4 __unused)
{
@@ -434,6 +434,11 @@
gdb_reg reg;
int c, error, len, regno;
+ if (dbgport == NULL) {
+ db_printf("GDB: No debug port configured.\n");
+ return (ENXIO);
+ }
+
gdb_getregs(®s, raw_regs);
/* "TxxPC:xxxxxxxx;FP:xxxxxxxx;SP:xxxxxxxx;" */
==== //depot/projects/sio/sys/ddb/ddb.h#3 (text+ko) ====
@@ -156,10 +156,19 @@
db_cmdfcn_t db_write_cmd;
db_cmdfcn_t db_show_one_thread;
-/* Remote GDB support. */
-int gdb_handle_exception(db_regs_t *, int);
-void gdb_init(void);
-db_cmdfcn_t db_gdb_cmd;
+/*
+ * Remote GDB support.
+ */
+db_cmdfcn_t db_gdb;
+
+gdb_reg gdb_getreg(struct gdb_registers *, int);
+void gdb_getregs(struct gdb_registers *, db_regs_t *);
+int gdb_handle_exception(db_regs_t *, int);
+void gdb_init(void);
+void gdb_setreg(struct gdb_registers *, int, gdb_reg);
+void gdb_setregs(struct gdb_registers *, db_regs_t *);
+void gdb_singlestep(struct gdb_registers *, int);
+int gdb_signal(int);
/* Scare the user with backtrace of curthread to console. */
void db_print_backtrace(void);
==== //depot/projects/sio/sys/dev/sio/sio.c#5 (text+ko) ====
@@ -679,7 +679,7 @@
sio_console.addr_type = com->addr_type;
device_set_softc(dev, &sio_console);
com = &sio_console;
- } else if (com->bst == sio_dbgport->bst &&
+ } else if (sio_dbgport != NULL && com->bst == sio_dbgport->bst &&
com->bsh == sio_dbgport->bsh) {
sio_dbgport->addr_res = com->addr_res;
sio_dbgport->addr_rid = com->addr_rid;
@@ -811,8 +811,17 @@
termioschars(&com->it_in);
com->it_out = com->it_in;
- if (com->consdev != NULL)
- device_printf(dev, "console\n");
+ if (com->consdev != NULL || com->dbgport) {
+ device_printf(dev, "is ");
+ if (com->consdev != NULL) {
+ printf("console");
+ if (com->dbgport)
+ printf("and ");
+ }
+ if (com->dbgport)
+ printf("debug port");
+ printf(".\n");
+ }
if (sio_fast_ih == NULL) {
swi_add(&tty_ithd, "tty:sio", siopoll, NULL, SWI_TTY, 0,
==== //depot/projects/sio/sys/dev/sio/sio_cons.c#4 (text+ko) ====
@@ -190,6 +190,7 @@
while ((sio_getreg(&sio_console, com_lsr) & LSR_THRE) == 0 && --to)
;
sio_setreg(&sio_console, com_data, c);
+ sio_barrier(&sio_console);
splx(s);
}
==== //depot/projects/sio/sys/dev/sio/sio_dbg.c#2 (text+ko) ====
@@ -88,19 +88,22 @@
* serial interface as the console.
*/
if (sio_console.bst == dd.bst && sio_console.bsh == dd.bsh) {
+ sio_dbgport = &sio_console;
+ if (sio_console.consdev != NULL) {
#ifdef DBG_REMOTE_CHAT
- sio_dbgport = &sio_console;
- printf("sio: using console as debug port\n");
- return (0);
+ printf("sio: using console as debug port\n");
+ /* XXX assume settings are the same. */
+ return (0);
#else
- printf("sio: debug port not supported over console\n");
- return (EBUSY);
+ printf("sio: debug port not supported over console\n");
+ return (EBUSY);
#endif
+ }
+ } else {
+ bzero(&sio_debugport, sizeof(sio_debugport));
+ sio_dbgport = &sio_debugport;
}
- bzero(&sio_debugport, sizeof(sio_debugport));
- sio_dbgport = &sio_debugport;
-
/* Minimum fields needed for rudimentary checks. */
sio_dbgport->bst = dd.bst;
sio_dbgport->bsh = dd.bsh;
@@ -137,10 +140,6 @@
{
u_char iir;
- /* Don't initialize if the debug port is the console. */
- if (sio_dbgport->consdev != NULL)
- return;
-
/* Disable all interrupt sources. */
sio_setreg(sio_dbgport, com_ier, 0);
sio_barrier(sio_dbgport);
@@ -182,7 +181,7 @@
{
}
-void
+static void
siodbgputc(int c)
{
int to;
@@ -191,6 +190,7 @@
while ((sio_getreg(sio_dbgport, com_lsr) & LSR_THRE) == 0 && --to)
;
sio_setreg(sio_dbgport, com_data, c);
+ sio_barrier(sio_dbgport);
}
static int
==== //depot/projects/sio/sys/i386/include/db_machdep.h#4 (text+ko) ====
@@ -121,11 +121,4 @@
gdb_reg es;
};
-gdb_reg gdb_getreg(struct gdb_registers *, int);
-void gdb_getregs(struct gdb_registers *, db_regs_t *);
-void gdb_setreg(struct gdb_registers *, int, gdb_reg);
-void gdb_setregs(struct gdb_registers *, db_regs_t *);
-void gdb_singlestep(struct gdb_registers *, int);
-int gdb_signal(int);
-
#endif /* !_MACHINE_DB_MACHDEP_H_ */
==== //depot/projects/sio/sys/ia64/ia64/db_interface.c#3 (text+ko) ====
@@ -548,3 +548,38 @@
db_show_mdpcpu(struct pcpu *pc)
{
}
+
+/*
+ * Remote GDB support.
+ */
+int
+gdb_signal(int vector)
+{
+ return (SIGILL);
+}
+
+gdb_reg
+gdb_getreg(struct gdb_registers *regs, int regnum)
+{
+ return (~0);
+}
+
+void
+gdb_setreg(struct gdb_registers *regs, int regnum, gdb_reg val)
+{
+}
+
+void
+gdb_getregs(struct gdb_registers *regs, db_regs_t *raw_regs)
+{
+}
+
+void
+gdb_setregs(struct gdb_registers *regs, db_regs_t *raw_regs)
+{
+}
+
+void
+gdb_singlestep(struct gdb_registers *regs, int set)
+{
+}
==== //depot/projects/sio/sys/ia64/include/db_machdep.h#2 (text+ko) ====
@@ -40,8 +40,6 @@
#include <machine/frame.h>
#include <machine/ia64_cpu.h>
-#define DB_NO_AOUT
-
struct ia64_bundle;
typedef vm_offset_t db_addr_t; /* address - unsigned */
@@ -111,4 +109,21 @@
*/
#define DB_ELFSIZE 64
+/*
+ * Remote GDB support.
+ */
+#define GDB_REGNUM_FP -1
+#define GDB_REGNUM_PC -1
+#define GDB_REGNUM_SP -1
+typedef uint32_t gdb_reg;
+typedef uint32_t gdb_addr;
+
+#define gdb_dec_addr gdb_dec_int32
+#define gdb_dec_reg gdb_dec_int32
+#define gdb_enc_reg gdb_enc_int32
+
+struct gdb_registers {
+ int dummy;
+};
+
#endif /* _MACHINE_DB_MACHDEP_H_ */
More information about the p4-projects
mailing list