From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29100 invoked by alias); 14 Apr 2010 07:00:55 -0000 Received: (qmail 29082 invoked by uid 22791); 14 Apr 2010 07:00:52 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Apr 2010 07:00:44 +0000 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 1E60D1B4037 for ; Wed, 14 Apr 2010 07:00:41 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH]: gdb: fdpic/frv: fix shared library loading Date: Wed, 14 Apr 2010 07:00:00 -0000 User-Agent: KMail/1.13.1 (Linux/2.6.33.2; KDE/4.4.1; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3377270.uciBoLNqpO"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201004140259.39671.vapier@gentoo.org> 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: 2010-04/txt/msg00442.txt.bz2 --nextPart3377270.uciBoLNqpO Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-length: 4387 The recent change to reload_shared_libraries() broke FDPIC shared libraries= as the solib-frv.c code was implicitly relying on the initial order of calls (first solib_addr() and then solib_create_inferior_hook()). It was maintaining internal state via enable_break{1,2}_done to handle this. While I could tweak these values a bit more, the original code wasn't terri= bly bullet proof -- if during the initial debug you attempted to view shared libraries, the enable2_break() code would whine about the ldso internal deb= ug addresses being unfetchable (and would actually attempt to read address 0x8= on the target). So I've dropped this implicit dependency on order (i.e. enable_break1_done) and updated the ldso poking code (i.e. enable_break2) to silently return when the internal debug address is still set to 0. It will remain this way until the ldso gets a chance to initialize at which point t= he code will act the same as before. While I have no way of testing the FRV, the Blackfin FDPIC code is using th= is same base in a 100% copy & paste method since we implemented FDPIC the same way as the FRV guys (I'll address this in the future). This fix was requir= ed in order to handle shared libraries with Blackfin FDPIC properly, and I see= no reason why it wouldn't also work for FRV (since the uClibc ldso FDPIC code = is the same too and that's really what this is poking). -mike 2010-04-14 Mike Frysinger * solib-frv.c (enable_break1_done): Delete. (enable_break2): Do not check enable_break1_done. Move the enable_break2_done setting and call to remove_solib_event_breakpoints() to the end. Return without warning when the contents of _dl_debug_addr are 0. (enable_break): Do not set enable_break1_done. (frv_clear_solib): Likewise. RCS file: /cvs/src/src/gdb/solib-frv.c,v retrieving revision 1.33 diff -u -p -r1.33 solib-frv.c --- gdb/solib-frv.c 24 Feb 2010 00:29:02 -0000 1.33 +++ gdb/solib-frv.c 14 Apr 2010 06:49:48 -0000 @@ -631,7 +631,6 @@ enable_break_failure_warning (void) =20 */ =20 -static int enable_break1_done =3D 0; static int enable_break2_done =3D 0; =20 static int @@ -642,15 +641,9 @@ enable_break2 (void) char **bkpt_namep; asection *interp_sect; =20 - if (!enable_break1_done || enable_break2_done) + if (enable_break2_done) return 1; =20 - enable_break2_done =3D 1; - - /* First, remove all the solib event breakpoints. Their addresses - may have changed since the last time we ran the program. */ - remove_solib_event_breakpoints (); - interp_text_sect_low =3D interp_text_sect_high =3D 0; interp_plt_sect_low =3D interp_plt_sect_high =3D 0; =20 @@ -771,6 +764,22 @@ enable_break2 (void) } addr =3D extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_o= rder); =20 + if (solib_frv_debug) + fprintf_unfiltered (gdb_stdlog, + "enable_break: _dl_debug_addr[0..3] =3D %s\n", + hex_string_custom (addr, 8)); + + /* If it's zero, then the ldso hasn't initialized yet, and so + there are no shared libs yet loaded. */ + if (addr =3D=3D 0) + { + if (solib_frv_debug) + fprintf_unfiltered (gdb_stdlog, + "enable_break: ldso not yet initialized\n"); + /* Do not warn, but mark to run again. */ + return 0; + } + /* Fetch the r_brk field. It's 8 bytes from the start of _dl_debug_addr. */ if (target_read_memory (addr + 8, addr_buf, sizeof addr_buf) !=3D 0) @@ -800,9 +809,15 @@ enable_break2 (void) /* We're also done with the loadmap. */ xfree (ldm); =20 + /* First, remove all the solib event breakpoints. Their addresses + may have changed since the last time we ran the program. */ + remove_solib_event_breakpoints (); + /* Now (finally!) create the solib breakpoint. */ create_solib_event_breakpoint (target_gdbarch, addr); =20 + enable_break2_done =3D 1; + return 1; } =20 @@ -847,7 +862,6 @@ enable_break (void) return 0; } =20 - enable_break1_done =3D 1; create_solib_event_breakpoint (target_gdbarch, symfile_objfile->ei.entry_point); =20 @@ -997,7 +1011,6 @@ static void frv_clear_solib (void) { lm_base_cache =3D 0; - enable_break1_done =3D 0; enable_break2_done =3D 0; main_lm_addr =3D 0; if (main_executable_lm_info !=3D 0) --nextPart3377270.uciBoLNqpO Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJLxWfbAAoJEEFjO5/oN/WB3goP/3izY0EwV3VmpS7jXrVY1kTc SqxZbNbo5YxbqfdcFdRac2vGR+akv9LRZ+38v8kVq0QapMmSO0uNOuyvZuCXsmQ9 1CzizX+av9/8p/lmFOH4Qr9zCZbC7aGhUXYkDJ1N9N3QptS7f8RcTNDcaDu2foq6 YbWnbNVCYlpvmRN8ZIJjWz2GEBd8dOGj5LJOb4pVQ6iylL/bqgNdowWnU3GuH3Cd VS0nwQyx3kl/yrCSsvb1iIINBf6oFCfCR/U5eN95XBAPcAi77S2twoKtC0f4HPcU /tFkJUBVxZWVdljwr49yuioFapoKrWXBXTQtcS6KILZp1n4PtF0W9s8R8XCiMkG1 GPQM1MfpaW8qq8PuKsIJOwA8wbLGamJCQ1ND8LdYV1O/trDn326huBU3vVbBARo6 DwX1z5kZ2ykidFWJBvx7IXDUcACj5hDS46T10rawLWmPpwi4ejPnPbkQ9AmtBg6T frqh5ejTw9SBFxNYc/PIfevAytXJQg2byDp7+J0xwIyOTiIumv+r2GtqWmIOVTt6 pJEZco77Ic2U4LYdhe1TtI1shqhg6ytmbatxjazIk/pjXH4Z7iHfkz0ju9ny7Jdl jV4HSKuqIjy0CO8AuM/+YEkkmloFdgvjKgHSnuf9cVjgIMzhdAnwLoax7+JiWwRz lzqtFV8z+o7zX0RDpY4M =n8x+ -----END PGP SIGNATURE----- --nextPart3377270.uciBoLNqpO--