This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Getting rid of PC_LOAD_SEGMENT
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA] Getting rid of PC_LOAD_SEGMENT
- From: "Peter.Schauer" <Peter dot Schauer at regent dot e-technik dot tu-muenchen dot de>
- Date: Sat, 11 Nov 2000 12:55:55 MET
PC_LOAD_SEGMENT is more or less a similar implementation of PC_SOLIB,
resulting in code duplication in stack.c. Historically PC_LOAD_SEGMENT
has been there before PC_SOLIB, but PC_SOLIB is now in more widespread use
and better maintained, so I'd suggest to replace PC_LOAD_SEGMENT with PC_SOLIB.
There are no regressions with the testsuite, but we get better information
from a stack backtrace through shared libraries.
Here is an example from the testsuite:
Without patch:
(gdb) PASS: gdb.base/corefile.exp: print func2::coremaker_local
bt
#0 0xd0170d28 in raise ()
#1 0xd016a454 in abort ()
#2 0x1000061c in func2 () at coremaker.c:107
#3 0x10000664 in func1 () at coremaker.c:113
#4 0x100006bc in main () at coremaker.c:119
#5 0x100001dc in __start ()
With patch:
(gdb) PASS: gdb.base/corefile.exp: print func2::coremaker_local
bt
#0 0xd0170d28 in raise () from /usr/lib/libc.a(shr.o)
#1 0xd016a454 in abort () from /usr/lib/libc.a(shr.o)
#2 0x1000061c in func2 () at coremaker.c:107
#3 0x10000664 in func1 () at coremaker.c:113
#4 0x100006bc in main () at coremaker.c:119
#5 0x100001dc in __start ()
Get rid of AIX specific PC_LOAD_SEGMENT, replace with PC_SOLIB.
* xcoffsolib.c (xcoff_solib_address): Renamed from
pc_load_segment_name. Return NULL if address is not in a shared
library. Cleanup shared library name construction, using asprintf.
Format shared library member names consistent with format in exec.c.
(solib_info): Format shared library member names consistent with
format in exec.c.
* config/rs6000/nm-rs6000.h: Replace PC_LOAD_SEGMENT with PC_SOLIB,
using xcoff_solib_address for PC_SOLIB definition.
* stack.c (print_frame): Remove PC_LOAD_SEGMENT code, no longer
needed.
*** ./config/rs6000/nm-rs6000.h.orig Thu Nov 9 12:05:14 2000
--- ./config/rs6000/nm-rs6000.h Thu Nov 9 12:04:37 2000
***************
*** 57,66 ****
struct target_ops;
extern void xcoff_relocate_core (struct target_ops *);
! /* Load segment of a given pc value. */
! #define PC_LOAD_SEGMENT(PC) pc_load_segment_name(PC)
! extern char *pc_load_segment_name (CORE_ADDR);
/* Return sizeof user struct to callers in less machine dependent routines */
--- 57,66 ----
struct target_ops;
extern void xcoff_relocate_core (struct target_ops *);
! /* If ADDR lies in a shared library, return its name. */
! #define PC_SOLIB(PC) xcoff_solib_address(PC)
! extern char *xcoff_solib_address (CORE_ADDR);
/* Return sizeof user struct to callers in less machine dependent routines */
*** ./stack.c.orig Thu Nov 9 11:34:42 2000
--- ./stack.c Thu Nov 9 11:58:44 2000
***************
*** 623,646 ****
annotate_frame_source_end ();
}
- #ifdef PC_LOAD_SEGMENT
- /* If we couldn't print out function name but if can figure out what
- load segment this pc value is from, at least print out some info
- about its load segment. */
- if (!funname)
- {
- annotate_frame_where ();
- #ifdef UI_OUT
- ui_out_wrap_hint (uiout, " ");
- ui_out_text (uiout, " from ");
- ui_out_field_string (uiout, "from", PC_LOAD_SEGMENT (fi->pc));
- #else
- wrap_here (" ");
- printf_filtered (" from %s", PC_LOAD_SEGMENT (fi->pc));
- #endif
- }
- #endif /* PC_LOAD_SEGMENT */
-
#ifdef PC_SOLIB
if (!funname || (!sal.symtab || !sal.symtab->filename))
{
--- 623,628 ----
*** ./xcoffsolib.c.orig Thu Nov 9 20:42:34 2000
--- ./xcoffsolib.c Sat Nov 11 11:50:32 2000
***************
*** 29,57 ****
#include "gdb_regex.h"
! /* Return the module name of a given text address. Note that returned buffer
! is not persistent. */
char *
! pc_load_segment_name (CORE_ADDR addr)
{
! static char buffer[BUFSIZ];
struct vmap *vp = vmap;
! buffer[0] = buffer[1] = '\0';
! for (; vp; vp = vp->nxt)
if (vp->tstart <= addr && addr < vp->tend)
{
! if (*vp->member)
{
! buffer[0] = '(';
! strcat (&buffer[1], vp->member);
! strcat (buffer, ")");
}
! strcat (buffer, vp->name);
return buffer;
}
! return "(unknown load module)";
}
static void solib_info (char *, int);
--- 29,64 ----
#include "gdb_regex.h"
! /* If ADDR lies in a shared library, return its name.
! Note that returned name points to static data whose content is overwritten
! by each call. */
char *
! xcoff_solib_address (CORE_ADDR addr)
{
! static char *buffer;
struct vmap *vp = vmap;
! /* The first vmap entry is for the exec file. */
!
! if (vp == NULL)
! return NULL;
! for (vp = vp->nxt; vp; vp = vp->nxt)
if (vp->tstart <= addr && addr < vp->tend)
{
! if (buffer != NULL)
{
! free (buffer);
! buffer = NULL;
}
! asprintf (&buffer, "%s%s%s%s",
! vp->name,
! *vp->member ? "(" : "",
! vp->member,
! *vp->member ? ")" : "");
return buffer;
}
! return NULL;
}
static void solib_info (char *, int);
***************
*** 84,93 ****
paddr (vp->tstart),paddr (vp->tend),
paddr (vp->dstart), paddr (vp->dend),
vp->loaded ? "Yes" : "No ",
*vp->member ? "(" : "",
vp->member,
! *vp->member ? ") " : "",
! vp->name);
}
}
--- 91,100 ----
paddr (vp->tstart),paddr (vp->tend),
paddr (vp->dstart), paddr (vp->dend),
vp->loaded ? "Yes" : "No ",
+ vp->name,
*vp->member ? "(" : "",
vp->member,
! *vp->member ? ")" : "");
}
}
--
Peter Schauer pes@regent.e-technik.tu-muenchen.de