The following patch for gdb 4.17 allows handling 64bit IRIX dwarf2 in gdb. This is required for using gdb on an IRIX -64 object file. It was contributed by Benjamin Gamsa to the gdb patches list, but has not been incorporated into gdb. The patches are said to be not too difficult to apply to gdb 5.0. Neither the author (Benjamin Gamsa) nor I, davea@sgi.com , make any guarantees of any kind about this patch. I do hope to get appropriate changes into top of trunk gdb before too long, but being on an extended vacation as I write this, I don't know I or anyone will get to it. davea@sgi.com August 2000 diff -rc -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ gdb-4.17.85-orig/gdb/config/mips/irix6-64.mt gdb-4.17.85/gdb/config/mips/irix6-64.mt *** gdb-4.17.85-orig/gdb/config/mips/irix6-64.mt Wed Mar 3 15:16:36 1999 --- gdb-4.17.85/gdb/config/mips/irix6-64.mt Wed Mar 3 11:41:24 1999 *************** *** 0 **** --- 1,3 ---- + # Target: MIPS SGI running Irix 6 for 64 bits + TDEPFILES= mips-tdep.o + TM_FILE= tm-irix6-64.h diff -rc -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ gdb-4.17.85-orig/gdb/config/mips/tm-irix6-64.h gdb-4.17.85/gdb/config/mips/tm-irix6-64.h *** gdb-4.17.85-orig/gdb/config/mips/tm-irix6-64.h Wed Mar 3 15:16:36 1999 --- gdb-4.17.85/gdb/config/mips/tm-irix6-64.h Wed Mar 3 14:59:27 1999 *************** *** 0 **** --- 1,80 ---- + /* Copyright (C) 1996 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + #define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN + + #define GDB_TARGET_IS_MIPS64 1 + + /* Use eight byte registers. */ + #define MIPS_REGSIZE 8 + + /* define 8 byte register type */ + #define REGISTER_VIRTUAL_TYPE(N) \ + (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) \ + ? builtin_type_double : builtin_type_long_long) \ + + /* Load double words in CALL_DUMMY. */ + #define OP_LDFPR 065 /* ldc1 */ + #define OP_LDGPR 067 /* ld */ + + /* define sizes for 64-bit data types */ + #define TARGET_LONG_BIT 64 + #define TARGET_LONG_LONG_BIT 64 + #define TARGET_PTR_BIT 64 + + + #include "mips/tm-irix5.h" + + /* from tm-irix5, but remove extra + 4 at end since reg are 8 bytes */ + + #undef SIGFRAME_PC_OFF + #define SIGFRAME_PC_OFF (SIGFRAME_BASE + 2 * 4) + #undef SIGFRAME_REGSAVE_OFF + #define SIGFRAME_REGSAVE_OFF (SIGFRAME_BASE + 2 * 4 + 8) + #undef SIGFRAME_FPREGSAVE_OFF + #define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_BASE + 2 * 4 + 8 + 32 * 8) + + /* undo tm-irix5 mis-conception of the types of registers */ + + #undef REGISTER_VIRTUAL_TYPE + #define REGISTER_VIRTUAL_TYPE(N) \ + (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) ? builtin_type_double \ + : ((N) == 32 /*SR*/) ? builtin_type_uint32 \ + : ((N) >= 70 && (N) <= 89) ? builtin_type_uint64 \ + : builtin_type_uint64) + + /* keep same basic registers, but change names to conform to n32/64 bit + conventions. */ + + #undef REGISTER_NAMES + #define REGISTER_NAMES \ + { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \ + "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3", \ + "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \ + "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra", \ + "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ + "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ + "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\ + "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",\ + "pc", "cause", "bad", "hi", "lo", "fsr", "fir" \ + } + + /* not sure about the sigframe stuff... just guessing we remove extra +4 */ + + #undef SIGFRAME_FPREGSAVE_OFF + #define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_BASE + 3 * 4 + 32 * 4) diff -rc -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ gdb-4.17.85-orig/gdb/configure.tgt gdb-4.17.85/gdb/configure.tgt *** gdb-4.17.85-orig/gdb/configure.tgt Wed Feb 24 15:57:08 1999 --- gdb-4.17.85/gdb/configure.tgt Wed Mar 3 11:41:24 1999 *************** *** 189,195 **** mips*-little-*) gdb_target=littlemips ;; mips*-*-lnews*) gdb_target=embedl ;; mips*-sgi-irix5*) gdb_target=irix5 ;; ! mips*-sgi-irix6*) gdb_target=irix5 ;; mips*-sgi-*) gdb_target=irix3 ;; mips*-sony-*) gdb_target=bigmips ;; mips*-*-mach3*) gdb_target=mipsm3 ;; --- 189,195 ---- mips*-little-*) gdb_target=littlemips ;; mips*-*-lnews*) gdb_target=embedl ;; mips*-sgi-irix5*) gdb_target=irix5 ;; ! mips*-sgi-irix6*) gdb_target=irix6-64 ;; mips*-sgi-*) gdb_target=irix3 ;; mips*-sony-*) gdb_target=bigmips ;; mips*-*-mach3*) gdb_target=mipsm3 ;; diff -rc -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ gdb-4.17.85-orig/gdb/dwarf2read.c gdb-4.17.85/gdb/dwarf2read.c *** gdb-4.17.85-orig/gdb/dwarf2read.c Mon Jan 11 16:51:37 1999 --- gdb-4.17.85/gdb/dwarf2read.c Wed Mar 3 21:56:43 1999 *************** *** 52,58 **** unsigned short version; /* version number -- 2 for DWARF version 2 */ unsigned int abbrev_offset; /* offset into .debug_abbrev section */ ! unsigned char addr_size; /* byte size of an address -- 4 */ } _COMP_UNIT_HEADER; #define _ACTUAL_COMP_UNIT_HEADER_SIZE 11 --- 52,58 ---- unsigned short version; /* version number -- 2 for DWARF version 2 */ unsigned int abbrev_offset; /* offset into .debug_abbrev section */ ! unsigned char addr_size; /* byte size of an address -- 4 or 8 */ } _COMP_UNIT_HEADER; #define _ACTUAL_COMP_UNIT_HEADER_SIZE 11 *************** *** 926,944 **** obstack_init (&dwarf2_tmp_obstack); back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL); while ((unsigned int) (info_ptr - dwarf_info_buffer) ! + ((info_ptr - dwarf_info_buffer) % 4) < dwarf_info_size) { beg_of_comp_unit = info_ptr; ! cu_header.length = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; cu_header.version = read_2_bytes (abfd, info_ptr); info_ptr += 2; ! cu_header.abbrev_offset = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; cu_header.addr_size = read_1_byte (abfd, info_ptr); info_ptr += 1; ! address_size = cu_header.addr_size; if (cu_header.version != 2) { --- 926,966 ---- obstack_init (&dwarf2_tmp_obstack); back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL); + /* temporary hack by ben */ + #if GDB_TARGET_IS_MIPS64 + address_size = 8; + #else + address_size = 4; + #endif + while ((unsigned int) (info_ptr - dwarf_info_buffer) ! + ((info_ptr - dwarf_info_buffer) % address_size) < dwarf_info_size) { beg_of_comp_unit = info_ptr; ! if (address_size == 4) { ! cu_header.length = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; ! } else { ! cu_header.length = read_8_bytes (abfd, info_ptr); ! info_ptr += 8; ! } cu_header.version = read_2_bytes (abfd, info_ptr); info_ptr += 2; ! if (address_size == 4) { ! cu_header.abbrev_offset = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; ! } else { ! cu_header.abbrev_offset = read_8_bytes (abfd, info_ptr); ! info_ptr += 8; ! } cu_header.addr_size = read_1_byte (abfd, info_ptr); info_ptr += 1; ! ! if ( address_size != cu_header.addr_size ) { ! error ("Dwarf error: cu address size %ld not what expected (%d)", ! (long)cu_header.addr_size, (long)address_size ); ! return; ! } if (cu_header.version != 2) { *************** *** 1027,1033 **** also happen.) This happens in VxWorks. */ free_named_symtabs (pst->filename); ! info_ptr = beg_of_comp_unit + cu_header.length + 4; } do_cleanups (back_to); } --- 1049,1055 ---- also happen.) This happens in VxWorks. */ free_named_symtabs (pst->filename); ! info_ptr = beg_of_comp_unit + cu_header.length + address_size; } do_cleanups (back_to); } *************** *** 1307,1318 **** make_cleanup ((make_cleanup_func) really_free_pendings, NULL); /* read in the comp_unit header */ ! cu_header.length = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; cu_header.version = read_2_bytes (abfd, info_ptr); info_ptr += 2; ! cu_header.abbrev_offset = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; cu_header.addr_size = read_1_byte (abfd, info_ptr); info_ptr += 1; --- 1329,1350 ---- make_cleanup ((make_cleanup_func) really_free_pendings, NULL); /* read in the comp_unit header */ ! if (address_size == 4) { ! cu_header.length = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; ! } else { ! cu_header.length = read_8_bytes (abfd, info_ptr); ! info_ptr += 8; ! } cu_header.version = read_2_bytes (abfd, info_ptr); info_ptr += 2; ! if (address_size == 4) { ! cu_header.abbrev_offset = read_4_bytes (abfd, info_ptr); ! info_ptr += 4; ! } else { ! cu_header.abbrev_offset = read_8_bytes (abfd, info_ptr); ! info_ptr += 8; ! } cu_header.addr_size = read_1_byte (abfd, info_ptr); info_ptr += 1; *************** *** 1887,1893 **** and create blank accessibility bitfields if necessary. */ TYPE_NFIELDS (type) = nfields; TYPE_FIELDS (type) = (struct field *) ! TYPE_ALLOC (type, sizeof (struct field) * nfields); memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields); if (fip->non_public_fields) --- 1919,1925 ---- and create blank accessibility bitfields if necessary. */ TYPE_NFIELDS (type) = nfields; TYPE_FIELDS (type) = (struct field *) ! TYPE_ALLOC (type, sizeof (struct field) * nfields); memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields); if (fip->non_public_fields) *************** *** 2518,2524 **** else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 || attr->form == DW_FORM_data2 ! || attr->form == DW_FORM_data4) { low = DW_UNSND (attr); } --- 2550,2557 ---- else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 || attr->form == DW_FORM_data2 ! || attr->form == DW_FORM_data4 ! || attr->form == DW_FORM_data8) { low = DW_UNSND (attr); } *************** *** 2544,2550 **** else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 || attr->form == DW_FORM_data2 ! || attr->form == DW_FORM_data4) { high = DW_UNSND (attr); } --- 2577,2584 ---- else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 || attr->form == DW_FORM_data2 ! || attr->form == DW_FORM_data4 ! || attr->form == DW_FORM_data8) { high = DW_UNSND (attr); } *************** *** 3458,3463 **** --- 3492,3501 ---- DW_UNSND (attr) = read_4_bytes (abfd, info_ptr); info_ptr += 4; break; + case DW_FORM_ref8: + DW_UNSND (attr) = read_8_bytes (abfd, info_ptr); + info_ptr += 8; + break; case DW_FORM_ref_udata: DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); info_ptr += bytes_read; *************** *** 3811,3823 **** line_ptr = dwarf_line_buffer + offset; /* read in the prologue */ ! lh.total_length = read_4_bytes (abfd, line_ptr); ! line_ptr += 4; line_end = line_ptr + lh.total_length; lh.version = read_2_bytes (abfd, line_ptr); line_ptr += 2; ! lh.prologue_length = read_4_bytes (abfd, line_ptr); ! line_ptr += 4; lh.minimum_instruction_length = read_1_byte (abfd, line_ptr); line_ptr += 1; lh.default_is_stmt = read_1_byte (abfd, line_ptr); --- 3849,3871 ---- line_ptr = dwarf_line_buffer + offset; /* read in the prologue */ ! if (address_size == 4) { ! lh.total_length = read_4_bytes (abfd, line_ptr); ! line_ptr += 4; ! } else { ! lh.total_length = read_8_bytes (abfd, line_ptr); ! line_ptr += 8; ! } line_end = line_ptr + lh.total_length; lh.version = read_2_bytes (abfd, line_ptr); line_ptr += 2; ! if (address_size == 4) { ! lh.prologue_length = read_4_bytes (abfd, line_ptr); ! line_ptr += 4; ! } else { ! lh.prologue_length = read_8_bytes (abfd, line_ptr); ! line_ptr += 8; ! } lh.minimum_instruction_length = read_1_byte (abfd, line_ptr); line_ptr += 1; lh.default_is_stmt = read_1_byte (abfd, line_ptr); *************** *** 3915,3921 **** switch (op_code) { case DW_LNS_extended_op: ! line_ptr += 1; /* ignore length */ extended_op = read_1_byte (abfd, line_ptr); line_ptr += 1; switch (extended_op) --- 3963,3971 ---- switch (op_code) { case DW_LNS_extended_op: ! /* ignore length */ ! read_unsigned_leb128 (abfd, line_ptr, &bytes_read); ! line_ptr += bytes_read; extended_op = read_1_byte (abfd, line_ptr); line_ptr += 1; switch (extended_op) *************** *** 3993,3999 **** basic_block = 1; break; case DW_LNS_const_add_pc: ! address += (255 - lh.opcode_base) / lh.line_range; break; case DW_LNS_fixed_advance_pc: address += read_2_bytes (abfd, line_ptr); --- 4043,4050 ---- basic_block = 1; break; case DW_LNS_const_add_pc: ! address += lh.minimum_instruction_length * ! (255 - lh.opcode_base) / lh.line_range; break; case DW_LNS_fixed_advance_pc: address += read_2_bytes (abfd, line_ptr); *************** *** 4006,4012 **** line += lh.line_base + (adj_opcode % lh.line_range); /* append row to matrix using current values */ record_line (current_subfile, line, address); ! basic_block = 1; } } } --- 4057,4063 ---- line += lh.line_base + (adj_opcode % lh.line_range); /* append row to matrix using current values */ record_line (current_subfile, line, address); ! basic_block = 0; } } } *************** *** 5469,5477 **** --- 5520,5530 ---- case DW_FORM_data1: case DW_FORM_data2: case DW_FORM_data4: + case DW_FORM_data8: case DW_FORM_ref1: case DW_FORM_ref2: case DW_FORM_ref4: + case DW_FORM_ref8: case DW_FORM_udata: case DW_FORM_sdata: fprintf (stderr, "constant: %d", DW_UNSND (&die->attrs[i])); *************** *** 5490,5496 **** case DW_FORM_strp: /* we do not support separate string section yet */ case DW_FORM_indirect: /* we do not handle indirect yet */ - case DW_FORM_data8: /* we do not have 64 bit quantities */ default: fprintf (stderr, "unsupported attribute form: %d.", die->attrs[i].form); --- 5543,5548 ---- *************** *** 5545,5550 **** --- 5597,5603 ---- case DW_FORM_ref1: case DW_FORM_ref2: case DW_FORM_ref4: + case DW_FORM_ref8: case DW_FORM_ref_udata: result = cu_header_offset + DW_UNSND (attr); break; *************** *** 5590,5598 **** current language and the current target machine. */ if (ftypes[typeid] == NULL) ! { ftypes[typeid] = cu_language_defn->la_fund_type (objfile, typeid); ! } return (ftypes[typeid]); } --- 5643,5651 ---- current language and the current target machine. */ if (ftypes[typeid] == NULL) ! { ftypes[typeid] = cu_language_defn->la_fund_type (objfile, typeid); ! } return (ftypes[typeid]); } diff -rc -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ gdb-4.17.85-orig/gdb/irix5-nat.c gdb-4.17.85/gdb/irix5-nat.c *** gdb-4.17.85-orig/gdb/irix5-nat.c Tue Jan 19 12:01:36 1999 --- gdb-4.17.85/gdb/irix5-nat.c Wed Mar 3 15:04:08 1999 *************** *** 466,471 **** --- 466,472 ---- return (1); } + /* LOCAL FUNCTION *************** *** 561,573 **** return NULL; /* Get address of first list entry. */ ! read_memory (debug_base, (char *) &listp, sizeof (struct obj_list *)); ! if (listp == NULL) return NULL; /* Get first list entry. */ - lladdr = (CORE_ADDR) listp; read_memory (lladdr, (char *) &list_old, sizeof (struct obj_list)); /* The first entry in the list is the object file we are debugging, --- 562,573 ---- return NULL; /* Get address of first list entry. */ ! read_memory (debug_base, (char *) &lladdr, sizeof(CORE_ADDR)); ! if (lladdr == NULL) return NULL; /* Get first list entry. */ read_memory (lladdr, (char *) &list_old, sizeof (struct obj_list)); /* The first entry in the list is the object file we are debugging, *************** *** 577,588 **** --- 577,597 ---- #ifdef HANDLE_NEW_OBJ_LIST if (list_old.data == NEW_OBJ_INFO_MAGIC) { + #if GDB_TARGET_IS_MIPS64 + Elf64_Obj_Info list_64; + + read_memory (lladdr, (char *) &list_64, sizeof (Elf64_Obj_Info)); + if (list_64.oi_size != sizeof (Elf64_Obj_Info)) + return NULL; + next_lladdr = (CORE_ADDR) list_64.oi_next; + #else Elf32_Obj_Info list_32; read_memory (lladdr, (char *) &list_32, sizeof (Elf32_Obj_Info)); if (list_32.oi_size != sizeof (Elf32_Obj_Info)) return NULL; next_lladdr = (CORE_ADDR) list_32.oi_next; + #endif } #endif *************** *** 643,648 **** --- 652,665 ---- sizeof (Elf32_Obj_Info)); next_lladdr = (CORE_ADDR) list_32.oi_next; } + else if (lm -> l_variant == OBJ_LIST_64) + { + Elf64_Obj_Info list_64; + status = target_read_memory (lm -> l_lladdr, + (char *) &list_64, + sizeof (Elf64_Obj_Info)); + next_lladdr = (CORE_ADDR) list_64.oi_next; + } #endif if (status != 0 || next_lladdr == 0) *************** *** 690,695 **** --- 707,731 ---- #ifdef HANDLE_NEW_OBJ_LIST if (list_old.data == NEW_OBJ_INFO_MAGIC) { + #if GDB_TARGET_IS_MIPS64 + Elf64_Obj_Info list_64; + + read_memory (lladdr, (char *) &list_64, sizeof (Elf64_Obj_Info)); + if (list_64.oi_size != sizeof (Elf64_Obj_Info)) + return; + new_lm -> l_variant = OBJ_LIST_64; + new_lm -> l_next = (CORE_ADDR) list_64.oi_next; + + target_read_string ((CORE_ADDR) list_64.oi_pathname, + &so_list_ptr -> so_name, + list_64.oi_pathname_len + 1, &errcode); + if (errcode != 0) + memory_error (errcode, (CORE_ADDR) list_64.oi_pathname); + + LM_ADDR (so_list_ptr) = (CORE_ADDR) list_64.oi_ehdr; + LM_OFFSET (so_list_ptr) = + (CORE_ADDR) list_64.oi_ehdr - (CORE_ADDR) list_64.oi_orig_ehdr; + #else Elf32_Obj_Info list_32; read_memory (lladdr, (char *) &list_32, sizeof (Elf32_Obj_Info)); *************** *** 707,712 **** --- 743,749 ---- LM_ADDR (so_list_ptr) = (CORE_ADDR) list_32.oi_ehdr; LM_OFFSET (so_list_ptr) = (CORE_ADDR) list_32.oi_ehdr - (CORE_ADDR) list_32.oi_orig_ehdr; + #endif } else #endif --gBBFr7Ir9EOA20Yy--