dyninst.git
6 years agoMerge branch 'jistone/coverity'
Josh Stone [Mon, 4 Nov 2013 21:51:48 +0000 (13:51 -0800)]
Merge branch 'jistone/coverity'

6 years agoFix infinite loops in x86/x86_64 tc_lock_lock
Josh Stone [Thu, 24 Oct 2013 04:03:08 +0000 (21:03 -0700)]
Fix infinite loops in x86/x86_64 tc_lock_lock

With -fvisibility=hidden, gcc gets too smart and inlines atomic_set into
tc_lock_lock.  The optimizer can't tell that the asm in atomic_set is
changing anything, because its input is a fixed pointer, not the
volatile value it points too.  So the x86_64 lock loop looks like this:

  34:   48 c7 c0 01 00 00 00    mov    $0x1,%rax
  3b:   48 89 d9                mov    %rbx,%rcx
  3e:   f0 48 87 01             lock xchg %rax,(%rcx)
  42:   48 89 c2                mov    %rax,%rdx
  45:   0f 1f 00                nopl   (%rax)
  48:   48 85 d2                test   %rdx,%rdx
  4b:   75 fb                   jne    48 <tc_lock_lock+0x28>

That is, on failure 4b jumps back to 48 forever.  It's also not really
correct to be using a 64-bit xchg, since the memory value is just int.
The 32-bit x86 version gets a similar loop with the xchg lifted out.

This patch greatly simplifies the asm, with its input "+m"(*val) ensuring
that gcc knows we're using the volatile value, and a broad "memory"
constraint so the lock can protect other data too.  That loop is now:

  11:   b9 01 00 00 00          mov    $0x1,%ecx
  16:   66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
  1d:   00 00 00
  20:   89 ca                   mov    %ecx,%edx
  22:   87 13                   xchg   %edx,(%rbx)
  24:   85 d2                   test   %edx,%edx
  26:   75 f8                   jne    20 <tc_lock_lock+0x20>

Signed-off-by: Josh Stone <jistone@redhat.com>
6 years agoReally enable -fvisibility=hidden for GCC builds
Josh Stone [Wed, 23 Oct 2013 22:48:50 +0000 (15:48 -0700)]
Really enable -fvisibility=hidden for GCC builds

The visibility flags were being added after the component directories
were specified, which apparently means those subdirectories don't get
the same flags.  Also, the flags weren't quoted correctly when defined,
and -fvisibility-inlines-hidden is only valid for C++.

Now the flags are defined using cmake/visibility.cmake, mimicking
warnings.cmake, and included in the same place in CMakeLists.txt.

I've found no regressions from this change, and there's a substantial
reduction in the size of the libraries.

Signed-off-by: Josh Stone <jistone@redhat.com>
6 years agoFix DYNINST_index_lock state and ppc64 writeFunctionPtr
Josh Stone [Thu, 17 Oct 2013 23:05:25 +0000 (16:05 -0700)]
Fix DYNINST_index_lock state and ppc64 writeFunctionPtr

There are two fixes in this patch to resolve hangs that we've seen on
ppc64 tests, most notably in test_thread_5.

The first is that DYNINST_index_lock may be left in a locked state from
DYNINSTthreadIndexSLOW when DYNINST_thread_hash_size is 0.  This simply
needs an unlock in that error path.

The second resolves *why* DYNINST_thread_hash_size is 0, even after it
was correctly initialized to 40.  This turned out to be corruption when
the mutator writeFunctionPtr sets DYNINST_pthread_self.  Those symbols
in libdyninstAPI_RT.so happen to be arranged like so:

    0000000000031180 B DYNINST_pthread_self
    0000000000031188 B DYNINST_sysEntry
    0000000000031190 B DYNINST_thread_hash_size

So writeFunctionPtr was sending three longs: the function descriptor
correctly in DYNINST_pthread_self; the toc in DYNINST_sysEntry, a dead
variable; and the guilty 0x0 in DYNINST_thread_hash_size.  The only
thing a function pointer actually needs is the function descriptor.

For comparison, on EL5 and EL6 our build has the symbols like so:

    000000000002c400 B DYNINST_pthread_self
    000000000002c408 B DYNINSTlinkSave
    000000000002c410 B DYNINSTtocSave
    000000000002c418 B DYNINST_sysEntry
    000000000002c420 B DYNINST_thread_hash_tids
    000000000002c428 B DYNINST_thread_hash_size

So that still clobbered data, but DYNINSTlinkSave and DYNINSTtocSave are
both unused variables -- no harm done.

Signed-off-by: Josh Stone <jistone@redhat.com>
6 years agoDon't stop mutatees for SIGINT
Josh Stone [Sat, 8 Jun 2013 01:46:04 +0000 (18:46 -0700)]
Don't stop mutatees for SIGINT

In PCEventHandler::shouldStopForSignal(), SIGINT is not a stopping
signal.  SIGINT's default action is to terminate the process, but it can
also be handled or ignored.  It never stops, to my knowledge.

It's hard for me to know the original author's intent, but the other
match on SIGSTOP does make sense.  SIGTSTP, SIGTTIN, and SIGTTOU are
also stopping signals, FWIW, but those may still be caught or ignored.

6 years agoXMM saves: if we're only looking at XMM0-XMM7 as save candidates, then save individua...
Bill Williams [Thu, 19 Sep 2013 19:11:17 +0000 (14:11 -0500)]
XMM saves: if we're only looking at XMM0-XMM7 as save candidates, then save individual live registers. If something more than that is live, fall back to a full fxsave/fxrestore.

6 years agoExperimental: replace fxsave with saves of XMM 0-7
Andrew Bernat [Tue, 2 Apr 2013 17:54:18 +0000 (12:54 -0500)]
Experimental: replace fxsave with saves of XMM 0-7

6 years agoJump tables: handle gcc 4.8 new form.
Bill Williams [Wed, 18 Sep 2013 20:10:18 +0000 (15:10 -0500)]
Jump tables: handle gcc 4.8 new form.

6 years agoMerge branch 'warnings' into coverity
Josh Stone [Tue, 17 Sep 2013 23:08:43 +0000 (16:08 -0700)]
Merge branch 'warnings' into coverity

6 years agodyninstAPI: unname an unused parameter in AstNode::checkType
Josh Stone [Tue, 10 Sep 2013 22:45:40 +0000 (15:45 -0700)]
dyninstAPI: unname an unused parameter in AstNode::checkType

Fixes this warning:

dyninstAPI/src/ast.C:2261:14: warning: unused parameter ‘func’ [-Wunused-parameter]
 BPatch_type *AstNode::checkType(BPatch_function* func) {
              ^

6 years agodyninstAPI_RT: fix many warnings from gcc 4.8
Josh Stone [Fri, 30 Aug 2013 23:27:37 +0000 (16:27 -0700)]
dyninstAPI_RT: fix many warnings from gcc 4.8

Some unused parameters, some size/sign comparison; nothing major.

6 years agodyninstAPI: remove the unused non-vector replaceHandler
Josh Stone [Fri, 30 Aug 2013 22:32:24 +0000 (15:32 -0700)]
dyninstAPI: remove the unused non-vector replaceHandler

This function has grown unused and obsolete due to changes elsewhere in
this source file.  The vectorized replaceHandler is still in use though.

dyninstAPI/src/parse-x86.C:256:13: warning: ‘bool replaceHandler(func_instance*, func_instance*, int_symbol*, std::string)’ defined but not used [-Wunused-function]
 static bool replaceHandler(func_instance *origHandler, func_instance *newHandler,
             ^

6 years agosymtabAPI: un-name a few unused parameter to avoid warnings
Josh Stone [Fri, 30 Aug 2013 22:24:58 +0000 (15:24 -0700)]
symtabAPI: un-name a few unused parameter to avoid warnings

symtabAPI/src/emitElfStatic-x86.C:88:13: warning: unused parameter ‘errMsg’ [-Wunused-parameter]
 static bool computeCtorDtorAddress(relocationEntry &rel, Offset globalOffset,
             ^
symtabAPI/src/emitElfStatic-x86.C:619:6: warning: unused parameter ‘lmap’ [-Wunused-parameter]
 bool emitElfStatic::createNewCtorRegion(LinkMap &lmap) {
      ^
symtabAPI/src/emitElfStatic-x86.C:651:6: warning: unused parameter ‘lmap’ [-Wunused-parameter]
 bool emitElfStatic::createNewDtorRegion(LinkMap &lmap) {
      ^

6 years agocommon: fix a visibility warning on P_cplus_demangle
Josh Stone [Fri, 30 Aug 2013 22:17:12 +0000 (15:17 -0700)]
common: fix a visibility warning on P_cplus_demangle

The attribute is ignored on function definitions, but COMMON_EXPORT
is already tagged on the declaration in linuxKludges.h anyway.

common/src/linuxKludges.C:183:23: warning: ‘visibility’ attribute ignored on non-class types [-Wattributes]
     bool includeTypes )
                       ^

6 years agoMerge remote-tracking branch 'origin/master' into warnings
Josh Stone [Tue, 17 Sep 2013 22:51:34 +0000 (15:51 -0700)]
Merge remote-tracking branch 'origin/master' into warnings

6 years agoMore gcc 4.8 fixes.
Bill Williams [Mon, 16 Sep 2013 18:29:57 +0000 (13:29 -0500)]
More gcc 4.8 fixes.

* Check whether snippet handles are empty and return NULL when inserting if so.
* BPatch_functions have params in both alpha and parameter order; getParams should return them in parameter order.
* DWARF 4 includes a (base, size) form for address ranges, as well as the (low, high) form that we had previously. Recognize this and handle accordingly.

6 years agoCMake patches: only install libdwarf/libelf if we built, and use local mirror for...
Bill Williams [Fri, 6 Sep 2013 19:19:52 +0000 (14:19 -0500)]
CMake patches: only install libdwarf/libelf if we built, and use local mirror for libdwarf rather than unreliable sgiweb site

6 years agoAdd libdl link dependency to proccontrol.
Bill Williams [Thu, 5 Sep 2013 22:24:04 +0000 (17:24 -0500)]
Add libdl link dependency to proccontrol.

6 years agoImprove retExpr type checking: disallow insertion at exit points of void functions.
Bill Williams [Thu, 5 Sep 2013 22:23:37 +0000 (17:23 -0500)]
Improve retExpr type checking: disallow insertion at exit points of void functions.

6 years agoAdd RelWithDebugInfo configuration.
Bill Williams [Wed, 4 Sep 2013 15:54:44 +0000 (10:54 -0500)]
Add RelWithDebugInfo configuration.

6 years agoBug fixes surrounding trap generation: postcondition of addTrap is that the codegen...
Bill Williams [Wed, 4 Sep 2013 15:54:08 +0000 (10:54 -0500)]
Bug fixes surrounding trap generation: postcondition of addTrap is that the codegen parameter contains the necessary changes to the address space (including none, in the dynamic mode case). Always add that codegen to the list of changes to apply. Respect user-level "useTraps" interface.

6 years agoTrap handling update: always respect the BPatch flag unless built without cap_mutatee...
Bill Williams [Tue, 3 Sep 2013 18:50:21 +0000 (13:50 -0500)]
Trap handling update: always respect the BPatch flag unless built without cap_mutatee_traps.

6 years agoRemove spurious output
Bill Williams [Fri, 23 Aug 2013 18:56:59 +0000 (13:56 -0500)]
Remove spurious output

6 years agoRedid static ctor/dtor handling to be compatible with init_array/fini_array as well...
Bill Williams [Thu, 22 Aug 2013 21:29:21 +0000 (16:29 -0500)]
Redid static ctor/dtor handling to be compatible with init_array/fini_array as well as ctors/dtors.

6 years agoAdd static targets
Bill Williams [Thu, 22 Aug 2013 16:38:25 +0000 (11:38 -0500)]
Add static targets

6 years agoRemove AIX code from RTlib tramp guard init
Bill Williams [Thu, 22 Aug 2013 15:35:11 +0000 (10:35 -0500)]
Remove AIX code from RTlib tramp guard init

6 years agoMerge branch 'symbol_visibility'
Bill Williams [Tue, 20 Aug 2013 16:13:09 +0000 (11:13 -0500)]
Merge branch 'symbol_visibility'

6 years agoAdded optimization flags for Windows release
Bill Williams [Tue, 20 Aug 2013 16:12:09 +0000 (11:12 -0500)]
Added optimization flags for Windows release

6 years agoMerge branch 'master' of ssh://git.dyninst.org/pub/dyninst
Bill Williams [Mon, 19 Aug 2013 15:22:29 +0000 (10:22 -0500)]
Merge branch 'master' of ssh://git.dyninst.org/pub/dyninst

6 years agoMerge
Bill Williams [Mon, 19 Aug 2013 15:17:50 +0000 (10:17 -0500)]
Merge

6 years agoRemove incorrect export declaration
Bill Williams [Fri, 9 Aug 2013 17:59:09 +0000 (12:59 -0500)]
Remove incorrect export declaration

6 years agoAdd newer versions to Boost_ADDITIONAL_VERSIONS
Bill Williams [Mon, 5 Aug 2013 20:04:43 +0000 (15:04 -0500)]
Add newer versions to Boost_ADDITIONAL_VERSIONS

6 years agoEnable verbose FindBoost
Bill Williams [Mon, 5 Aug 2013 19:39:06 +0000 (14:39 -0500)]
Enable verbose FindBoost

6 years agoExternalize dwarf/elf, search for PIC libiberty
Bill Williams [Fri, 26 Jul 2013 15:34:09 +0000 (10:34 -0500)]
Externalize dwarf/elf, search for PIC libiberty

6 years agoAppend RTlib properties, don't overwrite
Bill Williams [Mon, 22 Jul 2013 19:41:46 +0000 (14:41 -0500)]
Append RTlib properties, don't overwrite

6 years agoAdded -fvisibility=hidden to Linux builds, with export macros added in appropriate...
Bill Williams [Wed, 12 Jun 2013 21:19:30 +0000 (16:19 -0500)]
Added -fvisibility=hidden to Linux builds, with export macros added in appropriate places.

6 years agoMerge branch 'symtab_destruct_fix'
Xiaozhu Meng [Fri, 2 Aug 2013 16:31:22 +0000 (11:31 -0500)]
Merge branch 'symtab_destruct_fix'

This merge fixes the memory corruption problem happending in Symtab object destruction

6 years agoFix compilation errors with RHEL 5 systems
Matthew LeGendre [Mon, 29 Jul 2013 22:56:01 +0000 (15:56 -0700)]
Fix compilation errors with RHEL 5 systems

6 years agoFix issues with getting bad file/line callsite info for inlined functions
Matthew LeGendre [Tue, 23 Jul 2013 22:23:31 +0000 (15:23 -0700)]
Fix issues with getting bad file/line callsite info for inlined functions

6 years agoClean up properties
Bill Williams [Mon, 22 Jul 2013 20:58:23 +0000 (15:58 -0500)]
Clean up properties

6 years agoPrint output location for debugging
Bill Williams [Mon, 22 Jul 2013 20:34:46 +0000 (15:34 -0500)]
Print output location for debugging

6 years agoRevert bad property change; add status message; use proper libdl macro
Bill Williams [Mon, 22 Jul 2013 20:13:49 +0000 (15:13 -0500)]
Revert bad property change; add status message; use proper libdl macro

6 years agoAppend RTlib properties, don't overwrite
Bill Williams [Mon, 22 Jul 2013 19:41:46 +0000 (14:41 -0500)]
Append RTlib properties, don't overwrite

6 years ago1. Fix typos in changing ELF address
Xiaozhu Meng [Fri, 19 Jul 2013 15:10:59 +0000 (10:10 -0500)]
1. Fix typos in changing ELF address
2. Delete code for adding new regions at a wrong place
3. Get rid of an unused file

6 years agoSolve the memory corruption problem when destructing Symtab object
Xiaozhu Meng [Thu, 11 Jul 2013 18:37:31 +0000 (13:37 -0500)]
Solve the memory corruption problem when destructing Symtab object

6 years agoActually enable -fvisibility=hidden under CMake
Bill Williams [Thu, 27 Jun 2013 18:10:08 +0000 (13:10 -0500)]
Actually enable -fvisibility=hidden under CMake

6 years agoFix CMakeLists for export defs
Bill Williams [Wed, 26 Jun 2013 21:25:33 +0000 (16:25 -0500)]
Fix CMakeLists for export defs

6 years agoAdded -fvisibility=hidden to Linux builds, with export macros added in appropriate...
Bill Williams [Wed, 12 Jun 2013 21:19:30 +0000 (16:19 -0500)]
Added -fvisibility=hidden to Linux builds, with export macros added in appropriate places.

6 years ago[ABI] Return const std::string& for Statement::getFile()
Josh Stone [Wed, 26 Jun 2013 20:32:52 +0000 (13:32 -0700)]
[ABI] Return const std::string& for Statement::getFile()

This was returning a std::string, and BPatch_statement::fileName() was
then returning c_str() from that.  But since that string was temporary,
the memory backing it will be immediately freed.

The change to const std::string& shouldn't make any practical API
difference to callers, but it is an ABI change. (Though even that is
only if that simple function is ever not inlined...)

Reported by Coverity as WRAPPER_ESCAPE (CWE-825).

6 years agoUse a generic error message for gettid failure
Josh Stone [Wed, 26 Jun 2013 20:26:30 +0000 (13:26 -0700)]
Use a generic error message for gettid failure

In ProcSelf::getDefaultThread, it was using a temporary string to build
and error message with strerror, for setLastError.  This is an "escape",
because the c_str() value is invalid as soon as the string goes out of
scope.  But since gettid should never ever fail, and even if it did the
reason is logged by sw_printf, we can just be generic for setLastError.

Reported by Coverity as WRAPPER_ESCAPE (CWE-825).

6 years agoCMake integration for Windows.
Paradyn [Wed, 26 Jun 2013 18:51:28 +0000 (13:51 -0500)]
CMake integration for Windows.

6 years agoInitialize all members of SgAsm* classes
Josh Stone [Tue, 25 Jun 2013 21:05:14 +0000 (14:05 -0700)]
Initialize all members of SgAsm* classes

Reported by Coverity as UNINIT_CTOR (CWE-456)

6 years agoChange an unchecked dynamic_cast to static_cast
Josh Stone [Tue, 25 Jun 2013 20:43:39 +0000 (13:43 -0700)]
Change an unchecked dynamic_cast to static_cast

In getAsmSignedConstant, it already assumes the variantT is correct by
immediately dereferencing a dynamic_cast result.  Since dynamic_cast
could return NULL, and this is unchecked, it might as well commit to the
expectation by using a static_cast.

Reported by Coverity as FORWARD_NULL (CWE-476).

6 years agoAdd magic BG/Q LLNL include path
Andrew R. Bernat [Fri, 26 Apr 2013 20:26:41 +0000 (13:26 -0700)]
Add magic BG/Q LLNL include path

6 years agoRemove export statement; only valid in CMake 2.8 and above (and BATLab has 2.6)
Andrew Bernat [Thu, 25 Apr 2013 19:39:48 +0000 (14:39 -0500)]
Remove export statement; only valid in CMake 2.8 and above (and BATLab has 2.6)
Fix x86-linux build

6 years agoRename libstackwalker to libstackwalk to match earlier convention; fix PPC arch define
Andrew R. Bernat [Wed, 24 Apr 2013 16:21:16 +0000 (09:21 -0700)]
Rename libstackwalker to libstackwalk to match earlier convention; fix PPC arch define

6 years agoFix up CMake export config file ; remove codeCoverage ; remove testsuite
Andrew Bernat [Fri, 19 Apr 2013 20:26:22 +0000 (15:26 -0500)]
Fix up CMake export config file ; remove codeCoverage ; remove testsuite

6 years agoMove dynutil/h to common/h; move common/h to common/src. Update CMakeLists.txt
Andrew Bernat [Thu, 18 Apr 2013 21:17:25 +0000 (16:17 -0500)]
Move dynutil/h to common/h; move common/h to common/src. Update CMakeLists.txt

6 years agoMore fixes for testsuite generated files
Andrew Bernat [Tue, 16 Apr 2013 19:01:50 +0000 (14:01 -0500)]
More fixes for testsuite generated files

6 years agoGenerated CMake test files for other platforms
Andrew Bernat [Mon, 15 Apr 2013 20:28:45 +0000 (15:28 -0500)]
Generated CMake test files for other platforms

6 years agoAdd the x86_64/linux tests cmake structure
Andrew Bernat [Fri, 12 Apr 2013 22:02:36 +0000 (17:02 -0500)]
Add the x86_64/linux tests cmake structure

6 years agoRe-enable assembly support for tests.
Andrew Bernat [Fri, 12 Apr 2013 21:58:52 +0000 (16:58 -0500)]
Re-enable assembly support for tests.

6 years agoManually specify RT lib .S files to be built with gcc.
Andrew Bernat [Fri, 12 Apr 2013 21:29:57 +0000 (16:29 -0500)]
Manually specify RT lib .S files to be built with gcc.

6 years agoTest suite builds on amd-64/linux
Andrew Bernat [Fri, 12 Apr 2013 19:17:02 +0000 (14:17 -0500)]
Test suite builds on amd-64/linux

6 years agoUse lists of -Dcap and -Dbug defines so we can get the test suite to pull them in...
Andrew Bernat [Mon, 8 Apr 2013 18:37:50 +0000 (13:37 -0500)]
Use lists of -Dcap and -Dbug defines so we can get the test suite to pull them in too.

6 years agoMore WIP
Andrew Bernat [Wed, 3 Apr 2013 19:47:48 +0000 (14:47 -0500)]
More WIP

6 years agoCloser to having a working mutatee CMakefile structure
Andrew Bernat [Tue, 26 Mar 2013 21:51:39 +0000 (16:51 -0500)]
Closer to having a working mutatee CMakefile structure

6 years agoWIP commit
Andrew Bernat [Tue, 26 Mar 2013 15:32:56 +0000 (10:32 -0500)]
WIP commit

6 years agoWIP commit
Andrew Bernat [Mon, 25 Mar 2013 14:47:23 +0000 (09:47 -0500)]
WIP commit

6 years agoCMake testsuite WIP
Andrew Bernat [Fri, 22 Mar 2013 17:08:02 +0000 (12:08 -0500)]
CMake testsuite WIP

6 years agoGet CMake Dyninst building on linux/ppc64
Matthew LeGendre [Fri, 22 Mar 2013 17:59:22 +0000 (10:59 -0700)]
Get CMake Dyninst building on linux/ppc64

6 years agoTheoretically fix the 32-bit build check for RTlib
Andrew Bernat [Fri, 22 Mar 2013 00:42:11 +0000 (19:42 -0500)]
Theoretically fix the 32-bit build check for RTlib

6 years agoFixed relative path to sysname and dynsysname scripts to allow out-of-source build.
Andrew Bernat [Thu, 21 Mar 2013 23:43:43 +0000 (18:43 -0500)]
Fixed relative path to sysname and dynsysname scripts to allow out-of-source build.

6 years agoEven more ignores
Andrew Bernat [Thu, 21 Mar 2013 20:18:22 +0000 (15:18 -0500)]
Even more ignores

6 years agoRemove old Makefile system; testsuite is currently unmodified.
Andrew Bernat [Thu, 21 Mar 2013 20:16:54 +0000 (15:16 -0500)]
Remove old Makefile system; testsuite is currently unmodified.

6 years agoMore ignores
Andrew Bernat [Thu, 21 Mar 2013 20:14:44 +0000 (15:14 -0500)]
More ignores

6 years agoAdd CMake ignores
Andrew Bernat [Thu, 21 Mar 2013 20:14:23 +0000 (15:14 -0500)]
Add CMake ignores

6 years agoAdd auto-PLATFORM check; add flag for building 32-bit RTlib on 64-bit platforms.
Andrew Bernat [Thu, 21 Mar 2013 20:14:13 +0000 (15:14 -0500)]
Add auto-PLATFORM check; add flag for building 32-bit RTlib on 64-bit platforms.

6 years agoFix typo in i386 build
Andrew Bernat [Sat, 16 Mar 2013 01:19:56 +0000 (20:19 -0500)]
Fix typo in i386 build

6 years agoCMake apparently works!
Andrew Bernat [Fri, 15 Mar 2013 23:43:35 +0000 (18:43 -0500)]
CMake apparently works!

... except for ParseThat and the test suite.

6 years agoMore CMake work
Andrew Bernat [Fri, 15 Mar 2013 20:58:37 +0000 (15:58 -0500)]
More CMake work

6 years agoAdd DyninstAPI CMakeLists.txt
Andrew Bernat [Fri, 15 Mar 2013 00:08:27 +0000 (19:08 -0500)]
Add DyninstAPI CMakeLists.txt

6 years agoAdd CMakeLists.txt
Andrew Bernat [Fri, 8 Mar 2013 22:06:55 +0000 (16:06 -0600)]
Add CMakeLists.txt

6 years agoMore CMake WIP
Andrew Bernat [Fri, 8 Mar 2013 00:51:28 +0000 (18:51 -0600)]
More CMake WIP

6 years agoCMake initial WIP commit
Andrew Bernat [Wed, 6 Mar 2013 22:39:38 +0000 (16:39 -0600)]
CMake initial WIP commit

6 years agoFix a badly-sized malloc/realloc
Josh Stone [Fri, 31 May 2013 22:23:27 +0000 (15:23 -0700)]
Fix a badly-sized malloc/realloc

Detected by Coverity as a SIZECHECK (CWE-131)

Reported-by: William Cohen <wcohen@redhat.com>
6 years agoAddress some issues found by coverity (3/3)
William Cohen [Thu, 21 Mar 2013 16:38:21 +0000 (12:38 -0400)]
Address some issues found by coverity (3/3)

Fixes one instance of SIZECHECK (CWE-131)

6 years agoAddress some issues found by coverity (2/3)
William Cohen [Thu, 21 Mar 2013 16:22:51 +0000 (12:22 -0400)]
Address some issues found by coverity (2/3)

Fixes three instances of RESOURCE_LEAK (CWE-772)

6 years agoAddress some issues found by coverity (1/3)
William Cohen [Thu, 21 Mar 2013 16:12:18 +0000 (12:12 -0400)]
Address some issues found by coverity (1/3)

Fixes two instances of RESOURCE_LEAK (CWE-772)

6 years agoFix additional warnings given by gcc 4.8 -m32
Josh Stone [Fri, 31 May 2013 02:13:18 +0000 (19:13 -0700)]
Fix additional warnings given by gcc 4.8 -m32

6 years agosymtabAPI: fix warnings given by gcc 4.8
Josh Stone [Fri, 31 May 2013 01:32:47 +0000 (18:32 -0700)]
symtabAPI: fix warnings given by gcc 4.8

Compiling ../src/parseStab.C
../src/parseStab.C: In function ‘std::string Dyninst::SymtabAPI::parseStabString(Dyninst::SymtabAPI::Module*, int, char*, int, Dyninst::SymtabAPI::typeCommon*)’:
../src/parseStab.C:207:11: warning: variable ‘newType’ set but not used [-Wunused-but-set-variable]
    Type * newType = NULL; // For new types to add to the collection
           ^
../src/parseStab.C: In function ‘Dyninst::SymtabAPI::Type* parseArrayDef(Dyninst::SymtabAPI::Module*, const char*, int, char*&, int&, unsigned int)’:
../src/parseStab.C:1089:11: warning: variable ‘symdesc’ set but not used [-Wunused-but-set-variable]
     char *symdesc;
           ^
../src/parseStab.C:1090:9: warning: variable ‘symdescID’ set but not used [-Wunused-but-set-variable]
     int symdescID;
         ^
../src/parseStab.C: In function ‘char* parseFieldList(Dyninst::SymtabAPI::Module*, Dyninst::SymtabAPI::fieldListType*, char*, bool)’:
../src/parseStab.C:1712:6: warning: variable ‘size’ set but not used [-Wunused-but-set-variable]
  int size = 0;
      ^
../src/parseStab.C: In function ‘char* parseCPlusPlusInfo(Dyninst::SymtabAPI::Module*, char*, const char*, int)’:
../src/parseStab.C:1935:6: warning: variable ‘structsize’ set but not used [-Wunused-but-set-variable]
  int structsize;
      ^
../src/parseStab.C:1937:10: warning: variable ‘nestedType’ set but not used [-Wunused-but-set-variable]
     bool nestedType = false;
          ^
../src/parseStab.C: In function ‘char* parseTypeDef(Dyninst::SymtabAPI::Module*, char*, const char*, int, unsigned int)’:
../src/parseStab.C:2126:9: warning: variable ‘structsize’ set but not used [-Wunused-but-set-variable]
     int structsize;
         ^
Compiling ../src/emitElfStatic.C
../src/emitElfStatic.C:1765:6: warning: unused parameter ‘target’ [-Wunused-parameter]
 bool emitElfStatic::buildPLT(Symtab *target, Offset globalOffset,
      ^
../src/emitElfStatic.C:1765:6: warning: unused parameter ‘err’ [-Wunused-parameter]
../src/emitElfStatic.C:1765:6: warning: unused parameter ‘errMsg’ [-Wunused-parameter]
../src/emitElfStatic.C: In member function ‘Dyninst::Offset Dyninst::SymtabAPI::emitElfStatic::allocateRelocationSection(std::map<Dyninst::SymtabAPI::Symbol*, std::pair<long unsigned int, long unsigned int> >&, Dyninst::Offset, Dyninst::Offset&, Dyninst::SymtabAPI::Symtab*)’:
../src/emitElfStatic.C:1817:11: warning: unused variable ‘obj’ [-Wunused-variable]
   Object *obj = target->getObject();
           ^
../src/emitElfStatic.C: In member function ‘Dyninst::Offset Dyninst::SymtabAPI::emitElfStatic::allocateRelGOTSection(const std::map<Dyninst::SymtabAPI::Symbol*, std::pair<long unsigned int, long unsigned int> >&, Dyninst::Offset, Dyninst::Offset&)’:
../src/emitElfStatic.C:1835:12: warning: unused variable ‘relocSize’ [-Wunused-variable]
   unsigned relocSize = sizeof(Elf64_Rela);
            ^
../src/emitElfStatic.C: At global scope:
../src/emitElfStatic.C:1846:6: warning: unused parameter ‘err’ [-Wunused-parameter]
 bool emitElfStatic::buildRela(Symtab *target, Offset globalOffset,
      ^
../src/emitElfStatic.C:1846:6: warning: unused parameter ‘errMsg’ [-Wunused-parameter]
Compiling ../src/emitElfStatic-x86.C
../src/emitElfStatic-x86.C: In member function ‘bool Dyninst::SymtabAPI::emitElfStatic::archSpecificRelocation(Dyninst::SymtabAPI::Symtab*, Dyninst::SymtabAPI::Symtab*, char*, Dyninst::SymtabAPI::relocationEntry&, Dyninst::Offset, Dyninst::Offset, Dyninst::Offset, Dyninst::SymtabAPI::LinkMap&, std::string&)’:
../src/emitElfStatic-x86.C:167:67: warning: ‘addend’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                 rel.getRelType(), symbolOffset, addend, relOffset);
                                                                   ^
../src/emitElfStatic-x86.C:153:20: note: ‘addend’ was declared here
         Elf32_Word addend;
                    ^
Compiling ../src/Function.C
../src/Function.C: In constructor ‘Dyninst::SymtabAPI::FunctionBase::FunctionBase(Dyninst::SymtabAPI::Symbol*)’:
../src/Function.C:64:15: warning: converting to non-pointer type ‘unsigned int’ from NULL [-Wconversion-null]
    data(NULL)
               ^
../src/Function.C: In constructor ‘Dyninst::SymtabAPI::FunctionBase::FunctionBase()’:
../src/Function.C:76:15: warning: converting to non-pointer type ‘unsigned int’ from NULL [-Wconversion-null]
    data(NULL)
               ^
../src/Function.C: In constructor ‘Dyninst::SymtabAPI::FunctionBase::FunctionBase(Dyninst::SymtabAPI::Module*)’:
../src/Function.C:88:15: warning: converting to non-pointer type ‘unsigned int’ from NULL [-Wconversion-null]
    data(NULL)
               ^
../src/Function.C: In member function ‘bool Dyninst::SymtabAPI::FunctionBase::operator==(const Dyninst::SymtabAPI::FunctionBase&)’:
../src/Function.C:444:49: warning: cast from type ‘const Dyninst::SymtabAPI::FunctionBase*’ to type ‘Dyninst::SymtabAPI::Aggregate*’ casts away qualifiers [-Wcast-qual]
  return ((Aggregate &)(*this)) == ((Aggregate &)f);
                                                 ^
Compiling ../src/Variable.C
../src/Variable.C: In member function ‘bool Dyninst::SymtabAPI::Variable::operator==(const Dyninst::SymtabAPI::Variable&)’:
../src/Variable.C:195:49: warning: cast from type ‘const Dyninst::SymtabAPI::Variable*’ to type ‘Dyninst::SymtabAPI::Aggregate*’ casts away qualifiers [-Wcast-qual]
  return ((Aggregate &)(*this)) == ((Aggregate &)v);
                                                 ^
Compiling ../src/dwarfWalker.C
../src/dwarfWalker.C: In member function ‘Dyninst::SymtabAPI::typeArray* Dyninst::SymtabAPI::DwarfWalker::parseMultiDimensionalArray(Dwarf_Die, Dyninst::SymtabAPI::Type*)’:
../src/dwarfWalker.C:1870:276: warning: converting ‘false’ to pointer type ‘Dyninst::SymtabAPI::typeArray*’ [-Wconversion-null]
   DWARF_FAIL_RET(dwarf_dieoffset( range, & dieOffset, NULL ));
                                                                                                                                                                                                                                                                                    ^
../src/dwarfWalker.C:1880:201: warning: converting ‘false’ to pointer type ‘Dyninst::SymtabAPI::typeArray*’ [-Wconversion-null]
   DWARF_CHECK_RET(status == DW_DLV_ERROR);
                                                                                                                                                                                                         ^

6 years agoparseThat: fix warnings given by gcc 4.8
Josh Stone [Fri, 31 May 2013 00:31:33 +0000 (17:31 -0700)]
parseThat: fix warnings given by gcc 4.8

../src/parseThat.C: In function ‘bool runHunt_binaryEdit()’:
../src/parseThat.C:201:9: warning: variable ‘result’ set but not used [-Wunused-but-set-variable]
     int result, status;
         ^
../src/parseThat.C: In function ‘void parseArgs(int, char**)’:
../src/parseThat.C:806:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
                         info->tool = "parseThat";
                                    ^
../src/reglist.C: In member function ‘const char* reglist::getReason(char*)’:
../src/reglist.C:94:9: warning: converting ‘false’ to pointer type ‘const char*’ [-Wconversion-null]
  return false;
         ^

6 years agodynC_API: fix warnings given by gcc 4.8
Josh Stone [Fri, 31 May 2013 00:18:18 +0000 (17:18 -0700)]
dynC_API: fix warnings given by gcc 4.8

For the "string constant" errors, convert the yywarn/yyerror functions
from char* to const char*, and remove a lot of unnecessary strdups.

The remaining few warnings are straightforward.

Compiling ../src/lex.dynC.C
../src/C.l: In function ‘int dynClex()’:
../src/C.l:64:19: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 <<EOF>>        {yylval.context = "Syntax Error: Unterminated block comment"; return(ERROR);}
                   ^
../src/C.l:71:16: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 "char"[ \t\v\f]*"*" {yylval.sval = "char *"; return TYPE; }
                ^
../src/C.l:133:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
                   yylval.context = "Unterminated string constant";
                                    ^
../src/C.l:144:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
                       yylval.context = "constant out of bounds";
                                        ^
../src/C.l:153:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
                   yylval.context = "bad escape sequence";
                                    ^
../src/C.l:222:238: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 ^([^\n;{}])+\n {if(strstr(yytext, "//") != NULL){++line_num;}else{if(strncmp(yytext,"/*", 2) == 0){BEGIN(comment);++line_num;}else{if(lexVerbose)printf("No Semi!\n"); fatalError = true; dynClloc.first_column = yycolumn; yylval.context = "syntax error: missing ';'!"; yyless(yyleng - 1); return(ERROR);}}}
                                                                                                                                                                                                                                              ^
../src/C.l: In function ‘void set_lex_input(char*)’:
../src/C.l:236:20: warning: variable ‘bp’ set but not used [-Wunused-but-set-variable]

                    ^
Compiling ../src/dynC.tab.C
../src/C.y:41:25: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 char *dynCSnippetName = "";
                         ^
../src/C.y: In function ‘int dynCparse()’:
../src/C.y:328:83: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           yyerrorNoTok("Invalid number of arguments given in array initialization");
                                                                                   ^
../src/C.y:364:34: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
          yyerror("Syntax error");
                                  ^
../src/C.y:421:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           yywarn("Statement does nothing!");
                                           ^
../src/C.y:612:88: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           yyerrorNoTok("Local variables not allowed when snippet point is unspecified.");
                                                                                        ^
../src/C.y:642:88: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           yyerrorNoTok("Local variables not allowed when snippet point is unspecified.");
                                                                                        ^
../src/C.y:646:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           yyerror("Numbered indexes for parameters only");
                                                           ^
../src/C.y:771:83: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
              yyerrorNoTokNonUni("Return values only valid at function exit points");
                                                                                   ^
../src/C.y:796:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
        yyerror("Syntax error: unrecognized dyninst call");
                                                           ^
dynC.tab.c:2875:32: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
dynC.tab.c:3024:32: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

6 years agodyninstAPI: fix warnings given by gcc 4.8
Josh Stone [Thu, 30 May 2013 23:15:05 +0000 (16:15 -0700)]
dyninstAPI: fix warnings given by gcc 4.8

Compiling ../../dyninstAPI/src/linux-x86.C
../../dyninstAPI/src/linux-x86.C: In member function ‘AstNodePtr PCProcess::createUnprotectStackAST()’:
../../dyninstAPI/src/linux-x86.C:179:68: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     args.push_back(AstNode::operandNode(AstNode::Constant, (void *)size));
                                                                    ^
Compiling ../../dyninstAPI/src/emit-x86.C
../../dyninstAPI/src/emit-x86.C: In member function ‘virtual bool EmitterIA32::emitBTRestores(baseTramp*, codeGen&)’:
../../dyninstAPI/src/emit-x86.C:702:10: warning: variable ‘localSpace’ set but not used [-Wunused-but-set-variable]
     bool localSpace;
          ^
Compiling ../../dyninstAPI/src/unix.C
../../dyninstAPI/src/unix.C:286:6: warning: unused parameter ‘rights’ [-Wunused-parameter]
 bool PCProcess::getMemoryAccessRights(Address start, PCMemPerm& rights) {
      ^
Compiling ../../dyninstAPI/src/stackwalk-x86.C
../../dyninstAPI/src/stackwalk-x86.C: In member function ‘virtual bool StackwalkInstrumentationHelper::isInstrumentation(Dyninst::Address, Dyninst::Address*, unsigned int*, bool*, bool*)’:
../../dyninstAPI/src/stackwalk-x86.C:131:18: warning: variable ‘func’ set but not used [-Wunused-but-set-variable]
   func_instance *func = NULL;
                  ^
Compiling ../../dyninstAPI/src/IAPI_to_AST.C
../../dyninstAPI/src/IAPI_to_AST.C: In member function ‘virtual void ASTFactory::visit(Dyninst::InstructionAPI::RegisterAST*)’:
../../dyninstAPI/src/IAPI_to_AST.C:93:54: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
                       (void*)(convertRegID(r, unused))));
                                                      ^
Compiling ../src/Relocation/Widgets/CFWidget-x86.C
../src/Relocation/Widgets/CFWidget-x86.C: In member function ‘bool Dyninst::Relocation::CFWidget::generateIndirect(Dyninst::Relocation::CodeBuffer&, Dyninst::Relocation::CFWidget::Register, const Dyninst::Relocation::RelocBlock*, Dyninst::InstructionAPI::Instruction::Ptr)’:
../src/Relocation/Widgets/CFWidget-x86.C:85:98: warning: cast from type ‘const void*’ to type ‘unsigned char*’ casts away qualifiers [-Wcast-qual]
    ia32_decode(IA32_FULL_DECODER, (unsigned char *)insn->ptr(), orig_instr);
                                                                                                  ^
Compiling ../../dyninstAPI/src/BPatch_image.C
../../dyninstAPI/src/BPatch_image.C: In member function ‘BPatch_variableExpr* BPatch_image::findVariable(const char*, bool)’:
../../dyninstAPI/src/BPatch_image.C:699:19: warning: variable ‘var_as’ set but not used [-Wunused-but-set-variable]
     AddressSpace *var_as = NULL;
                   ^
Compiling ../../dyninstAPI/src/BPatch_snippet.C
../../dyninstAPI/src/BPatch_snippet.C: In constructor ‘BPatch_registerExpr::BPatch_registerExpr(Dyninst::MachRegister)’:
../../dyninstAPI/src/BPatch_snippet.C:967:58: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
                                                  (void *)reg));
                                                          ^
../../dyninstAPI/src/BPatch_snippet.C: In function ‘void constructorHelper(void (* const&)(BPatch_point*, void*), bool, BPatch_stInterpret, AstNodePtr&, AstNodePtr&)’:
../../dyninstAPI/src/BPatch_snippet.C:1631:67: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     idNode = AstNode::operandNode(AstNode::Constant, (void*)(int) cb_id );
                                                                   ^
../../dyninstAPI/src/BPatch_snippet.C:1644:62: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     icNode = AstNode::operandNode(AstNode::Constant, (void*) ic );
                                                              ^
Compiling ../../dyninstAPI/src/BPatch_process.C
../../dyninstAPI/src/BPatch_process.C: In member function ‘virtual BPatch_object* BPatch_process::loadLibrary(const char*, bool)’:
../../dyninstAPI/src/BPatch_process.C:1009:18: warning: converting ‘false’ to pointer type ‘BPatch_object*’ [-Wconversion-null]
           return false;
                  ^
../../dyninstAPI/src/BPatch_process.C:1036:38: warning: converting ‘false’ to pointer type ‘BPatch_object*’ [-Wconversion-null]
    if (dlopen_func == NULL) return false;
                                      ^
../../dyninstAPI/src/BPatch_process.C: In member function ‘bool BPatch_process::protectAnalyzedCode()’:
../../dyninstAPI/src/BPatch_process.C:1740:10: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
     bool ret = true;
          ^
Compiling ../../dyninstAPI/src/ast.C
../../dyninstAPI/src/ast.C: In member function ‘bool AstOperatorNode::generateOptimizedAssignment(codeGen&, bool)’:
../../dyninstAPI/src/ast.C:902:13: warning: variable ‘data_oper’ set but not used [-Wunused-but-set-variable]
    AstNode *data_oper = NULL, *const_oper = NULL;
             ^
../../dyninstAPI/src/ast.C: In member function ‘virtual BPatch_type* AstOperatorNode::checkType()’:
../../dyninstAPI/src/ast.C:2270:52: warning: variable ‘eType’ set but not used [-Wunused-but-set-variable]
     BPatch_type *lType = NULL, *rType = NULL, *eType = NULL;
                                                    ^
Compiling ../../dyninstAPI/src/codegen.C
../../dyninstAPI/src/codegen.C: In member function ‘std::string codeGen::format() const’:
../../dyninstAPI/src/codegen.C:776:92: warning: cast from type ‘const void*’ to type ‘unsigned int*’ casts away qualifiers [-Wcast-qual]
      ret << "\t" << base << ": " << insn->format(base) << " / " << *((unsigned *)insn->ptr()) << endl;
                                                                                            ^
Compiling ../../dyninstAPI/src/image.C
../../dyninstAPI/src/image.C: In member function ‘Dyninst::SymtabAPI::Symbol* image::symbol_info(const string&)’:
../../dyninstAPI/src/image.C:2036:15: warning: converting ‘false’ to pointer type ‘Dyninst::SymtabAPI::Symbol*’ [-Wconversion-null]
        return false;
               ^
Compiling ../../dyninstAPI/src/mapped_object.C
../../dyninstAPI/src/mapped_object.C: In member function ‘block_instance* mapped_object::findBlockByEntry(Dyninst::Address)’:
../../dyninstAPI/src/mapped_object.C:632:52: warning: converting ‘false’ to pointer type ‘block_instance*’ [-Wconversion-null]
     if (!findBlocksByAddr(addr, allBlocks)) return false;
                                                    ^
Compiling ../../dyninstAPI/src/hybridOverwrites.C
../../dyninstAPI/src/hybridOverwrites.C: In member function ‘bool HybridAnalysisOW::removeLoop(HybridAnalysisOW::owLoop*, bool, BPatch_point*, bool)’:
../../dyninstAPI/src/hybridOverwrites.C:236:61: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
             overwriteAnalysis(writePoint,(void*)loop->getID());
                                                             ^
Compiling ../../dyninstAPI/src/dynProcess.C
../../dyninstAPI/src/dynProcess.C: In static member function ‘static PCProcess* PCProcess::setupForkedProcess(PCProcess*, Dyninst::ProcControlAPI::Process::ptr)’:
../../dyninstAPI/src/dynProcess.C:194:20: warning: converting ‘false’ to pointer type ‘PCProcess*’ [-Wconversion-null]
             return false;
                    ^
Compiling ../src/Relocation/Springboard.C
../src/Relocation/Springboard.C: In member function ‘Dyninst::Relocation::SpringboardBuilder::generateResult_t Dyninst::Relocation::SpringboardBuilder::generateSpringboard(std::list<codeGen>&, const Dyninst::Relocation::SpringboardReq&, Dyninst::Relocation::SpringboardMap&)’:
../src/Relocation/Springboard.C:217:13: warning: variable ‘size’ set but not used [-Wunused-but-set-variable]
    unsigned size;
             ^

6 years agoFix a typo in saving EFLAGS
Josh Stone [Thu, 30 May 2013 23:02:51 +0000 (16:02 -0700)]
Fix a typo in saving EFLAGS

This seems to be an obvious typo, flagged by a GCC warning:

Compiling ../../dyninstAPI/src/registerSpace.C
../../dyninstAPI/src/registerSpace.C: In member function ‘bool registerSpace::saveVolatileRegisters(codeGen&)’:
../../dyninstAPI/src/registerSpace.C:545:48: warning: value computed is not used [-Wunused-value]
           registers_[REGNUM_EFLAGS]->liveState == registerSlot::spilled;
                                                ^

6 years agodyninstAPI_RT: fix warnings given by gcc 4.8
Josh Stone [Thu, 30 May 2013 22:41:34 +0000 (15:41 -0700)]
dyninstAPI_RT: fix warnings given by gcc 4.8

Compiling ../src/RTstatic_ctors_dtors-x86.c (noPIC)
../src/RTstatic_ctors_dtors-x86.c: In function ‘DYNINSTglobal_irel_handler’:
../src/RTstatic_ctors_dtors-x86.c:123:11: warning: assignment makes pointer from integer without a cast [enabled by default]
       ptr = *(rel->offset);
           ^

6 years agostackwalk: fix warnings given by gcc 4.8
Josh Stone [Thu, 30 May 2013 22:34:38 +0000 (15:34 -0700)]
stackwalk: fix warnings given by gcc 4.8

Compiling ../src/dbginfo-stepper.C
../src/dbginfo-stepper.C: In member function ‘Dyninst::Stackwalker::gcframe_ret_t Dyninst::Stackwalker::DebugStepperImpl::getCallerFrameArch(Dyninst::Address, const Dyninst::Stackwalker::Frame&, Dyninst::Stackwalker::Frame&, Dyninst::Dwarf::DwarfFrameParser::Ptr, bool)’:
../src/dbginfo-stepper.C:306:26: warning: variable ‘arch’ set but not used [-Wunused-but-set-variable]
    Dyninst::Architecture arch;
                          ^
Compiling ../src/sw_pcontrol.C
../src/sw_pcontrol.C: In member function ‘std::string Dyninst::Stackwalker::ProcDebug::getExecutablePath()’:
../src/sw_pcontrol.C:378:216: warning: converting ‘false’ to pointer type for argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ [-Wconversion-null]
    CHECK_PROC_LIVE;
                                                                                                                                                                                                                        ^

6 years ago[API] Change sw_c out_frame parameters into actual outputs
Josh Stone [Thu, 30 May 2013 22:23:29 +0000 (15:23 -0700)]
[API] Change sw_c out_frame parameters into actual outputs

The out_frame parameters of walkSingleFrame and getInitialFrame are
frame_t, a struct which is passed by value.  GCC 4.8 warns that this
parameter is set but not used:

Compiling ../src/sw_c.C
../src/sw_c.C: In function ‘int walkSingleFrame(walker_t, frame_t, frame_t)’:
../src/sw_c.C:117:5: warning: parameter ‘out_frame’ set but not used [-Wunused-but-set-parameter]
 int walkSingleFrame(walker_t walker, frame_t frame, frame_t out_frame)
     ^
../src/sw_c.C: In function ‘int getInitialFrame(walker_t, frame_t)’:
../src/sw_c.C:131:5: warning: parameter ‘out_frame’ set but not used [-Wunused-but-set-parameter]
 int getInitialFrame(walker_t walker, frame_t out_frame)
     ^

In order for this to be an actual output parameter, these will have to
be frame_t* parameters.  This is a simple change, but it does change the
API of these functions.  Given that they formerly couldn't work at all,
I expect no one is using these anyway...

6 years agoproccontrol: fix warnings given by gcc 4.8
Josh Stone [Thu, 30 May 2013 22:12:23 +0000 (15:12 -0700)]
proccontrol: fix warnings given by gcc 4.8

Compiling ../src/linux.C
../src/linux.C: In member function ‘virtual bool linux_thread::plat_setAllRegisters(int_registerPool&)’:
../src/linux.C:2043:115: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
             result = do_ptrace((pt_req) PTRACE_POKEUSER, lwp, (void *) (unsigned long) di->second.first, (void *) res);
                                                                                                                   ^
../src/linux.C: In member function ‘virtual bool linux_thread::plat_setRegister(Dyninst::MachRegister, Dyninst::MachRegisterVal)’:
../src/linux.C:2175:52: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       result = do_ptrace((pt_req) PTRACE_POKEUSR, lwp, (void *) offset, (void *) value);
                                                    ^
../src/linux.C:2175:69: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       result = do_ptrace((pt_req) PTRACE_POKEUSR, lwp, (void *) offset, (void *) value);
                                                                     ^
../src/linux.C:2179:52: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       result = do_ptrace((pt_req) PTRACE_POKEUSR, lwp, (void *) offset, (void *) value);
                                                    ^
../src/linux.C: In member function ‘virtual bool linux_thread::thrdb_getThreadArea(int, Dyninst::Address&)’:
../src/linux.C:2295:60: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
          int result = do_ptrace((pt_req) PTRACE_GET_THREAD_AREA, lwp, (void *) val, &addrv);
                                                            ^
../src/linux.C:2316:68: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
          int result = do_ptrace((pt_req) PTRACE_ARCH_PRCTL, lwp, &addrv, (void *) op);
                                                                    ^
Compiling ../src/unix.C
../src/unix.C: In member function ‘virtual bool unix_process::plat_findAllocatedRegionAround(Dyninst::Address, Dyninst::ProcControlAPI::Process::MemoryRegion&)’:
../src/unix.C:241:21: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
     memRegion.first  = NULL;
                     ^
../src/unix.C:242:22: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
     memRegion.second = NULL;
                      ^
Compiling ../src/event.C
../src/event.C: In destructor ‘virtual Dyninst::ProcControlAPI::EventRPC::~EventRPC()’:
../src/event.C:601:29: warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
    memset(wrapper, 0, sizeof(wrapper));
                             ^
Compiling ../src/handler.C
../src/handler.C: In member function ‘bool HandlerPool::handleEvent(Dyninst::ProcControlAPI::Event::ptr)’:
../src/handler.C:364:14: warning: variable ‘etype’ set but not used [-Wunused-but-set-variable]
    EventType etype = orig_ev->getEventType();
              ^
Compiling ../src/process.C
../src/process.C: In member function ‘virtual bool int_process::forked()’:
../src/process.C:617:16: warning: variable ‘initial_thread’ set but not used [-Wunused-but-set-variable]
    int_thread *initial_thread;
                ^
../src/process.C: In constructor ‘int_process::int_process(Dyninst::PID, int_process*)’:
../src/process.C:1384:1: warning: ‘int_process::exec_mem_cache’ is initialized with itself [-Winit-self]
 int_process::int_process(Dyninst::PID pid_, int_process *p) :
 ^
../src/process.C: In member function ‘virtual bool int_process::plat_findAllocatedRegionAround(Dyninst::Address, Dyninst::ProcControlAPI::Process::MemoryRegion&)’:
../src/process.C:1875:21: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
     memRegion.first  = NULL;
                     ^
../src/process.C:1876:22: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
     memRegion.second = NULL;
                      ^
../src/process.C: In constructor ‘int_breakpoint::int_breakpoint(Dyninst::ProcControlAPI::Breakpoint::ptr)’:
../src/process.C:4605:25: warning: converting ‘false’ to pointer type ‘void*’ [-Wconversion-null]
    offset_transfer(false)
                         ^
../src/process.C: In constructor ‘int_breakpoint::int_breakpoint(Dyninst::Address, Dyninst::ProcControlAPI::Breakpoint::ptr, bool)’:
../src/process.C:4621:23: warning: converting ‘false’ to pointer type ‘void*’ [-Wconversion-null]
    offset_transfer(off)
                       ^
../src/process.C: In constructor ‘int_breakpoint::int_breakpoint(unsigned int, unsigned int, Dyninst::ProcControlAPI::Breakpoint::ptr)’:
../src/process.C:4636:27: warning: converting ‘false’ to pointer type ‘void*’ [-Wconversion-null]
   suppress_callbacks(false)
                           ^
Compiling ../src/irpc.C
../src/irpc.C: In destructor ‘Dyninst::ProcControlAPI::IRPC::~IRPC()’:
../src/irpc.C:1331:28: warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   memset(wrapper, 0, sizeof(wrapper));
                            ^
Compiling ../src/processplat.C
../src/processplat.C: In member function ‘bool int_remoteIO::getFileStatData(Dyninst::ProcControlAPI::FileSet&)’:
../src/processplat.C:973:9: warning: variable ‘had_error’ set but not used [-Wunused-but-set-variable]
    bool had_error = false;
         ^

6 years agoCorrect several reversed prefix/postfix operators
Josh Stone [Thu, 30 May 2013 22:11:23 +0000 (15:11 -0700)]
Correct several reversed prefix/postfix operators

This was backwards in a few places, so a reminder:

  operator++() and operator--() are the *prefix* versions,
  which are expected to return the updated value.

  operator++(int) and operator--(int) are the *postfix* versions,
  which are expected to return the original value.

Of course, C++ is loose enough that you could do anything you like with
these operator overloads, but these corrections appear to have intended
normal semantics. :)

FWIW, the uses I surveyed were all ignoring the prefix/postfix return
value anyway, so hopefully there weren't any bugs lurking anywhere.