From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1750 invoked by alias); 18 Sep 2007 23:15:03 -0000 Received: (qmail 1673 invoked by uid 22791); 18 Sep 2007 23:15:01 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 18 Sep 2007 23:14:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 435282AAF79 for ; Tue, 18 Sep 2007 19:14:51 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Z8GTKdhJB5gn for ; Tue, 18 Sep 2007 19:14:51 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A525F2AAF6B for ; Tue, 18 Sep 2007 19:14:50 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 6DF51E7B58; Tue, 18 Sep 2007 16:14:48 -0700 (PDT) Date: Tue, 18 Sep 2007 23:15:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFC/commit] Getting rid of tm-rs6000.h (PROCESS_LINENUMBER_HOOK) Message-ID: <20070918231448.GS29127@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00246.txt.bz2 --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1952 Hello, There is only one macro left in tm-rs6000.h, which is: /* In xcoff, we cannot process line numbers when we see them. This is mainly because we don't know the boundaries of the include files. So, we postpone that, and then enter and sort(?) the whole line table at once, when we are closing the current symbol table in end_symtab(). */ #define PROCESS_LINENUMBER_HOOK() aix_process_linenos () extern void aix_process_linenos (void); The AIX port is the only port that defines this macro, and it's only used in one place: buildsym.c:end_symtab(). I think the most appropriate way to define this notion is as a gdbarch method, set only in the case of AIX. This is what this patch does. I must say that I am really bad at finding names. I did my best for the name of the gdbarch method, but better suggestions would be very much appreciated. 2007-09-18 Joel Brobecker * gdbarch.sh: Add new buildsym_linetable_hook gdbarch function. * gdbarch.h, gdbarch.c: Regenerate. * buildsym.c (end_symtab): Replace use of PROCESS_LINENUMBER_HOOK by use of gdbarch_buildsym_linetable_hook. * xcoffread.h: New file. * xcoffread.c: Add include of xcoffread.h. * rs6000-aix-tdep.c: Add include of xcoffread.h. (rs6000_aix_init_osabi): Set buildsym_linetable_hook gdbarch function. * Makefile.in (xcoffread_h): New variable. (rs6000-aix-tdep.o): Add dependency on xcoffread.h. (xcoffread.o): Likewise. * config/powerpc/aix.mt (DEPRECATED_TM_FILE): Delete. * config/rs6000/tm-rs6000.h: Delete. The associated documentation update is pretty straightforward. 2007-09-18 Joel Brobecker * gdbint.texinfo (Target Conditionals): Remove documentation of PROCESS_LINENUMBER_HOOK. This was tested on powerpc-aix. Does it look good? Thanks, -- Joel --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="aix-hook.diff" Content-length: 9197 Index: gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.441 diff -u -p -r1.441 gdbarch.sh --- gdbarch.sh 3 Sep 2007 23:06:35 -0000 1.441 +++ gdbarch.sh 18 Sep 2007 22:37:31 -0000 @@ -652,6 +652,10 @@ F::void:skip_permanent_breakpoint:struct # Refresh overlay mapped state for section OSECT. F::void:overlay_update:struct obj_section *osect:osect + +# If defined, this function is called at the end of the creation +# of each symbol table and should build the associated line table. +F::void:buildsym_linetable_hook:void: EOF } Index: gdbarch.h =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.h,v retrieving revision 1.359 diff -u -p -r1.359 gdbarch.h --- gdbarch.h 3 Sep 2007 23:06:35 -0000 1.359 +++ gdbarch.h 18 Sep 2007 22:37:31 -0000 @@ -687,6 +687,15 @@ typedef void (gdbarch_overlay_update_fty extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect); extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update); +/* If defined, this function is called at the end of the creation + of each symbol table and should build the associated line table. */ + +extern int gdbarch_buildsym_linetable_hook_p (struct gdbarch *gdbarch); + +typedef void (gdbarch_buildsym_linetable_hook_ftype) (void); +extern void gdbarch_buildsym_linetable_hook (struct gdbarch *gdbarch); +extern void set_gdbarch_buildsym_linetable_hook (struct gdbarch *gdbarch, gdbarch_buildsym_linetable_hook_ftype *buildsym_linetable_hook); + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); Index: gdbarch.c =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.c,v retrieving revision 1.403 diff -u -p -r1.403 gdbarch.c --- gdbarch.c 3 Sep 2007 23:06:35 -0000 1.403 +++ gdbarch.c 18 Sep 2007 22:37:31 -0000 @@ -230,6 +230,7 @@ struct gdbarch int vbit_in_delta; gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint; gdbarch_overlay_update_ftype *overlay_update; + gdbarch_buildsym_linetable_hook_ftype *buildsym_linetable_hook; }; @@ -352,6 +353,7 @@ struct gdbarch startup_gdbarch = 0, /* vbit_in_delta */ 0, /* skip_permanent_breakpoint */ 0, /* overlay_update */ + 0, /* buildsym_linetable_hook */ /* startup_gdbarch() */ }; @@ -599,6 +601,7 @@ verify_gdbarch (struct gdbarch *current_ /* Skip verify of vbit_in_delta, invalid_p == 0 */ /* Skip verify of skip_permanent_breakpoint, has predicate */ /* Skip verify of overlay_update, has predicate */ + /* Skip verify of buildsym_linetable_hook, has predicate */ buf = ui_file_xstrdup (log, &dummy); make_cleanup (xfree, buf); if (strlen (buf) > 0) @@ -684,6 +687,12 @@ gdbarch_dump (struct gdbarch *current_gd "gdbarch_dump: breakpoint_from_pc = <0x%lx>\n", (long) current_gdbarch->breakpoint_from_pc); fprintf_unfiltered (file, + "gdbarch_dump: gdbarch_buildsym_linetable_hook_p() = %d\n", + gdbarch_buildsym_linetable_hook_p (current_gdbarch)); + fprintf_unfiltered (file, + "gdbarch_dump: buildsym_linetable_hook = <0x%lx>\n", + (long) current_gdbarch->buildsym_linetable_hook); + fprintf_unfiltered (file, "gdbarch_dump: byte_order = %s\n", paddr_d (current_gdbarch->byte_order)); fprintf_unfiltered (file, @@ -3001,6 +3010,30 @@ set_gdbarch_overlay_update (struct gdbar gdbarch->overlay_update = overlay_update; } +int +gdbarch_buildsym_linetable_hook_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + return gdbarch->buildsym_linetable_hook != NULL; +} + +void +gdbarch_buildsym_linetable_hook (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->buildsym_linetable_hook != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_buildsym_linetable_hook called\n"); + gdbarch->buildsym_linetable_hook (); +} + +void +set_gdbarch_buildsym_linetable_hook (struct gdbarch *gdbarch, + gdbarch_buildsym_linetable_hook_ftype buildsym_linetable_hook) +{ + gdbarch->buildsym_linetable_hook = buildsym_linetable_hook; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ Index: buildsym.c =================================================================== RCS file: /cvs/src/src/gdb/buildsym.c,v retrieving revision 1.50 diff -u -p -r1.50 buildsym.c --- buildsym.c 23 Aug 2007 18:08:26 -0000 1.50 +++ buildsym.c 18 Sep 2007 22:37:08 -0000 @@ -933,10 +933,11 @@ end_symtab (CORE_ADDR end_addr, struct o &objfile->objfile_obstack); } -#ifndef PROCESS_LINENUMBER_HOOK -#define PROCESS_LINENUMBER_HOOK() -#endif - PROCESS_LINENUMBER_HOOK (); /* Needed for xcoff. */ + /* There are certain object formats such as XCOFF where we cannot + process the line table before having finished reading the debugging + info. If necessary, read the lineable now. */ + if (gdbarch_buildsym_linetable_hook_p (current_gdbarch)) + gdbarch_buildsym_linetable_hook (current_gdbarch); /* Now create the symtab objects proper, one for each subfile. */ /* (The main file is the last one on the chain.) */ Index: xcoffread.c =================================================================== RCS file: /cvs/src/src/gdb/xcoffread.c,v retrieving revision 1.54 diff -u -p -r1.54 xcoffread.c --- xcoffread.c 23 Aug 2007 18:08:47 -0000 1.54 +++ xcoffread.c 18 Sep 2007 22:38:23 -0000 @@ -55,6 +55,8 @@ /* For interface with stabsread.c. */ #include "aout/stab_gnu.h" +#include "xcoffread.h" + /* We put a pointer to this structure in the read_symtab_private field of the psymtab. */ Index: rs6000-aix-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-aix-tdep.c,v retrieving revision 1.6 diff -u -p -r1.6 rs6000-aix-tdep.c --- rs6000-aix-tdep.c 30 Aug 2007 13:13:59 -0000 1.6 +++ rs6000-aix-tdep.c 18 Sep 2007 22:38:01 -0000 @@ -26,6 +26,7 @@ #include "regset.h" #include "rs6000-tdep.h" #include "ppc-tdep.h" +#include "xcoffread.h" /* Core file support. */ @@ -168,6 +169,12 @@ rs6000_aix_init_osabi (struct gdbarch_in /* Minimum possible text address in AIX. */ gdbarch_tdep (gdbarch)->text_segment_base = 0x10000000; + + /* In xcoff, we cannot process line numbers when we see them. This is + mainly because we don't know the boundaries of the include files. + So, we postpone that, and then enter and sort(?) the whole line table + at once, when we are closing the current symbol table in end_symtab(). */ + set_gdbarch_buildsym_linetable_hook (gdbarch, aix_process_linenos); } void Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.936 diff -u -p -r1.936 Makefile.in --- Makefile.in 5 Sep 2007 00:14:02 -0000 1.936 +++ Makefile.in 18 Sep 2007 22:36:51 -0000 @@ -836,6 +836,7 @@ vax_tdep_h = vax-tdep.h vec_h = vec.h $(gdb_assert_h) $(gdb_string_h) version_h = version.h wrapper_h = wrapper.h $(gdb_h) +xcoffread_h = xcoffread.h xcoffsolib_h = xcoffsolib.h xml_support_h = xml-support.h $(gdb_obstack_h) $(vec_h) xml_tdesc_h = xml-tdesc.h @@ -2539,7 +2540,8 @@ rs6000-tdep.o: rs6000-tdep.c $(defs_h) $ $(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \ $(frame_unwind_h) $(frame_base_h) $(rs6000_tdep_h) $(dwarf2_frame_h) rs6000-aix-tdep.o: rs6000-aix-tdep.c $(defs_h) $(gdb_string_h) $(osabi_h) \ - $(regcache_h) $(regset_h) $(rs6000_tdep_h) $(ppc_tdep_h) + $(regcache_h) $(regset_h) $(rs6000_tdep_h) $(ppc_tdep_h) \ + $(xcoffread_h) s390-nat.o: s390-nat.c $(defs_h) $(regcache_h) $(inferior_h) \ $(s390_tdep_h) $(target_h) $(linux_nat_h) s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \ @@ -2849,7 +2851,7 @@ xcoffread.o: xcoffread.c $(defs_h) $(bfd $(coff_internal_h) $(libcoff_h) $(coff_xcoff_h) $(libxcoff_h) \ $(coff_rs6000_h) $(symtab_h) $(gdbtypes_h) $(symfile_h) \ $(objfiles_h) $(buildsym_h) $(stabsread_h) $(expression_h) \ - $(complaints_h) $(gdb_stabs_h) $(aout_stab_gnu_h) + $(complaints_h) $(gdb_stabs_h) $(aout_stab_gnu_h) $(xcoffread_h) xcoffsolib.o: xcoffsolib.c $(defs_h) $(bfd_h) $(xcoffsolib_h) $(inferior_h) \ $(gdbcmd_h) $(symfile_h) $(frame_h) $(gdb_regex_h) xml-tdesc.o: xml-tdesc.c $(defs_h) $(target_h) $(target_descriptions_h) \ Index: config/powerpc/aix.mt =================================================================== RCS file: /cvs/src/src/gdb/config/powerpc/aix.mt,v retrieving revision 1.9 diff -u -p -r1.9 aix.mt --- config/powerpc/aix.mt 10 Feb 2006 20:56:15 -0000 1.9 +++ config/powerpc/aix.mt 18 Sep 2007 22:38:29 -0000 @@ -1,4 +1,3 @@ # Target: PowerPC running AIX TDEPFILES= rs6000-tdep.o rs6000-aix-tdep.o \ xcoffread.o ppc-sysv-tdep.o solib.o solib-svr4.o -DEPRECATED_TM_FILE= config/rs6000/tm-rs6000.h --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xcoffread.h" Content-length: 823 /* Copyright (C) 2007 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 3 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, see . */ #ifndef XCOFFREAD_H #define XCOFFREAD_H extern void aix_process_linenos (void); #endif --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="aix-hook-doc.diff" Content-length: 691 Index: doc/gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.266 diff -u -p -r1.266 gdbint.texinfo --- doc/gdbint.texinfo 5 Jul 2007 12:22:32 -0000 1.266 +++ doc/gdbint.texinfo 18 Sep 2007 22:38:39 -0000 @@ -3846,10 +3846,6 @@ instead of value. This method replaces @code{DEPRECATED_REG_STRUCT_HAS_ADDR} (@pxref{DEPRECATED_REG_STRUCT_HAS_ADDR}). -@item PROCESS_LINENUMBER_HOOK -@findex PROCESS_LINENUMBER_HOOK -A hook defined for XCOFF reading. - @item gdbarch_ps_regnum (@var{gdbarch} @findex gdbarch_ps_regnum If defined, this function returns the number of the processor status --lrZ03NoBR/3+SXJZ--