public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* kgdb support for gdb: patch 1
@ 2004-10-21 17:22 Amit S. Kale
  2004-10-22 12:28 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Amit S. Kale @ 2004-10-21 17:22 UTC (permalink / raw)
  To: GDB discussions

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

Hi,

I have been working on the changes suggested by Mark K and Andrew C. Here is 
the first patch. This adds support for a new osabi for linux kernel.

I haven't added any support for detecting kernel osabi automatically. 
Detecting it with present kernel binary structure is rather shaky. It's safer 
to let users run the command "set osabi Linux-kernel".

I'll be later sending more patches.

Please review it and let me know if it's ok for inclusion in gdb.
Thanks.
-Amit

[-- Attachment #2: lk.patch --]
[-- Type: text/x-diff, Size: 2225 bytes --]

Index: gdb/gdb/i386-linux-tdep.c
===================================================================
--- gdb.orig/gdb/i386-linux-tdep.c	2004-08-07 02:28:28.000000000 +0530
+++ gdb/gdb/i386-linux-tdep.c	2004-10-21 18:18:18.000000000 +0530
@@ -27,6 +27,7 @@
 #include "inferior.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "elf-bfd.h"
 
 #include "gdb_string.h"
 
@@ -416,6 +417,26 @@
   set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
 }
 
+static void
+i386_linuxkernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* Linux Kernel uses ELF format for vmlinux file.  */
+  i386_elf_init_abi (info, gdbarch);
+
+  set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
+  set_gdbarch_register_name (gdbarch, i386_linux_register_name);
+  set_gdbarch_register_reggroup_p (gdbarch, i386_linux_register_reggroup_p);
+
+  tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
+  tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
+  tdep->sizeof_gregset = 17 * 4;
+
+  tdep->jb_pc_offset = 20;	/* From <bits/setjmp.h>.  */
+
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern void _initialize_i386_linux_tdep (void);
 
@@ -424,4 +445,6 @@
 {
   gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
 			  i386_linux_init_abi);
+  gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUXKERNEL,
+			  i386_linuxkernel_init_abi);
 }
Index: gdb/gdb/defs.h
===================================================================
--- gdb.orig/gdb/defs.h	2004-10-12 15:36:14.000000000 +0530
+++ gdb/gdb/defs.h	2004-10-21 18:14:02.000000000 +0530
@@ -1031,6 +1031,7 @@
   GDB_OSABI_SOLARIS,
   GDB_OSABI_OSF1,
   GDB_OSABI_LINUX,
+  GDB_OSABI_LINUX_KERNEL,
   GDB_OSABI_FREEBSD_AOUT,
   GDB_OSABI_FREEBSD_ELF,
   GDB_OSABI_NETBSD_AOUT,
Index: gdb/gdb/osabi.c
===================================================================
--- gdb.orig/gdb/osabi.c	2004-07-03 02:57:17.000000000 +0530
+++ gdb/gdb/osabi.c	2004-10-21 18:14:02.000000000 +0530
@@ -57,6 +57,7 @@
   "Solaris",
   "OSF/1",
   "GNU/Linux",
+  "Linux-kernel",
   "FreeBSD a.out",
   "FreeBSD ELF",
   "NetBSD a.out",

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: kgdb support for gdb: patch 1
  2004-10-21 17:22 kgdb support for gdb: patch 1 Amit S. Kale
@ 2004-10-22 12:28 ` Mark Kettenis
  2004-10-28 10:56   ` Amit S. Kale
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2004-10-22 12:28 UTC (permalink / raw)
  To: amitkale; +Cc: gdb

   From: "Amit S. Kale" <amitkale@linsyssoft.com>
   Date: Thu, 21 Oct 2004 18:21:08 +0530

   Hi,

   I haven't added any support for detecting kernel osabi
   automatically.  Detecting it with present kernel binary structure
   is rather shaky. It's safer to let users run the command "set osabi
   Linux-kernel".

Fair enough.  Indeed it seems that vmlinux is a fairly standard static
ELF executable.

   I'll be later sending more patches.

   Please review it and let me know if it's ok for inclusion in gdb.

Of course it isn't, since this can't compile ;-).  You seem to be in
limbo betwen LINUXKERNEL and LINUX_KERNEL.  Please choose the variant
*with* the underscore.

Anyway, I think for the kernel you shouldn't use the Linux register
cache layout, bur rather the normal register layout.  The Linux
register cache includes the "orig_eax" pseudo register that is
implemented by the kernel.  My guess is that the kernel itself doesn't
have it.  I'm not completely sure though, but unless you can motivate
why you do need "orig_eax" please remove these lines:

   +  set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
   +  set_gdbarch_register_name (gdbarch, i386_linux_register_name);
   +  set_gdbarch_register_reggroup_p (gdbarch, i386_linux_register_reggroup_p);

These lines will need adjustments too:

   +  tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
   +  tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
   +  tdep->sizeof_gregset = 17 * 4;

Setting tdep->gregset_num_regs to I386_NUM_GREGS should be OK.

Apart from that, you'll also need to provide a ChangeLog.

Can you post an update patch?

Cheers,

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: kgdb support for gdb: patch 1
  2004-10-22 12:28 ` Mark Kettenis
@ 2004-10-28 10:56   ` Amit S. Kale
  0 siblings, 0 replies; 3+ messages in thread
From: Amit S. Kale @ 2004-10-28 10:56 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 1911 bytes --]

Sorry about the compile error. I have done the changes you have suggested 
below. Here is a new patch.

-Amit

On Thursday 21 Oct 2004 10:52 pm, Mark Kettenis wrote:
>    From: "Amit S. Kale" <amitkale@linsyssoft.com>
>    Date: Thu, 21 Oct 2004 18:21:08 +0530
>
>    Hi,
>
>    I haven't added any support for detecting kernel osabi
>    automatically.  Detecting it with present kernel binary structure
>    is rather shaky. It's safer to let users run the command "set osabi
>    Linux-kernel".
>
> Fair enough.  Indeed it seems that vmlinux is a fairly standard static
> ELF executable.
>
>    I'll be later sending more patches.
>
>    Please review it and let me know if it's ok for inclusion in gdb.
>
> Of course it isn't, since this can't compile ;-).  You seem to be in
> limbo betwen LINUXKERNEL and LINUX_KERNEL.  Please choose the variant
> *with* the underscore.
>
> Anyway, I think for the kernel you shouldn't use the Linux register
> cache layout, bur rather the normal register layout.  The Linux
> register cache includes the "orig_eax" pseudo register that is
> implemented by the kernel.  My guess is that the kernel itself doesn't
> have it.  I'm not completely sure though, but unless you can motivate
> why you do need "orig_eax" please remove these lines:
>
>    +  set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
>    +  set_gdbarch_register_name (gdbarch, i386_linux_register_name);
>    +  set_gdbarch_register_reggroup_p (gdbarch,
> i386_linux_register_reggroup_p);
>
> These lines will need adjustments too:
>
>    +  tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
>    +  tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset);
>    +  tdep->sizeof_gregset = 17 * 4;
>
> Setting tdep->gregset_num_regs to I386_NUM_GREGS should be OK.
>
> Apart from that, you'll also need to provide a ChangeLog.
>
> Can you post an update patch?
>
> Cheers,
>
> Mark

[-- Attachment #2: lk.patch --]
[-- Type: text/x-diff, Size: 2693 bytes --]

Index: gdb/gdb/i386-linux-tdep.c
===================================================================
--- gdb.orig/gdb/i386-linux-tdep.c	2004-08-07 02:28:28.000000000 +0530
+++ gdb/gdb/i386-linux-tdep.c	2004-10-26 14:59:29.000000000 +0530
@@ -27,6 +27,7 @@
 #include "inferior.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "elf-bfd.h"
 
 #include "gdb_string.h"
 
@@ -416,6 +417,25 @@
   set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
 }
 
+static void
+i386_linux_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* Linux Kernel uses ELF format for vmlinux file.  */
+  i386_elf_init_abi (info, gdbarch);
+
+  /* We can use the register offsets used for linux applications. Only
+   * first 16 elements of the array will be used for kernel. Offsets of those
+   * are identical for applications and kernel.  */
+  tdep->gregset_reg_offset = i386_linux_gregset_reg_offset;
+  tdep->gregset_num_regs = I386_NUM_GREGS;
+  tdep->sizeof_gregset = I386_NUM_GREGS * 4;
+
+  tdep->jb_pc_offset = 20;	/* From <bits/setjmp.h>.  */
+
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern void _initialize_i386_linux_tdep (void);
 
@@ -424,4 +444,6 @@
 {
   gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
 			  i386_linux_init_abi);
+  gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX_KERNEL,
+			  i386_linux_kernel_init_abi);
 }
Index: gdb/gdb/defs.h
===================================================================
--- gdb.orig/gdb/defs.h	2004-10-12 15:36:14.000000000 +0530
+++ gdb/gdb/defs.h	2004-10-26 14:46:27.000000000 +0530
@@ -1031,6 +1031,7 @@
   GDB_OSABI_SOLARIS,
   GDB_OSABI_OSF1,
   GDB_OSABI_LINUX,
+  GDB_OSABI_LINUX_KERNEL,
   GDB_OSABI_FREEBSD_AOUT,
   GDB_OSABI_FREEBSD_ELF,
   GDB_OSABI_NETBSD_AOUT,
Index: gdb/gdb/osabi.c
===================================================================
--- gdb.orig/gdb/osabi.c	2004-07-03 02:57:17.000000000 +0530
+++ gdb/gdb/osabi.c	2004-10-26 14:46:27.000000000 +0530
@@ -57,6 +57,7 @@
   "Solaris",
   "OSF/1",
   "GNU/Linux",
+  "Linux-kernel",
   "FreeBSD a.out",
   "FreeBSD ELF",
   "NetBSD a.out",
Index: gdb/gdb/ChangeLog
===================================================================
--- gdb.orig/gdb/ChangeLog	2004-10-26 14:45:24.000000000 +0530
+++ gdb/gdb/ChangeLog	2004-10-26 14:57:25.000000000 +0530
@@ -1,3 +1,7 @@
+2004-10-26  Amit S. Kale <amitkale@linsyssoft.com>
+	* i386-linux-tdep.c: Added a new osabi Linux-kernel for debugging
+	a remotely running linux kernel.
+
 2004-10-25  Andrew Cagney  <cagney@gnu.org>
 
 	* NEWS: Add Changes since GDB 6.3 section.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-26  9:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-21 17:22 kgdb support for gdb: patch 1 Amit S. Kale
2004-10-22 12:28 ` Mark Kettenis
2004-10-28 10:56   ` Amit S. Kale

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).