From f8a2df7bbf1021058bc13d1f806a7fec3c89ee62 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 1 Dec 2011 12:19:54 -0800 Subject: Fix a couple of JDWP bugs. First, dalvikvm's behavior of just carrying on if it failed to set up JDWP was the opposite of helpful. It's wasted loads of my time lately, and I've already benefitted in the half hour since making this a hard stop. Second, I was accidentally reporting upcall frames. I don't know why I wasn't always seeing this -- because we always make an upcall to 'main' -- but it was repeatable if the stack was short enough. Change-Id: Iee14867f596436bed5ca0546db71e62b62d11f41 --- src/debugger.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/debugger.cc b/src/debugger.cc index 7128fdc0a4..37b02aff4f 100644 --- a/src/debugger.cc +++ b/src/debugger.cc @@ -323,8 +323,10 @@ void Dbg::StartJdwp() { // debugger. gJdwpState = JDWP::JdwpState::Create(&gJdwpOptions); if (gJdwpState == NULL) { - LOG(WARNING) << "debugger thread failed to initialize"; - return; + // We probably failed because some other process has the port already, which means that + // if we don't abort the user is likely to think they're talking to us when they're actually + // talking to that other process. + LOG(FATAL) << "debugger thread failed to initialize"; } // If a debugger has already attached, send the "welcome" message. @@ -1103,8 +1105,11 @@ int Dbg::GetThreadFrameCount(JDWP::ObjectId threadId) { ScopedThreadListLock thread_list_lock; struct CountStackDepthVisitor : public Thread::StackVisitor { CountStackDepthVisitor() : depth(0) {} - virtual void VisitFrame(const Frame&, uintptr_t) { - ++depth; + virtual void VisitFrame(const Frame& f, uintptr_t) { + // TODO: we'll need to skip callee-save frames too. + if (f.HasMethod()) { + ++depth; + } } size_t depth; }; @@ -1120,8 +1125,9 @@ bool Dbg::GetThreadFrame(JDWP::ObjectId threadId, int desired_frame_number, JDWP : found(false) ,depth(0), desired_frame_number(desired_frame_number), pFrameId(pFrameId), pLoc(pLoc) { } virtual void VisitFrame(const Frame& f, uintptr_t pc) { + // TODO: we'll need to skip callee-save frames too. if (!f.HasMethod()) { - return; // These don't count? + return; // The debugger can't do anything useful with a frame that has no Method*. } if (depth == desired_frame_number) { -- cgit v1.2.3-59-g8ed1b