PERFORCE change 48765 for review

Marcel Moolenaar marcel at FreeBSD.org
Thu Mar 11 21:58:19 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=48765

Change 48765 by marcel at marcel_nfs on 2004/03/11 21:57:54

	Add an active field to the KDB backend structure and the
	GDB debug port structure. Meaning of these are:
		-1	backend or port is dead,
		0	backend or port is inactive,
		>0	backend or port is active.
	Use the active field to iterate over the linker set and
	display probed backends or ports.
	
	Initialize the GDB debug port after probing. uart(4) now
	properly displays:
	
	uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 on acpi0
	uart0: debug port (115200,n,8,1)

Affected files ...

.. //depot/projects/gdb/sys/gdb/gdb.h#3 edit
.. //depot/projects/gdb/sys/gdb/gdb_main.c#2 edit
.. //depot/projects/gdb/sys/kern/subr_kdb.c#4 edit
.. //depot/projects/gdb/sys/sys/kdb.h#3 edit

Differences ...

==== //depot/projects/gdb/sys/gdb/gdb.h#3 (text+ko) ====

@@ -44,6 +44,7 @@
 	gdb_probe_f	*gdb_probe;
 	gdb_putc_f	*gdb_putc;
 	gdb_term_f	*gdb_term;
+	int		gdb_active;
 };
 
 #define	GDB_DBGPORT(name, probe, init, term, checkc, getc, putc)	\
@@ -58,4 +59,6 @@
 	};								\
 	DATA_SET(gdb_dbgport_set, name##_gdb_dbgport)
 
+extern struct gdb_dbgport *gdb_cur;
+
 #endif /* !_GDB_GDB_H_ */

==== //depot/projects/gdb/sys/gdb/gdb_main.c#2 (text+ko) ====

@@ -55,22 +55,27 @@
 	SET_FOREACH(iter, gdb_dbgport_set) {
 		dp = *iter;
 		pri = (dp->gdb_probe != NULL) ? dp->gdb_probe() : -1;
-		if (pri >= 0) {
-			if (cur_pri == -1)
-				printf("GDB: debug ports:");
-			printf(" %s", dp->gdb_name);
-			if (pri > cur_pri) {
-				cur_pri = pri;
-				gdb_cur = dp;
-			}
+		dp->gdb_active = (pri >= 0) ? 0 : -1;
+		if (pri > cur_pri) {
+			cur_pri = pri;
+			gdb_cur = dp;
 		}
 	}
-	if (cur_pri != -1) {
+	if (gdb_cur != NULL) {
+		printf("GDB: debug ports:");
+		SET_FOREACH(iter, gdb_dbgport_set) {
+			dp = *iter;
+			if (dp->gdb_active == 0)
+				printf(" %s", dp->gdb_name);
+		}
 		printf("\n");
-		printf("GDB: current=%s\n", gdb_cur->gdb_name);
 	} else
 		printf("GDB: no debug ports present\n");
-	return ((cur_pri == -1) ? 0 : 1);
+	if (gdb_cur != NULL) {
+		gdb_cur->gdb_init();
+		printf("GDB: current port: %s\n", gdb_cur->gdb_name);
+	}
+	return ((gdb_cur != NULL) ? 1 : 0);
 }
 
 static int

==== //depot/projects/gdb/sys/kern/subr_kdb.c#4 (text+ko) ====

@@ -133,21 +133,23 @@
 	SET_FOREACH(iter, kdb_dbbe_set) {
 		be = *iter;
 		pri = (be->dbbe_init != NULL) ? be->dbbe_init() : -1;
-		if (pri >= 0) {
-			if (cur_pri == -1)
-				printf("KDB: debugger backends:");
-			printf(" %s", be->dbbe_name);
-			if (pri > cur_pri) {
-				cur_pri = pri;
-				kdb_cur = be;
-			}
+		be->dbbe_active = (pri >= 0) ? 0 : -1;
+		if (pri > cur_pri) {
+			cur_pri = pri;
+			kdb_cur = be;
 		}
 	}
-	if (cur_pri != -1) {
+	if (kdb_cur != NULL) {
+		printf("KDB: debugger backends:");
+		SET_FOREACH(iter, kdb_dbbe_set) {
+			be = *iter;
+			if (be->dbbe_active == 0)
+				printf(" %s", be->dbbe_name);
+		}
 		printf("\n");
-		printf("KDB: current=%s\n", kdb_cur->dbbe_name);
-	} else
-		printf("KDB: no debugger backends present\n");
+		printf("KDB: current backend: %s\n",
+		    kdb_cur->dbbe_name);
+	}
 }
 
 /*

==== //depot/projects/gdb/sys/sys/kdb.h#3 (text+ko) ====

@@ -42,6 +42,7 @@
 	dbbe_init_f	*dbbe_init;
 	dbbe_trace_f	*dbbe_trace;
 	dbbe_trap_f	*dbbe_trap;
+	int		dbbe_active;
 };
 
 #define	KDB_BACKEND(name, init, trace, enter, trap)	\


More information about the p4-projects mailing list