From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31663 invoked by alias); 10 Feb 2003 12:30:36 -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 31655 invoked from network); 10 Feb 2003 12:30:35 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by 172.16.49.205 with SMTP; 10 Feb 2003 12:30:35 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id 9E4B759D347; Mon, 10 Feb 2003 13:30:34 +0100 (CET) Received: from suse.cz (naga.suse.cz [10.20.1.16]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id h1ACUY411697; Mon, 10 Feb 2003 13:30:34 +0100 X-Authentication-Warning: chimera.suse.cz: Host naga.suse.cz [10.20.1.16] claimed to be suse.cz Message-ID: <3E479B6A.30705@suse.cz> Date: Mon, 10 Feb 2003 12:30:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: Elena Zannoni Cc: GDB Patches Subject: Re: [RFA] Runtime Dwarf2 CFI engine cleanup References: <3E197C8F.3010903@suse.cz> <15934.38824.98344.150611@localhost.redhat.com> In-Reply-To: <15934.38824.98344.150611@localhost.redhat.com> Content-Type: multipart/mixed; boundary="------------020108050106040800030200" X-SW-Source: 2003-02/txt/msg00256.txt.bz2 This is a multi-part message in MIME format. --------------020108050106040800030200 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1959 Elena Zannoni wrote: > Michal Ludvig writes: > > Hi all, > > the attached is a fix for the problem described here: > > http://sources.redhat.com/ml/gdb/2002-12/msg00246.html > > > > I've created a new function cleanup_cfi() in dwarf2cfi.c that deletes > > all CIEs and FDEs of objfiles removed later by objfile_purge_solibs(). > > So far it works fine but I don't know how should I correctly call it. > > > I have tried your function, and it does fixes some weird errors which occur > on rerun. > > I just tried by using the hack of defining GDB_TARGET_IS_X86_64, which > is definitely a bad thing. > > I think that the best way is to define a gdbarch method, just like it > was done for gdbarch_dwarf2_build_frame_info. How about adding dwarf2cfi.o to all targets? When there is for example mipsread.o compiled into gdb on x86-64 (why? because there is no option to say what features a given target needs.) than dwarf2cfi.o could go there as well... I hope more and more targets will use it in the near future. The attached is a version that adds dwarf2cfi.o for all targets. If it's unacceptable this way I'll provide gdbarch-ed version instead. But I think that gdbarch_*() functions are good for the case when on different targets a different functions are called to do a given task (eg. read register). But in this case you must call cleanup_cfi() in all targets that use CFI. No option. Calling it shouldn't depend on setting gdbarch value. Instead it should depend on linking dwarf2cfi.o into the gdb. > In the patch below, you cannot use printf's. Use printf_filtered. But > maybe, better yet, using a warning here would be more appropriate. It isn't a warning, just an informational message. Now it's printed only when info_verbose is set. > Watch out for the non-GNU indentation and spacing. Reindented. OK to commit? Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * (+420) 296.545.373 * http://www.suse.cz --------------020108050106040800030200 Content-Type: text/plain; name="rerun-cfi4all-2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rerun-cfi4all-2.diff" Content-length: 4897 2003-02-10 Michal Ludvig * dwarf2cfi.c (struct cie_unit): New items 'keep' and 'refs'. (cleanup_cfi): New function. * infcmd.c (run_command): Call cleanup_cfi(). * Makefile.in: Link dwarf2cfi.[co] to all targets. * config/i386/x86-64linux.mt: Remove dwarf2cfi.o from TDEPFILES. Index: dwarf2cfi.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v retrieving revision 1.31 diff -u -p -r1.31 dwarf2cfi.c --- dwarf2cfi.c 10 Feb 2003 11:50:20 -0000 1.31 +++ dwarf2cfi.c 10 Feb 2003 12:10:21 -0000 @@ -64,6 +64,12 @@ struct cie_unit struct objfile *objfile; + /* Keep or destroy this CIE on new run? */ + int keep; + + /* How many FDEs refer to this CIE? */ + int refs; + /* Next in chain. */ struct cie_unit *next; }; @@ -289,6 +295,90 @@ frame_state_alloc (void) (struct frame_state_reg *) obstack_alloc (&unwind_tmp_obstack, regs_size); memset (fs->regs.reg, 0, regs_size); return fs; +} + +void +cleanup_cfi (void *name) +{ + struct objfile *ofp; + struct cie_unit *cie, *cie_prev; + int fde_index = 0, fde_free = 0; + + cie = cie_chunks; + while (cie) + { + cie->refs = 0; + cie->keep = 0; + cie = cie->next; + } + + /* Mark all unwanted CIEs. */ + ALL_OBJFILES (ofp) + { + if (!(ofp->flags & OBJF_USERLOADED) && (ofp->flags & OBJF_SHARED)) + { + if (info_verbose) + printf_filtered ("\tRemoving %s...\n", ofp->name); + } + else + { + if (info_verbose) + printf_filtered ("\tKeeping %s...\n", ofp->name); + + cie = cie_chunks; + while (cie) + { + if (cie->objfile == ofp) + cie->keep = 1; + cie = cie->next; + } + } + } + + /* Remove all FDEs pointing to unwanted CIEs. */ + for (fde_index = 0, fde_free = 0; + fde_index < fde_chunks.elems; fde_index++, fde_free++) + { + if (!fde_chunks.array[fde_index]->cie_ptr->keep) + { + fde_free--; + continue; + } + else if (fde_free < fde_index) + fde_chunks.array[fde_free] = fde_chunks.array[fde_index]; + fde_chunks.array[fde_free]->cie_ptr->refs++; + } + fde_chunks.elems = fde_free; + + /* Remove all unwanted CIEs. */ + cie = cie_chunks; + cie_prev = NULL; + while (cie) + { + struct cie_unit *cie_tmp; + + if (!cie->keep || !cie->refs) + { + cie_tmp = cie; + if (cie_prev == NULL) + { + cie_chunks = cie->next; + cie = cie_chunks; + } + else + { + cie_prev->next = cie->next; + cie = cie->next; + } + /* cie_prev must remain unchanged. */ + xfree (cie_tmp); + } + else + { + cie_prev = cie; + cie = cie->next; + } + } } static void Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.72 diff -u -p -r1.72 infcmd.c --- infcmd.c 1 Feb 2003 17:28:40 -0000 1.72 +++ infcmd.c 10 Feb 2003 12:10:21 -0000 @@ -401,6 +401,8 @@ Start it from the beginning? ")) clear_breakpoint_hit_counts (); + cleanup_cfi (); + /* Purge old solib objfiles. */ objfile_purge_solibs (); Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.328 diff -u -p -r1.328 Makefile.in --- Makefile.in 7 Feb 2003 05:33:44 -0000 1.328 +++ Makefile.in 10 Feb 2003 12:10:21 -0000 @@ -514,7 +514,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr charset.c cli-out.c coffread.c complaints.c completer.c corefile.c \ cp-abi.c cp-support.c cp-valprint.c \ dbxread.c demangle.c disasm.c doublest.c \ - dummy-frame.c dwarfread.c dwarf2read.c \ + dummy-frame.c dwarfread.c dwarf2read.c dwarf2cfi.c \ elfread.c environ.c eval.c event-loop.c event-top.c expprint.c \ f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c frame.c \ frame-unwind.c \ @@ -835,7 +835,7 @@ COMMON_OBS = version.o blockframe.o brea gdb-events.o \ exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \ dbxread.o coffread.o elfread.o \ - dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \ + dwarfread.o dwarf2read.o dwarf2cfi.o mipsread.o stabsread.o corefile.o \ c-lang.o f-lang.o \ ui-out.o cli-out.o \ varobj.o wrapper.o \ Index: config/i386/x86-64linux.mt =================================================================== RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mt,v retrieving revision 1.6 diff -u -p -r1.6 x86-64linux.mt --- config/i386/x86-64linux.mt 21 Dec 2002 21:09:58 -0000 1.6 +++ config/i386/x86-64linux.mt 10 Feb 2003 12:10:21 -0000 @@ -1,6 +1,6 @@ # Target: AMD x86-64 running GNU/Linux -TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o dwarf2cfi.o \ - i386-tdep.o i387-tdep.o \ +TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o \ + i386-tdep.o i386-linux-tdep.o i387-tdep.o \ solib.o solib-svr4.o solib-legacy.o GDB_MULTI_ARCH=GDB_MULTI_ARCH_TM --------------020108050106040800030200--