From eab89a09d26fd39cdbb3ddd826465c8661403b89 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 2 Mar 2011 22:53:11 -0800 Subject: [PATCH] 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 --- util/statetrace/SConscript | 39 +++++++++++ util/statetrace/SConstruct | 43 ++++++++++-- .../tracechild.cc} | 2 +- .../tracechild.hh} | 2 +- .../{tracechild_arm.cc => arm/tracechild.cc} | 2 +- .../{tracechild_arm.hh => arm/tracechild.hh} | 2 +- .../tracechild.cc} | 2 +- .../tracechild.hh} | 2 +- .../tracechild.cc} | 2 +- .../tracechild.hh} | 2 +- .../{tracechild_arch.cc => base/arch_check.h} | 70 ++++++++++++------- util/statetrace/{ => base}/regstate.hh | 0 util/statetrace/{ => base}/statetrace.cc | 2 + util/statetrace/{ => base}/tracechild.cc | 0 util/statetrace/{ => base}/tracechild.hh | 2 +- 15 files changed, 135 insertions(+), 37 deletions(-) create mode 100644 util/statetrace/SConscript rename util/statetrace/arch/{tracechild_amd64.cc => amd64/tracechild.cc} (99%) rename util/statetrace/arch/{tracechild_amd64.hh => amd64/tracechild.hh} (99%) rename util/statetrace/arch/{tracechild_arm.cc => arm/tracechild.cc} (99%) rename util/statetrace/arch/{tracechild_arm.hh => arm/tracechild.hh} (99%) rename util/statetrace/arch/{tracechild_i386.cc => i386/tracechild.cc} (98%) rename util/statetrace/arch/{tracechild_i386.hh => i386/tracechild.hh} (98%) rename util/statetrace/arch/{tracechild_sparc.cc => sparc/tracechild.cc} (99%) rename util/statetrace/arch/{tracechild_sparc.hh => sparc/tracechild.hh} (99%) rename util/statetrace/{tracechild_arch.cc => base/arch_check.h} (54%) rename util/statetrace/{ => base}/regstate.hh (100%) rename util/statetrace/{ => base}/statetrace.cc (99%) rename util/statetrace/{ => base}/tracechild.cc (100%) rename util/statetrace/{ => base}/tracechild.hh (98%) diff --git a/util/statetrace/SConscript b/util/statetrace/SConscript new file mode 100644 index 000000000..7099b0a51 --- /dev/null +++ b/util/statetrace/SConscript @@ -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) diff --git a/util/statetrace/SConstruct b/util/statetrace/SConstruct index de0eade6a..2e93162d8 100644 --- a/util/statetrace/SConstruct +++ b/util/statetrace/SConstruct @@ -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//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 +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// 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)) diff --git a/util/statetrace/arch/tracechild_amd64.cc b/util/statetrace/arch/amd64/tracechild.cc similarity index 99% rename from util/statetrace/arch/tracechild_amd64.cc rename to util/statetrace/arch/amd64/tracechild.cc index 780bb75a5..5d3b660ab 100644 --- a/util/statetrace/arch/tracechild_amd64.cc +++ b/util/statetrace/arch/amd64/tracechild.cc @@ -35,7 +35,7 @@ #include #include -#include "tracechild_amd64.hh" +#include "arch/amd64/tracechild.hh" using namespace std; diff --git a/util/statetrace/arch/tracechild_amd64.hh b/util/statetrace/arch/amd64/tracechild.hh similarity index 99% rename from util/statetrace/arch/tracechild_amd64.hh rename to util/statetrace/arch/amd64/tracechild.hh index 256be5766..6f28bc0bd 100644 --- a/util/statetrace/arch/tracechild_amd64.hh +++ b/util/statetrace/arch/amd64/tracechild.hh @@ -37,7 +37,7 @@ #include #include -#include "tracechild.hh" +#include "base/tracechild.hh" class AMD64TraceChild : public TraceChild { diff --git a/util/statetrace/arch/tracechild_arm.cc b/util/statetrace/arch/arm/tracechild.cc similarity index 99% rename from util/statetrace/arch/tracechild_arm.cc rename to util/statetrace/arch/arm/tracechild.cc index bd4f4bd36..97b8d06ec 100644 --- a/util/statetrace/arch/tracechild_arm.cc +++ b/util/statetrace/arch/arm/tracechild.cc @@ -47,7 +47,7 @@ #include #include -#include "tracechild_arm.hh" +#include "arch/arm/tracechild.hh" using namespace std; diff --git a/util/statetrace/arch/tracechild_arm.hh b/util/statetrace/arch/arm/tracechild.hh similarity index 99% rename from util/statetrace/arch/tracechild_arm.hh rename to util/statetrace/arch/arm/tracechild.hh index 0379885f1..f4e8ca694 100644 --- a/util/statetrace/arch/tracechild_arm.hh +++ b/util/statetrace/arch/arm/tracechild.hh @@ -48,7 +48,7 @@ #include #include #include -#include "tracechild.hh" +#include "base/tracechild.hh" class ARMTraceChild : public TraceChild diff --git a/util/statetrace/arch/tracechild_i386.cc b/util/statetrace/arch/i386/tracechild.cc similarity index 98% rename from util/statetrace/arch/tracechild_i386.cc rename to util/statetrace/arch/i386/tracechild.cc index 2cdeb29fa..0d868767c 100644 --- a/util/statetrace/arch/tracechild_i386.cc +++ b/util/statetrace/arch/i386/tracechild.cc @@ -33,7 +33,7 @@ #include #include -#include "tracechild_i386.hh" +#include "arch/i386/tracechild.hh" using namespace std; diff --git a/util/statetrace/arch/tracechild_i386.hh b/util/statetrace/arch/i386/tracechild.hh similarity index 98% rename from util/statetrace/arch/tracechild_i386.hh rename to util/statetrace/arch/i386/tracechild.hh index 7f9f7499e..3af621ed6 100644 --- a/util/statetrace/arch/tracechild_i386.hh +++ b/util/statetrace/arch/i386/tracechild.hh @@ -37,7 +37,7 @@ #include #include -#include "tracechild.hh" +#include "base/tracechild.hh" class I386TraceChild : public TraceChild { diff --git a/util/statetrace/arch/tracechild_sparc.cc b/util/statetrace/arch/sparc/tracechild.cc similarity index 99% rename from util/statetrace/arch/tracechild_sparc.cc rename to util/statetrace/arch/sparc/tracechild.cc index dba8fa53d..b18739e24 100644 --- a/util/statetrace/arch/tracechild_sparc.cc +++ b/util/statetrace/arch/sparc/tracechild.cc @@ -33,7 +33,7 @@ #include #include -#include "tracechild_sparc.hh" +#include "arch/sparc/tracechild.hh" using namespace std; diff --git a/util/statetrace/arch/tracechild_sparc.hh b/util/statetrace/arch/sparc/tracechild.hh similarity index 99% rename from util/statetrace/arch/tracechild_sparc.hh rename to util/statetrace/arch/sparc/tracechild.hh index e479fce55..27670604a 100644 --- a/util/statetrace/arch/tracechild_sparc.hh +++ b/util/statetrace/arch/sparc/tracechild.hh @@ -39,7 +39,7 @@ #include #include -#include "tracechild.hh" +#include "base/tracechild.hh" struct regs; diff --git a/util/statetrace/tracechild_arch.cc b/util/statetrace/base/arch_check.h similarity index 54% rename from util/statetrace/tracechild_arch.cc rename to util/statetrace/base/arch_check.h index 052784df2..db513a08e 100644 --- a/util/statetrace/tracechild_arch.cc +++ b/util/statetrace/base/arch_check.h @@ -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 diff --git a/util/statetrace/regstate.hh b/util/statetrace/base/regstate.hh similarity index 100% rename from util/statetrace/regstate.hh rename to util/statetrace/base/regstate.hh diff --git a/util/statetrace/statetrace.cc b/util/statetrace/base/statetrace.cc similarity index 99% rename from util/statetrace/statetrace.cc rename to util/statetrace/base/statetrace.cc index ccc408fa7..c01147b86 100644 --- a/util/statetrace/statetrace.cc +++ b/util/statetrace/base/statetrace.cc @@ -28,6 +28,8 @@ * Authors: Gabe Black */ +#include "base/arch_check.h" + #include #include #include diff --git a/util/statetrace/tracechild.cc b/util/statetrace/base/tracechild.cc similarity index 100% rename from util/statetrace/tracechild.cc rename to util/statetrace/base/tracechild.cc diff --git a/util/statetrace/tracechild.hh b/util/statetrace/base/tracechild.hh similarity index 98% rename from util/statetrace/tracechild.hh rename to util/statetrace/base/tracechild.hh index ad7e60e06..bca04b414 100644 --- a/util/statetrace/tracechild.hh +++ b/util/statetrace/base/tracechild.hh @@ -31,7 +31,7 @@ #ifndef TRACECHILD_HH #define TRACECHILD_HH -#include "regstate.hh" +#include "base/regstate.hh" class TraceChild : public RegState { -- 2.30.2