Re: gdb.mi/mi-cli.exp failures

Andrew Cagney
2003-03-31T21:08:17Z

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

>> [ I just got back from vacation, so my apologies if I've missed some
>> discussion relevant to this. ]
>>
>> I'm getting a testsuite failure on gdb.mi/mi-cli.exp: the relevant bit
>> of gdb.log is as follows:
>>
>> 888-interpreter-exec console "set $pc=0x0"
>> &"frame.c:62: internal-error: get_frame_id: Assertion `!legacy_frame_p (current_gdbarch)' failed.\n"
>> &"A problem internal to GDB has been detected. Further\ndebugging may prove unreliable.\n"
>> ERROR: Process no longer exists
>> UNRESOLVED: gdb.mi/mi-cli.exp: -interpreter-exec console "set $pc=0x0"
>> testcase ./gdb.mi/mi-cli.exp completed in 1 seconds
>>
>> This is with GDB updated an hour or so ago, with i686-pc-linux-gnu,
>> GCC 3.1, DWARF 2.
>>

> FYI, my test run from my just committed call_dummy_p change had the usual 21 failures. Yet, mysteriously, for my next set of patches, I'm seeing the failures jump to 28.
>
> While I'll note that I'm the prime suspect, did anything else get changed?

David,

Applying the attached to BFD fixes the problem ....

CC'ing bfd.

Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 17997 bytes --]

? diffs
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.1976
retrieving revision 1.1975
diff -u -r1.1976 -r1.1975
--- ChangeLog 31 Mar 2003 18:13:24 -0000 1.1976
+++ ChangeLog 29 Mar 2003 01:26:33 -0000 1.1975
@@ -1,20 +1,3 @@
-2003-03-31 David Heine <dlheine@suif.stanford.edu>
-
- * aoutx.h (aout_link_hash_table_create): Use bfd_malloc instead of
- bfd_alloc.
- * dwarf2.c (concat_filename): Always allocate space for the
- returned filename.
- (decode_line_info): Free the allocated filename returned by
- concat_filename.
- * elf-eh-frame.c (bfd_elf_write_section_eh_frame): Fix memory leaks.
- * elf.c (copy_private_bfd_data): Likewise.
- (_bfd_elf_slurp_version_tables): Fix bug freeing contents pointer.
- * elflink.h (elf_link_sort_relocs): Fix memory leak.
- * format.c (bfd_check_format_matches): Likewise.
- * linker.c (bfd_generic_final_link): Likewise.
- * opncls.c (find_separate_debug_info): Likewise.
- * simple.c (bfd_simple_get_relocated_section_contents): Likewise.
-
2003-03-28 H.J. Lu <hjl@gnu.org>

* elflink.h (elf_link_add_object_symbols): Correctly combine
Index: aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.40
retrieving revision 1.39
diff -u -r1.40 -r1.39
--- aoutx.h 31 Mar 2003 18:13:24 -0000 1.40
+++ aoutx.h 31 Dec 2002 07:29:25 -0000 1.39
@@ -1,6 +1,6 @@
/* BFD semi-generic back-end for a.out binaries.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
- 2001, 2002, 2003
+ 2001, 2002
Free Software Foundation, Inc.
Written by Cygnus Support.

@@ -105,7 +105,9 @@
in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
to use the
@file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
- configuration is selected. */
+ configuration is selected.
+
+*/

/* Some assumptions:
* Any BFD with D_PAGED set is ZMAGIC, and vice versa.
@@ -155,8 +157,9 @@
The standard records contain only an
address, a symbol index, and a type field. The extended records
(used on 29ks and sparcs) also have a full integer for an
- addend. */
+ addend.

+*/
#ifndef CTOR_TABLE_RELOC_HOWTO
#define CTOR_TABLE_RELOC_IDX 2
#define CTOR_TABLE_RELOC_HOWTO(BFD) \
@@ -227,8 +230,7 @@

/* Convert standard reloc records to "arelent" format (incl byte swap). */

-reloc_howto_type howto_table_std[] =
-{
+reloc_howto_type howto_table_std[] = {
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone. */
HOWTO ( 0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", TRUE, 0x000000ff,0x000000ff, FALSE),
HOWTO ( 1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
@@ -3065,10 +3067,9 @@
struct aout_link_hash_table *ret;
bfd_size_type amt = sizeof (struct aout_link_hash_table);

- ret = (struct aout_link_hash_table *) bfd_malloc (amt);
+ ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
-
if (! NAME(aout,link_hash_table_init) (ret, abfd,
NAME(aout,link_hash_newfunc)))
{
@@ -3905,8 +3906,10 @@
for (o = abfd->sections; o != NULL; o = o->next)
{
for (p = o->link_order_head; p != NULL; p = p->next)
- if (p->type == bfd_indirect_link_order)
- p->u.indirect.section->linker_mark = TRUE;
+ {
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->linker_mark = TRUE;
+ }
}

have_link_order_relocs = FALSE;
Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.43
retrieving revision 1.42
diff -u -r1.43 -r1.42
--- dwarf2.c 31 Mar 2003 18:13:25 -0000 1.43
+++ dwarf2.c 12 Dec 2002 10:26:01 -0000 1.42
@@ -1,5 +1,5 @@
/* DWARF 2 support.
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.

Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
@@ -911,9 +911,6 @@
info->end_sequence = end_sequence;
}

-/* Extract a fully qualified filename from a line info table.
- The returned string has been xmalloc'ed. */
-
static char *
concat_filename (table, file)
struct line_info_table* table;
@@ -925,13 +922,12 @@
{
(*_bfd_error_handler)
(_("Dwarf Error: mangled line number section (bad file number)."));
- return concat ("<unknown>");
+ return "<unknown>";
}

filename = table->files[file - 1].name;
-
- if (IS_ABSOLUTE_PATH (filename))
- return concat (filename);
+ if (IS_ABSOLUTE_PATH(filename))
+ return filename;
else
{
char* dirname = (table->files[file - 1].dir
@@ -941,9 +937,9 @@
/* Not all tools set DW_AT_comp_dir, so dirname may be unknown. The
best we can do is return the filename part. */
if (dirname == NULL)
- return concat (filename);
+ return filename;
else
- return concat (dirname, "/", filename, NULL);
+ return (char*) concat (dirname, "/", filename, NULL);
}
}

@@ -1276,7 +1272,6 @@
based, the references are 1 based. */
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
- free (filename);
filename = concat_filename (table, file);
break;
}
@@ -1301,7 +1296,6 @@
default:
{
int i;
-
/* Unknown standard opcode, ignore it. */
for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++)
{
@@ -1311,8 +1305,6 @@
}
}
}
-
- free (filename);
}

return table;
Index: elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.23
retrieving revision 1.22
diff -u -r1.23 -r1.22
--- elf-eh-frame.c 31 Mar 2003 18:13:25 -0000 1.23
+++ elf-eh-frame.c 6 Feb 2003 23:01:04 -0000 1.22
@@ -2,21 +2,21 @@
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Jakub Jelinek <jakub@redhat.com>.

- This file is part of BFD, the Binary File Descriptor library.
+This file is part of BFD, the Binary File Descriptor library.

- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

#include "bfd.h"
#include "sysdep.h"
@@ -39,7 +39,7 @@
static int cie_compare
PARAMS ((struct cie *, struct cie *));
static int vma_compare
- PARAMS ((const PTR, const PTR));
+ PARAMS ((const PTR a, const PTR b));

/* Helper function for reading uleb128 encoded data. */

@@ -1112,7 +1112,7 @@
fde_count x [encoded] initial_loc, fde
(array of encoded pairs containing
FDE initial_location field and FDE address,
- sorted by increasing initial_loc). */
+ sorted by increasing initial_loc) */

bfd_boolean
_bfd_elf_write_section_eh_frame_hdr (abfd, info)
@@ -1125,7 +1125,6 @@
bfd_byte *contents;
asection *eh_frame_sec;
bfd_size_type size;
- bfd_boolean retval;

htab = elf_hash_table (info);
hdr_info = &htab->eh_info;
@@ -1142,18 +1141,15 @@

eh_frame_sec = bfd_get_section_by_name (abfd, ".eh_frame");
if (eh_frame_sec == NULL)
- {
- free (contents);
- return FALSE;
- }
+ return FALSE;

memset (contents, 0, EH_FRAME_HDR_SIZE);
- contents[0] = 1; /* Version. */
- contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset. */
+ contents[0] = 1; /* Version */
+ contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset */
if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
{
- contents[2] = DW_EH_PE_udata4; /* FDE count encoding. */
- contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* Search table enc. */
+ contents[2] = DW_EH_PE_udata4; /* FDE count encoding */
+ contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* search table enc */
}
else
{
@@ -1181,9 +1177,7 @@
}
}

- retval = bfd_set_section_contents (abfd, sec->output_section,
- contents, (file_ptr) sec->output_offset,
- sec->_cooked_size);
- free (contents);
- return retval;
+ return bfd_set_section_contents (abfd, sec->output_section,
+ contents, (file_ptr) sec->output_offset,
+ sec->_cooked_size);
}
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.181
retrieving revision 1.180
diff -u -r1.181 -r1.180
--- elf.c 31 Mar 2003 18:13:25 -0000 1.181
+++ elf.c 24 Feb 2003 18:07:22 -0000 1.180
@@ -5068,10 +5068,7 @@
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
- {
- free (sections);
- return FALSE;
- }
+ return FALSE;

/* Initialise the fields of the segment map. Set the physical
physical address to the LMA of the first section that has
@@ -5306,10 +5303,7 @@
amt = (bfd_size_type) (1 + symcount) * bed->s->sizeof_sym;
outbound_syms = bfd_alloc (abfd, amt);
if (outbound_syms == NULL)
- {
- _bfd_stringtab_free (stt);
- return FALSE;
- }
+ return FALSE;
symtab_hdr->contents = (PTR) outbound_syms;

outbound_shndx = NULL;
@@ -5319,11 +5313,7 @@
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx);
outbound_shndx = bfd_zalloc (abfd, amt);
if (outbound_shndx == NULL)
- {
- _bfd_stringtab_free (stt);
- return FALSE;
- }
-
+ return FALSE;
symtab_shndx_hdr->contents = outbound_shndx;
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
symtab_shndx_hdr->sh_size = amt;
@@ -5367,10 +5357,7 @@
syms[idx]->name,
TRUE, FALSE);
if (sym.st_name == (unsigned long) -1)
- {
- _bfd_stringtab_free (stt);
- return FALSE;
- }
+ return FALSE;
}

type_ptr = elf_symbol_from (abfd, syms[idx]);
@@ -5459,7 +5446,6 @@
syms[idx]->name ? syms[idx]->name : "<Local sym>",
sec->name);
bfd_set_error (bfd_error_invalid_operation);
- _bfd_stringtab_free (stt);
return FALSE;
}

@@ -5920,7 +5906,7 @@
return TRUE;

error_return:
- if (contents != NULL)
+ if (contents == NULL)
free (contents);
return FALSE;
}
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.211
retrieving revision 1.210
diff -u -r1.211 -r1.210
--- elflink.h 31 Mar 2003 18:13:25 -0000 1.211
+++ elflink.h 29 Mar 2003 01:26:33 -0000 1.210
@@ -4855,7 +4855,6 @@
}
}

- free (sort);
*psec = reldyn;
return ret;
}
Index: format.c
===================================================================
RCS file: /cvs/src/src/bfd/format.c,v
retrieving revision 1.13
retrieving revision 1.12
diff -u -r1.13 -r1.12
--- format.c 31 Mar 2003 18:13:25 -0000 1.13
+++ format.c 14 Feb 2003 11:16:09 -0000 1.12
@@ -163,11 +163,7 @@
if (!abfd->target_defaulted)
{
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
- {
- if (matching)
- free ((PTR) matching_vector);
- return FALSE;
- }
+ return FALSE;

right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));

@@ -218,11 +214,7 @@
abfd->xvec = *target; /* Change BFD's target temporarily. */

if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- {
- if (matching)
- free ((PTR) matching_vector);
- return FALSE;
- }
+ return FALSE;

/* If _bfd_check_format neglects to set bfd_error, assume
bfd_error_wrong_format. We didn't used to even pay any
Index: linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.30
retrieving revision 1.29
diff -u -r1.30 -r1.29
--- linker.c 31 Mar 2003 18:13:25 -0000 1.30
+++ linker.c 20 Dec 2002 22:41:13 -0000 1.29
@@ -1,23 +1,23 @@
/* linker.c -- BFD linker routines
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support

- This file is part of BFD, the Binary File Descriptor library.
+This file is part of BFD, the Binary File Descriptor library.

- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

#include "bfd.h"
#include "sysdep.h"
@@ -2081,12 +2081,12 @@
input_section,
relocs,
symbols);
- free (relocs);
if (reloc_count < 0)
return FALSE;
BFD_ASSERT ((unsigned long) reloc_count
== input_section->reloc_count);
o->reloc_count += reloc_count;
+ free (relocs);
}
}
if (o->reloc_count > 0)
Index: opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.15
retrieving revision 1.14
diff -u -r1.15 -r1.14
--- opncls.c 31 Mar 2003 18:13:25 -0000 1.15
+++ opncls.c 31 Jan 2003 10:04:16 -0000 1.14
@@ -931,13 +931,8 @@

basename = get_debug_link_info (abfd, & crc32);

- if (basename == NULL)
+ if (basename == NULL || strlen (basename) < 1)
return NULL;
- if (strlen (basename) < 1)
- {
- free (basename);
- return NULL;
- }

dir = xstrdup (abfd->filename);
BFD_ASSERT (strlen (dir) != 0);
Index: simple.c
===================================================================
RCS file: /cvs/src/src/bfd/simple.c,v
retrieving revision 1.6
retrieving revision 1.5
diff -u -r1.6 -r1.5
--- simple.c 31 Mar 2003 18:13:25 -0000 1.6
+++ simple.c 30 Nov 2002 08:39:40 -0000 1.5
@@ -1,5 +1,5 @@
/* simple.c -- BFD simple client routines
- Copyright 2002, 2003
+ Copyright 2002
Free Software Foundation, Inc.
Contributed by MontaVista Software, Inc.

@@ -135,7 +135,7 @@
struct bfd_link_order link_order;
struct bfd_link_callbacks callbacks;
bfd_byte *contents, *data;
- int storage_needed;
+ int storage_needed, number_of_symbols;
asymbol **symbol_table;

if (! (sec->flags & SEC_RELOC))
@@ -187,7 +187,7 @@

storage_needed = bfd_get_symtab_upper_bound (abfd);
symbol_table = (asymbol **) bfd_malloc (storage_needed);
- bfd_canonicalize_symtab (abfd, symbol_table);
+ number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);

contents = bfd_get_relocated_section_contents (abfd,
&link_info,
@@ -208,6 +208,5 @@

bfd_link_hash_table_free (abfd, link_info.hash);

- free (symbol_table);
return contents;
}
Index: version.h
===================================================================
RCS file: /cvs/src/src/bfd/version.h,v
retrieving revision 1.521
retrieving revision 1.520
diff -u -r1.521 -r1.520
--- version.h 31 Mar 2003 00:00:06 -0000 1.521
+++ version.h 30 Mar 2003 00:00:05 -0000 1.520
@@ -1,3 +1,3 @@
-#define BFD_VERSION_DATE 20030331
+#define BFD_VERSION_DATE 20030330
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_string@