- Notifications
You must be signed in to change notification settings - Fork63
facebookarchive/ds2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ds2 is a debug server designed to be used withLLDB toperform remote debugging of Linux, Android, FreeBSD, Windows and Windows Phonetargets. Windows/Windows Phone support is still under active development.
Launch ds2 with something like:
$ ./ds2 gdbserver localhost:4242 /path/to/TestSimpleOutput
ds2 is now ready to accept connections on port 4242 from lldb.
$ lldb /path/to/TestSimpleOutputCurrent executable set to '/path/to/TestSimpleOutput' (x86_64).(lldb) gdb-remote localhost:4242Process 8336 stopped* thread #1: tid = 8336, 0x00007ffff7ddb2d0, name = 'TestSimpleOutput', stop reason = signal SIGTRAP frame #0: 0x00007ffff7ddb2d0-> 0x7ffff7ddb2d0: movq %rsp, %rdi 0x7ffff7ddb2d3: callq 0x7ffff7ddea70 0x7ffff7ddb2d8: movq %rax, %r12 0x7ffff7ddb2db: movl 0x221b17(%rip), %eax(lldb) b mainBreakpoint 1: where = TestSimpleOutput`main + 29 at TestSimpleOutput.cpp:6, address = 0x000000000040096d[... debug debug ...](lldb) cProcess 8336 resumingProcess 8336 exited with status = 0 (0x00000000)(lldb)
ds2 accepts the following options:
usage: ds2 [RUN_MODE] [OPTIONS] [[HOST]:PORT] [-- PROGRAM [ARGUMENTS...]] -a, --attach ARG attach to the name or PID specified -f, --daemonize detach and become a daemon -d, --debug enable debug log output -F, --fd ARG use a file descriptor to communicate -g, --gdb-compat force ds2 to run in gdb compat mode -o, --log-file ARG output log messages to the file specified -N, --named-pipe ARG determine a port dynamically and write back to FIFO -n, --no-colors disable colored output -D, --remote-debug enable log for remote protocol packets -R, --reverse-connect connect back to the debugger at [HOST]:PORT -e, --set-env ARG... add an element to the environment before launch -S, --setsid make ds2 run in its own session -E, --unset-env ARG... remove an element from the environment before lauch -l, --listen ARG specify the [host]:port to listen on [host]:port the [host]:port to connect to
After building ds2 for your target, run it with the binary to debug, or attachto an already running process. Then, start LLDB as usual and attach to the ds2instance with thegdb-remote
command.
The run mode and port number must be specified, where run mode is eitherg[dbserver]
orp[latform]
. In most cases, theg[dbserver]
option is desired.
ds2 usesCMake to generate its build system. A varietyof CMake toolchain files are provided to help with cross compilation for othertargets.
ds2 needs cmake, a C++11 compiler, flex and bison.
After cloning the ds2 repository, run the following commands to build for thecurrent host:
cd ds2mkdir build&&cd buildcmake ..make
ds2 builds on Windows using Visual Studio. You'll need:
- Windows builds of CMake for which you can grab binarieshere;
- flex and bison binaries -- easiest way to get these is to install them withCygwin and add that to your
PATH
(usuallyC:\cygwin\bin
); - an install of Visual Studio -- we use VS2015, but VS2013 should work too.
Then, as with linux, use CMake to generate the build system, then use msbuild(or the script provided) to build the binary:
cd ds2mkdir build&&cd buildcmake ....\Support\Scripts\build-windows.bat
ds2 can be built for Windows Phone, which will generate a dll that can later beloaded in by the application we are debugging as a separate process. This needsVisual Studio 2015.
To build for Windows Phone, use theToolchain-WinStore.cmake
toolchain fileas well as the "Visual Studio 14 2015 ARM" CMake generator.
cd ds2mkdir build&&cd buildcmake -G"Visual Studio 14 2015 ARM" -DCMAKE_TOOLCHAIN_FILE=../Support/CMake/Toolchain-WinStore.cmake" ....\Support\Scripts\build-windows.bat
For Android native debugging, it is possible to build ds2 with the Android NDK.A script is provided to download the Android NDK automatically for you.
Support/Scripts/prepare-android-ndk.py
will download a working versionof the NDK, extract it, and install it to/tmp/android-ndk
.
cd ds2./Support/Scripts/prepare-android-ndk.pymkdir build&&cd buildcmake -DCMAKE_TOOLCHAIN_FILE=../Support/CMake/Toolchain-Android-ARM.cmake ..make
Note that this will build ds2 targeting the highest level API level that theNDK supports. If you want to target another api level, e.g. 21, add the flag-DCMAKE_SYSTEM_VERSION=21
to your cmake invocation.
If you would like to use ds2 to run tests in the LLDB test suite using anAndroid device, you should use the scriptSupport/Scripts/prepare-android-ndk.py
to get a checkout of the android NDK.The LLDB test suite expects an NDK to exist on your host, and that script willdownload and unpack it where the CMake Toolchain files expect it to be.
Cross-compiling for Linux-ARM is also possible. On Ubuntu 14.04, install an armtoolchain (for instanceg++-4.8-arm-linux-gnueabihf
) and use the providedtoolchain file.
cd ds2mkdir build&&cd buildcmake -DCMAKE_TOOLCHAIN_FILE=../Support/CMake/Toolchain-Linux-ARM.cmake ..make
This will generate a binary that you can copy to your device to startdebugging.
See theCONTRIBUTING.md
file for how to help out.
ds2 is licensed under the University of Illinois/NCSA Open Source License.
We also provide an additional patent grant which can be found in thePATENTS
file in the root directory of this source tree.
regsgen2, a tool used to generate register definitions is also licensed underthe University of Illinois/NCSA Open Source License and uses a json librarylicensed under the Boost Software License. A complete copy of the latter can befound inTools/libjson/LICENSE_1_0.txt
.