This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[OB] dwarf2read.c: fix build error
- From: Hui Zhu <teawater at gmail dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Fri, 13 Aug 2010 11:20:38 +0800
- Subject: [OB] dwarf2read.c: fix build error
Hi,
I got some error with cvs-head:
gcc -g -O2 -I. -I../../src/gdb -I../../src/gdb/common
-I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
-I../../src/gdb/../opcodes/.. -I../../src/gdb/../readline/.. -I../bfd
-I../../src/gdb/../bfd -I../../src/gdb/../include -I../libdecnumber
-I../../src/gdb/../libdecnumber -I../../src/gdb/gnulib -Ignulib
-DMI_OUT=1 -DTUI=1 -DGDBTK -I/usr/include -I/usr/include -Wall
-Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function
-Wno-switch -Wno-char-subscripts -Werror -c -o dwarf2read.o -MT
dwarf2read.o -MMD -MP -MF .deps/dwarf2read.Tpo
../../src/gdb/dwarf2read.c
cc1: warnings being treated as errors
../../src/gdb/dwarf2read.c: In function 'load_full_comp_unit':
../../src/gdb/dwarf2read.c:7977: warning: 'back_to' may be used
uninitialized in this function
../../src/gdb/dwarf2read.c:7977: note: 'back_to' was declared here
make[2]: *** [dwarf2read.o] Error 1
gcc -g -O2 -I. -I../../src/gdb -I../../src/gdb/common
-I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
-I../../src/gdb/../opcodes/.. -I../../src/gdb/../readline/.. -I../bfd
-I../../src/gdb/../bfd -I../../src/gdb/../include -I../libdecnumber
-I../../src/gdb/../libdecnumber -I../../src/gdb/gnulib -Ignulib
-DMI_OUT=1 -DTUI=1 -DGDBTK -I/usr/include -I/usr/include -Wall
-Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function
-Wno-switch -Wno-char-subscripts -Werror -c -o dwarf2read.o -MT
dwarf2read.o -MMD -MP -MF .deps/dwarf2read.Tpo
../../src/gdb/dwarf2read.c
cc1: warnings being treated as errors
../../src/gdb/dwarf2read.c: In function 'find_partial_die':
../../src/gdb/dwarf2read.c:3250: warning: 'free_cu_cleanup' may be
used uninitialized in this function
../../src/gdb/dwarf2read.c:3250: note: 'free_cu_cleanup' was declared here
make[2]: *** [dwarf2read.o] Error 1
if (this_cu->cu == NULL)
{
cu = alloc_one_comp_unit (objfile);
read_cu = 1;
/* If an error occurs while loading, release our storage. */
free_cu_cleanup = make_cleanup (free_one_comp_unit, cu);
if (read_cu)
{
/* We've successfully allocated this compilation unit. Let our
caller clean it up when finished with it. */
discard_cleanups (free_cu_cleanup);
}
if (cu->dwarf2_abbrevs == NULL)
{
dwarf2_read_abbrevs (cu->objfile->obfd, cu);
back_to = make_cleanup (dwarf2_free_abbrev_table, cu);
read_abbrevs = 1;
}
if (read_abbrevs)
do_cleanups (back_to);
So I checked in a patch to fix them.
BTW, I got this error because my gcc is too old?
Thanks,
Hui
2010-08-13 Hui Zhu <teawater@gmail.com>
* dwarf2read.c (load_partial_comp_unit): Initialize free_cu_cleanup.
(read_comp_unit): Initialize back_to.
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.436
retrieving revision 1.437
diff -u -r1.436 -r1.437
--- src/gdb/dwarf2read.c 2010/08/12 19:55:38 1.436
+++ src/gdb/dwarf2read.c 2010/08/13 03:14:03 1.437
@@ -3247,7 +3247,7 @@
gdb_byte *info_ptr, *beg_of_comp_unit;
struct die_info *comp_unit_die;
struct dwarf2_cu *cu;
- struct cleanup *free_abbrevs_cleanup, *free_cu_cleanup;
+ struct cleanup *free_abbrevs_cleanup, *free_cu_cleanup = NULL;
struct attribute *attr;
int has_children;
struct die_reader_specs reader_specs;
@@ -7974,7 +7974,7 @@
{
struct die_reader_specs reader_specs;
int read_abbrevs = 0;
- struct cleanup *back_to;
+ struct cleanup *back_to = NULL;
struct die_info *die;
if (cu->dwarf2_abbrevs == NULL)