Florian Krohm 665280aeaf Merge r14202 from the BUF_REMOVAL branch to trunk.
This patch changes the interface and behaviour of VG_(demangle) and
VG_(maybe_Z_demangle). Instead of copying the demangled name into a
fixed sized buffer that is passed in from the caller (HChar *buf, Int n_buf),
the demangling functions will now return a pointer to the full-length
demangled name (HChar **result). It is the caller's responsiblilty to
make a copy if needed. 

This change in function parameters ripples upward
- first: to get_sym_name
- then to the convenience wrappers
  - VG_(get_fnname)
  - VG_(get_fnname_w_offset)
  - VG_(get_fnname_if_entry)
  - VG_(get_fnname_raw)
  - VG_(get_fnname_no_cxx_demangle)
  - VG_(get_datasym_and_offset)

The changes in foComplete then forces the arguments of
  - VG_(get_objname) to be changed as well

There are some issues regarding the ownership and persistence of
character strings to consider.
In general, the returned character string is owned by "somebody else"
which means the caller must not free it. Also, the caller must not 
modify the returned string as it possibly points to read only memory.
Additionally, the returned string is not necessarily persistent. Here are
the scenarios:
- the returned string is a demangled function name in which case the
  memory holding the string will be freed when the demangler is called again.
- the returned string hangs off of a DebugInfo structure in which case
  it will be freed when the DebugInfo is discarded
- the returned string hangs off of a segment in the address space manager
  in which case it may be overwritten when the segment is merged with
  another segment
So the rule of thunb here is: if in doubt strdup the string.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14664
2014-10-25 19:20:38 +00:00
..
2014-10-22 22:25:30 +00:00
2014-10-22 22:25:30 +00:00
2014-10-22 22:25:30 +00:00
2014-10-22 22:25:30 +00:00
2014-10-22 22:25:30 +00:00
2014-10-22 22:25:30 +00:00

On 4 Apr 06, the debuginfo reader (m_debuginfo) was majorly cleaned up
and restructured.  It has been a bit of a tangle for a while.  On 18 Sep 14
the STABS support was completely removed. The new structure looks like this:

                  debuginfo.c 
  
                   readelf.c

                  readdwarf.c

                   storage.c

Each .c can only call those below it on the page.

storage.c contains the SegInfo structure and stuff for 
maintaining/searching arrays of symbols, line-numbers, and Dwarf CF 
info records.

readdwarf.c parses the relevant kind of info and call storage.c to
store the results.

readelf.c reads ELF format, hands syms directly to storage.c,
then delegates to readdwarf.c for debug info.  All straightforward.

debuginfo.c is the top-level file, and is quite small.

There are 2 goals to this:

(1) Generally tidy up something which needs tidying up

(2) Introduce more modularity, so as to make it easier to add
    readers for other formats, if needed

Rationale for (1) and (2) are obvious.

Originally there was also goal (3) Simplify the stabs reader.
But stabs support was broken since 3.9.0 and completely removed in 3.10.0.

The worst thing is that it is the stabs type reader that was crashing,
not the stabs line-number reader.
Old versions of the stabs type reader can be found in the subversion repository
as m_debuginfo/UNUSED_STABS.txt, the stabs line-number reader was in
m_debuginfo/readstabs.c. The old version of this file explained more
about the setup.