7 years agodyninstAPI: Limit cerr messages to debug mode
Josh Stone [Fri, 7 Feb 2014 02:13:42 +0000 (18:13 -0800)]
dyninstAPI: Limit cerr messages to debug mode

A few places in AddressSpace were writing directly to cerr, when they
ought to save messages for debug-enabled cerr only.

7 years agodyninstAPI: Check for termination after removing tracedSyscalls
Josh Stone [Fri, 7 Feb 2014 02:11:31 +0000 (18:11 -0800)]
dyninstAPI: Check for termination after removing tracedSyscalls

It's possible to get markExited() while handling events for the
tracedSyscalls_->remove* calls, which makes the following pcProc_->detach()
a NULL dereference.  Simply calling isTerminated() protects this case.

7 years agodyninstAPI: Continue after loadLibrary
Josh Stone [Fri, 7 Feb 2014 02:07:27 +0000 (18:07 -0800)]
dyninstAPI: Continue after loadLibrary

If BPatch_process::loadLibrary() had to stop the process at its start,
then it should also continue execution before returning.  This was changed
in commit 3faa4175c8100, a large commit with no explanation for this
particular change, possibly an accident.

7 years agoUse const string& parameters for stats
Josh Stone [Tue, 28 Jan 2014 02:19:50 +0000 (18:19 -0800)]
Use const string& parameters for stats

The stats functions don't need mutable parameters, so a const& suffices
just fine.  Also convert all the fixed string names of counters and
timers from string literals to std::string in dyninstAPI and parseAPI.

Even when stats were disabled, there was a fair amount of time spent
just preparing the string object for stats calls.  The optimization of
this patch shows 5-10% reduction in parse time on large binaries.

7 years agoIncrease Instruction::raw_insn_T.small_insn size
Josh Stone [Tue, 28 Jan 2014 01:59:43 +0000 (17:59 -0800)]
Increase Instruction::raw_insn_T.small_insn size

By making this union .small_insn a uintptr_t, so it's the same size as
.large_insn, we can avoid some memory allocation without taking any more
memory in Instruction itself.  (PPC instructions are always 32-bit, so
there it's left as unsigned int.)

With this optimization on x86_64, the number of large_insn allocations
required is greatly reduced.  Many instructions are more than 4 bytes,
but it's less common to have more than 8 bytes.

7 years agocommon: Skip get_immediate_operand without any imm
Josh Stone [Tue, 28 Jan 2014 01:45:32 +0000 (17:45 -0800)]
common: Skip get_immediate_operand without any imm

For x86 image::findMain, we blindly look for the first call from the
entry address, then grab the immediate operand from the preceding
instruction.  Sometimes that instruction may not even have any immediate
operands, and the heuristic fails with a message on stderr like:

  arch-x86.C[5602]:  invalid immediate size 0 in insn

This now occurs with some ET_DYN binaries that are allowed by commit
44205dbd2d90, when those are really DSOs and not PIE.  However, this
could conceivably also happen for any executable that doesn't fit the
heuristic pattern.

This patch quietly returns 0 from get_immediate_operand when there are
no operands, and image::findMain will treat this as an invalid address.

7 years agoMerge branch 'jistone/coverity'
Josh Stone [Wed, 12 Feb 2014 22:07:45 +0000 (14:07 -0800)]
Merge branch 'jistone/coverity'

7 years agoMerge branch 'jistone/platform'
Josh Stone [Wed, 12 Feb 2014 22:05:55 +0000 (14:05 -0800)]
Merge branch 'jistone/platform'


7 years agoMerge branch 'master' of git.dyninst.org:/pub/dyninst
Matthew LeGendre [Tue, 4 Feb 2014 18:52:32 +0000 (10:52 -0800)]
Merge branch 'master' of git.dyninst.org:/pub/dyninst

7 years agoRemove prints that were triggering when disassembling libraries under findMain
Matthew LeGendre [Tue, 4 Feb 2014 00:56:12 +0000 (16:56 -0800)]
Remove prints that were triggering when disassembling libraries under findMain

7 years agoAllow Linux to build while implementing memory usage interface
Matthew LeGendre [Mon, 3 Feb 2014 23:15:24 +0000 (15:15 -0800)]
Allow Linux to build while implementing memory usage interface

7 years agoMerge branch 'master' of git.dyninst.org:/pub/dyninst
Matthew LeGendre [Mon, 3 Feb 2014 23:10:30 +0000 (15:10 -0800)]
Merge branch 'master' of git.dyninst.org:/pub/dyninst

7 years agoFix issue with dwarf range offsets being used with incorrect base addresses.
Matthew LeGendre [Mon, 3 Feb 2014 23:09:59 +0000 (15:09 -0800)]
Fix issue with dwarf range offsets being used with incorrect base addresses.

7 years agoMoved r_debug assert to the Linux runDYNINSTBaseInit()
Emily Jacobson [Mon, 3 Feb 2014 21:53:04 +0000 (15:53 -0600)]
Moved r_debug assert to the Linux runDYNINSTBaseInit()

7 years agoInstall public dataflowAPI headers
Emily Jacobson [Thu, 30 Jan 2014 17:54:30 +0000 (11:54 -0600)]
Install public dataflowAPI headers

7 years agoFix accumulate() in alias.isAlias case to record transfer func
Emily Jacobson [Thu, 30 Jan 2014 17:45:40 +0000 (11:45 -0600)]
Fix accumulate() in alias.isAlias case to record transfer func
whose target is the current target (rather than alias.target).

7 years agoHandle cyclic dependencies in fixpoint algorithm in stackanalysis
Emily Jacobson [Thu, 30 Jan 2014 17:43:06 +0000 (11:43 -0600)]
Handle cyclic dependencies in fixpoint algorithm in stackanalysis

7 years agoMerge branch 'master' of git.dyninst.org:/pub/dyninst
Matthew LeGendre [Mon, 27 Jan 2014 18:45:41 +0000 (10:45 -0800)]
Merge branch 'master' of git.dyninst.org:/pub/dyninst


7 years agoUpdated parseAPI documentation PDF (missed in previous commit)
Emily Jacobson [Mon, 27 Jan 2014 16:36:42 +0000 (10:36 -0600)]
Updated parseAPI documentation PDF (missed in previous commit)

7 years agoFixed SymtabAPI documentation example 3 to use current API
Emily Jacobson [Mon, 27 Jan 2014 16:35:26 +0000 (10:35 -0600)]
Fixed SymtabAPI documentation example 3 to use current API

7 years agoExport r_debug from the RTlib on Linux and
Emily Jacobson [Wed, 22 Jan 2014 19:10:39 +0000 (13:10 -0600)]
Export r_debug from the RTlib on Linux and
verify that it's properly present before trying to use.

7 years agodyninstAPI: Fix a debug vsnprintf length
Josh Stone [Tue, 21 Jan 2014 02:17:27 +0000 (18:17 -0800)]
dyninstAPI: Fix a debug vsnprintf length

The vsnprintf call is writing to an offset in the fixed errbuf, so it
needs to subtract that offset from the length told to vsnprintf.

Reported by coverity as OVERRUN.

7 years agodyninstAPI: Pad the fixed x86 instructions
Josh Stone [Tue, 21 Jan 2014 02:15:24 +0000 (18:15 -0800)]
dyninstAPI: Pad the fixed x86 instructions

The arrays used to generate illegal & trap instructions can be static
const, but still the analyzer doesn't see that the instruction decoder
won't actually read past their ends.  It's not a big deal to just pad
both illegalRep[] and trapRep[] to 8 bytes to be sure.

Reported by coverity as OVERRUN.

7 years agosymtabAPI: Initialize locals in read_except_table_gcc2
Josh Stone [Tue, 21 Jan 2014 01:35:10 +0000 (17:35 -0800)]
symtabAPI: Initialize locals in read_except_table_gcc2

These can't actually be unset unless the address size was something other
than 4 or 8, but the static analyzer doesn't know that invariant.

Reported by coverity as UNINIT.

7 years agosymtabAPI: Error out on unknown createRelocationSections
Josh Stone [Tue, 21 Jan 2014 01:33:25 +0000 (17:33 -0800)]
symtabAPI: Error out on unknown createRelocationSections

It shouldn't happen, but to the static analyzer it looks like an odd
relocation combination in createRelocationSections will lead to using
unset local variables.  Add a quick check to make sure we got something.

Reported by coverity as UNINIT.

7 years agostackwalk: Fix result logic in getInitialFrameImpl
Josh Stone [Tue, 21 Jan 2014 01:30:33 +0000 (17:30 -0800)]
stackwalk: Fix result logic in getInitialFrameImpl

The former "result = !result || getRegValue(...)" ends up toggling any
failed states.  A "result = result && ..." instead maintains failure.

Reported by coverity as UNINIT.

7 years agoinstructionAPI: Don't try to delete in Instruction copy ctor
Josh Stone [Tue, 21 Jan 2014 01:26:53 +0000 (17:26 -0800)]
instructionAPI: Don't try to delete in Instruction copy ctor

The Instruction copy constructor was trying to check the previous m_size
and delete previous m_RawInsn before copying, but there isn't any previous
state because this is a new object.

Reported by coverity as UNINIT.

7 years agodyninstAPI: Check the bounds of boundsArray
Josh Stone [Tue, 21 Jan 2014 01:24:52 +0000 (17:24 -0800)]
dyninstAPI: Check the bounds of boundsArray

When merging contiguous ranges of boundsArray, the code failed to make
sure that the array has anything in it yet.

Reported by coverity as UNINIT.

7 years agodyninstAPI: Make sure dominator nullNode always looks initialized
Josh Stone [Tue, 21 Jan 2014 01:21:52 +0000 (17:21 -0800)]
dyninstAPI: Make sure dominator nullNode always looks initialized

There's a mutual dependency between dominatorCFG and dominatorBB in how
nullNode is initialized.  To the analyzer, it looks like the uninitialized
pointer is used in BB, even though CFG straightens it out immediately.
Letting nullNode start NULL clears up the confusion.

Reported by coverity as UNINIT.

7 years agocommon: Initialize SymReader structs to zero
Josh Stone [Tue, 21 Jan 2014 01:18:29 +0000 (17:18 -0800)]
common: Initialize SymReader structs to zero

Reported by coverity as UNINIT at various use sites.

7 years agosymtabAPI: Fix coverity UNINIT_CTOR errors
Josh Stone [Mon, 20 Jan 2014 23:23:43 +0000 (15:23 -0800)]
symtabAPI: Fix coverity UNINIT_CTOR errors

7 years agopatchAPI: Fix coverity UNINIT_CTOR errors
Josh Stone [Mon, 20 Jan 2014 23:23:24 +0000 (15:23 -0800)]
patchAPI: Fix coverity UNINIT_CTOR errors

7 years agodyninstAPI: Fix coverity UNINIT_CTOR errors
Josh Stone [Mon, 20 Jan 2014 23:21:57 +0000 (15:21 -0800)]
dyninstAPI: Fix coverity UNINIT_CTOR errors

7 years agodyninstAPI: Remove mapped_object::getModulePart()
Josh Stone [Fri, 17 Jan 2014 22:11:38 +0000 (14:11 -0800)]
dyninstAPI: Remove mapped_object::getModulePart()

The last in-tree caller was removed in commit f2869360c0f0, over 16
years ago, when it was shared_object.  Since mapped_object is now an
internal class, it should be perfectly safe to remove this.

This function was flagged by cppcheck for mismatched allocation, using
delete on strdup memory.

7 years agoClean up bad merge
Bill Williams [Fri, 17 Jan 2014 22:12:31 +0000 (16:12 -0600)]
Clean up bad merge

7 years agoCMake 2.6 compatibility fixes.
Bill Williams [Wed, 15 Jan 2014 19:51:31 +0000 (13:51 -0600)]
CMake 2.6 compatibility fixes.

More messages during build

7 years agoWarning cleanup
Bill Williams [Wed, 15 Jan 2014 19:51:15 +0000 (13:51 -0600)]
Warning cleanup

7 years agoMerge branch 'findMain'
Josh Stone [Fri, 17 Jan 2014 02:44:54 +0000 (18:44 -0800)]
Merge branch 'findMain'

7 years agoRemove remnant .cvsignore files
Josh Stone [Thu, 16 Jan 2014 22:15:38 +0000 (14:15 -0800)]
Remove remnant .cvsignore files

7 years agoisTailcall fix: fallthroughs are not tailcalls
Emily Jacobson [Thu, 16 Jan 2014 20:06:12 +0000 (14:06 -0600)]
isTailcall fix: fallthroughs are not tailcalls

7 years agoRemove HP/UX remnant
Josh Stone [Thu, 16 Jan 2014 20:29:50 +0000 (12:29 -0800)]
Remove HP/UX remnant

7 years agoRemove remnants of IA64
Josh Stone [Thu, 16 Jan 2014 20:22:48 +0000 (12:22 -0800)]
Remove remnants of IA64

7 years agocommon: Note FreeBSD in Types.h
Josh Stone [Thu, 16 Jan 2014 19:56:05 +0000 (11:56 -0800)]
common: Note FreeBSD in Types.h

7 years agoPurge AIX support
Josh Stone [Thu, 16 Jan 2014 19:54:18 +0000 (11:54 -0800)]
Purge AIX support

7 years agoRemove remnants of Sparc and Solaris
Josh Stone [Thu, 16 Jan 2014 18:18:40 +0000 (10:18 -0800)]
Remove remnants of Sparc and Solaris

7 years agoRemove remnants of Alpha and OSF
Josh Stone [Thu, 16 Jan 2014 02:39:48 +0000 (18:39 -0800)]
Remove remnants of Alpha and OSF

7 years agoRemove remnants of MIPS, including IRIX and WinCE
Josh Stone [Thu, 16 Jan 2014 02:10:45 +0000 (18:10 -0800)]
Remove remnants of MIPS, including IRIX and WinCE

7 years agodyninstAPI: Set image::findMain's findings as LOCAL/INTERNAL
Josh Stone [Wed, 15 Jan 2014 19:20:32 +0000 (11:20 -0800)]
dyninstAPI: Set image::findMain's findings as LOCAL/INTERNAL

When we look for new symbols in image::findMain, it's not really the
intent to make these global/exported symbols.  It doesn't matter so much
for live processes, but these shouldn't be exported in rewritten
binaries.  This patch sets them as LOCAL and INTERNAL instead.

Note, this is only for Linux and FreeBSD, but Windows may want it too.

7 years agoMerge branch 'master' of git.dyninst.org:/pub/dyninst
Matthew LeGendre [Wed, 15 Jan 2014 00:10:57 +0000 (16:10 -0800)]
Merge branch 'master' of git.dyninst.org:/pub/dyninst


7 years agodyninstAPI: Expand powerpc support in image::findMain
Josh Stone [Tue, 14 Jan 2014 20:34:10 +0000 (12:34 -0800)]
dyninstAPI: Expand powerpc support in image::findMain

First, this function needs to respect the ELF entry address, rather than
assuming that entry is at the start of the .text section.  This was
already handled in x86, so we just need the same in powerpc.

Second, we need to add ppc64 support to the section which currently
handles ppc32.  This requires dereferencing .opd indirection, and ppc64
also uses a TOC-based load which the current dataflowAPI code can't
handle.  For this case, just use a simple InstructionAPI eval with the
known TOC r2 register.

7 years agodyninstAPI: Let image::findMain inspect PIE too
Josh Stone [Tue, 14 Jan 2014 21:39:36 +0000 (13:39 -0800)]
dyninstAPI: Let image::findMain inspect PIE too

Position-independent executables (PIE) are generally indistinguishable
from any other shared object, but we still need to find main() in these
when they're stripped.  One clue is the presence of INTERP, which PIEs
will always have.  (Some DSOs also have INTERP, but this is rare.)

7 years agoFix AddressSpace initialization order
Josh Stone [Tue, 14 Jan 2014 22:14:39 +0000 (14:14 -0800)]
Fix AddressSpace initialization order

7 years agoFix another unused parameter
Josh Stone [Tue, 14 Jan 2014 22:14:22 +0000 (14:14 -0800)]
Fix another unused parameter

7 years agoBetter warning fix for unused parameters
Josh Stone [Tue, 14 Jan 2014 22:12:10 +0000 (14:12 -0800)]
Better warning fix for unused parameters

Commit f284f869b0b4 turned unused parameters into unused "dummy"
variables, which gcc 4.8 still warns about.  Using the parameter in a
void expression is a more reliable workaround.

7 years agoFix to handleCondDirExits
Emily Jacobson [Tue, 14 Jan 2014 17:03:16 +0000 (11:03 -0600)]
Fix to handleCondDirExits

7 years agoRemoved nonexistent API call in ParseAPI::Block documentation
Emily Jacobson [Thu, 9 Jan 2014 17:53:44 +0000 (11:53 -0600)]
Removed nonexistent API call in ParseAPI::Block documentation

7 years agoFinish the plumbing to ensure that added libraries including the RTlib get DT_NEEDED...
Bill Williams [Mon, 13 Jan 2014 20:14:43 +0000 (14:14 -0600)]
Finish the plumbing to ensure that added libraries including the RTlib get DT_NEEDED = SONAME.

7 years agoWarning fix
Bill Williams [Mon, 13 Jan 2014 19:08:24 +0000 (13:08 -0600)]
Warning fix

7 years agoBuild fix
Bill Williams [Mon, 13 Jan 2014 19:08:17 +0000 (13:08 -0600)]
Build fix

7 years agofileName() returns SONAME if present now, for proper DT_NEEDED updates when rewriting
Bill Williams [Fri, 10 Jan 2014 23:08:12 +0000 (17:08 -0600)]
fileName() returns SONAME if present now, for proper DT_NEEDED updates when rewriting

7 years agoRe-transpose arguments, because CMake 2.6 is dumb
Bill Williams [Fri, 10 Jan 2014 23:07:33 +0000 (17:07 -0600)]
Re-transpose arguments, because CMake 2.6 is dumb

7 years agoProper fix for building RTlib under CMake 2.6
Bill Williams [Fri, 10 Jan 2014 19:06:35 +0000 (13:06 -0600)]
Proper fix for building RTlib under CMake 2.6

7 years agoTwo more CMake 2.6 fixes: proper order of arguments, and only use LINK_PRIVATE where...
Bill Williams [Thu, 9 Jan 2014 21:34:21 +0000 (15:34 -0600)]
Two more CMake 2.6 fixes: proper order of arguments, and only use LINK_PRIVATE where it's supported.

7 years agoFixed a CMake 2.6 bug where it wouldn't recognize libdwarf_imp as a target (and thus...
Bill Williams [Thu, 9 Jan 2014 16:44:21 +0000 (10:44 -0600)]
Fixed a CMake 2.6 bug where it wouldn't recognize libdwarf_imp as a target (and thus wouldn't add a libelf_imp dependency) if we weren't building our own libdwarf. Also cleaned up indentation (as in, it exists now in these CMake files).

7 years agoIncrease BG/Q attach timeout to five minutes.
Matthew LeGendre [Tue, 7 Jan 2014 20:33:30 +0000 (12:33 -0800)]
Increase BG/Q attach timeout to five minutes.

7 years agoMerge branch 'master' of git.dyninst.org:/pub/dyninst
Matthew LeGendre [Tue, 7 Jan 2014 18:31:01 +0000 (10:31 -0800)]
Merge branch 'master' of git.dyninst.org:/pub/dyninst

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

7 years agoChange __FILE__ to FILE__ prints in stackwalker to shorten logs
Matthew LeGendre [Tue, 7 Jan 2014 18:28:50 +0000 (10:28 -0800)]
Change __FILE__ to FILE__ prints in stackwalker to shorten logs

7 years agoFix PC/BGQ crashes on attach timeout
Matthew LeGendre [Tue, 7 Jan 2014 18:28:07 +0000 (10:28 -0800)]
Fix PC/BGQ crashes on attach timeout

7 years agoImplement PC memory usage interface on BGQ
Matthew LeGendre [Tue, 7 Jan 2014 18:26:27 +0000 (10:26 -0800)]
Implement PC memory usage interface on BGQ

7 years agoFix issue with optimization options not being used in RT library build
Matthew LeGendre [Tue, 7 Jan 2014 18:19:20 +0000 (10:19 -0800)]
Fix issue with optimization options not being used in RT library build

7 years agoWIP for testing: properly track springboard locations persistently and per-process...
Bill Williams [Mon, 6 Jan 2014 18:56:30 +0000 (12:56 -0600)]
WIP for testing: properly track springboard locations persistently and per-process, rather than only persistent tracking of traps, globally

7 years agoClean up proccontrol debugging prints. We now print base filenames rather than full...
Matthew LeGendre [Fri, 20 Dec 2013 18:31:46 +0000 (10:31 -0800)]
Clean up proccontrol debugging prints.  We now print base filenames rather than full paths in printfs

7 years agoClean RT library cmake cache before configuring to work around cmake bug where re...
Matthew LeGendre [Fri, 20 Dec 2013 18:31:09 +0000 (10:31 -0800)]
Clean RT library cmake cache before configuring to work around cmake bug where re-running cmake forgets the CMAKE_INSTALL_PREFIX

7 years agoFix procset iterator: we can't necessarily initialize the container from NULL. Had...
Bill Williams [Thu, 19 Dec 2013 17:37:52 +0000 (11:37 -0600)]
Fix procset iterator: we can't necessarily initialize the container from NULL. Had better be able to default-construct it though.

7 years agosymtabAPI: Trim AObject and Object constructors.
Josh Stone [Wed, 18 Dec 2013 00:50:58 +0000 (16:50 -0800)]
symtabAPI: Trim AObject and Object constructors.

Neither of these classes should ever be copied, so declare the standard
copy constructors as private, without implementation; operator= as well.
Remove a few other unimplemented constructors too.

Note: The updates to Object-nt were made by inspection only and should
be checked.  Object-coff and Object-xcoff were already using obsolete
AObject constructors; if dead they should be considered for removal.

7 years agoInitialize thrd in a new FrameNode ctor
Josh Stone [Sat, 14 Dec 2013 02:31:02 +0000 (18:31 -0800)]
Initialize thrd in a new FrameNode ctor

Reported by Coverity as UNINIT_CTOR.

7 years agoInitialize and free PSetFeatures::memset
Josh Stone [Sat, 14 Dec 2013 02:26:20 +0000 (18:26 -0800)]
Initialize and free PSetFeatures::memset

Reported by Coverity as UNINIT_CTOR

7 years agostackwalk: convert some stderr chatter to sw_printf
Josh Stone [Fri, 6 Dec 2013 19:32:46 +0000 (11:32 -0800)]
stackwalk: convert some stderr chatter to sw_printf

7 years agosymtabAPI: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:56:55 +0000 (10:56 -0800)]
symtabAPI: Fix Coverity UNINIT_CTOR errors

7 years agosymlite: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:56:46 +0000 (10:56 -0800)]
symlite: Fix Coverity UNINIT_CTOR errors

7 years agostackwalk: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:56:37 +0000 (10:56 -0800)]
stackwalk: Fix Coverity UNINIT_CTOR errors

7 years agoproccontrol: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:56:24 +0000 (10:56 -0800)]
proccontrol: Fix Coverity UNINIT_CTOR errors

7 years agoparseAPI: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:56:11 +0000 (10:56 -0800)]
parseAPI: Fix Coverity UNINIT_CTOR errors

7 years agoinstructionAPI: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:55:53 +0000 (10:55 -0800)]
instructionAPI: Fix Coverity UNINIT_CTOR errors

7 years agoelf: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:55:40 +0000 (10:55 -0800)]
elf: Fix Coverity UNINIT_CTOR errors

7 years agodataflowAPI: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:55:31 +0000 (10:55 -0800)]
dataflowAPI: Fix Coverity UNINIT_CTOR errors

7 years agocommon: Fix Coverity UNINIT_CTOR errors
Josh Stone [Fri, 6 Dec 2013 18:54:58 +0000 (10:54 -0800)]
common: Fix Coverity UNINIT_CTOR errors

7 years agoUse 'delete' for objects created with 'new'
Josh Stone [Wed, 4 Dec 2013 00:58:45 +0000 (16:58 -0800)]
Use 'delete' for objects created with 'new'

These two instances were incorrectly using free().

Reported by clang-analyzer as Memory Error : Bad deallocator.

7 years agoFix accidental switch fallthrough
Josh Stone [Fri, 22 Nov 2013 20:13:59 +0000 (12:13 -0800)]
Fix accidental switch fallthrough

These were reported by Coverity as MISSING_BREAK, and it seems true -
they should not be falling through to the next case.  Add breaks.

7 years agoAnnotate intentional switch fallthrough
Josh Stone [Fri, 22 Nov 2013 20:11:30 +0000 (12:11 -0800)]
Annotate intentional switch fallthrough

These were reported by Coverity as MISSING_BREAK, but they're
intentionally falling through to the next case.  Coverity will infer
this intent if there's a comment in the last line instead of a break.

7 years agoReimplement Linux P_copy with fstream
Josh Stone [Fri, 22 Nov 2013 19:18:11 +0000 (11:18 -0800)]
Reimplement Linux P_copy with fstream

Coverity reported RESOURCE_LEAK for the fds on error paths, and I see it
also doesn't check write() return value.  It's much easier to just let
fstream do the buffer management and IO.

Note: P_copy doesn't appear to actually be used anywhere, and the former
destination mode 0 was also suspicious.  Maybe it should be removed.

7 years agoReimplement getLinuxMaps in real C++
Josh Stone [Fri, 22 Nov 2013 02:44:37 +0000 (18:44 -0800)]
Reimplement getLinuxMaps in real C++

Coverity reported a few OVERFLOW weaknesses in the previous buffer-happy
code.  The whole function is much simpler using fstream to read maps.

7 years agoemitElf: Fix possible sign-extension errors
Josh Stone [Fri, 22 Nov 2013 00:56:36 +0000 (16:56 -0800)]
emitElf: Fix possible sign-extension errors

When you have an expression type "<uint64_t> = <uint16_t> * <uint16_t>",
it sadly takes a detour into signed values.  The operands will be
promoted to int, then multiplied, then sign-extended to finally fill
uint64_t.  If the multiplication result is greater than 0x7fffffff,
overflowing int, then the top 32 bits of the uint64_t will all be 1s.
(That's if the compiler doesn't blow up the int overflow as undefined.)

The easiest solution is to forcefully promote the operands to the target
size and sign before multiplying.

Reported by Coverity as SIGN_EXTENSION.

7 years agostackwalk: Don't leak CallChecker instances
Josh Stone [Fri, 22 Nov 2013 00:28:01 +0000 (16:28 -0800)]
stackwalk: Don't leak CallChecker instances

Both AnalysisStepperImpl and WandererHelper create CallCheckers in their
constructors, so they should delete in their deconstructors.

Reported by Coverity as CTOR_DTOR_LEAK.

7 years agoproccontrol: Flatten up_notify as a member of int_notify
Josh Stone [Thu, 21 Nov 2013 23:53:04 +0000 (15:53 -0800)]
proccontrol: Flatten up_notify as a member of int_notify

In the int_notify ctor, up_notify is newed, but this member is never
deleted.  Since this object never changes, it doesn't need to be a
pointer at all, so make it a direct member.

However, int_notify is a singleton that's never deleted, so the overall
leakiness isn't really changed here.

Reported by Coverity as CTOR_DTOR_LEAK.

7 years agosymlite: Use pread rather than lseek save/restore
Josh Stone [Thu, 21 Nov 2013 23:34:44 +0000 (15:34 -0800)]
symlite: Use pread rather than lseek save/restore

In SymLite::getInterpreterName, it was doing a SEEK_CUR, SEEK_SET,
read(), then SEEK_SET back to the original offset.  This can all be
replaced by using pread() to read from any offset without affecting the
actual file offset.

The former lseeks triggered Coverity CHECKED_RETURN & NEGATIVE_RETURNS.

7 years agocommon: Fix a sizeof error in calloc/realloc
Josh Stone [Thu, 21 Nov 2013 04:37:44 +0000 (20:37 -0800)]
common: Fix a sizeof error in calloc/realloc

An allocation resulting in (anno_list_t*) should not use the pointer
size, but rather sizeof(anno_list_t).  It just happened to be harmless
here because anno_list_t is itself typedef void*, so the same size.

Reported by Coverity as SIZEOF_MISMATCH.

7 years agopatchAPI: Remove 'during' before destroying it
Josh Stone [Thu, 21 Nov 2013 01:01:55 +0000 (17:01 -0800)]
patchAPI: Remove 'during' before destroying it

In PatchParseCallback::remove_edge_cb, if it has pe->points_.during,
then this is both destroyed and removed from PatchFunctions.  However,
PatchCallback::destroy will delete the point if not batching, and
PatchFunction::remove dereferences it, so destroy must come after.

Reported by Coverity as USE_AFTER_FREE.

7 years agoproccontrol: Avoid dereferencing a deleted 'this'
Josh Stone [Thu, 21 Nov 2013 00:55:09 +0000 (16:55 -0800)]
proccontrol: Avoid dereferencing a deleted 'this'

In linux_process::preTerminate, a debug message asking, "Is this irony?"
has its own irony by calling getPid() when 'this' was just deleted.

Reported by Coverity as USE_AFTER_FREE.

7 years agosymlite: Don't use a delete pointer
Josh Stone [Thu, 21 Nov 2013 00:47:44 +0000 (16:47 -0800)]
symlite: Don't use a delete pointer

In SymElfFactory::closeSymbolReader, if 'ser' isn't in open_symelfs,
then it is deleted, so the function should return without using 'ser'
any more.

Reported by Coverity as USE_AFTER_FREE.