6 years agoFix bugs in copying loop tree info
Xiaozhu Meng [Tue, 16 Sep 2014 02:55:03 +0000 (21:55 -0500)]
Fix bugs in copying loop tree info

6 years agochange dyninstAPI loop interface and dominator info interface to use PatchAPI
Xiaozhu Meng [Tue, 16 Sep 2014 02:06:33 +0000 (21:06 -0500)]
change dyninstAPI loop interface and dominator info interface to use PatchAPI

6 years agoAdd loop interface and dominator info interface to PatchAPI
Xiaozhu Meng [Mon, 15 Sep 2014 18:24:16 +0000 (13:24 -0500)]
Add loop interface and dominator info interface to PatchAPI

6 years agoDecouple calculation for loops, loop nesting structure, and dominator information
Xiaozhu Meng [Fri, 12 Sep 2014 19:44:14 +0000 (14:44 -0500)]
Decouple calculation for loops, loop nesting structure, and dominator information

6 years agoCopy natural loop analysis to ParseAPI and create loop interfaces in ParseAPI
Xiaozhu Meng [Fri, 29 Aug 2014 15:42:48 +0000 (10:42 -0500)]
Copy natural loop analysis to ParseAPI and create loop interfaces in ParseAPI

6 years agoAdded Makefile.doc files for latex-based manuals.
Emily Gember-Jacobson [Mon, 18 Aug 2014 15:37:25 +0000 (10:37 -0500)]
Added Makefile.doc files for latex-based manuals.

6 years agodyninstAPI_RT: add DLLEXPORT to DYNINSTstaticMode
Josh Stone [Tue, 12 Aug 2014 01:20:43 +0000 (18:20 -0700)]
dyninstAPI_RT: add DLLEXPORT to DYNINSTstaticMode

This variable is used by the mutator now, and it needs to be fully
exported to remain visible in a distro-packager stripped binary.

6 years agoparseAPI: return size_t from Function::num_blocks()
Josh Stone [Mon, 11 Aug 2014 19:38:50 +0000 (12:38 -0700)]
parseAPI: return size_t from Function::num_blocks()

Changing to size_t from int better matches the size of the underlying type,
and also allows comparison to other sizes without any "signed vs. unsigned"
warnings.  This function is new to 8.2, so API/ABI isn't a concern.

A few places which used num_blocks() in dyninstAPI are also updated to
size_t, but none of these are in public headers.

6 years agoSpringboard: revert a kludge from conflictInRelocated
Josh Stone [Mon, 11 Aug 2014 19:29:54 +0000 (12:29 -0700)]
Springboard: revert a kludge from conflictInRelocated

The root problem in springboards from relocated code should be solved by
commit de280f74f40e, so we can now allow this to return false again when
no reasons for conflict are found.

6 years agoproccontrol: correct the format string of a debug printf
Josh Stone [Mon, 11 Aug 2014 19:24:53 +0000 (12:24 -0700)]
proccontrol: correct the format string of a debug printf

6 years agodyninstAPI: Match EdgePredicateAdapter::pred_impl to its parent
Josh Stone [Mon, 21 Apr 2014 17:47:44 +0000 (10:47 -0700)]
dyninstAPI: Match EdgePredicateAdapter::pred_impl to its parent

GCC 4.8.2 says:

parseAPI/h/ParseContainers.h:58:15: warning: ‘bool Dyninst::ParseAPI::iterator_predicate<VALUE, REFERENCE>::pred_impl(REFERENCE) const [with VALUE = edge_instance*; REFERENCE = edge_instance*]’ was hidden [-Woverloaded-virtual]
  virtual bool pred_impl(const REFERENCE) const
dyninstAPI/src/block.h:75:17: warning:   by ‘virtual bool EdgePredicateAdapter::pred_impl(const edge_instance*) const’ [-Woverloaded-virtual]
    virtual bool pred_impl(const edge_instance *e) const { return int_->pred_impl(e->edge()); };

In this case, "REFERENCE" is "edge_instance *", and since the const
applies to the template type as a whole, the parameter at the base class
is effectively "edge_instance * const".  Derived EdgePredicateAdapter
needs to match that signature to avoid the warning.

Note: in iterator_predicate, with "REFERENCE = VALUE &", the effective
type of "const REFERENCE" is "VALUE & const", which is not a useful
thing to say since references are always unchanging.  The intent was
probably to arrive at "const VALUE &", equivalently "VALUE const &".
But since this is in a public interface, I'll leave it alone for now.

6 years agodoc updates
Bill Williams [Fri, 8 Aug 2014 18:51:29 +0000 (13:51 -0500)]
doc updates

6 years agoClean up handling of events on deleted llprocs.
Bill Williams [Fri, 8 Aug 2014 14:58:01 +0000 (09:58 -0500)]
Clean up handling of events on deleted llprocs.

6 years agoLogic cleanup
Bill Williams [Fri, 8 Aug 2014 00:01:21 +0000 (19:01 -0500)]
Logic cleanup

6 years agoFinal(?) cleanup
Bill Williams [Wed, 6 Aug 2014 20:46:45 +0000 (15:46 -0500)]
Final(?) cleanup

6 years agoMerge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2
Bill Williams [Wed, 6 Aug 2014 15:52:46 +0000 (10:52 -0500)]
Merge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Fri, 25 Jul 2014 16:22:35 +0000 (11:22 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoBugfix: it's not an error to get a post-exit event on a terminated process
Paradyn [Fri, 25 Jul 2014 16:19:52 +0000 (11:19 -0500)]
Bugfix: it's not an error to get a post-exit event on a terminated process

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Thu, 24 Jul 2014 21:55:09 +0000 (16:55 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoCleanup
Paradyn [Thu, 24 Jul 2014 21:51:48 +0000 (16:51 -0500)]

6 years agoProccontrol fixes
Paradyn [Thu, 24 Jul 2014 19:35:40 +0000 (14:35 -0500)]
Proccontrol fixes

6 years agoMerge branch 'v8.2' of ssh://follis/p/paradyn/development/bill/head/dyninst into...
Paradyn [Wed, 23 Jul 2014 16:18:20 +0000 (11:18 -0500)]
Merge branch 'v8.2' of ssh://follis/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Tue, 22 Jul 2014 16:09:58 +0000 (11:09 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Tue, 22 Jul 2014 16:09:50 +0000 (11:09 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2


6 years agoRemove windows hacks; we should get pre-exit from the RTlib now.
Bill Williams [Tue, 22 Jul 2014 16:09:13 +0000 (11:09 -0500)]
Remove windows hacks; we should get pre-exit from the RTlib now.

6 years agoStarting from the default size buffer, we try to read the memory map
Francis Deslauriers [Tue, 22 Jul 2014 16:06:09 +0000 (11:06 -0500)]
Starting from the default size buffer, we try to read the memory map
without allocating new space. If we reach the end of the buffer before
the end of the file, we allocate a buffer twice as big and try again.
When we reach the MAX_MAP_SIZE we return an error to the calling

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
6 years agoRevert bad fix.
Bill Williams [Tue, 22 Jul 2014 15:55:39 +0000 (10:55 -0500)]
Revert bad fix.

6 years agoAllow partial decoding of location lists in DWARF; this is a more graceful failure...
Bill Williams [Tue, 22 Jul 2014 15:55:26 +0000 (10:55 -0500)]
Allow partial decoding of location lists in DWARF; this is a more graceful failure than all-or-nothing, and we won't give the user any locations we don't understand.

6 years agoDocumentation updates
Bill Williams [Tue, 22 Jul 2014 15:54:47 +0000 (10:54 -0500)]
Documentation updates

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Mon, 21 Jul 2014 15:53:35 +0000 (10:53 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoGet RTlib events for pre-exit on Windows
Bill Williams [Mon, 21 Jul 2014 15:53:16 +0000 (10:53 -0500)]
Get RTlib events for pre-exit on Windows

6 years agoSpringboard: force traps on reinstrumentation that used NOP padding
Josh Stone [Thu, 17 Jul 2014 21:39:15 +0000 (14:39 -0700)]
Springboard: force traps on reinstrumentation that used NOP padding

If we consume NOP-padding between functions to get room for a jump, that
padding may not exist in the relocation buffer.  Remember such ranges so
we can deal with that in reinstrumentation, and force it to trap instead.

Relocation buffers might be closer together than the original functions,
so while a 5-byte jump was ok before, writing the same near the end of
one relocation buffer would overflow and clobber instructions in the next.

6 years agoproccontrol: Don't reference thread states too early
Josh Stone [Thu, 17 Jul 2014 21:26:55 +0000 (14:26 -0700)]
proccontrol: Don't reference thread states too early

There was a chicken-and-egg in the int_thread constructor:

- int_thread calls the constructor for its first state.
- StateTracker calls its own setState.
- setState reads the up_thr handler and generator states,
  which aren't initialized yet!

Thankfully it didn't actually use those uninitized states unless
up_thr->up_thread is set, which isn't until after the initializer
list is done.  So it was harmless, but technically undefined behavior.

The fix is to not even read the generator and handler states until
up_thread is set.

6 years agoTesting WIP
Bill Williams [Wed, 16 Jul 2014 18:32:44 +0000 (13:32 -0500)]
Testing WIP

6 years agoFix DYNINST_DEBUG_WRITE for empty writes
Josh Stone [Wed, 16 Jul 2014 01:02:46 +0000 (18:02 -0700)]
Fix DYNINST_DEBUG_WRITE for empty writes

PCProcess::writeDebugDataSpace was crashing on the null buffer when
amount is 0.  The for-loop test "i < amount-1" was underflowed, which
means it would try to loop until i = (unsigned)-1.

6 years agodyninstAPI: Stop the process when removing syscalls
Josh Stone [Fri, 11 Jul 2014 19:19:31 +0000 (12:19 -0700)]
dyninstAPI: Stop the process when removing syscalls

When detaching from a process, it needs to be stopped to remove syscall
instrumentation.  If it's not already, stop it first and continue after.

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Tue, 8 Jul 2014 19:29:29 +0000 (14:29 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoPossible fix for the debian/ubuntu bug of doom
Bill Williams [Tue, 8 Jul 2014 19:29:04 +0000 (14:29 -0500)]
Possible fix for the debian/ubuntu bug of doom

6 years agodynC: regenerate with newer bison and flex
Josh Stone [Tue, 1 Jul 2014 20:15:13 +0000 (13:15 -0700)]
dynC: regenerate with newer bison and flex

- Process C.l with flex 2.5.37.
- Process C.y with bison 2.7.
- Move dynC.tab.h out of public headers.

6 years agodynC: Fix soname and exports
Josh Stone [Tue, 1 Jul 2014 20:10:49 +0000 (13:10 -0700)]
dynC: Fix soname and exports

- Include dynC_API in the list of versioned libraries.
- Define DYNC_EXPORT and use it for createSnippet.

6 years agoKludge the CXX11 checks for cmake 2.6.4
Josh Stone [Tue, 1 Jul 2014 00:09:24 +0000 (17:09 -0700)]
Kludge the CXX11 checks for cmake 2.6.4

6 years agoFix Windows. Again.
Bill Williams [Fri, 27 Jun 2014 14:33:24 +0000 (09:33 -0500)]
Fix Windows. Again.

6 years agoMerge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2
Bill Williams [Fri, 27 Jun 2014 14:06:46 +0000 (09:06 -0500)]
Merge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2

6 years agoFix BGQ build errors
Matthew LeGendre [Wed, 25 Jun 2014 22:53:19 +0000 (15:53 -0700)]
Fix BGQ build errors

6 years agoAdd error returns to syscall tracing
Matthew LeGendre [Wed, 25 Jun 2014 22:52:59 +0000 (15:52 -0700)]
Add error returns to syscall tracing

6 years agoUndo swap to parseAPI data structures, as this is harmful
Bill Williams [Wed, 25 Jun 2014 20:23:30 +0000 (15:23 -0500)]
Undo swap to parseAPI data structures, as this is harmful

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Wed, 25 Jun 2014 16:50:41 +0000 (11:50 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoFix bad merge
Bill Williams [Wed, 25 Jun 2014 16:47:29 +0000 (11:47 -0500)]
Fix bad merge

6 years agoAdd missing exports
Bill Williams [Fri, 20 Jun 2014 15:29:18 +0000 (10:29 -0500)]
Add missing exports

6 years agoWindows build fixes.
Bill Williams [Wed, 25 Jun 2014 16:41:09 +0000 (11:41 -0500)]
Windows build fixes.

6 years agoMerge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dynin...
Bill Williams [Wed, 25 Jun 2014 15:46:48 +0000 (10:46 -0500)]
Merge branch 'v8.2' of ssh://follis.cs.wisc.edu/p/paradyn/development/bill/head/dyninst into v8.2

6 years agoDon't double-count exit events; this can lead to double-counting the main thread...
Bill Williams [Wed, 25 Jun 2014 15:41:35 +0000 (10:41 -0500)]
Don't double-count exit events; this can lead to double-counting the main thread's exit.

6 years agoRelax an invalid assert: if we post an RPC to a process that is (for example) exiting...
Bill Williams [Wed, 25 Jun 2014 15:41:02 +0000 (10:41 -0500)]
Relax an invalid assert: if we post an RPC to a process that is (for example) exiting, we may not have any threads available. Bail, don't assert.

6 years agoMerge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2
Paradyn [Mon, 23 Jun 2014 22:11:52 +0000 (17:11 -0500)]
Merge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2


6 years agoFixes ParseAPI block list access in CFGModifier
Mike Lam [Fri, 20 Jun 2014 18:48:18 +0000 (14:48 -0400)]
Fixes ParseAPI block list access in CFGModifier

7 years agoAdd missing exports
Bill Williams [Fri, 20 Jun 2014 15:29:18 +0000 (10:29 -0500)]
Add missing exports

7 years agoHave springboard system use parseapi data structures
Bill Williams [Fri, 20 Jun 2014 15:29:08 +0000 (10:29 -0500)]
Have springboard system use parseapi data structures

7 years agoSome final bits of fixup: keep block counts accurate, and allow blocks that are not...
Bill Williams [Thu, 19 Jun 2014 22:50:39 +0000 (17:50 -0500)]
Some final bits of fixup: keep block counts accurate, and allow blocks that are not in any function to be cannibalized for springboard space.

7 years agoMerge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2
Bill Williams [Thu, 19 Jun 2014 20:34:18 +0000 (15:34 -0500)]
Merge branch 'v8.2' of ssh://git.dyninst.org/pub/dyninst into v8.2

7 years agoAdd alternating entry/exit event mechanism for handling the ppc case
Bill Williams [Thu, 19 Jun 2014 20:04:43 +0000 (15:04 -0500)]
Add alternating entry/exit event mechanism for handling the ppc case

7 years agoFix for proper interaction between full syscall tracing and proper postponing of...
Bill Williams [Mon, 16 Jun 2014 16:02:21 +0000 (11:02 -0500)]
Fix for proper interaction between full syscall tracing and proper postponing of syscall callbacks in normal execution.

7 years agoppc fixes
William Williams [Fri, 13 Jun 2014 20:07:59 +0000 (13:07 -0700)]
ppc fixes

7 years agoGet pre-exit events via proccontrol callback.
Bill Williams [Wed, 11 Jun 2014 18:17:17 +0000 (13:17 -0500)]
Get pre-exit events via proccontrol callback.
Always report pre-exit events as normal exit, as we have an exit code and our best chance at a manipulable process then.
Decode exit code with ptrace's event message on pre-exit.

7 years agoDwarf FrameParsers are not uniquely determined by a DwarfHandle; there may be multipl...
Bill Williams [Wed, 11 Jun 2014 18:14:04 +0000 (13:14 -0500)]
Dwarf FrameParsers are not uniquely determined by a DwarfHandle; there may be multiple architectures present. Use the right one.

7 years agoBug fix for 32/64 operand sizes.
Bill Williams [Wed, 28 May 2014 20:19:16 +0000 (15:19 -0500)]
Bug fix for 32/64 operand sizes.

7 years agoFix crash bug: we need to finalize when we ask for num_blocks.
Bill Williams [Wed, 28 May 2014 20:18:51 +0000 (15:18 -0500)]
Fix crash bug: we need to finalize when we ask for num_blocks.

7 years agoPass size through into generateOptimizedAssignment and don't generate a 32-bit move...
Bill Williams [Mon, 19 May 2014 20:20:22 +0000 (15:20 -0500)]
Pass size through into generateOptimizedAssignment and don't generate a 32-bit move for a 64-bit assignment.

7 years agoWhitespace cleanup
Bill Williams [Fri, 9 May 2014 19:03:11 +0000 (14:03 -0500)]
Whitespace cleanup

7 years agoRemove ParseAPI's per-function vector of blocks, replacing it with a range of iterato...
Bill Williams [Fri, 9 May 2014 19:03:03 +0000 (14:03 -0500)]
Remove ParseAPI's per-function vector of blocks, replacing it with a range of iterators over the values of the addr->block map.

7 years agoDwarf parsing fix
Bill Williams [Fri, 9 May 2014 19:01:08 +0000 (14:01 -0500)]
Dwarf parsing fix

7 years agoDynC build fix
Bill Williams [Fri, 9 May 2014 19:00:53 +0000 (14:00 -0500)]
DynC build fix

7 years agoSyscall events cleanup
Bill Williams [Fri, 9 May 2014 19:00:40 +0000 (14:00 -0500)]
Syscall events cleanup

7 years agoC++11 detection on a per-feature basis via BSD-licensed CMake scripts (that will...
Bill Williams [Wed, 30 Apr 2014 15:51:44 +0000 (10:51 -0500)]
C++11 detection on a per-feature basis via BSD-licensed CMake scripts (that will become part of 2.8.x at some point).

7 years agoInitialize DYNINSTstaticMode=0 from the mutator if present, not from common init...
Bill Williams [Wed, 30 Apr 2014 15:49:22 +0000 (10:49 -0500)]
Initialize DYNINSTstaticMode=0 from the mutator if present, not from common init code.

7 years agoInitial dynC CMakeLists
Bill Williams [Wed, 30 Apr 2014 15:48:44 +0000 (10:48 -0500)]
Initial dynC CMakeLists

7 years agoSyscall merge cleanup
Bill Williams [Wed, 30 Apr 2014 15:48:22 +0000 (10:48 -0500)]
Syscall merge cleanup

7 years agoFix the *other* place where we need to make shdr alignment >= data alignment
Bill Williams [Tue, 25 Mar 2014 21:02:33 +0000 (16:02 -0500)]
Fix the *other* place where we need to make shdr alignment >= data alignment

7 years agoAdded syscalls/ directory with processing script and current unistd.h files
Emily R. Jacobson [Mon, 10 Jun 2013 14:47:03 +0000 (09:47 -0500)]
Added syscalls/ directory with processing script and current unistd.h files

7 years agoInitial implementation of system call events in ProcControlAPI.
Emily R. Jacobson [Mon, 10 Jun 2013 14:42:44 +0000 (09:42 -0500)]
Initial implementation of system call events in ProcControlAPI.

7 years agoIncrease FPOS value.
Ray Chen [Wed, 18 Jun 2014 07:51:26 +0000 (03:51 -0400)]
Increase FPOS value.

Otherwise, the operand semantic may overlap with the semantic flag
value.  For example, s1R2R3R would be equivalent to (fNT << FPOS).

7 years agoAdd entry for SSE cmpsd instruction.
Ray Chen [Wed, 18 Jun 2014 07:45:24 +0000 (03:45 -0400)]
Add entry for SSE cmpsd instruction.

This allows our decoder to correctly differentiate
between the "Compare String" family of instructions
(CMPS/CMPSB/CMPSW/CMPSD/CMPSQ), and the "Compare Scalar
Double-Precision Floating-Point Values" instruction (CMPSD).

7 years agoFix improper use of ia32_locations' REX fields.
Ray Chen [Wed, 18 Jun 2014 07:11:32 +0000 (03:11 -0400)]
Fix improper use of ia32_locations' REX fields.

The rex_[wrxb] fields of class ia32_locations store the unshifted
value of their corresponding bit.  This led to erroneous comparisons
(e.g., rex_w == 0x1) to test for presence.

To reduce confusion, all comparisons involving these fields now use
non-zero as a presence test.

7 years agoChange Symtab::getContainingFunction to use symbols for function lookups rather than...
Matthew LeGendre [Tue, 17 Jun 2014 23:49:43 +0000 (16:49 -0700)]
Change Symtab::getContainingFunction to use symbols for function lookups rather than DWARF ranges, which gives a significant memory/time savings to STAT.

7 years agodyninstAPI_RT: fix export consistency for Windows
Josh Stone [Tue, 3 Jun 2014 22:41:03 +0000 (15:41 -0700)]
dyninstAPI_RT: fix export consistency for Windows

7 years agosymtabAPI: Start dwarf type ids at 1
Josh Stone [Thu, 29 May 2014 01:26:42 +0000 (18:26 -0700)]
symtabAPI: Start dwarf type ids at 1

It turns out test_type_info doesn't like ID 0.

7 years agosymtabAPI: Use dyn_hash_map for type IDs, and split on is_info
Josh Stone [Thu, 29 May 2014 01:02:59 +0000 (18:02 -0700)]
symtabAPI: Use dyn_hash_map for type IDs, and split on is_info

A hash map affords faster lookup, especially for such simple keys.

Splitting into two maps, rather than using pair<offset,bool> as before,
also makes an easier key lookup and more optimized storage.

7 years agosymtabAPI: Protect against GNU alt forms
Josh Stone [Thu, 29 May 2014 00:29:41 +0000 (17:29 -0700)]
symtabAPI: Protect against GNU alt forms

Both DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt refer to an alternate
file, specified in .gnu_debugaltlink, which neither libdwarf or symtabAPI
currently understand.  We can at least recognize and skip past them though.

If we encounter a dwarf_diename() with an unhandled form, we now treat that
as if there weren't a name at all.  If we encounter a reference that's not
a normal offset, as with ref_alt, then this is now treated as a quiet
error, noted only in dwarf_printf.

7 years agosymtabAPI: walk partial units too
Josh Stone [Thu, 29 May 2014 00:22:54 +0000 (17:22 -0700)]
symtabAPI: walk partial units too

7 years agosymtabAPI: sanity-check line ranges
Josh Stone [Wed, 28 May 2014 22:20:22 +0000 (15:20 -0700)]
symtabAPI: sanity-check line ranges

Valgrind reported an invalid memory access in getLineInformation, which
turned out to be an index past the end of the srcFiles() vector.  Add a
sanity check to abort bad values.

7 years agosymtabAPI: Return a string from Object::getFileName
Josh Stone [Wed, 28 May 2014 19:34:12 +0000 (12:34 -0700)]
symtabAPI: Return a string from Object::getFileName

In Object-elf.C, getFileName was returning mf->filename().c_str(), which
is a use-after-free since mf->filename() is a temporary string.  Change
it to return the string instead, so it has a proper lifetime.

(Found via valgrind memcheck)

7 years agosymtabAPI: Automate context push/pop in DwarfWalker
Josh Stone [Wed, 28 May 2014 19:28:42 +0000 (12:28 -0700)]
symtabAPI: Automate context push/pop in DwarfWalker

In DwarfWalker::parse_int, there are many exit points between context push
and pop, especially for errors.  If the pop is missed, then the whole stack
may get into a bad state.  This patch adds a ContextGuard which manages the
push and pop via object lifetime, so all exit paths will be covered.

7 years agosymtabAPI: improve sig8 identification
Josh Stone [Wed, 28 May 2014 19:15:49 +0000 (12:15 -0700)]
symtabAPI: improve sig8 identification

- Give type units a module name based on the signature.
- Declare type units in dwarf_printf while walking.

7 years agosymtabAPI: Enable DW_FORM_ref_sig8
Josh Stone [Wed, 28 May 2014 00:57:43 +0000 (17:57 -0700)]
symtabAPI: Enable DW_FORM_ref_sig8

DwarfWalker first scans for DW_TAG_type_unit and allocates a type ID for
each signature, so that later DW_FORM_ref_sig8 can look it up later.
When the actual type die is walked, its offset will map to the same ID.

7 years agosymtabAPI: Walk both .debug_types and .debug_info
Josh Stone [Tue, 27 May 2014 23:06:26 +0000 (16:06 -0700)]
symtabAPI: Walk both .debug_types and .debug_info

7 years agosymtabAPI: Add indirection between dwarf offsets and type IDs
Josh Stone [Tue, 27 May 2014 22:22:36 +0000 (15:22 -0700)]
symtabAPI: Add indirection between dwarf offsets and type IDs

The identity mapping between dwarf offsets and int type IDs is
problematic because offsets are actually 64-bit, so they may overflow an
int on 2GB+ files.  Offsets are also relative to their section, which
can be either .debug_info or .debug_types, so that overlap also needs to
be avoided.

The new DwarfWalker::type_ids_ maps between a pair offset,is_info to
typeId_t values incremented on demand.

7 years agosymtabAPI: Remove unused dwarf enclosureMap
Josh Stone [Tue, 27 May 2014 22:06:56 +0000 (15:06 -0700)]
symtabAPI: Remove unused dwarf enclosureMap

7 years agosymtabAPI: Extend recognized DW_LANG constants
Josh Stone [Fri, 23 May 2014 23:32:07 +0000 (16:32 -0700)]
symtabAPI: Extend recognized DW_LANG constants

DW_LANG_C99 has existed since DWARF3, with support in libdwarf too.
DWARF5 will add constants for C++03, C++11, and C11, and we can prepare
for these now with simple #ifdefs.


7 years agosymtabAPI: Add support for DW_AT_linkage_name
Josh Stone [Fri, 23 May 2014 22:47:00 +0000 (15:47 -0700)]
symtabAPI: Add support for DW_AT_linkage_name

The common DW_AT_MIPS_linkage_name extension was added to DWARF4 as
DW_AT_linkage_name, with the exact same meaning.

7 years agosymtabAPI: Switch to .debug_types-aware libdwarf interfaces
Josh Stone [Fri, 23 May 2014 22:28:17 +0000 (15:28 -0700)]
symtabAPI: Switch to .debug_types-aware libdwarf interfaces

There's an is_info parameter in dwarf_offdie_b, dwarf_siblingof_b, and
dwarf_next_cu_header_c which let's callers specify if the context is
.debug_info or .debug_types.  While symtabAPI only bothers with info at
the moment, changing to these functions will prepare for types later.

These interfaces have been in libdwarf since 20111030, and header_c was
already used in a couple places, so the requirements haven't changed.

7 years agosymtabAPI: Don't hardcode the CU header size
Josh Stone [Fri, 23 May 2014 21:41:19 +0000 (14:41 -0700)]
symtabAPI: Don't hardcode the CU header size

DwarfWalker::compile_offset was being set as 11 bytes before the first
die in a cu, but this isn't always correct. (see DWARF sec 7.4 & 7.5.1)
However, we already have the next_cu_header to tells us the offset of
each following cu in the loop.