Skip to content

Commit

Permalink
* dwarf.c (free_line_header): Don't free dirs if dirs_count == 0.
Browse files Browse the repository at this point in the history
	(read_line_header): Don't allocate dirs if dirs_count == 0.
	* edtest.c: New file.
	* edtest2.c: New file.
	* Makefile.am (edtest_SOURCES, edtest_LDADD): Define.
	(check_PROGRAMS): Add edtest.
	(edtest2_build.c, gen_edtest2_build): New targets.
	* Makefile.in: Rebuild.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248295 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ian committed May 19, 2017
1 parent 0a0ee50 commit d8178f6
Show file tree
Hide file tree
Showing 6 changed files with 365 additions and 15 deletions.
11 changes: 11 additions & 0 deletions libbacktrace/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2017-05-19 Than McIntosh <[email protected]>

* dwarf.c (free_line_header): Don't free dirs if dirs_count == 0.
(read_line_header): Don't allocate dirs if dirs_count == 0.
* edtest.c: New file.
* edtest2.c: New file.
* Makefile.am (edtest_SOURCES, edtest_LDADD): Define.
(check_PROGRAMS): Add edtest.
(edtest2_build.c, gen_edtest2_build): New targets.
* Makefile.in: Rebuild.

2017-03-08 Sam Thursfield <[email protected]>

* btest.c (test5): Replace #ifdef guard with 'unused' attribute
Expand Down
11 changes: 11 additions & 0 deletions libbacktrace/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ stest_LDADD = libbacktrace.la

check_PROGRAMS += stest

edtest_SOURCES = edtest.c edtest2_build.c
edtest_LDADD = libbacktrace.la

check_PROGRAMS += edtest

edtest2_build.c: gen_edtest2_build; @true
gen_edtest2_build: $(srcdir)/edtest2.c
cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
$(SHELL) $(srcdir)/../move-if-change tmp-edtest2_build.c edtest2_build.c
echo timestamp > $@

endif NATIVE

# We can't use automake's automatic dependency tracking, because it
Expand Down
24 changes: 20 additions & 4 deletions libbacktrace/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@SET_MAKE@

# Makefile.am -- Backtrace Makefile.
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
# Copyright (C) 2012-2017 Free Software Foundation, Inc.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -84,7 +84,7 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
check_PROGRAMS = $(am__EXEEXT_1)
@NATIVE_TRUE@am__append_1 = btest stest
@NATIVE_TRUE@am__append_1 = btest stest edtest
subdir = .
DIST_COMMON = README ChangeLog $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/configure \
Expand Down Expand Up @@ -113,13 +113,18 @@ am__DEPENDENCIES_1 =
am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \
print.lo sort.lo state.lo
libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS)
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT)
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT) \
@NATIVE_TRUE@ edtest$(EXEEXT)
@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT)
btest_OBJECTS = $(am_btest_OBJECTS)
@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la
btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
@NATIVE_TRUE@am_edtest_OBJECTS = edtest.$(OBJEXT) \
@NATIVE_TRUE@ edtest2_build.$(OBJEXT)
edtest_OBJECTS = $(am_edtest_OBJECTS)
@NATIVE_TRUE@edtest_DEPENDENCIES = libbacktrace.la
@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT)
stest_OBJECTS = $(am_stest_OBJECTS)
@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
Expand All @@ -136,7 +141,7 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
$(btest_SOURCES) $(stest_SOURCES)
$(btest_SOURCES) $(edtest_SOURCES) $(stest_SOURCES)
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
Expand Down Expand Up @@ -330,6 +335,8 @@ TESTS = $(check_PROGRAMS)
@NATIVE_TRUE@btest_LDADD = libbacktrace.la
@NATIVE_TRUE@stest_SOURCES = stest.c
@NATIVE_TRUE@stest_LDADD = libbacktrace.la
@NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c
@NATIVE_TRUE@edtest_LDADD = libbacktrace.la

# We can't use automake's automatic dependency tracking, because it
# breaks when using bootstrap-lean. Automatic dependency tracking
Expand Down Expand Up @@ -422,6 +429,9 @@ clean-checkPROGRAMS:
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES)
@rm -f btest$(EXEEXT)
$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
edtest$(EXEEXT): $(edtest_OBJECTS) $(edtest_DEPENDENCIES) $(EXTRA_edtest_DEPENDENCIES)
@rm -f edtest$(EXEEXT)
$(LINK) $(edtest_OBJECTS) $(edtest_LDADD) $(LIBS)
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES)
@rm -f stest$(EXEEXT)
$(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS)
Expand Down Expand Up @@ -745,6 +755,12 @@ uninstall-am:
mostlyclean-multi pdf pdf-am ps ps-am tags uninstall \
uninstall-am


@NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true
@NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c
@NATIVE_TRUE@ cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
@NATIVE_TRUE@ $(SHELL) $(srcdir)/../move-if-change tmp-edtest2_build.c edtest2_build.c
@NATIVE_TRUE@ echo timestamp > $@
alloc.lo: config.h backtrace.h internal.h
backtrace.lo: config.h backtrace.h internal.h
btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h
Expand Down
25 changes: 14 additions & 11 deletions libbacktrace/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,16 +1563,15 @@ add_line (struct backtrace_state *state, struct dwarf_data *ddata,
return 1;
}

/* Free the line header information. If FREE_FILENAMES is true we
free the file names themselves, otherwise we leave them, as there
may be line structures pointing to them. */
/* Free the line header information. */

static void
free_line_header (struct backtrace_state *state, struct line_header *hdr,
backtrace_error_callback error_callback, void *data)
{
backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *),
error_callback, data);
if (hdr->dirs_count != 0)
backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *),
error_callback, data);
backtrace_free (state, hdr->filenames,
hdr->filenames_count * sizeof (char *),
error_callback, data);
Expand Down Expand Up @@ -1633,12 +1632,16 @@ read_line_header (struct backtrace_state *state, struct unit *u,
++hdr->dirs_count;
}

hdr->dirs = ((const char **)
backtrace_alloc (state,
hdr->dirs_count * sizeof (const char *),
line_buf->error_callback, line_buf->data));
if (hdr->dirs == NULL)
return 0;
hdr->dirs = NULL;
if (hdr->dirs_count != 0)
{
hdr->dirs = ((const char **)
backtrace_alloc (state,
hdr->dirs_count * sizeof (const char *),
line_buf->error_callback, line_buf->data));
if (hdr->dirs == NULL)
return 0;
}

i = 0;
while (*hdr_buf.buf != '\0')
Expand Down
Loading

0 comments on commit d8178f6

Please sign in to comment.