From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26360 invoked by alias); 12 Jan 2012 12:05:32 -0000 Received: (qmail 26346 invoked by uid 22791); 12 Jan 2012 12:05:29 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 12:05:16 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BA80FCB324B for ; Thu, 12 Jan 2012 13:05:16 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BKeg-LgWReCc for ; Thu, 12 Jan 2012 13:05:16 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id A8614CB2C7B for ; Thu, 12 Jan 2012 13:05:16 +0100 (CET) From: Tristan Gingold Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: [Patch]: Improve handling of DW_LNE_define_file Date: Thu, 12 Jan 2012 12:05:00 -0000 Message-Id: To: binutils Development Mime-Version: 1.0 (Apple Message framework v1251.1) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00164.txt.bz2 Hi, while investigating some issues on ia64 hp/ux, I made the following improve= ments to dwarf.c: * hp/ux C compiler (at least the version I have) emit wrong length for DW_L= NE_define_file opcode. We can't fix that but detecting it is nice. * objdump -WL crashed on DW_LNE_define_file and in fact incorrectly handled= it. This patch fixes this issue. * objdump -WL generates 'UNKNOWN' messages for DW_LNE_set_discriminator and= DW_LNE_HP_set_sequence opcodes. After displaying the id of the opcode, I = choose to ignore them. No regression for x86 GNU Linux. Ok for trunk ? Tristan. binutils/ 2012-01-12 Tristan Gingold * dwarf.c (process_extended_line_op): Reindent define_file output. Detect define_file opcode length mismatch. (display_debug_lines_decoded): Add an entry in file_table for each define_file opcode. Ignore DW_LNE_set_discriminator and DW_LNE_HP_set_sequence. Display extended opcode for unhandle opcode. index a775818..08f472f 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -247,6 +247,7 @@ process_extended_line_op (unsigned char *data, int is_s= tmt) unsigned int len; unsigned char *name; dwarf_vma adr; + unsigned char *orig_data =3D data; =20 len =3D read_leb128 (data, & bytes_read, 0); data +=3D bytes_read; @@ -277,7 +278,7 @@ process_extended_line_op (unsigned char *data, int is_s= tmt) break; =20 case DW_LNE_define_file: - printf (_(" define new File Table entry\n")); + printf (_("define new File Table entry\n")); printf (_(" Entry\tDir\tTime\tSize\tName\n")); =20 printf (" %d\t", ++state_machine_regs.last_file_entry); @@ -288,7 +289,11 @@ process_extended_line_op (unsigned char *data, int is_= stmt) printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, = 0))); data +=3D bytes_read; printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, = 0))); - printf ("%s\n\n", name); + data +=3D bytes_read; + printf ("%s", name); + if (data - orig_data !=3D len) + printf (_(" [Bad opcode length]")); + printf ("\n\n"); break; =20 case DW_LNE_set_discriminator: @@ -2800,7 +2805,9 @@ display_debug_lines_decoded (struct dwarf_section *se= ction, int offset_size; int i; File_Entry *file_table =3D NULL; + unsigned int n_files =3D 0; unsigned char **directory_table =3D NULL; + unsigned int n_directories =3D 0; =20 hdrptr =3D data; =20 @@ -2885,7 +2892,6 @@ display_debug_lines_decoded (struct dwarf_section *se= ction, data =3D standard_opcodes + linfo.li_opcode_base - 1; if (*data !=3D 0) { - unsigned int n_directories =3D 0; unsigned char *ptr_directory_table =3D data; =20 while (*data !=3D 0) @@ -2912,7 +2918,6 @@ display_debug_lines_decoded (struct dwarf_section *se= ction, /* Traverse the File Name table just to count the entries. */ if (*data !=3D 0) { - unsigned int n_files =3D 0; unsigned char *ptr_file_name_table =3D data; =20 while (*data !=3D 0) @@ -3044,21 +3049,36 @@ display_debug_lines_decoded (struct dwarf_section *= section, break; case DW_LNE_define_file: { - unsigned int dir_index =3D 0; + file_table =3D (File_Entry *) + xmalloc ((n_files + 1) * sizeof (File_Entry)); =20 ++state_machine_regs.last_file_entry; + /* Source file name. */ + file_table[n_files].name =3D op_code_data; op_code_data +=3D strlen ((char *) op_code_data) + 1; - dir_index =3D read_leb128 (op_code_data, & bytes_rea= d, 0); + /* Directory index. */ + file_table[n_files].directory_index =3D + read_leb128 (op_code_data, & bytes_read, 0); op_code_data +=3D bytes_read; - read_leb128 (op_code_data, & bytes_read, 0); + /* Last modification time. */ + file_table[n_files].modification_date =3D + read_leb128 (op_code_data, & bytes_read, 0); op_code_data +=3D bytes_read; - read_leb128 (op_code_data, & bytes_read, 0); + /* File length. */ + file_table[n_files].length =3D + read_leb128 (op_code_data, & bytes_read, 0); =20 - printf ("%s:\n", directory_table[dir_index]); + n_files++; break; } + case DW_LNE_set_discriminator: + case DW_LNE_HP_set_sequence: + /* Simply ignored. */ + break; + default: - printf (_("UNKNOWN: length %d\n"), ext_op_code_len - b= ytes_read); + printf (_("UNKNOWN (%u): length %d\n"), + ext_op_code, ext_op_code_len - bytes_read); break; } data +=3D ext_op_code_len;