Page MenuHomeFreeBSD

D22767.diff
No OneTemporary

D22767.diff

Index: head/sys/gdb/gdb_main.c
===================================================================
--- head/sys/gdb/gdb_main.c
+++ head/sys/gdb/gdb_main.c
@@ -769,6 +769,10 @@
do_qXfer();
} else if (gdb_rx_equal("Search:memory:")) {
gdb_do_mem_search();
+#ifdef __powerpc__
+ } else if (gdb_rx_equal("Offsets")) {
+ gdb_cpu_do_offsets();
+#endif
} else if (!gdb_cpu_query())
gdb_tx_empty();
break;
Index: head/sys/powerpc/include/gdb_machdep.h
===================================================================
--- head/sys/powerpc/include/gdb_machdep.h
+++ head/sys/powerpc/include/gdb_machdep.h
@@ -131,5 +131,6 @@
void *gdb_cpu_getreg(int, size_t *);
void gdb_cpu_setreg(int, void *);
int gdb_cpu_signal(int, int);
+void gdb_cpu_do_offsets(void);
#endif /* !_MACHINE_GDB_MACHDEP_H_ */
Index: head/sys/powerpc/powerpc/gdb_machdep.c
===================================================================
--- head/sys/powerpc/powerpc/gdb_machdep.c
+++ head/sys/powerpc/powerpc/gdb_machdep.c
@@ -48,6 +48,8 @@
#include <gdb/gdb.h>
#include <gdb/gdb_int.h>
+extern vm_offset_t __startkernel;
+
void *
gdb_cpu_getreg(int regnum, size_t *regsz)
{
@@ -100,4 +102,29 @@
return (vector);
else
return (SIGEMT);
+}
+
+void
+gdb_cpu_do_offsets(void)
+{
+ /*
+ * On PowerPC, .text starts at KERNBASE + SIZEOF_HEADERS and
+ * text segment at KERNBASE - SIZEOF_HEADERS.
+ * On PowerPC64, .text starts at KERNBASE and text segment at
+ * KERNBASE - 0x100.
+ * In both cases, the text segment offset is aligned to 64KB.
+ *
+ * The __startkernel variable holds the relocated KERNBASE offset.
+ * Thus, as long as SIZEOF_HEADERS doesn't get bigger than 0x100
+ * (which would lead to other issues), aligning __startkernel to
+ * 64KB gives the text segment offset.
+ *
+ * TODO: Add DataSeg to response. On PowerPC64 all sections reside
+ * in a single LOAD segment, but on PowerPC modifiable data reside
+ * in a separate segment, that GDB should also relocate.
+ */
+ gdb_tx_begin(0);
+ gdb_tx_str("TextSeg=");
+ gdb_tx_varhex(__startkernel & ~0xffff);
+ gdb_tx_end();
}

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 22, 2:13 AM (3 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16764533
Default Alt Text
D22767.diff (2 KB)

Event Timeline