Skip to content

Commit

Permalink
Provide better advice on using gdb with debuggerd on crashed applicat…
Browse files Browse the repository at this point in the history
…ions.

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 <piet@cyngn.com>
  • Loading branch information
Pete Delaney authored and Gerrit Code Review committed Jun 16, 2015
1 parent e3465bf commit cd24260
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions debuggerd/debuggerd.cpp
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

#define LOG_TAG "DEBUG"

#include <stdio.h>
#include <errno.h>
#include <signal.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit cd24260

Please sign in to comment.