From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25457 invoked by alias); 31 Oct 2009 15:08:43 -0000 Received: (qmail 25446 invoked by uid 22791); 31 Oct 2009 15:08:41 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 31 Oct 2009 15:08:37 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9VF8aMr022071 for ; Sat, 31 Oct 2009 11:08:36 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9VF8Wsf000789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 31 Oct 2009 11:08:35 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n9VF8Vre028083 for ; Sat, 31 Oct 2009 16:08:31 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n9VF8TER028082 for gdb-patches@sourceware.org; Sat, 31 Oct 2009 16:08:30 +0100 Date: Sat, 31 Oct 2009 15:08:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] cleanup: Remove INVALID_ENTRY_POINT (+FR-V modification) Message-ID: <20091031150829.GA27608@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes 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: 2009-10/txt/msg00706.txt.bz2 Hi, this patch has no (longer) relationship to other patches of mine, I just thought when I accidentally wrote it it is worth to submit this cleanup. CORE_ADDR width is now a bit problematic in GDB builds supporting for 32bit and 64bit targets (to be described elsewhere). Therefore INVALID_ENTRY_POINT caught my eye as it should have type `CORE_ADDR' but it is `int'. Which still works in common cases due to automatic signed extension but it looks dangerous. I do not have FR-V to test, enable_break has been slightly updated over the point of using new EI.ENTRY_POINT_P. Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan 2009-10-31 Jan Kratochvil Remove INVALID_ENTRY_POINT. * objfiles.c (init_entry_point_info): Stop using INVALID_ENTRY_POINT. Initialize EI.ENTRY_POINT_P. (entry_point_address, objfile_relocate): Use EI.ENTRY_POINT_P. * objfiles.h (struct entry_info): Simplify entry_point comment. New field entry_point_p. (INVALID_ENTRY_POINT): Remove. * solib-frv.c (enable_break): Check for NULL SYMFILE_OBJFILE and its EI.ENTRY_POINT_P. Return 0 if ".interp" is not found. --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -294,17 +294,21 @@ init_entry_point_info (struct objfile *objfile) /* Executable file -- record its entry point so we'll recognize the startup file because it contains the entry point. */ objfile->ei.entry_point = bfd_get_start_address (objfile->obfd); + objfile->ei.entry_point_p = 1; } else if (bfd_get_file_flags (objfile->obfd) & DYNAMIC && bfd_get_start_address (objfile->obfd) != 0) - /* Some shared libraries may have entry points set and be - runnable. There's no clear way to indicate this, so just check - for values other than zero. */ - objfile->ei.entry_point = bfd_get_start_address (objfile->obfd); + { + /* Some shared libraries may have entry points set and be + runnable. There's no clear way to indicate this, so just check + for values other than zero. */ + objfile->ei.entry_point = bfd_get_start_address (objfile->obfd); + objfile->ei.entry_point_p = 1; + } else { /* Examination of non-executable.o files. Short-circuit this stuff. */ - objfile->ei.entry_point = INVALID_ENTRY_POINT; + objfile->ei.entry_point_p = 0; } } @@ -316,7 +320,7 @@ entry_point_address (void) struct gdbarch *gdbarch; CORE_ADDR entry_point; - if (symfile_objfile == NULL) + if (symfile_objfile == NULL || !symfile_objfile->ei.entry_point_p) return 0; gdbarch = get_objfile_arch (symfile_objfile); @@ -702,7 +706,7 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) to be out of order. */ msymbols_sort (objfile); - if (objfile->ei.entry_point != ~(CORE_ADDR) 0) + if (objfile->ei.entry_point_p) { /* Relocate ei.entry_point with its section offset, use SECT_OFF_TEXT only as a fallback. */ --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -100,15 +100,11 @@ struct objfile_data; struct entry_info { - - /* The value we should use for this objects entry point. - The illegal/unknown value needs to be something other than 0, ~0 - for instance, which is much less likely than 0. */ - + /* The relocated value we should use for this objfile entry point. */ CORE_ADDR entry_point; -#define INVALID_ENTRY_POINT (~0) /* ~0 will not be in any file, we hope. */ - + /* Set to 1 iff ENTRY_POINT contains a valid value. */ + unsigned entry_point_p : 1; }; /* Sections in an objfile. The section offsets are stored in the --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -822,30 +822,43 @@ enable_break (void) may have changed since the last time we ran the program. */ remove_solib_event_breakpoints (); - /* Check for the presence of a .interp section. If there is no - such section, the executable is statically linked. */ - - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); - - if (interp_sect) + if (symfile_objfile == NULL) { - enable_break1_done = 1; - create_solib_event_breakpoint (target_gdbarch, - symfile_objfile->ei.entry_point); + if (solib_frv_debug) + fprintf_unfiltered (gdb_stdlog, + "enable_break: No symbol file found.\n"); + return 0; + } + if (!symfile_objfile->ei.entry_point_p) + { if (solib_frv_debug) fprintf_unfiltered (gdb_stdlog, - "enable_break: solib event breakpoint placed at entry point: %s\n", - hex_string_custom - (symfile_objfile->ei.entry_point, 8)); + "enable_break: Symbol file has no entry point.\n"); + return 0; } - else + + /* Check for the presence of a .interp section. If there is no + such section, the executable is statically linked. */ + + interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); + + if (interp_sect == NULL) { if (solib_frv_debug) fprintf_unfiltered (gdb_stdlog, - "enable_break: No .interp section found.\n"); + "enable_break: No .interp section found.\n"); + return 0; } + enable_break1_done = 1; + create_solib_event_breakpoint (target_gdbarch, + symfile_objfile->ei.entry_point); + + if (solib_frv_debug) + fprintf_unfiltered (gdb_stdlog, + "enable_break: solib event breakpoint placed at entry point: %s\n", + hex_string_custom (symfile_objfile->ei.entry_point, 8)); return 1; }