From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 566 invoked by alias); 15 Apr 2003 01:00:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 519 invoked from network); 15 Apr 2003 01:00:33 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 15 Apr 2003 01:00:33 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h3F10XD22536 for ; Mon, 14 Apr 2003 21:00:33 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3F10Xq14951 for ; Mon, 14 Apr 2003 21:00:33 -0400 Received: from localhost.localdomain (vpn50-42.rdu.redhat.com [172.16.50.42]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3F10W223729 for ; Mon, 14 Apr 2003 21:00:33 -0400 Received: (from kev@localhost) by localhost.localdomain (8.11.6/8.11.6) id h3F10RR29398 for gdb-patches@sources.redhat.com; Mon, 14 Apr 2003 18:00:27 -0700 Date: Tue, 15 Apr 2003 01:00:00 -0000 From: Kevin Buettner Message-Id: <1030415010027.ZM29397@localhost.localdomain> To: gdb-patches@sources.redhat.com Subject: [PATCH] solib-svr4.c: Warn if no shared library support MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg00298.txt.bz2 I've just committed the patch below. For a (non-native) Linux/MIPS target, if you do: set osabi none and then connect to the remote target, you'll (eventually) see an internal error similar to the following: .../solib-svr4.c:1368: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled. A problem internal to GDB has been detected. Further debugging may prove unreliable. The patch below will cause a warning to be printed instead when connecting to the target: warning: no shared library support for this OS / ABI This makes debugging somewhat more reliable (assuming that you knew what you were doing when setting osabi in the first place). Native targets are unaffected because they pick up shared library via the host's file. That said, this support is quite likely wrong when changing the osabi to a value for which no shared library support has been defined. Thanks (again) to Chris Demetriou for bringing this problem to my attention. * solib-svr4.c (svr4_have_link_map_offsets): New function. (locate_base): Return early if there aren't any link map offsets. (svr4_solib_create_inferior_hook): Warn if shared library support is unavailable. Index: solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.31 diff -u -p -r1.31 solib-svr4.c --- solib-svr4.c 8 Apr 2003 19:21:15 -0000 1.31 +++ solib-svr4.c 15 Apr 2003 00:26:43 -0000 @@ -43,6 +43,7 @@ static struct link_map_offsets *svr4_fetch_link_map_offsets (void); static struct link_map_offsets *legacy_fetch_link_map_offsets (void); +static int svr4_have_link_map_offsets (void); /* fetch_link_map_offsets_gdbarch_data is a handle used to obtain the architecture specific link map offsets fetching function. */ @@ -542,9 +543,10 @@ locate_base (void) /* Check to see if we have a currently valid address, and if so, avoid doing all this work again and just return the cached address. If we have no cached address, try to locate it in the dynamic info - section for ELF executables. */ + section for ELF executables. There's no point in doing any of this + though if we don't have some link map offsets to work with. */ - if (debug_base == 0) + if (debug_base == 0 && svr4_have_link_map_offsets ()) { if (exec_bfd != NULL && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour) @@ -1273,6 +1275,13 @@ svr4_solib_create_inferior_hook (void) /* Relocate the main executable if necessary. */ svr4_relocate_main_executable (); + if (!svr4_have_link_map_offsets ()) + { + warning ("no shared library support for this OS / ABI"); + return; + + } + if (!enable_break ()) { warning ("shared library handler failed to enable breakpoint"); @@ -1390,6 +1399,20 @@ svr4_fetch_link_map_offsets (void) } else return (flmo ()); +} + +/* Return 1 if a link map offset fetcher has been defined, 0 otherwise. */ +static int +svr4_have_link_map_offsets (void) +{ + struct link_map_offsets *(*flmo)(void) = + gdbarch_data (current_gdbarch, fetch_link_map_offsets_gdbarch_data); + if (flmo == NULL + || (flmo == legacy_fetch_link_map_offsets + && legacy_svr4_fetch_link_map_offsets_hook == NULL)) + return 0; + else + return 1; } /* set_solib_svr4_fetch_link_map_offsets() is intended to be called by