Commit Graph

53 Commits

Author SHA1 Message Date
David Anderson
ac6673e32f dwarfdump
* print_die.c: Fix typo in error message.
* print_frames.c: Do additional checks for incorrect data
  when printing frame instructions to avoid dwarfdump crash..

libdwarf
    * dwarf_form.c: Directly check expression length against
      section length in case expression length very very large.
    * dwarf_query.c: _dwarf_calculate_info_section_*() routines
      made clearer and the *_start_ptr() instance also now returns
      the length (via a pointer arg).
    * dwarf_xu_index.c: Check data read from the section so
      a wildly large columns count or slots count will be caught
      and an error returned.
2016-05-18 18:50:58 -07:00
David Anderson
82d8e00785 bugxml/data.txt
Moved a couple functions between source files
and made them static. A couple commentary changes.
print_frames.c, though, needed hardening against
corrupt frame data.
dwarfdump/globals.h
dwarfdump/print_aranges.c
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_sections.c

All data reads from an object ensure the
read is actually in a section.
It is always possible something was overlooked, but
all the reading macros and functions now do checks.
libdwarf/dwarf_arange.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_form.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame2.c
libdwarf/dwarf_global.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_loc.c
libdwarf/dwarf_loc2.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_print_lines.c
libdwarf/dwarf_query.c
libdwarf/dwarf_ranges.c
libdwarf/dwarf_util.c
libdwarf/dwarf_util.h
libdwarf/dwarf_xu_index.c
libdwarf/libdwarf.h.in
2016-05-12 07:39:36 -07:00
David Anderson
eb1472afac New bugr reports.
bugxml/data.txt

Now prints strings so that
control characters do not
cause problems. Easier to read too.
dwarfdump/Makefile.in
dwarfdump/NEWS
dwarfdump/dwarfdump.1
dwarfdump/dwarfdump.c
dwarfdump/globals.h
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_lines.c
dwarfdump/print_macro.c
dwarfdump/print_macros.c
dwarfdump/sanitized.c

Removed trailing whitespace.
dwarfexample/simplereader.c

New checking for corrupt input.
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_form.c
libdwarf/dwarf_line.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_query.c
libdwarf/dwarf_util.h
libdwarf/libdwarf.h.in
2016-05-06 08:26:36 -07:00
David Anderson
0c259d4b70 libdwarf
* dwarf_die_deliv.c: Deleted unused local variable.
    * dwarf_form.c,dwarf_macro.c, dwarf_macro5.c: Now uses
      DCODE_LEB128*_CK nearly everywhere
      for better checking for corrupted data.
    * dwarf_opaque.h:New argument to _dwarf_get_addr_index_itself()
      for better data checks..
    * dwarf_query.c: Uses revised _dwarf_get_addr_index_itself()
      interface.
    * dwarf_util.c: Fixed formatting errors.
2016-04-30 07:15:22 -07:00
David Anderson
76b6fb5846 Remove duplicative print of error number.
dwarfdump/dwarfdump.c

Ensure dependency on dwarf_errmsg_list.c
libdwarf/Makefile.in

Do much much more testing to ensure we do not
run off the end of section or accept a bogus
leb number.
libdwarf/dwarf_abbrev.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame.h
libdwarf/dwarf_frame2.c
libdwarf/dwarf_frame3.c
libdwarf/dwarf_leb.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line.h
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_query.c
libdwarf/dwarf_util.c
libdwarf/dwarf_util.h
libdwarf/libdwarf.h.in
2016-04-27 13:00:06 -07:00
Carlos Alberto Enciso
e8701c78b8 Memory corruption due to incorrect usage of memory allocator type.
dwarf_alloc.h, dwarf_alloc.c, dwarf_base_types.h, dwarf_opaque.h:
  New allocator type (DW_DLA_CHAIN_2), to allow a list of addressed
  types (address, offset).

dwarf_query.c: Use the new allocator type.
2016-02-19 14:39:14 +00:00
David Anderson
c446254e5e Add support for SHF_COMPRESSED
libdwarf/README
libdwarf/dwarf_elf_access.c
libdwarf/dwarf_error.c
libdwarf/dwarf_init_finish.c
libdwarf/dwarf_opaque.h
libdwarf/libdwarf.h.in
libdwarf/libdwarfdefs.h
2016-02-10 09:05:27 -08:00
David Anderson
2e5e4b4d8b Fixing -m and getting good output of dwarf5 macros.
Still no handling of macro import.
dwarfdump/dwarfdump.c
dwarfdump/print_lines.c
dwarfdump/print_macro.c

Fixing handling of DWARF5 macros.
libdwarf/dwarf_line.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_macro5.h
libdwarf/dwarf_opaque.h
2015-12-20 20:08:17 -08:00
David Anderson
e68baed644 Making the macro printing more correct.
Not yet quite right or complete.
dwarfdump/ChangeLog
dwarfdump/print_macro.c
libdwarf/ChangeLog
libdwarf/dwarf_init_finish.c
libdwarf/dwarf_line.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_macro5.h
libdwarf/dwarf_opaque.h
libdwarf/dwarf_util.c
libdwarf/dwarf_util.h
2015-12-20 10:36:29 -08:00
David Anderson
7a6a2c793f This now does nearly all of DWARF5 macro printing.
dwarfdump/print_macro.c

libdwarf/dwarf_form.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_macro5.h
libdwarf/dwarf_opaque.h
libdwarf/libdwarf.h.in
2015-12-15 12:57:33 -08:00
David Anderson
da724a0bc5 Now check FORM codes in abbrevs for sensible values.
Error off if invalid.
dwarf_abbrev.c
dwarf_die_deliv.c
dwarf_error.c
dwarf_opaque.h
dwarf_query.c
dwarf_util.c
dwarf_util.h
libdwarf.h.in
2015-12-08 10:46:23 -08:00
David Anderson
940b561d3a Updated dwarfdump version string.
Updated all the configure scripts to support zlib and
reading compressed .zdebug_ DWARF sections.

All works fine without zlib (though reading .zdebug sections
not possible without zlib).

A few lines of code and some internal-to-libdwarf structs
change slightly for .zedebug support.  There is  no
change to public interfaces.
2015-11-26 08:27:17 -08:00
David Anderson
7c417212c4 dwarf.h
Since .zdebug compressed dwarf is becoming
more commonly used, this is preparation for
noticing and decompressing zdebug sections
when zlib is present at build time..

dwarf_elf_access.c
dwarf_init_finish.c
dwarf_opaque.h
dwarf_tied.c
2015-11-25 12:32:56 -08:00
David Anderson
6b65d5f0e0 dwarfdump
* print_abbrevs.c(dwarf_get_array_info): Initialize local variable.
     * print_die.c(get_location_list): Initialize local variable.:
     * dwarf_loc.h: Add declaration of _dwarf_loc_block_sanity_check().
     * dwarf_loc.c: Call new function  _dwarf_loc_block_sanity_check
     * dwarf_loc2.c: Implement and call new function
       _dwarf_loc_block_sanity_check to avoid duplicating code.

libdwarf
* dwarf_opaque.h: Delete two useless blank lines.
2015-11-11 15:55:20 -08:00
David Anderson
8b2ac2b95a * dwarfdump.1: Documented -x line5=.
* dwarfdump.c: Revised -g so it no longer turns on -i.
       Revised the meaning of -g to mean use old loclist interfaces
       (for testing the older interfaces with dwarfdump).
     * print_die.c(get_small_encoding_integer_and_name): a dwarf_dealloc
       referenced err whereas *err was correct.
       Revised loclist output making it look a bit like DWARF5
       even for DWARF2,3,4 output. Reads better, I think.
     * print_locs.c: -l gets a 'no longer supported' message

dwarfdump/dwarfdump.1
dwarfdump/dwarfdump.c
dwarfdump/print_die.c
dwarfdump/print_locs.c

     * dwarf_alloc.c: Added new checks so  user mixing up
       tied dbg with regular dbg won't lead to crashes
       when calling dwarf_dealloc or dwarf_finish().
       Zeroed out some fields to recognize space deallocated.
     * dwarf_die_deliv.c: Added support of split dwarf
       DW_AT_[GNU_]ranges_base
     * dwarf_form.c: Load string from tieddbg when appropriate.
     * dwarf_harmless.c: On free() zero out a field to show that was done.
     * dwarf_loc.c: Correct the handling of split dwarf loclist.
     * dwarf_opaque.h: Add cc_ranges_base_present for split dwarf.
       Add _dwarf_get_ranges_base_attr_from_tied() for split dwarf.
     * dwarf_query.c: Get and remember skeleton compilaton unit
       DW_AT_[GNU_]ranges_base from tied objects for split dwarf.
     * dwarf_ranges.c: If a tied object present, look for ranges
       there, not in split dwarf object.
     * dwarf_util.c: Housekeeping zeros out fields to ensure not
       used after dealloc.

libdwarf/dwarf_alloc.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_form.c
libdwarf/dwarf_harmless.c
libdwarf/dwarf_loc.c
libdwarf/dwarf_loc2.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_original_elf_init.c
libdwarf/dwarf_query.c
libdwarf/dwarf_ranges.c
libdwarf/dwarf_util.c
2015-11-07 14:42:52 -08:00
David Anderson
0052aa52f4 Revisions for DWARF5 expression handling complete, one thinks.
Next is testing.

   dwarfdump/Makefile.in
   dwarfdump/configure
   dwarfdump/configure.in
   dwarfdump/dwarfdump.c
   dwarfdump/globals.h
   dwarfdump/print_die.c
   dwarfdump/print_frames.c
   dwarfdump/print_frames.h
   dwarfdump/print_lines.c
   dwarfdump/print_locs.c

   libdwarf/Makefile.in
   libdwarf/dwarf_alloc.c
   libdwarf/dwarf_alloc.h
   libdwarf/dwarf_error.c
   libdwarf/dwarf_frame.c
   libdwarf/dwarf_loc.c
   libdwarf/dwarf_loc.h
   libdwarf/dwarf_loc2.c
   libdwarf/dwarf_opaque.h
   libdwarf/dwarf_query.c
   libdwarf/libdwarf.h.in
2015-11-01 08:30:30 -08:00
David Anderson
4b54aad40f libdwarf for DWARF5 loclists
examples.c: Add commentary to example9.
dwarf_alloc.c: Add DW_DLA_LOC_BLOCK_C and DW_CLA_LOCDESC_C
       allocation descriptions to array.
dwarf_alloc.h: Increase ALLOC_AREA_INDEX_TABLE_MAX to match.
dwarf_base_types.h: Increase MAX_DW_DLA to match.
dwarf_die_deliv.c: Switch some returns from pointer to
       the standard int DW_DLV_OK etc and return pointer through
       an argument.  Identify which CUs are dwo by checking name
       for a .dwo ending. Fix whitespace endings.
dwarf_error.c: Add DW_DLE 309 to 311 errors to descriptions array.
dwarf_form.c: Remove trailing whitespace. Reformat one line
       so it is not so long.
dwarf_line.c: Add {} on if for clarity.
       Fix whitespace endings.
dwarf_line_table_reader.c: Fix whitespace endings.
dwarf_loc.c: Refactor loc. expr. reader into a
       routine that reads one expression, _darf_read_loc_expr_op()..
       Add DWARF5 operators.
       Add preliminary dwo expression support (which will change
       but this is a start).  Old expression interface now
       explicitly supports only DWARF 2,3,4. No DWARF5.
       Add preliminary loclist_c support (it will change).
       Add commentary about the old loclist interface.
dwarf_loc.h: First cut of new interfaces (functional, not
       public structs).
dwarf_opaque.h: Add cc_is_dwo flag to cu context struct.
libdwarf.h.in: Rework some loclist commentary.
       Add first try at new loclist interfaces for DWARF2,3,4,5.
       New error codes for new loclist/dwo code.
libdwarf2.1.mm: Rev 2.32. New wording on old loclist
       interfaces.
2015-10-25 09:41:39 -07:00
David Anderson
4130f07d25 dwarfdump
* dwarfdump.c: Add enum line_flag_type_e so we can test
       all the srclines interfaces (4 of them). Expand -x
       for that too.
     * print_die.c: Support DW_FORM_GNU_strp_alt.
     * print_lines.c: Update for old and new srclines
       interfaces.
     * globals.h: Added the enum line_flag_e variable for
       recording -x line5= value.

libdwarf
     * checkexamples.c: Fixed data type in the example code.
     * dwarf.h: Updated comment about DW_FORM_GNU_strp_alt
     * dwarf_elf_access.c: Fixed trailing whitespace and
       removed debug printf that got left in.
     * dwarf_error.c: Add new TIED file errors.
       DW_DLE_NO_TIED_FILE_AVAILABLE, DW_DLE_NO_TIED_STRING_AVAILABLE.
     * dwarf_form.c: Added support for DW_FORM_GNU_strp_alt.
     * dwarf_init_finish.c: #if 0 routine all_sig8bits_zero().
    * dwarf_line.c: Now always notice windows-like c: etc
       as start of a full path. Ensure directories with \ are
       turned to / in line tables. (for full such transforms
       configure with --enable-windowspath ) Remove some debug #ifdef
       lines.
       Alter the linecontext interface to pass back table count,
       not linecount.
    * dwarf_line.h: Add commentary and lc_table_count field.
     * dwarf_line_table_reader_common.c: Fix indent/trailing whitespace.
       Now sets lc_table_count;
     * dwarf_opaque.h: Add _dwarf_get_string_from_tied() interface.
     * dwarf_print_lines.c: Remove trailing whitespace and some debug printf..
     * libdwarf.h.in: New error codes. Fix trailing whitespace. Expand
       commentary.
2015-10-15 09:27:28 -07:00
David Anderson
456fe6c3c8 Changed an internal function to have a leading _ in the name
and added a Dwarf_CU_Context argument so we can get address
size and segment size when not in the line table.
All this related to two-level line tables.

dwarfdump/print_lines.c
libdwarf/dwarf.h
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line.h
libdwarf/dwarf_opaque.h
libdwarf/dwarf_print_lines.c
libdwarf/dwarf_sort_line.c
libdwarf/libdwarf.h.in
2015-09-19 18:21:52 -07:00
David Anderson
75cef5f84e Small corrections to dwarfdump.c for DebugFission handling.
More substantial corrections to get the DebugFission code
in libdwarf working.
2015-09-12 12:46:01 -07:00
David Anderson
c5ab119f8c Adding -x tied=<path> option to dwarfdump and added
code in libdwarf to go to the other, the tied, object
and retrieve .debug_addr data.
dwarfdump/ChangeLog
dwarfdump/dwarfdump.1
dwarfdump/dwarfdump.c
dwarfdump/print_die.c
libdwarf/ChangeLog
libdwarf/Makefile.in
libdwarf/dwarf_alloc.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_error.c
libdwarf/dwarf_form.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_original_elf_init.c
libdwarf/dwarf_query.c
dwarf_tied.c
libdwarf/libdwarf.h.in
2015-09-11 09:04:05 -07:00
David Anderson
059395fa7a Implementing DWARF5 (and DWARF4 as an extension) DWP Package
File support.
dwarfdump/print_die.c
dwarfexample/simplereader.c
libdwarf/NEWS
libdwarf/dwarf_abbrev.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_form.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_util.c
libdwarf/dwarf_xu_index.c
libdwarf/libdwarf.h.in
libdwarf/libdwarf2.1.mm
libdwarf/libdwarf2.1.pdf
2015-05-06 10:55:32 -07:00
David Anderson
c665613423 libdwarf: major changes to support DWP Package Files
in DWARF5.   Some support of DWARF5 generally.

DWP support itself not well tested, but for non-DWP
objects things work as before.
2015-05-01 17:10:42 -07:00
David Anderson
1a51e18826 Now defining and using
DW_CIE_VERSION* DW_CU_VERSION**
       DW_ARANGES_VERSION* DW_LINE_VERSION* DW_LOC_VERSION*
       DW_LINE_STR_VERSION5, DW_MACRO_VERSION5,
       DW_LINE_LOC, DW_NAMES_VERSION5, DW_PUBNAMES_VERSION*,
       DW_PUBTYPES_VERSION*, DW_STR_OFFSETS_VERSION5,
       DW_SUP_VERSION*, DW_CU_INDEX_VERSION5

exclusively. Deleting the CURRENT_VERSION_STAMP* macros.
The intent is to improve readability given we now have
4 versions of DWARF to deal with.
2015-04-23 13:37:37 -07:00
David Anderson
b755b9f925 Added DWARF5 tags and attributes.
(the standard is not yet final, some of these additions could change).
Added checking code to fix libdwarf coredumps when it is given
erroneous DWARF.
2015-02-04 13:31:09 -08:00
David Anderson
2d88cea086 libdwarf: Complete the removal of obsolete SGI postal address and
oss.sgi.com from copyright notices.
libdwarf/LIBDWARFCOPYRIGHT has an original example of copyright
and explains the change.
2015-01-31 10:09:02 -08:00
David Anderson
b004f18f43 Changing the hash return from the debugfission
from an integer to an 8 byte glob: Dwarf_Sig8
2015-01-31 09:03:03 -08:00
David Anderson
be85a0a4cb Adds support to printing .dwp DWARF5.
DebugFission.
On FreeBSD is still problematic option handling.
2015-01-21 15:08:30 -08:00
David Anderson
b6ea605c1e Changes to support debugfission added, so we can
dump dwarf from .dwp files.
Some additional change an testing will be added.
2015-01-18 12:48:41 -08:00
David Anderson
901e351412 libdwarf/dwarf_opaque.h: One new comment had a bad
indent. Fixed.
2014-07-11 16:04:07 -07:00
David Anderson
f9d9bba06f libdwarf/dwarf_opaque.h: Clarified the meaning of
various CU context struct fields by adding comments.
2014-07-11 16:02:02 -07:00
David Anderson
aa30004c5e libdwarf/dwarf_opaque.h: Altered a couple comments
to make them clearer.
2014-07-11 15:24:08 -07:00
David Anderson
f8caa95d63 libdwarf and dwarfdump now begin to support the DWARF5
sections .debug_tu_index and .debug_cu_index.
2014-07-09 14:45:30 -07:00
David Anderson
0fed4afaa7 libdwarf:
dwarf_arange.c(dwarf_get_aranges_list): Remove the length variable
   as its calculated value is unused.  rename length to area_length
   for clarity.  Calculate arange_ptr_past_end early and
   correctly.  Ensure that the test for version 4 is a >=
   to reflect normal standards upgrades.
dwarf_die_deliv.c(dwarf_find_offdie_CU_Context): Add commentary
   about offsets and lengths for clarity.
   Rename fields for clarity about local vs global offset.
   Use the newly named fields for precise tests of section overflow of
   a type unit.
Other changes in libdwarf were additions and modifications of commentary.
2014-07-05 10:14:12 -07:00
David Anderson
9297b3032a Fixes a mistake in checking a offset in dwarf_die_deliv.c
The mistake resulted in an error-return on a really really
short .debug_types section where there
was no error.

Removes unused local variables.
Switches a couple struct members (in dwarf_opaque.h) from
Dwarf_Word to Dwarf_Unsigned.
2014-07-03 12:47:54 -07:00
David Anderson
a7096d4360 libdwarf: removed newly introduced indent errors and removed
newly introduced trailing whitespace.
2014-07-01 17:00:08 -07:00
David Anderson
b37e94d0a7 Adds printing of the .gdb_index section header
and the -I dwarfdump option to select that section.
2014-06-29 11:55:51 -07:00
David Anderson
858fd0df59 A few files had unused variables. Now fixed.
dwarf_query.c had a bug, hidden by an ommission from
dwarf_opaque.h.    All these were exposed by compiling -Wall.
2014-05-19 13:35:00 -07:00
David Anderson
2b628409f9 Fixed numerous indent errors and removed
trailing whitespace.
2014-05-18 10:51:30 -07:00
David Anderson
f5e2be3ebd Now handles most of Debug Fission, but
this version needs small corrections to finish the
DebugFission support.
2014-05-18 10:29:33 -07:00
David Anderson
f471b3786b Adds support and refactoring for reading and printing
DebugFission data.  There are new attributes (with GNU
forms and standard forms) and DW_OP's too.
Libdwarf reader code refactored so the new sections are
easily handled.
2014-05-16 19:10:52 -07:00
David Anderson
af405cd9a4 Added support for DW_FORM_GNU_str_index and debug fission (.dwo)
GNU objects.   Partial support for DW_FORM_GNU_addr_index.
2014-05-11 10:05:53 -07:00
David Anderson
86784da7c2 libdwarf:
* dwarf_alloc.c: Refactored and added relevant commentary.
      Added a check for debug_types in dwarf_dealloc().
    * dwarf_init_finish.c: Corrected a comment and made one line
      declation-is-initialization.
    * dwarf_opaque.h: Added commentary.
2014-01-30 13:05:57 -08:00
David Anderson
affafa89fb Removed trailing (and useless) whitespace from all the lines
containing it.  Many many files had such.
2014-01-29 15:02:07 -08:00
David Anderson
545d698072 Now using tsearch style calls with
dwarf_tsearch implementation.
Fixed a small memory curruption in dwarfdump2/print_pubnames.cc
Added tsearch directory with various sorts of tree searches
(all written from scratch, not copied from anywhere).
2014-01-29 11:41:39 -08:00
David Anderson
a33289863d Now dwarf_print_lines() works via callback instead of using
stdout directly.
dwarfdump[2] use this new feature now.
The new interfaces in libdwarf.h to support this are documented.
Some minor botches in libdwarf2.1.mm (bad formatting) fixed.
2013-08-15 12:42:44 -07:00
David Anderson
f2509d0f4d Fix nasty bug where cc_length was used where cc_length_size
was needed to get offset size.
2013-01-25 10:43:22 -08:00
David Anderson
791398ca4d Makes it easier to build under FreeBSD.
Fixes signed/unsigned comparison issues noted by -Wsign-compare
2013-01-16 15:51:41 -08:00
David Anderson
e5e99e5b17 Move static array with changeable data into Dwarf_Debug struct,
fixing botch in 20121127 release.
Fix value returned (through argument) from dwarf_formflag().
Make some global data which is actually const as const.
2012-11-29 14:34:45 -08:00
David Anderson
a08a8549e3 Now we support .debug_types (type unit DIEs) in -i output. 2011-10-29 16:32:34 -07:00