diff --git a/.gitignore b/.gitignore index de90463d8a27..65f382c8333a 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,6 @@ cscope.* tags TAGS *~ +/protobuf/frame.piqi.pb-c.c +/protobuf/frame.piqi.pb-c.h +/protobuf/frame.piqi.proto diff --git a/Makefile b/Makefile index 423e373fed3e..b3e3fb690a68 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,14 @@ ifneq ($(wildcard config-host.mak),) all: include config-host.mak +ifeq ($(HAS_TRACEWRAP),y) +all: protoframes + +protoframes: + make -C protobuf +endif + + # Check that we're not trying to do an out-of-tree build from # a tree that's been used for an in-tree build. ifneq ($(realpath $(SRC_PATH)),$(realpath .)) @@ -146,8 +154,13 @@ ifeq ($(CONFIG_SMARTCARD_NSS),y) include $(SRC_PATH)/libcacard/Makefile endif + + + all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules + + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) diff --git a/README.md b/README.md index 8ece8aa3e8ca..93a9c171918a 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,19 @@ project. # Installing released binaries -If you don't want to mess with the source and building, then you can just -dowload a tarball with prebuilt binaries. Look at the latest release and +If you don't want to mess with the source and building, then you can just +dowload a tarball with prebuilt binaries. Look at the latest release and it might happen, that we have built binaries for your linux distribution, if it is not the case, then create an issue, and we will build it for you. -Let's pretend, that you're using Ubuntu Trusty, and install it. First +Let's pretend, that you're using Ubuntu Trusty, and install it. First download it with your favorite downloader: ``` wget https://github.com/BinaryAnalysisPlatform/qemu/releases/download/v2.0.0-tracewrap-alpha/qemu-tracewrap-ubuntu-14.04.4-LTS.tgz ``` -Install it in the specified prefix with a command like `tar -C -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz`, e.g., +Install it in the specified prefix with a command like `tar -C -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz`, e.g., to install in your home directory: ``` tar -C $HOME -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz @@ -62,42 +62,36 @@ $ opam install piqi ## Building -Download [bap-traces](https://github.com/BinaryAnalysisPlatform/bap-traces) with +Download [bap-frames](https://github.com/BinaryAnalysisPlatform/bap-frames) with following command ```bash -$ git clone https://github.com/BinaryAnalysisPlatform/bap-traces.git +$ git clone https://github.com/BinaryAnalysisPlatform/bap-frames.git ``` Download qemu tracer with following command ```bash -$ git clone git@github.com:BinaryAnalysisPlatform/qemu.git -b tracewrap +$ git clone git@github.com:BinaryAnalysisPlatform/qemu.git ``` -Change folder to qemu and build tracer with command +Change folder to qemu and build tracer: ```bash -$ ./configure --prefix=$HOME --with-tracewrap=`realpath ../bap-frames` \ ---extra-ldflags=-Lprotobuf --target-list="arm-linux-user i386-linux-user \ -x86_64-linux-user mips-linux-user" -$ make -C protobuf +$ cd qemu +$ ./configure --prefix=$HOME --with-tracewrap=../bap-frames --target-list="`echo {arm,i386,x86_64,mips}-linux-user`" $ make $ make install ``` # Usage -To run executable `exec` and to save the trace data to `exec.trace`, use +To run executable `exec` compiled for `arch`, use `qemu-arch exec` command, e.g., +`qemu-x86_64 /bin/ls`. It will dump the trace into `ls.frames` file. You can configure +the filename with `-tracefile` option, e.g., `qemu-arm -tracefile arm.ls.frames ls` -```bash -$ qemu-arm -tracefile exec.trace exec # trace ARM target executable -$ qemu-i386 -tracefile exec.trace exec # trace X86 target executable -$ qemu-x86_64 -tracefile exec.trace exec # trace X86-64 target executable -$ qemu-mips -tracefile exec.trace exec # trace MIPS target executable -``` Hints: use option -L to set the elf interpreter prefix to 'path'. Use -[fetchlibs.sh](https://raw.githubusercontent.com/BinaryAnalysisPlatform/bap-traces/master/test/fetchlibs.sh) +[fetchlibs.sh](https://raw.githubusercontent.com/BinaryAnalysisPlatform/bap-frames/master/test/fetchlibs.sh) to download arm and x86 libraries. # Notes diff --git a/configure b/configure index 1eb03f30e8a7..d58e636e7b0d 100755 --- a/configure +++ b/configure @@ -749,13 +749,13 @@ for opt do ;; --with-trace-file=*) trace_file="$optarg" ;; - --with-tracewrap=*) + --with-tracewrap=*) tracewrap="yes" - TRACEWRAP_DIR="$optarg" - QEMU_INCLUDES="$QEMU_INCLUDES -I\$(SRC_PATH)/protobuf/ " + TRACEWRAP_DIR="`realpath $optarg`" + QEMU_INCLUDES="$QEMU_INCLUDES -I\$(SRC_PATH)/protobuf/ -I$TRACEWRAP_DIR/libtrace/src/" QEMU_CFLAGS="$QEMU_CFLAGS -L\$(SRC_PATH)/protobuf -DHAS_TRACEWRAP " - LIBS="$LIBS -ltrace -lprotobuf-c " - ;; + LIBS="$LIBS -lprotoframes -lprotobuf-c " + ;; --enable-gprof) gprof="yes" ;; --enable-gcov) gcov="yes" @@ -5227,4 +5227,3 @@ printf "exec" >>config.status printf " '%s'" "$0" "$@" >>config.status echo >>config.status chmod +x config.status - diff --git a/linux-user/arm/trace_info.h b/linux-user/arm/trace_info.h new file mode 100644 index 000000000000..c859196afca2 --- /dev/null +++ b/linux-user/arm/trace_info.h @@ -0,0 +1,6 @@ +#pragma once + +#include "frame_arch.h" + +const uint64_t frame_arch = frame_arch_arm; +const uint64_t frame_mach = frame_mach_arm_unknown; diff --git a/linux-user/i386/trace_info.h b/linux-user/i386/trace_info.h index 9f94a18bdd2a..f2e9fe71fdde 100644 --- a/linux-user/i386/trace_info.h +++ b/linux-user/i386/trace_info.h @@ -1,6 +1,6 @@ #pragma once -#include "disas/bfd.h" +#include "frame_arch.h" -const uint64_t bfd_arch = bfd_arch_i386; -const uint64_t bfd_machine = bfd_mach_i386_i386; +const uint64_t frame_arch = frame_arch_i386; +const uint64_t frame_mach = frame_mach_i386_i386; diff --git a/linux-user/mips/trace_info.h b/linux-user/mips/trace_info.h index 43f581bf393d..ea78cd3e83c1 100644 --- a/linux-user/mips/trace_info.h +++ b/linux-user/mips/trace_info.h @@ -1,7 +1,6 @@ #pragma once -#include "disas/bfd.h" +#include "frame_arch.h" -const uint64_t bfd_arch = bfd_arch_mips; -const uint64_t bfd_machine = 32 ; /* bfd_mach_mipsisa32 */ -/* our bfd.h is so outdated, that it doesn't include it.*/ +const uint64_t frame_arch = frame_arch_mips; +const uint64_t frame_mach = frame_mach_mipsisa32 ; diff --git a/linux-user/x86_64/trace_info.h b/linux-user/x86_64/trace_info.h index 728b34160322..ed8f8ed1d9c2 100644 --- a/linux-user/x86_64/trace_info.h +++ b/linux-user/x86_64/trace_info.h @@ -1,6 +1,6 @@ #pragma once -#include "disas/bfd.h" +#include "frame_arch.h" -const uint64_t bfd_arch = bfd_arch_i386; -const uint64_t bfd_machine = bfd_mach_x86_64; +const uint64_t frame_arch = frame_arch_i386; +const uint64_t frame_mach = frame_mach_x86_64; diff --git a/protobuf/Makefile b/protobuf/Makefile index cffc72303e1a..2e3a2d224fc9 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -4,11 +4,12 @@ CC=gcc FILENAME=frame.piqi EXT=pb-c +PROTOFILE=$(TRACEWRAP_DIR)/piqi/$(FILENAME) -all: libtrace.a +all: libprotoframes.a -$(FILENAME).proto: - piqi to-proto $(TRACEWRAP_DIR)/$(FILENAME) -o $(FILENAME).proto +$(FILENAME).proto: $(PROTOFILE) + piqi to-proto $(PROTOFILE) -o $(FILENAME).proto $(FILENAME).$(EXT).c: $(FILENAME).proto protoc-c --c_out=. $(FILENAME).proto @@ -18,8 +19,8 @@ $(FILENAME).$(EXT).c: $(FILENAME).proto $(FILENAME).$(EXT).o: $(FILENAME).$(EXT).c $(FILENAME).$(EXT).h $(CC) -fPIC -c -o $(FILENAME).$(EXT).o $(FILENAME).$(EXT).c -libtrace.a: $(FILENAME).$(EXT).o - ar rcs libtrace.a $(FILENAME).$(EXT).o +libprotoframes.a: $(FILENAME).$(EXT).o + ar rcs libprotoframes.a $(FILENAME).$(EXT).o clean: - rm libtrace.a $(FILENAME).$(EXT).[hco] + rm $(FILENAME).$(EXT).[hco] $(FILENAME).proto diff --git a/target-arm/trace_info.h b/target-arm/trace_info.h deleted file mode 100644 index 5e43be347f46..000000000000 --- a/target-arm/trace_info.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "disas/bfd.h" - -const uint64_t bfd_arch = bfd_arch_arm; -const uint64_t bfd_machine = bfd_mach_arm_unknown; diff --git a/tracewrap.c b/tracewrap.c index 7697a9e8ae11..9cbc0ae200b5 100644 --- a/tracewrap.c +++ b/tracewrap.c @@ -95,8 +95,8 @@ static void write_header(void) { uint64_t toc_off = 0L; WRITE(magic_number); WRITE(out_trace_version); - WRITE(bfd_arch); - WRITE(bfd_machine); + WRITE(frame_arch); + WRITE(frame_mach); WRITE(toc_num_frames); WRITE(toc_off); }