Statetrace: Accomodate cross compiling statetrace with scons.

--HG--
rename : util/statetrace/arch/tracechild_amd64.cc => util/statetrace/arch/amd64/tracechild.cc
rename : util/statetrace/arch/tracechild_amd64.hh => util/statetrace/arch/amd64/tracechild.hh
rename : util/statetrace/arch/tracechild_arm.cc => util/statetrace/arch/arm/tracechild.cc
rename : util/statetrace/arch/tracechild_arm.hh => util/statetrace/arch/arm/tracechild.hh
rename : util/statetrace/arch/tracechild_i386.cc => util/statetrace/arch/i386/tracechild.cc
rename : util/statetrace/arch/tracechild_i386.hh => util/statetrace/arch/i386/tracechild.hh
rename : util/statetrace/arch/tracechild_sparc.cc => util/statetrace/arch/sparc/tracechild.cc
rename : util/statetrace/arch/tracechild_sparc.hh => util/statetrace/arch/sparc/tracechild.hh
rename : util/statetrace/tracechild_arch.cc => util/statetrace/base/arch_check.h
rename : util/statetrace/regstate.hh => util/statetrace/base/regstate.hh
rename : util/statetrace/statetrace.cc => util/statetrace/base/statetrace.cc
rename : util/statetrace/tracechild.cc => util/statetrace/base/tracechild.cc
rename : util/statetrace/tracechild.hh => util/statetrace/base/tracechild.hh
This commit is contained in:
Gabe Black 2011-03-02 22:53:11 -08:00
parent 9151c4039a
commit eab89a09d2
15 changed files with 135 additions and 37 deletions

View file

@ -0,0 +1,39 @@
# Copyright (c) 2011 Gabe Black
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Gabe Black
import os
Import('env', 'arch')
env.Append(CPPPATH=Dir('.'))
sources = [os.path.join('base', 'statetrace.cc'),
os.path.join('base', 'tracechild.cc'),
os.path.join('arch', arch, 'tracechild.cc')]
objects = [env.Object(source) for source in sources]
env.Program('statetrace', objects)

View file

@ -26,7 +26,42 @@
#
# Authors: Gabe Black
sources = ['statetrace.cc', 'tracechild.cc', 'tracechild_arch.cc']
cxx_flags = "-O3 -ggdb -I ./ -I ./arch"
objects = [Object(source, CXXFLAGS=cxx_flags) for source in sources]
Program('statetrace', objects)
Help('''
To build a version of statetrace suitable to run on a particular ISA, use a
target of the form build/<arch>/statetrace. For example, to build statetrace
for ARM binaries, run:
scons build/arm/statetrace
You may need a cross compiler in order to build statetrace successfully. To
specify an alternative compiler, set the CXX scons argument on the command
line. The CXX environment variable is NOT considered when selecting the
compiler. To override the compiler for a particular target ISA, set the
<arch>CXX scons argument. For example, to build both the AMD64 version and
the ARM version at the same time using the system compiler for the AMD64
version and a cross compiler for arm, your command line would look like the
following:
scons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
After a successful build, the statetrace binary(binaries) will be located in
the build/<arch>/ directories you specified on the command line.
''')
arches = 'amd64', 'arm', 'i386', 'sparc'
import os
main = Environment()
main.SetOption('duplicate', 'soft-copy')
main['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
main['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
for arch in arches:
env = main.Clone()
env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX'])
env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper())
Export('env', 'arch')
env.SConscript('SConscript', variant_dir = os.path.join('build', arch))

View file

@ -35,7 +35,7 @@
#include <stdint.h>
#include <string.h>
#include "tracechild_amd64.hh"
#include "arch/amd64/tracechild.hh"
using namespace std;

View file

@ -37,7 +37,7 @@
#include <cassert>
#include <string>
#include "tracechild.hh"
#include "base/tracechild.hh"
class AMD64TraceChild : public TraceChild
{

View file

@ -47,7 +47,7 @@
#include <cstring>
#include <cstdio>
#include "tracechild_arm.hh"
#include "arch/arm/tracechild.hh"
using namespace std;

View file

@ -48,7 +48,7 @@
#include <string>
#include <sys/user.h>
#include <sys/ptrace.h>
#include "tracechild.hh"
#include "base/tracechild.hh"
class ARMTraceChild : public TraceChild

View file

@ -33,7 +33,7 @@
#include <sys/ptrace.h>
#include <stdint.h>
#include "tracechild_i386.hh"
#include "arch/i386/tracechild.hh"
using namespace std;

View file

@ -37,7 +37,7 @@
#include <cassert>
#include <string>
#include "tracechild.hh"
#include "base/tracechild.hh"
class I386TraceChild : public TraceChild
{

View file

@ -33,7 +33,7 @@
#include <sys/ptrace.h>
#include <stdint.h>
#include "tracechild_sparc.hh"
#include "arch/sparc/tracechild.hh"
using namespace std;

View file

@ -39,7 +39,7 @@
#include <sys/ptrace.h>
#include <sys/types.h>
#include "tracechild.hh"
#include "base/tracechild.hh"
struct regs;

View file

@ -28,29 +28,51 @@
* Authors: Gabe Black
*/
#if defined __alpha__
#error "Alpha architecture not implemented"
#elif defined __amd64__
#include "arch/tracechild_amd64.cc"
#elif defined __arm__
#include "arch/tracechild_arm.cc"
#elif defined __hppa__
#error "Hppa architecture not implemented"
#elif defined __i386__ || defined __i486__ || \
defined __i586__ || defined __i686
#include "arch/tracechild_i386.cc"
#elif defined __ia64__
#error "IA64 architecture not implemented"
#elif defined __mips__
#error "Mips architecture not implemented"
#elif defined __powerpc__
#error "PowerPC architecture not implemented"
#elif defined __sparc__
#include "arch/tracechild_sparc.cc"
#elif defined __sh__
#include "SuperH architecture not implemented"
#elif defined __s390__
#include "System/390 architecture not implemented"
#if defined __STATETRACE_ALPHA__
#if !defined __alpha__
#error "Alpha toolchain required."
#endif
#elif defined __STATETRACE_AMD64__
#if !defined __amd64__
#error "Amd64 toolchain required."
#endif
#elif defined __STATETRACE_ARM__
#if !defined __arm__
#error "Arm toolchain required."
#endif
#elif defined __STATETRACE_HPPA__
#if !defined __hppa__
#error "Hppa toolchain required."
#endif
#elif defined __STATETRACE_I386__
#if !(defined __i386__ || defined __i486__ || \
defined __i586__ || defined __i686)
#error "I386 toolchain required."
#endif
#elif defined __STATETRACE_IA64__
#if !defined __ia64__
#error "IA64 toolchain required."
#endif
#elif defined __STATETRACE_MIPS__
#if !defined __mips__
#error "Mips toolchain required."
#endif
#elif defined __STATETRACE_POWERPC__
#if !defined __powerpc__
#error "PowerPC toolchain required."
#endif
#elif defined __STATETRACE_SPARC__
#if !defined __sparc__
#error "Sparc toolchain required."
#endif
#elif defined __STATETRACE_SH__
#if !defined __sh__
#error "SuperH toolchain required."
#endif
#elif defined __STATETRACE__S390__
#if !defined __s390__
#error "System/390 toolchain required."
#endif
#else
#error "Couldn't determine architecture"
#error "Couldn't determine architecture."
#endif

View file

@ -28,6 +28,8 @@
* Authors: Gabe Black
*/
#include "base/arch_check.h"
#include <cstring>
#include <errno.h>
#include <fstream>

View file

@ -31,7 +31,7 @@
#ifndef TRACECHILD_HH
#define TRACECHILD_HH
#include "regstate.hh"
#include "base/regstate.hh"
class TraceChild : public RegState
{