summaryrefslogtreecommitdiff
path: root/util/statetrace
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2011-03-02 22:53:11 -0800
committerGabe Black <gblack@eecs.umich.edu>2011-03-02 22:53:11 -0800
commiteab89a09d26fd39cdbb3ddd826465c8661403b89 (patch)
tree42dd7b2e69e909c08e437ba86c4c9bf3f8a3b63b /util/statetrace
parent9151c4039a6a113f77c9f6587a6fe0399ae19068 (diff)
downloadgem5-eab89a09d26fd39cdbb3ddd826465c8661403b89.tar.xz
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
Diffstat (limited to 'util/statetrace')
-rw-r--r--util/statetrace/SConscript39
-rw-r--r--util/statetrace/SConstruct43
-rw-r--r--util/statetrace/arch/amd64/tracechild.cc (renamed from util/statetrace/arch/tracechild_amd64.cc)2
-rw-r--r--util/statetrace/arch/amd64/tracechild.hh (renamed from util/statetrace/arch/tracechild_amd64.hh)2
-rw-r--r--util/statetrace/arch/arm/tracechild.cc (renamed from util/statetrace/arch/tracechild_arm.cc)2
-rw-r--r--util/statetrace/arch/arm/tracechild.hh (renamed from util/statetrace/arch/tracechild_arm.hh)2
-rw-r--r--util/statetrace/arch/i386/tracechild.cc (renamed from util/statetrace/arch/tracechild_i386.cc)2
-rw-r--r--util/statetrace/arch/i386/tracechild.hh (renamed from util/statetrace/arch/tracechild_i386.hh)2
-rw-r--r--util/statetrace/arch/sparc/tracechild.cc (renamed from util/statetrace/arch/tracechild_sparc.cc)2
-rw-r--r--util/statetrace/arch/sparc/tracechild.hh (renamed from util/statetrace/arch/tracechild_sparc.hh)2
-rw-r--r--util/statetrace/base/arch_check.h (renamed from util/statetrace/tracechild_arch.cc)70
-rw-r--r--util/statetrace/base/regstate.hh (renamed from util/statetrace/regstate.hh)0
-rw-r--r--util/statetrace/base/statetrace.cc (renamed from util/statetrace/statetrace.cc)2
-rw-r--r--util/statetrace/base/tracechild.cc (renamed from util/statetrace/tracechild.cc)0
-rw-r--r--util/statetrace/base/tracechild.hh (renamed from util/statetrace/tracechild.hh)2
15 files changed, 135 insertions, 37 deletions
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/<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))
diff --git a/util/statetrace/arch/tracechild_amd64.cc b/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 <stdint.h>
#include <string.h>
-#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
index 256be5766..6f28bc0bd 100644
--- a/util/statetrace/arch/tracechild_amd64.hh
+++ b/util/statetrace/arch/amd64/tracechild.hh
@@ -37,7 +37,7 @@
#include <cassert>
#include <string>
-#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
index bd4f4bd36..97b8d06ec 100644
--- a/util/statetrace/arch/tracechild_arm.cc
+++ b/util/statetrace/arch/arm/tracechild.cc
@@ -47,7 +47,7 @@
#include <cstring>
#include <cstdio>
-#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
index 0379885f1..f4e8ca694 100644
--- a/util/statetrace/arch/tracechild_arm.hh
+++ b/util/statetrace/arch/arm/tracechild.hh
@@ -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
diff --git a/util/statetrace/arch/tracechild_i386.cc b/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 <sys/ptrace.h>
#include <stdint.h>
-#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
index 7f9f7499e..3af621ed6 100644
--- a/util/statetrace/arch/tracechild_i386.hh
+++ b/util/statetrace/arch/i386/tracechild.hh
@@ -37,7 +37,7 @@
#include <cassert>
#include <string>
-#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
index dba8fa53d..b18739e24 100644
--- a/util/statetrace/arch/tracechild_sparc.cc
+++ b/util/statetrace/arch/sparc/tracechild.cc
@@ -33,7 +33,7 @@
#include <sys/ptrace.h>
#include <stdint.h>
-#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
index e479fce55..27670604a 100644
--- a/util/statetrace/arch/tracechild_sparc.hh
+++ b/util/statetrace/arch/sparc/tracechild.hh
@@ -39,7 +39,7 @@
#include <sys/ptrace.h>
#include <sys/types.h>
-#include "tracechild.hh"
+#include "base/tracechild.hh"
struct regs;
diff --git a/util/statetrace/tracechild_arch.cc b/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
index bab3485c6..bab3485c6 100644
--- a/util/statetrace/regstate.hh
+++ b/util/statetrace/base/regstate.hh
diff --git a/util/statetrace/statetrace.cc b/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 <cstring>
#include <errno.h>
#include <fstream>
diff --git a/util/statetrace/tracechild.cc b/util/statetrace/base/tracechild.cc
index b5665ff37..b5665ff37 100644
--- a/util/statetrace/tracechild.cc
+++ b/util/statetrace/base/tracechild.cc
diff --git a/util/statetrace/tracechild.hh b/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
{