From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075325906801.tru64-unix-managers.marc@archive.invalid> From: Christophe Colle Date: Sat, 30 Dec 1995 17:54:02 +0000 To: tru64-unix-managers Subject: gdb and digital unix 3.2C .. the patch X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075325906801 Hi all, Because I received already so many requests for the patch, I will post them to this list ... Have fun ... Christophe | \ ============================================================= | \ Colle Christophe Phone: +32-(0)9-2403955 +---- mail: colle@krtkg1.rug.ac.be http://krtkg1.rug.ac.be/~colle | ----------+ When I'm not in Ghent, Then I'm probably Sailing \________| ======= Radiotherapy Department, Ghent ============= ---------- Forwarded message ---------- Date: Fri, 29 Dec 95 16:12:05 MET From: Peter.Schauer To: Christophe Colle Subject: Re: gdb and digital unix 3.2C OSF 3.2C strips all debugging symbols from startup files and shared libraries, and gdb-4.15 is unable to deal with it. Below is a bunch of patches that handle all known gdb-4.15/OSF-3.2C problems, they will be part of the next GDB release. *** gdb-4.15/gdb/alpha-tdep.c.orig Wed Aug 2 05:13:27 1995 --- gdb-4.15/gdb/alpha-tdep.c Fri Nov 17 18:20:30 1995 *************** *** 260,267 **** alpha_extra_func_info_t proc_desc = frame->proc_desc; /* We have to get the saved pc from the sigcontext if it is a signal handler frame. */ ! int pcreg = frame->signal_handler_caller ? PC_REGNUM ! : (proc_desc ? PROC_PC_REG(proc_desc) : RA_REGNUM); if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc)) return read_memory_integer(frame->frame - 8, 8); --- 260,266 ---- alpha_extra_func_info_t proc_desc = frame->proc_desc; /* We have to get the saved pc from the sigcontext if it is a signal handler frame. */ ! int pcreg = frame->signal_handler_caller ? PC_REGNUM : frame->pc_reg; if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc)) return read_memory_integer(frame->frame - 8, 8); *************** *** 273,281 **** alpha_saved_pc_after_call (frame) struct frame_info *frame; { ! alpha_extra_func_info_t proc_desc = find_proc_desc (frame->pc, frame->next); ! int pcreg = proc_desc ? PROC_PC_REG (proc_desc) : RA_REGNUM; return read_register (pcreg); } --- 272,290 ---- alpha_saved_pc_after_call (frame) struct frame_info *frame; { ! CORE_ADDR pc = frame->pc; ! CORE_ADDR tmp; ! alpha_extra_func_info_t proc_desc; ! int pcreg; ! ! /* Skip over shared library trampoline if necessary. */ ! tmp = SKIP_TRAMPOLINE_CODE (pc); ! if (tmp != 0) ! pc = tmp; + proc_desc = find_proc_desc (pc, frame->next); + pcreg = proc_desc ? PROC_PC_REG (proc_desc) : RA_REGNUM; + return read_register (pcreg); } *************** *** 350,355 **** --- 359,365 ---- int frame_size; int has_frame_reg = 0; unsigned long reg_mask = 0; + int pcreg = -1; if (start_pc == 0) return NULL; *************** *** 379,388 **** --- 389,423 ---- int reg = (word & 0x03e00000) >> 21; reg_mask |= 1 << reg; temp_saved_regs.regs[reg] = sp + (short)word; + if (pcreg == -1) + pcreg = reg; } else if (word == 0x47de040f) /* bis sp,sp fp */ has_frame_reg = 1; } + if (pcreg == -1) + { + while (cur_pc < (limit_pc + 12) && cur_pc < (start_pc + 12)) + { + char buf[4]; + unsigned long word; + int status; + + status = read_memory_nobpt (cur_pc, buf, 4); + if (status) + memory_error (status, cur_pc); + cur_pc += 4; + word = extract_unsigned_integer (buf, 4); + + if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */ + && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */ + { + pcreg = (word & 0x03e00000) >> 21; + break; + } + } + } + if (has_frame_reg) PROC_FRAME_REG(&temp_proc_desc) = GCC_FP_REGNUM; else *************** *** 389,395 **** PROC_FRAME_REG(&temp_proc_desc) = SP_REGNUM; PROC_FRAME_OFFSET(&temp_proc_desc) = frame_size; PROC_REG_MASK(&temp_proc_desc) = reg_mask; ! PROC_PC_REG(&temp_proc_desc) = RA_REGNUM; PROC_LOCALOFF(&temp_proc_desc) = 0; /* XXX - bogus */ return &temp_proc_desc; } --- 424,430 ---- PROC_FRAME_REG(&temp_proc_desc) = SP_REGNUM; PROC_FRAME_OFFSET(&temp_proc_desc) = frame_size; PROC_REG_MASK(&temp_proc_desc) = reg_mask; ! PROC_PC_REG(&temp_proc_desc) = (pcreg == -1) ? RA_REGNUM : pcreg; PROC_LOCALOFF(&temp_proc_desc) = 0; /* XXX - bogus */ return &temp_proc_desc; } *************** *** 530,535 **** --- 565,571 ---- { PROC_LOCALOFF (found_heuristic) = PROC_LOCALOFF (proc_desc); + PROC_PC_REG (found_heuristic) = PROC_PC_REG (proc_desc); proc_desc = found_heuristic; } } *************** *** 613,625 **** frame->next ? cached_proc_desc : find_proc_desc(frame->pc, frame->next); frame->saved_regs = NULL; ! frame->proc_desc = ! proc_desc == &temp_proc_desc ? 0 : proc_desc; if (proc_desc) { ! /* Get the locals offset from the procedure descriptor, it is valid ! even if we are in the middle of the prologue. */ frame->localoff = PROC_LOCALOFF(proc_desc); /* Fixup frame-pointer - only needed for top frame */ --- 649,664 ---- frame->next ? cached_proc_desc : find_proc_desc(frame->pc, frame->next); frame->saved_regs = NULL; ! frame->localoff = 0; ! frame->pc_reg = RA_REGNUM; ! frame->proc_desc = proc_desc == &temp_proc_desc ? 0 : proc_desc; if (proc_desc) { ! /* Get the locals offset and the saved pc register from the ! procedure descriptor, they are valid even if we are in the ! middle of the prologue. */ frame->localoff = PROC_LOCALOFF(proc_desc); + frame->pc_reg = PROC_PC_REG(proc_desc); /* Fixup frame-pointer - only needed for top frame */ *************** *** 639,649 **** if (proc_desc == &temp_proc_desc) { ! frame->saved_regs = (struct frame_saved_regs*) ! obstack_alloc (&frame_cache_obstack, ! sizeof (struct frame_saved_regs)); ! *frame->saved_regs = temp_saved_regs; ! frame->saved_regs->regs[PC_REGNUM] = frame->saved_regs->regs[RA_REGNUM]; } } } --- 678,699 ---- if (proc_desc == &temp_proc_desc) { ! char *name; ! ! /* Do not set the saved registers for a sigtramp frame, ! alpha_find_saved_registers will do that for us. ! We can't use frame->signal_handler_caller, it is not yet set. */ ! find_pc_partial_function (frame->pc, &name, ! (CORE_ADDR *)NULL,(CORE_ADDR *)NULL); ! if (!IN_SIGTRAMP (frame->pc, name)) ! { ! frame->saved_regs = (struct frame_saved_regs*) ! obstack_alloc (&frame_cache_obstack, ! sizeof (struct frame_saved_regs)); ! *frame->saved_regs = temp_saved_regs; ! frame->saved_regs->regs[PC_REGNUM] ! = frame->saved_regs->regs[RA_REGNUM]; ! } } } } *** gdb-4.15/gdb/blockframe.c.orig Wed Aug 2 05:13:43 1995 --- gdb-4.15/gdb/blockframe.c Fri Nov 17 17:02:12 1995 *************** *** 734,740 **** I don't really understand the reasoning behind the magic handling for mst_trampoline symbols. */ ! #ifdef INHIBIT_SUNSOLIB_TRANSFER_TABLE_HACK cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); #else if (msymbol -> type == mst_text || msymbol -> type == mst_file_text) --- 734,740 ---- I don't really understand the reasoning behind the magic handling for mst_trampoline symbols. */ ! #if 1 cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); #else if (msymbol -> type == mst_text || msymbol -> type == mst_file_text) *** gdb-4.15/gdb/config/alpha/tm-alpha.h.orig Wed Aug 2 05:27:06 1995 --- gdb-4.15/gdb/config/alpha/tm-alpha.h Tue Oct 17 22:00:52 1995 *************** *** 401,406 **** --- 401,407 ---- #define EXTRA_FRAME_INFO \ int localoff; \ + int pc_reg; \ alpha_extra_func_info_t proc_desc; \ struct frame_saved_regs *saved_regs; *************** *** 433,437 **** --- 434,442 ---- #ifndef VM_MIN_ADDRESS #define VM_MIN_ADDRESS (CORE_ADDR)0x120000000 #endif + + /* If PC is in a shared library trampoline code, return the PC + where the function itself actually starts. If not, return 0. */ + #define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc) #endif /* TM_ALPHA_H */ *** gdb-4.15/gdb/mipsread.c.orig Wed Aug 2 05:19:53 1995 --- gdb-4.15/gdb/mipsread.c Fri Nov 17 17:02:12 1995 *************** *** 118,123 **** --- 118,137 ---- install_minimal_symbols (objfile); + if (mainline + && objfile->ei.entry_point != INVALID_ENTRY_POINT + && objfile->ei.entry_file_lowpc == INVALID_ENTRY_LOWPC) + { + struct minimal_symbol *m; + + m = lookup_minimal_symbol_by_pc (objfile->ei.entry_point); + if (m && SYMBOL_NAME (m + 1)) + { + objfile->ei.entry_file_lowpc = SYMBOL_VALUE_ADDRESS (m); + objfile->ei.entry_file_highpc = SYMBOL_VALUE_ADDRESS (m + 1); + } + } + do_cleanups (back_to); } *************** *** 309,320 **** break; else if (dyn_tag == DT_MIPS_LOCAL_GOTNO) { ! dt_mips_local_gotno = bfd_h_get_32 (abfd, ! (bfd_byte *) x_dynp->d_un.d_val); } else if (dyn_tag == DT_MIPS_GOTSYM) { ! dt_mips_gotsym = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp->d_un.d_val); } } if (dt_mips_local_gotno < 0 || dt_mips_gotsym < 0) --- 323,337 ---- break; else if (dyn_tag == DT_MIPS_LOCAL_GOTNO) { ! if (dt_mips_local_gotno < 0) ! dt_mips_local_gotno ! = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp->d_un.d_val); } else if (dyn_tag == DT_MIPS_GOTSYM) { ! if (dt_mips_gotsym < 0) ! dt_mips_gotsym ! = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp->d_un.d_val); } } if (dt_mips_local_gotno < 0 || dt_mips_gotsym < 0) *** gdb-4.15/gdb/symfile.c.orig Wed Aug 2 05:23:56 1995 --- gdb-4.15/gdb/symfile.c Fri Nov 17 17:02:13 1995 *************** *** 301,309 **** { /* Examination of non-executable.o files. Short-circuit this stuff. */ objfile -> ei.entry_point = INVALID_ENTRY_POINT; - objfile -> ei.entry_file_lowpc = INVALID_ENTRY_LOWPC; - objfile -> ei.entry_file_highpc = INVALID_ENTRY_HIGHPC; } } /* Get current entry point address. */ --- 301,313 ---- { /* Examination of non-executable.o files. Short-circuit this stuff. */ objfile -> ei.entry_point = INVALID_ENTRY_POINT; } + objfile -> ei.entry_file_lowpc = INVALID_ENTRY_LOWPC; + objfile -> ei.entry_file_highpc = INVALID_ENTRY_HIGHPC; + objfile -> ei.entry_func_lowpc = INVALID_ENTRY_LOWPC; + objfile -> ei.entry_func_highpc = INVALID_ENTRY_HIGHPC; + objfile -> ei.main_func_lowpc = INVALID_ENTRY_LOWPC; + objfile -> ei.main_func_highpc = INVALID_ENTRY_HIGHPC; } /* Get current entry point address. */ *** gdb-4.15/gdb/top.c.orig Fri Oct 6 22:25:37 1995 --- gdb-4.15/gdb/top.c Tue Dec 12 20:17:20 1995 *************** *** 1820,1825 **** --- 1820,1826 ---- init_signals () { signal (SIGINT, request_quit); + signal (SIGTRAP, SIG_DFL); /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get passed to the inferior, which we don't want. It would be > > > Dear gdb-users, > > I'm running digital unix 3.2c and osf v 2.0. It seems like or gbd isn't > working anymore for osf 3.2C, or osf 3.2C has a broken file. I'm not sure. > > a case: > #include > > main() > { > puts("hi there"); > } > > > > one of the step in the compilation procedure is linking: > ld -g2 -O1 -call_shared /usr/lib/cmplrs/cc/crt0.o test.o -lc > This is done automatically by the cc or gcc command. > > procedure 1: > ------------ > When I use the /usr/lib/cmplrs/cc/crt0.o from osf 3.2C then i get this > result: > colle@krtkg1> ld -g2 -O1 -call_shared /usr/lib/cmplrs/cc/crt0.o test.o -lc > colle@krtkg1> gdb a.out > GDB is free software and you are welcome to distribute copies of it > under certain conditions; type "show copying" to see the conditions. > There is absolutely no warranty for GDB; type "show warranty" for details. > GDB 4.15.1 (alpha-dec-osf3.2), Copyright 1995 Free Software Foundation, > Inc... > (gdb) b 5 > Breakpoint 1 at 0x1200011a0: file test.c, line 5. > (gdb) run > Starting program: /usr/users/colle/ircdir/a.out > > Breakpoint 1, main () at test.c:5 > 5 puts("hi there"); > (gdb) ba > #0 main () at test.c:5 > #1 0x120001120 in __start () > #2 0x120001120 in __start () > #3 0x120001120 in __start () > #4 0x120001120 in __start () > #5 0x120001120 in __start () > #6 0x120001120 in __start () > #7 0x120001120 in __start () > #8 0x120001120 in __start () > #9 0x120001120 in __start () > #10 0x120001120 in __start () > #11 0x120001120 in __start () > #12 0x120001120 in __start () > #13 0x120001120 in __start () > #14 0x120001120 in __start () > #15 0x120001120 in __start () > #16 0x120001120 in __start () > #17 0x120001120 in __start () > #18 0x120001120 in __start () > #19 0x120001120 in __start () > #20 0x120001120 in __start () > #21 0x120001120 in __start () > #22 0x120001120 in __start () > ---Type to continue, or q to quit--- > > > and so on .... > > > > procedure 2: > ------------ > If otherwise i use the //usr/lib/cmplrs/cc/crt0.o from a machine with osf > v2.0 then I get this result (/krtkg4 is /usr on the other machine): > colle@krtkg1> ld -g2 -O1 -call_shared /krtkg4/lib/cmplrs/cc/crt0.o > test.o -lc > colle@krtkg1> gdb a.out > GDB is free software and you are welcome to distribute copies of it > under certain conditions; type "show copying" to see the conditions. > There is absolutely no warranty for GDB; type "show warranty" for details. > GDB 4.15.1 (alpha-dec-osf3.2), Copyright 1995 Free Software Foundation, > Inc... > (gdb) b 5 > Breakpoint 1 at 0x1200010f0: file test.c, line 5. > (gdb) run > Starting program: /usr/users/colle/ircdir/a.out > > Breakpoint 1, main () at test.c:5 > 5 puts("hi there"); > (gdb) ba > #0 main () at test.c:5 > (gdb) > > > As you can see the second result is what I want! Both linkings were done > on the same machine, with the same linker, but with a different crt0.o file > > The question is: > ---------------- > Is gdb buggy for this crt0.o file, or is it the new digital unix 3.2C? > > I have 2 machines with the new osf release. One is an older machine which > I reinstalled from scratch a few weeks ago, and the other one is a brand > new one with the osf installed by digital. > The third machine is still running osf v2.0. > I tell this because I heard people who are running gdb on a 3.x machine > without problems. I think they didn't install from scratch and I think > they probably have an old crt0.o file > > Is anyone able to tell me if gdb is bad? or is that new crt0.o file? > > Any help is appreciated. > > Thanks. > > > | \ ============================================================= > | \ Colle Christophe Phone: +32-(0)9-2403955 > +---- mail: colle@krtkg1.rug.ac.be http://krtkg1.rug.ac.be/~colle > | > ----------+ When I'm not in Ghent, Then I'm probably Sailing > \________| ======= Radiotherapy Department, Ghent ============= > > -- Peter Schauer pes@regent.e-technik.tu-muenchen.de