Enable debugging of RS code under GDB
- Add/integrate GDBJITRegistrar support class for interfacing with GDB
-- Once the GDBJITRegistrar is merged into LLVM trunk (and AOSP upgrades LLVM)
all files GDB* should be removed, and replaced with appropriate includes
- Basic [host|target]-side integration tests
-- host-tests: use bcc driver and clang to verify gdb output
-- target-tests: run skeleton apk on target and verify gdb output
- Add support for optimization_level metadata in bcinfo, libbcc
-- Disabled some LTO passes when optimization_level = 0
-- move register allocator registration after metadata inspection
- Initial version of android-commands.py GDB plugin (for test infrastructure)
-- relevant commands: load-android-app, run-android-app, start-android-app
-- tested versions: gdb (7.2, 7.3), python (2.6, 2.7)
- build 'bcc' driver tool by default in eng builds
Change-Id: I99e0c11c8591c6d911632c1dcc82dd8fbe1244a8
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index f772c64..97d8803 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -32,6 +32,7 @@
#include "DebugHelper.h"
#include "FileHandle.h"
+#include "GDBJITRegistrar.h"
#include "ScriptCompiled.h"
#include "ScriptCached.h"
#include "Sha1Helper.h"
@@ -46,7 +47,6 @@
#include <string.h>
#include <cutils/properties.h>
-
namespace {
bool getBooleanProp(const char *str) {
@@ -215,6 +215,7 @@
return 1;
}
+ int status = -1;
#if USE_CACHE
if (cacheDir && cacheName) {
// Set Cache Directory and File Name
@@ -227,19 +228,25 @@
// Load Cache File
if (internalLoadCache(false) == 0) {
- return 0;
+ status = 0;
}
}
#endif
- int status = internalCompile(false);
- if (status != 0) {
- LOGE("LLVM error message: %s\n", getCompilerErrorMessage());
+ if (status == -1) {
+ status = internalCompile(false);
+ if (status != 0) {
+ LOGE("LLVM error message: %s\n", getCompilerErrorMessage());
+ }
+ }
+
+ // FIXME: Registration can be conditional on the presence of debug metadata
+ if (status == 0) {
+ registerObjectWithGDB(getELF(), getELFSize()); // thread-safe registration
}
return status;
}
-
#if USE_CACHE
int Script::internalLoadCache(bool checkOnly) {
if (getBooleanProp("debug.bcc.nocache")) {
@@ -762,7 +769,11 @@
case ScriptStatus::Compiled: {
return mCompiled->getELFSize();
}
-
+#if USE_CACHE
+ case ScriptStatus::Cached: {
+ return mCached->getELFSize();
+ }
+#endif
default: {
return 0;
}
@@ -774,7 +785,11 @@
case ScriptStatus::Compiled: {
return mCompiled->getELF();
}
-
+#if USE_CACHE
+ case ScriptStatus::Cached: {
+ return mCached->getELF();
+ }
+#endif
default: {
return NULL;
}