From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2300 invoked by alias); 5 Jul 2011 16:27:55 -0000 Received: (qmail 2290 invoked by uid 22791); 5 Jul 2011 16:27:53 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,TVD_RCVD_SPACE_BRACKET,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-da01.nokia.com) (147.243.128.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Jul 2011 16:27:37 +0000 Received: from nokia.com (localhost [127.0.0.1]) by mgw-da01.nokia.com (Switch-3.4.4/Switch-3.4.3) with ESMTP id p65GRODZ018761; Tue, 5 Jul 2011 19:27:24 +0300 Received: from bettdhcp167109.europe.nokia.com ([bettdhcp167109.europe.nokia.com [172.25.167.109]]) by mgw-da01.nokia.com with RELAY id p65GQuAD018057 ; Tue, 5 Jul 2011 19:27:00 +0300 Subject: Re: [PATCH,gdb, Update2]: ensures that cie ptr of an fda is a cie Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Fawzi Mohamed In-Reply-To: <20110705151427.GW2407@adacore.com> Date: Tue, 05 Jul 2011 16:57:00 -0000 Cc: , ext Tristan Gingold , Andr? P?nitz Content-Transfer-Encoding: quoted-printable Message-Id: <6ECF244D-CE83-4D2D-9414-E3376A87233F@nokia.com> References: <20110704184111.GP2407@adacore.com> <29C73230-F22F-4551-B99F-B21E6B61CCAF@nokia.com> <20110705151427.GW2407@adacore.com> To: ext Joel Brobecker X-Nokia-AV: Clean 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: 2011-07/txt/msg00158.txt.bz2 On Jul 5, 2011, at 5:14 PM, ext Joel Brobecker wrote: >> 2011-07-04 Fawzi Mohamed >>=20 >> * dwarf2-frame.c (decode_frame_entry, decode_frame_entry_1): ensure >> that CIE pointer of an FDE really points to a CIE=20 >=20 > Just a few more nits... (a lot of rules, I know, but we try to have > a consistent development style). eh eh I sort of expected it, so I put a number after update in the subject = :) > [...] > Empty line between documentation comment and start of definition... this doesn't seem to be much followed in this file... I am fixing it for th= e functions I touch... but I suppose it doesn't apply for in function comments, as it is never use= d like that in this file. > [...] >> + /* checks that we expected a CIE */ >> + gdb_assert ((entry_type & eh_cie_type_id) !=3D 0); >=20 > Same here as well. But I think you meant something like `We expect > a CIE.'. actually no at that point he found a CIE but he has to check that a CIE was= actually expected. I have reworded it to /* Check that a CIE was expected. */ another thing that I have noted os 0x0c characters in the file (new page in= ascii), not sure why they are there. anyway here is the updated patch 2011-07-04 Fawzi Mohamed * dwarf2-frame.c (decode_frame_entry, decode_frame_entry_1): Ensure that CIE pointer of an FDE really points to a CIE . Index: gdb/dwarf2-frame.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v retrieving revision 1.125 diff -f -d -u -r1.125 dwarf2-frame.c --- gdb/dwarf2-frame.c 4 Jul 2011 16:30:09 -0000 1.125 +++ gdb/dwarf2-frame.c 5 Jul 2011 16:17:57 -0000 @@ -1801,17 +1801,30 @@ #define DW64_CIE_ID ~0 #endif =20 +/* Defines the type of eh_frames that are expected to be decoded: CIE, FDE + or any of them. */ + +enum eh_frame_type +{ + eh_cie_type_id =3D 1 << 0, + eh_fde_type_id =3D 1 << 1, + eh_cie_or_fde_type_id =3D eh_cie_type_id + eh_fde_type_id +}; + static gdb_byte *decode_frame_entry (struct comp_unit *unit, gdb_byte *sta= rt, int eh_frame_p, struct dwarf2_cie_table *cie_table, - struct dwarf2_fde_table *fde_table); + struct dwarf2_fde_table *fde_table, + enum eh_frame_type entry_type); + +/* Decode the next CIE or FDE, entry_type specifies the expected type. + Return NULL if invalid input, otherwise the next byte to be processed. = */ =20 -/* Decode the next CIE or FDE. Return NULL if invalid input, otherwise - the next byte to be processed. */ static gdb_byte * decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_fram= e_p, struct dwarf2_cie_table *cie_table, - struct dwarf2_fde_table *fde_table) + struct dwarf2_fde_table *fde_table, + enum eh_frame_type entry_type) { struct gdbarch *gdbarch =3D get_objfile_arch (unit->objfile); gdb_byte *buf, *end; @@ -1862,6 +1875,9 @@ char *augmentation; unsigned int cie_version; =20 + /* Check that a CIE was expected. */ + gdb_assert ((entry_type & eh_cie_type_id) !=3D 0); + /* Record the offset into the .debug_frame section of this CIE. */ cie_pointer =3D start - unit->dwarf_frame_buffer; =20 @@ -2027,6 +2043,9 @@ /* This is a FDE. */ struct dwarf2_fde *fde; =20 + /* Check that an FDE was expected. */ + gdb_assert ((entry_type & eh_fde_type_id) !=3D 0); + /* In an .eh_frame section, the CIE pointer is the delta between the address within the FDE where the CIE pointer is stored and the address of the CIE. Convert it to an offset into the .eh_frame @@ -2048,7 +2067,8 @@ if (fde->cie =3D=3D NULL) { decode_frame_entry (unit, unit->dwarf_frame_buffer + cie_pointer, - eh_frame_p, cie_table, fde_table); + eh_frame_p, cie_table, fde_table, + eh_cie_type_id); fde->cie =3D find_cie (cie_table, cie_pointer); } =20 @@ -2089,11 +2109,14 @@ return end; } =20 -/* Read a CIE or FDE in BUF and decode it. */ +/* Read a CIE or FDE in BUF and decode it. Entry_type specifies if we expe= ct + an FDE or a CIE. */ + static gdb_byte * decode_frame_entry (struct comp_unit *unit, gdb_byte *start, int eh_frame_= p, struct dwarf2_cie_table *cie_table, - struct dwarf2_fde_table *fde_table) + struct dwarf2_fde_table *fde_table, + enum eh_frame_type entry_type) { enum { NONE, ALIGN4, ALIGN8, FAIL } workaround =3D NONE; gdb_byte *ret; @@ -2102,7 +2125,7 @@ while (1) { ret =3D decode_frame_entry_1 (unit, start, eh_frame_p, - cie_table, fde_table); + cie_table, fde_table,entry_type); if (ret !=3D NULL) break; =20 @@ -2256,7 +2279,8 @@ frame_ptr =3D unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_= size) frame_ptr =3D decode_frame_entry (unit, frame_ptr, 1, - &cie_table, &fde_table); + &cie_table, &fde_table, + eh_cie_or_fde_type_id); =20 if (cie_table.num_entries !=3D 0) { @@ -2277,7 +2301,8 @@ frame_ptr =3D unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) frame_ptr =3D decode_frame_entry (unit, frame_ptr, 0, - &cie_table, &fde_table); + &cie_table, &fde_table, + eh_cie_or_fde_type_id); } =20 /* Discard the cie_table, it is no longer needed. */