AMD64 - Fix kgdb for kernel core files.
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 13 Aug 2009 20:26:37 +0000 (13:26 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 13 Aug 2009 20:26:37 +0000 (13:26 -0700)
* Add a dummy sniffer to set the osabi, as the kernel binary may not
  have an ABI tag.

gnu/usr.bin/gdb/kgdb/kgdb.c
gnu/usr.bin/gdb/kgdb/trgt_amd64.c

index 63d955e..0c784fd 100644 (file)
@@ -214,12 +214,25 @@ kgdb_parse(const char *exp)
 
 #define        MSGBUF_SEQ_TO_POS(size, seq)    ((seq) % (size))
 
+/*
+ * Fake-up because kernel may not have an ABI tag.
+ */
+static int
+kgdb_dummy_sniffer(bfd *bfd)
+{
+       return(GDB_OSABI_DRAGONFLY_ELF);
+}
+
+
 static void
 kgdb_init_target(void)
 {
        bfd *kern_bfd;
        int kern_desc;
 
+       gdbarch_register_osabi_sniffer(bfd_arch_i386, bfd_target_elf_flavour,
+                                       kgdb_dummy_sniffer);
+
        kern_desc = open(kernel, O_RDONLY);
        if (kern_desc == -1)
                errx(1, "couldn't open a kernel image");
index 9b28df0..84ca265 100644 (file)
@@ -167,28 +167,29 @@ kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
        target_read_memory(*addrp, valuep, regsz);
 }
 
-const struct frame_unwind kgdb_trgt_trapframe_unwind = {
-        NORMAL_FRAME,
-        &kgdb_trgt_trapframe_this_id,
-        &kgdb_trgt_trapframe_prev_register
-};
-
-const struct frame_unwind *
-kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
+int
+kgdb_trgt_trapframe_sniffer(const struct frame_unwind *self,
+                           struct frame_info *next_frame,
+                           void **this_prologue_cache)
 {
        char *pname;
        CORE_ADDR pc;
 
-       pc = frame_pc_unwind(next_frame);
-       if (pc == 0)
-               return (&kgdb_trgt_trapframe_unwind);
+       pc = frame_unwind_address_in_block(next_frame, NORMAL_FRAME);
        pname = NULL;
        find_pc_partial_function(pc, &pname, NULL, NULL);
        if (pname == NULL)
-               return (NULL);
+               return (0);
        if (strcmp(pname, "calltrap") == 0 ||
-           (pname[0] == 'X' && pname[1] != '_'))
-               return (&kgdb_trgt_trapframe_unwind);
-       /* printf("%s: %lx =%s\n", __func__, pc, pname); */
-       return (NULL);
+           strcmp(pname, "dblfault_handler") == 0 ||
+           (pname[0] == 'X' && pname[1] == '_'))
+               return (1);
+       return (0);
 }
+
+const struct frame_unwind kgdb_trgt_trapframe_unwind = {
+        NORMAL_FRAME,
+        &kgdb_trgt_trapframe_this_id,
+        &kgdb_trgt_trapframe_prev_register,
+       .sniffer = kgdb_trgt_trapframe_sniffer
+};