From cd2426086a840d7d7aa755e92e4cbae89e7e80d7 Mon Sep 17 00:00:00 2001 From: Pete Delaney Date: Thu, 4 Jun 2015 17:33:14 -0700 Subject: [PATCH] Provide better advice on using gdb with debuggerd on crashed applications. Let CyanogenMod developers know of a Cyanogen enhancement made by Clark Scheff and Steve Kondik where the graphical debugger interface ddd can be used with crashed applications. The new in-line function, dddclient, is now available in addition to the std Google gdbclient interface. Also, let users know that they have set their property debug.db.uid too low to enable debuggerd to wait for gdb to attach. If they haven't set debug.db.uid; let them know; and offer a hint on how to do it, without their having to Google for the web page. Change-Id: I467d861c0fffe34e8532a8bc7cf7bfdab9f56447 Signed-off-by: Pete Delaney --- debuggerd/debuggerd.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp index 8b95920a2bf..5eef93ff9fb 100644 --- a/debuggerd/debuggerd.cpp +++ b/debuggerd/debuggerd.cpp @@ -15,6 +15,8 @@ * limitations under the License. */ +#define LOG_TAG "DEBUG" + #include #include #include @@ -75,11 +77,13 @@ static void wait_for_user_action(const debugger_request_t &request) { "* and start gdbclient:\n" "*\n" "* gdbclient %s :5039 %d\n" + "* or\n" + "* dddclient %s :5039 %d\n" "*\n" "* Wait for gdb to start, then press the VOLUME DOWN key\n" "* to let the process continue crashing.\n" "********************************************************", - request.pid, exe, request.tid); + request.pid, exe, request.tid, exe, request.tid); // Wait for VOLUME DOWN. if (init_getevent() == 0) { @@ -278,7 +282,19 @@ static bool should_attach_gdb(debugger_request_t* request) { char value[PROPERTY_VALUE_MAX]; property_get("debug.db.uid", value, "-1"); int debug_uid = atoi(value); - return debug_uid >= 0 && request->uid <= (uid_t)debug_uid; + if (debug_uid >= 0 && request->uid <= (uid_t)debug_uid) { + return true; + } else { + /* External docs say to use 10,000 but more is likely needed; be helpful. */ + if (request->uid > (uid_t)debug_uid) { + ALOGI("request->uid:%d > property debug.db.uid:%d; NOT waiting for gdb.", + request->uid, debug_uid); + } else { + ALOGI("property debug.db.uid not set; NOT waiting for gdb."); + ALOGI("HINT: adb shell setprop debug.db.uid 100000"); + ALOGI("HINT: adb forward tcp:5039 tcp:5039"); + } + } } return false; }