logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

[RFC] x86-64 targeted gdb and corefiles: msg#00942

gdb.patches

Subject: [RFC] x86-64 targeted gdb and corefiles

Hi all,
this patch allows reading of coredumps on non-native gdb configured for x86-64 target. It works pretty well in this form, but I had to modify gregset.h, what is unwise. I know I have to move the modifications somewhere else, but ... where? Can someone give me an advice, please?

BTW If anyone would like to apply this patch, please update bfd to current CVS as well, since I fixed there some stuff related to this issue on friady.

Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@xxxxxxx
* +420 2 9654 5373 * http://www.suse.cz
Index: gregset.h
===================================================================
RCS file: /cvs/src/src/gdb/gregset.h,v
retrieving revision 1.7
diff -c -3 -p -r1.7 gregset.h
*** gregset.h 8 May 2002 23:29:11 -0000 1.7
--- gregset.h 27 May 2002 12:22:24 -0000
***************
*** 21,26 ****
--- 21,41 ----
#ifndef GREGSET_H
#define GREGSET_H

+ /* We can't include x86-64's <asm/elf.h> directly,
+ so we must copy appropriate typedefs here. */
+ #define ELF_NGREG 27
+ typedef unsigned long long elf_greg_t;
+ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+ /* Register set for the extended floating-point registers. Includes
+ the Pentium III SSE registers in addition to the classic
+ floating-point stuff. */
+ typedef unsigned char elf_fpregset_t[512];
+
+
+ #define GDB_GREGSET_T elf_gregset_t
+ #define GDB_FPREGSET_T elf_fpregset_t
+
#ifndef GDB_GREGSET_T
#define GDB_GREGSET_T gregset_t
#endif
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 x86-64-linux-nat.c
*** x86-64-linux-nat.c 11 May 2002 17:22:26 -0000 1.12
--- x86-64-linux-nat.c 27 May 2002 12:22:26 -0000
*************** x86_64_linux_dr_get_status (void)
*** 130,166 ****
(FP0_REGNUM <= (regno) && (regno) <= MXCSR_REGNUM)


- /* Transfering the general-purpose registers between GDB, inferiors
- and core files. */
-
- /* Fill GDB's register array with the general-purpose register values
- in *GREGSETP. */
-
- void
- supply_gregset (elf_gregset_t * gregsetp)
- {
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < x86_64_num_gregs; i++)
- supply_register (i, (char *) (regp + x86_64_regmap[i]));
- }
-
- /* Fill register REGNO (if it is a general-purpose register) in
- *GREGSETPS with the value in GDB's register array. If REGNO is -1,
- do this for all registers. */
-
- void
- fill_gregset (elf_gregset_t * gregsetp, int regno)
- {
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- int i;
-
- for (i = 0; i < x86_64_num_gregs; i++)
- if ((regno == -1 || regno == i))
- read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
- }
-
/* Fetch all general-purpose registers from process/thread TID and
store their values in GDB's register array. */

--- 130,135 ----
*************** store_regs (int tid, int regno)
*** 192,218 ****
perror_with_name ("Couldn't write registers");
}

-
- /* Transfering floating-point registers between GDB, inferiors and cores. */
-
- /* Fill GDB's register array with the floating-point register values in
- *FPREGSETP. */
-
- void
- supply_fpregset (elf_fpregset_t * fpregsetp)
- {
- i387_supply_fxsave ((char *) fpregsetp);
- }
-
- /* Fill register REGNO (if it is a floating-point register) in
- *FPREGSETP with the value in GDB's register array. If REGNO is -1,
- do this for all registers. */
-
- void
- fill_fpregset (elf_fpregset_t * fpregsetp, int regno)
- {
- i387_fill_fxsave ((char *) fpregsetp, regno);
- }

/* Fetch all floating-point registers from process/thread TID and store
thier values in GDB's register array. */
--- 161,166 ----
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 x86-64-linux-tdep.c
*** x86-64-linux-tdep.c 24 Feb 2002 22:14:33 -0000 1.4
--- x86-64-linux-tdep.c 27 May 2002 12:22:26 -0000
***************
*** 25,32 ****
--- 25,43 ----
#include "inferior.h"
#include "gdbcore.h"
#include "regcache.h"
+ #include "i387-tdep.h"
#include "x86-64-tdep.h"
#include "dwarf2cfi.h"
+ #include "gregset.h"
+
+ static int x86_64_regmap[] = {
+ 10, 5, 11, 12,
+ 13, 14, 4, 19,
+ 9, 8, 7, 6,
+ 3, 2, 1, 0,
+ 16, 18,
+ 23, 24, 25, 26
+ };

#define LINUX_SIGTRAMP_INSN0 (0x48) /* mov $NNNNNNNN,%rax */
#define LINUX_SIGTRAMP_OFFSET0 (0)
*************** x86_64_linux_frame_saved_pc (struct fram
*** 134,136 ****
--- 145,200 ----
return x86_64_linux_sigtramp_saved_pc (frame);
return cfi_get_ra (frame);
}
+
+ /* Transfering the general-purpose registers between GDB, inferiors
+ and core files. */
+
+ /* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+ void
+ supply_gregset (elf_gregset_t * gregsetp)
+ {
+ elf_greg_t *regp = (elf_greg_t *) gregsetp;
+ int i;
+
+ for (i = 0; i < x86_64_num_gregs; i++)
+ supply_register (i, (char *) (regp + x86_64_regmap[i]));
+ }
+
+ /* Fill register REGNO (if it is a general-purpose register) in
+ *GREGSETPS with the value in GDB's register array. If REGNO is -1,
+ do this for all registers. */
+
+ void
+ fill_gregset (elf_gregset_t * gregsetp, int regno)
+ {
+ elf_greg_t *regp = (elf_greg_t *) gregsetp;
+ int i;
+
+ for (i = 0; i < x86_64_num_gregs; i++)
+ if ((regno == -1 || regno == i))
+ read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
+ }
+
+ /* Transfering floating-point registers between GDB, inferiors and cores. */
+
+ /* Fill GDB's register array with the floating-point register values in
+ *FPREGSETP. */
+
+ void
+ supply_fpregset (elf_fpregset_t * fpregsetp)
+ {
+ i387_supply_fxsave ((char *) fpregsetp);
+ }
+
+ /* Fill register REGNO (if it is a floating-point register) in
+ *FPREGSETP with the value in GDB's register array. If REGNO is -1,
+ do this for all registers. */
+
+ void
+ fill_fpregset (elf_fpregset_t * fpregsetp, int regno)
+ {
+ i387_fill_fxsave ((char *) fpregsetp, regno);
+ }
+
<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo