Go to file
Alan Modra 19cacf6729 Use bfd_alloc memory for read_debugging_info storage
Trying to free malloc'd memory used by the stabs and coff debug info
parsers is complicated, and traversing the trees generated requires a
lot of code.  It's better to bfd_alloc the memory which allows it all
to be freed without fuss when the bfd is closed.  In the process of
doing this I reverted most of commit a633691333.

Some of the stabs handling code grows arrays of pointers with realloc,
to deal with arbitrary numbers of fields, function args, etc.  The
code still does that but copies over to bfd_alloc memory when
finished.  The alternative is to parse twice, once to size, then again
to populate the arrays.  I think that complication is unwarranted.

Note that there is a greater than zero chance this patch breaks
something, eg. that I missed an attempt to free obj_alloc memory.
Also it seems there are no tests in the binutils testsuite aimed at
exercising objdump --debugging.

	* budbg.h (finish_stab, parse_stab): Update prototypes
	* debug.c: Include bucomm.h.
	(struct debug_handle): Add "abfd" field.
	(debug_init): Add "abfd" param.  bfd_alloc handle.
	(debug_xalloc, debug_xzalloc): New functions.  Use throughout
	in place of xmalloc and memset.
	(debug_start_source): Remove "name_used" param.
	* debug.h (debug_init, debug_start_source): Update prototypes.
	(debug_xalloc, debug_xzalloc): Declare.
	* objcopy.c (copy_object): Don't free dhandle.
	* objdump.c (dump_bfd): Likewise.
	* rdcoff.c (coff_get_slot): Add dhandle arg.  debug_xzalloc
	memory in place of xcalloc.  Update callers.
	(parse_coff_struct_type): Don't leak on error return.  Copy
	fields over to debug_xalloc memory.
	(parse_coff_enum_type): Copy names and vals over the
	debug_xalloc memory.
	* rddbg.c (read_debugging_info): Adjust debug_init call.
	Don't free dhandle.
	(read_section_stabs_debugging_info): Don't free shandle.
	Adjust parse_stab call.  Call finish_stab on error return.
	(read_symbol_stabs_debugging_info): Similarly.
	* stabs.c (savestring): Delete unnecessary forward declaration.
	Add dhandle param.  debug_xalloc memory.  Update callers.
	(start_stab): Delete unnecessary casts.
	(finish_stab): Add "emit" param.  Free file_types, so_string,
	and stabs handle.
	(parse_stab): Delete string_used param.  Revert code dealing
	with string_used.  Copy so_string passed to debug_set_filename
	and stored as main_filename to debug_xalloc memory.  Similarly
	for string passed to debug_start_source and push_bincl.  Copy
	args to debug_xalloc memory.  Don't leak args.
	(parse_stab_enum_type): Copy names and values to debug_xalloc
	memory.  Don't free name.
	(parse_stab_struct_type): Don't free fields.
	(parse_stab_baseclasses): Delete unnecessary cast.
	(parse_stab_struct_fields): Return debug_xalloc fields.
	(parse_stab_cpp_abbrev): Use debug_xalloc for _vb$ type name.
	(parse_stab_one_struct_field): Don't free name.
	(parse_stab_members): Copy variants and methods to
	debug_xalloc memory.  Don't free name or argtypes.
	(parse_stab_argtypes): Use debug_xalloc memory for physname
	and args.
	(push_bincl): Add dhandle param.  Use debug_xalloc memory.
	(stab_record_variable): Use debug_xalloc memory.
	(stab_emit_pending_vars): Don't free var list.
	(stab_find_slot): Add dhandle param.  Use debug_xzalloc
	memory.  Update all callers.
	(stab_find_tagged_type): Don't free name.  Use debug_xzalloc.
	(stab_demangle_qualified): Don't free name.
	(stab_demangle_template): Don't free s1.
	(stab_demangle_args): Tidy pvarargs refs.  Copy *pargs on
	success to debug_xalloc memory, free on failure.
	(stab_demangle_fund_type): Don't free name.
	(stab_demangle_v3_arglist): Copy args to debug_xalloc memory.
	Don't free dt.
2023-04-04 12:47:56 +09:30
bfd Automatic date update in version.in 2023-04-04 00:00:14 +00:00
binutils Use bfd_alloc memory for read_debugging_info storage 2023-04-04 12:47:56 +09:30
config
contrib
cpu
elfcpp
etc
gas opcodes/arm: adjust whitespace in cpsie instruction 2023-04-03 12:11:32 +01:00
gdb Add readMemory and writeMemory requests to DAP 2023-04-03 08:47:52 -06:00
gdbserver gdbserver: allow agent expressions to fail with invalid memory access 2023-04-03 14:46:32 +01:00
gdbsupport gdb: move displaced_step_dump_bytes into gdbsupport (and rename) 2023-03-29 08:57:10 +01:00
gnulib
gold Add an option to the gold linker to put its version string into the .comment section. 2023-03-27 11:10:10 +01:00
gprof
gprofng gprofng: Add version symbols to libgprofng.ver 2023-03-29 23:09:40 -07:00
include aarch64: Remove stray reglist variable 2023-03-30 17:01:30 +01:00
intl
ld lto: Don't add indirect symbols for versioned aliases in IR 2023-03-31 08:34:48 -07:00
libbacktrace
libctf
libdecnumber
libiberty
libsframe
opcodes asan: csky floatformat_to_double uninitialised value 2023-04-03 23:14:41 +09:30
readline
sim
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore
ar-lib
ChangeLog
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.