From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 420 invoked by alias); 10 Aug 2013 00:33:22 -0000 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 Received: (qmail 411 invoked by uid 89); 10 Aug 2013 00:33:21 -0000 X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 10 Aug 2013 00:33:20 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1V7x7I-0000cC-EW from Yao_Qi@mentor.com ; Fri, 09 Aug 2013 17:33:12 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 9 Aug 2013 17:33:12 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Fri, 9 Aug 2013 17:33:11 -0700 Message-ID: <52058A17.2050101@codesourcery.com> Date: Sat, 10 Aug 2013 00:33:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: CC: Pedro Alves , "'gdb-patches@sourceware.org'" , Mike Frysinger Subject: Re: [PATCH, gdbserver] Further cleanup of FDPIC/DSBT divergences References: <51C34F14.8070803@codesourcery.com> <51C84CBD.10506@codesourcery.com> <51C84DD4.4090001@codesourcery.com> <5203CA36.5000206@codesourcery.com> <520505D9.8080103@redhat.com> <520524D8.40408@codesourcery.com> In-Reply-To: <520524D8.40408@codesourcery.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2013-08/txt/msg00285.txt.bz2 On 08/10/2013 01:20 AM, Luis Machado wrote: > +/* Scan for DYNTAG in .dynamic section of ABFD. If DYNTAG is found 1 > + is returned and the corresponding PTR is set. We only search in > + the BFD, not in the target's memory. */ > + > +static int > +scan_dyntag_in_bfd (int dyntag, bfd *abfd, CORE_ADDR *ptr) Luis, We've already have a function scan_dyntag in solib-dsbt.c which reads in both BFD and the target memory. There are some duplications in scan_dyntag and scan_dyntag_in_bfd. We can combine them into one function, probably. > +/* Given a shared library filename, load it up and find > + out what is its dsbt index. */ > + > +static int > +fetch_solib_dsbt_index (const char *filename) > +{ > + unsigned long dsbt_index; > + CORE_ADDR addr; > + bfd *solib_bfd = NULL; > + volatile struct gdb_exception ex; > + > + if (filename == NULL) > + return -1; > + > + /* Open the shared library. */ > + TRY_CATCH (ex, RETURN_MASK_ALL) > + { > + solib_bfd = solib_bfd_open ((char *) filename); > + } > + if (solib_bfd == NULL) > + { > + return -1; > + } Unnecessary braces. > + > + /* Fetch the DSBT_INDEX from the shared library file on disk. */ > + if (scan_dyntag_in_bfd (DT_TIC6X_DSBT_INDEX, solib_bfd, &addr) == 0) I don't find the definition of DT_TIC6X_DSBT_INDEX. In uclibc, I only find DT_C6000_DSBT_INDEX. > @@ -684,24 +795,50 @@ dsbt_current_sos (void) > sizeof lm_buf.l_addr.map, > byte_order); > > - ret = target_read_memory (map_addr + 12, (gdb_byte *) &indexword, > - sizeof indexword); > - if (ret) > + /* Fetch the name. */ > + addr = extract_unsigned_integer (lm_buf.l_name, > + sizeof (lm_buf.l_name), > + byte_order); > + target_read_string (addr, &name_buf, SO_NAME_MAX_PATH_SIZE - 1, > + &errcode); > + > + if (errcode != 0) > { > - warning (_("dsbt_current_sos: Unable to read dsbt index." > - " Shared object chain may be incomplete.")); > - break; > + warning (_("dsbt_current_sos: Can't read pathname for link " > + "map entry: %s."), safe_strerror (errcode)); > + > + /* Since we do not have a pathname, just assume that > + dsbt_index equals a dummy value of 1. This way we can ^^ -1? -- Yao (齐尧)