From b679d8afa0667daa0d2ed68b2445444f1a625efa Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 19 Mar 2016 16:21:45 -0400 Subject: [PATCH] Debugger: Fix #12693. DwarfImageDebugInfo: - When resolving the address of a PIC function that a value was returned by, check if the resulting address actually belongs to the same image as the caller. If not, find the appropriate image for the new address. Combined with the previous commits, this fixes the issue that functions called indirectly by PLT entry that jumped to another image entirely wouldn't be mapped back to their corresponding FunctionDebugInfo instance, and thus would be skipped since we couldn't determine a type to associate the return value with. --- src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 29fb16f07d..69765e3aa8 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2012-2014, Rene Gollent, rene@gollent.com. + * Copyright 2012-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -1209,6 +1209,16 @@ DwarfImageDebugInfo::_CreateReturnValues(ReturnValueInfoList* returnValueInfos, subroutineAddress, subroutineState, subroutineAddress); if (result != B_OK) continue; + if (!targetImage->ContainsAddress(subroutineAddress)) { + // the PLT entry doesn't necessarily point to a function + // in the same image; as such we may need to try to + // resolve the target address again. + targetImage = image->GetTeam()->ImageByAddress( + subroutineAddress); + if (targetImage == NULL) + continue; + imageInfo = targetImage->GetImageDebugInfo(); + } } targetFunction = imageInfo->FunctionAtAddress(subroutineAddress);