From cb19ebf7609f74b223bd86c94f721498795f9bba Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Tue, 11 Mar 2014 15:26:35 +0100 Subject: Fix debugger crash in native method frames. The main crash happens when we try to read (StackFrame::GetValues) or write (StackFrame::SetValues) values in native frames. We use the method's vmap to know where Dalvik registers live but native methods don't have vmap. The fix is to reply with the OPAQUE_FRAME error which indicates local values are not accessible in the frame. We prevent from dereferencing null code item which causes some crashes too. This happens when we compute the line table (Method::LineTable) and variable table (Method::VariableTable) of methods without code: native, proxy and abstract methods. We do not expect to encounter abstract methods though. We take care of these kinds of method when mangling/demangling local value slots. We also fix the location's pc of native and proxy frames where it must be -1 (as 8-byte value). We'll use this property to detect such frames in the JDWP tests. Bug: 13366758 Change-Id: I78e3263fbf2681b5573571c846390d52b9193849 --- runtime/jdwp/jdwp_handler.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'runtime/jdwp') diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc index 4b170ba..5f21098 100644 --- a/runtime/jdwp/jdwp_handler.cc +++ b/runtime/jdwp/jdwp_handler.cc @@ -1409,7 +1409,10 @@ static JdwpError SF_GetValues(JdwpState*, Request& request, ExpandBuf* pReply) size_t width = Dbg::GetTagWidth(reqSigByte); uint8_t* ptr = expandBufAddSpace(pReply, width+1); - Dbg::GetLocalValue(thread_id, frame_id, slot, reqSigByte, ptr, width); + JdwpError error = Dbg::GetLocalValue(thread_id, frame_id, slot, reqSigByte, ptr, width); + if (error != ERR_NONE) { + return error; + } } return ERR_NONE; @@ -1431,7 +1434,10 @@ static JdwpError SF_SetValues(JdwpState*, Request& request, ExpandBuf*) uint64_t value = request.ReadValue(width); VLOG(jdwp) << " --> slot " << slot << " " << sigByte << " " << value; - Dbg::SetLocalValue(thread_id, frame_id, slot, sigByte, value, width); + JdwpError error = Dbg::SetLocalValue(thread_id, frame_id, slot, sigByte, value, width); + if (error != ERR_NONE) { + return error; + } } return ERR_NONE; -- cgit v1.1