From 2d377cd6888775fe682e49a1ac34a3a6feb78708 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 10 May 2017 10:58:59 +0100 Subject: [PATCH] tombstoned: Add a shared library version of libtombstoned_client... .. for ART and the frameworks to link against. In the new stack dumping scheme (see related bug), the Java runtime will communicate with tombstoned in order to obtain a FD to which it can write its traces. Also move things around to separate headers that are private implementation details from headers that constitute the public debuggerd API. There are currently only three such headers : - tombstoned/tombstoned.h - debuggerd/client.h - debuggerd/handler.h Bug: 32064548 Test: make Change-Id: If1b8578550e373d84828b180bbe585f1088d1aa3 --- debuggerd/Android.bp | 37 +++++++++++++++---- debuggerd/client/debuggerd_client.cpp | 7 ++-- debuggerd/client/debuggerd_client_test.cpp | 2 +- debuggerd/crash_dump.cpp | 6 +-- debuggerd/debuggerd.cpp | 2 +- debuggerd/debuggerd_test.cpp | 9 +++-- debuggerd/handler/debuggerd_fallback.cpp | 4 +- debuggerd/{include/debuggerd => }/protocol.h | 0 .../include/tombstoned}/tombstoned.h | 0 debuggerd/tombstoned/intercept_manager.cpp | 4 +- debuggerd/tombstoned/tombstoned.cpp | 4 +- .../{ => tombstoned}/tombstoned_client.cpp | 6 +-- debuggerd/util.cpp | 4 +- debuggerd/{include/debuggerd => }/util.h | 0 14 files changed, 54 insertions(+), 31 deletions(-) rename debuggerd/{include/debuggerd => }/protocol.h (100%) rename debuggerd/{include/debuggerd => tombstoned/include/tombstoned}/tombstoned.h (100%) rename debuggerd/{ => tombstoned}/tombstoned_client.cpp (97%) rename debuggerd/{include/debuggerd => }/util.h (100%) diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp index 37d54d74f..3a80b50bb 100644 --- a/debuggerd/Android.bp +++ b/debuggerd/Android.bp @@ -11,12 +11,32 @@ cc_defaults { local_include_dirs: ["include"], } -// Utility library to tombstoned and get an output fd. -cc_library_static { +cc_library_shared { name: "libtombstoned_client", defaults: ["debuggerd_defaults"], srcs: [ - "tombstoned_client.cpp", + "tombstoned/tombstoned_client.cpp", + "util.cpp", + ], + + static_libs: [ + "libasync_safe" + ], + + shared_libs: [ + "libcutils", + "libbase", + ], + + export_include_dirs: ["tombstoned/include"] +} + +// Utility library to tombstoned and get an output fd. +cc_library_static { + name: "libtombstoned_client_static", + defaults: ["debuggerd_defaults"], + srcs: [ + "tombstoned/tombstoned_client.cpp", "util.cpp", ], @@ -25,6 +45,8 @@ cc_library_static { "libcutils", "libbase", ], + + export_include_dirs: ["tombstoned/include"] } // Core implementation, linked into libdebuggerd_handler and the dynamic linker. @@ -64,7 +86,7 @@ cc_library_static { whole_static_libs: [ "libdebuggerd_handler_core", - "libtombstoned_client", + "libtombstoned_client_static", "libasync_safe", "libbase", "libdebuggerd", @@ -159,10 +181,8 @@ cc_test { srcs: [ "client/debuggerd_client_test.cpp", "debuggerd_test.cpp", - "tombstoned_client.cpp", - "util.cpp" ], - static_libs: ["libasync_safe"], + static_libs: ["libasync_safe", "libtombstoned_client_static"], }, }, @@ -171,6 +191,7 @@ cc_test { "libbase", "libcutils", "libdebuggerd_client", + "liblog" ], static_libs: [ @@ -211,7 +232,7 @@ cc_binary { }, static_libs: [ - "libtombstoned_client", + "libtombstoned_client_static", "libdebuggerd", "libcutils", ], diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp index 2be13c611..4ce038ce4 100644 --- a/debuggerd/client/debuggerd_client.cpp +++ b/debuggerd/client/debuggerd_client.cpp @@ -31,9 +31,10 @@ #include #include #include -#include -#include -#include + +#include "debuggerd/handler.h" +#include "protocol.h" +#include "util.h" using namespace std::chrono_literals; diff --git a/debuggerd/client/debuggerd_client_test.cpp b/debuggerd/client/debuggerd_client_test.cpp index aff03e598..8f97db1fa 100644 --- a/debuggerd/client/debuggerd_client_test.cpp +++ b/debuggerd/client/debuggerd_client_test.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include "util.h" using namespace std::chrono_literals; using android::base::unique_fd; diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index d2a42396a..be2807914 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -48,9 +48,9 @@ #include "utility.h" #include "debuggerd/handler.h" -#include "debuggerd/protocol.h" -#include "debuggerd/tombstoned.h" -#include "debuggerd/util.h" +#include "protocol.h" +#include "tombstoned/tombstoned.h" +#include "util.h" using android::base::unique_fd; using android::base::ReadFileToString; diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp index 492e9f023..4997dd64b 100644 --- a/debuggerd/debuggerd.cpp +++ b/debuggerd/debuggerd.cpp @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include "util.h" using android::base::unique_fd; diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 0b4bbfb60..f17724a40 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -35,12 +35,13 @@ #include #include #include -#include -#include -#include -#include #include +#include "debuggerd/handler.h" +#include "protocol.h" +#include "tombstoned/tombstoned.h" +#include "util.h" + using namespace std::chrono_literals; using android::base::unique_fd; diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp index 47c98d1c9..a9c9862e4 100644 --- a/debuggerd/handler/debuggerd_fallback.cpp +++ b/debuggerd/handler/debuggerd_fallback.cpp @@ -42,8 +42,8 @@ #include #include "debuggerd/handler.h" -#include "debuggerd/tombstoned.h" -#include "debuggerd/util.h" +#include "tombstoned/tombstoned.h" +#include "util.h" #include "backtrace.h" #include "tombstone.h" diff --git a/debuggerd/include/debuggerd/protocol.h b/debuggerd/protocol.h similarity index 100% rename from debuggerd/include/debuggerd/protocol.h rename to debuggerd/protocol.h diff --git a/debuggerd/include/debuggerd/tombstoned.h b/debuggerd/tombstoned/include/tombstoned/tombstoned.h similarity index 100% rename from debuggerd/include/debuggerd/tombstoned.h rename to debuggerd/tombstoned/include/tombstoned/tombstoned.h diff --git a/debuggerd/tombstoned/intercept_manager.cpp b/debuggerd/tombstoned/intercept_manager.cpp index dff942cc9..4d4eb9e19 100644 --- a/debuggerd/tombstoned/intercept_manager.cpp +++ b/debuggerd/tombstoned/intercept_manager.cpp @@ -28,8 +28,8 @@ #include #include -#include "debuggerd/protocol.h" -#include "debuggerd/util.h" +#include "protocol.h" +#include "util.h" using android::base::unique_fd; diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp index 80dbef522..05df9f2b6 100644 --- a/debuggerd/tombstoned/tombstoned.cpp +++ b/debuggerd/tombstoned/tombstoned.cpp @@ -35,8 +35,8 @@ #include #include "debuggerd/handler.h" -#include "debuggerd/protocol.h" -#include "debuggerd/util.h" +#include "protocol.h" +#include "util.h" #include "intercept_manager.h" diff --git a/debuggerd/tombstoned_client.cpp b/debuggerd/tombstoned/tombstoned_client.cpp similarity index 97% rename from debuggerd/tombstoned_client.cpp rename to debuggerd/tombstoned/tombstoned_client.cpp index e878b6a49..39dc6eb07 100644 --- a/debuggerd/tombstoned_client.cpp +++ b/debuggerd/tombstoned/tombstoned_client.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "debuggerd/tombstoned.h" +#include "tombstoned/tombstoned.h" #include #include @@ -25,8 +25,8 @@ #include #include -#include "debuggerd/protocol.h" -#include "debuggerd/util.h" +#include "protocol.h" +#include "util.h" using android::base::unique_fd; diff --git a/debuggerd/util.cpp b/debuggerd/util.cpp index 32d2f1880..c6a997bef 100644 --- a/debuggerd/util.cpp +++ b/debuggerd/util.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "debuggerd/util.h" +#include "util.h" #include @@ -22,7 +22,7 @@ #include #include -#include +#include "protocol.h" using android::base::unique_fd; diff --git a/debuggerd/include/debuggerd/util.h b/debuggerd/util.h similarity index 100% rename from debuggerd/include/debuggerd/util.h rename to debuggerd/util.h