From cba80e074419f068a252ce9a114a791bb4dd701c Mon Sep 17 00:00:00 2001 From: Romaric JODIN Date: Fri, 26 Jul 2019 15:30:58 +0200 Subject: [PATCH] dpu: fix unwind not to segv when it can get the symbol of a function Fix #1 --- .../Plugins/Process/Utility/UnwindDPU.cpp | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lldb/source/Plugins/Process/Utility/UnwindDPU.cpp b/lldb/source/Plugins/Process/Utility/UnwindDPU.cpp index aa7f3e3e0b912a..2465e2a36951a5 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindDPU.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindDPU.cpp @@ -95,16 +95,21 @@ uint32_t UnwindDPU::DoGetFrameCount() { // have the good value for r22, but it's normal as its frame is not yet set, // let's just add 1 to it so that we are sure that it will be seen as the // youngest one when comparing StackID). pc is in r23. - Function *fct; + Function *fct = NULL; GetFunction(&fct, first_pc_addr); - lldb::addr_t start_addr = fct->GetAddressRange().GetBaseAddress().GetFileAddress(); - if (((first_pc_addr >= start_addr) && (first_pc_addr < (start_addr + 16))) || - PCIsInstructionReturn(fct, first_pc_addr)) { - prev_frame->cfa++; - RegisterValue reg_r23; - reg_ctx_sp->ReadRegister(reg_ctx_sp->GetRegisterInfoByName("r23"), reg_r23); - SetFrame(&prev_frame, first_r22_value, FORMAT_PC(reg_r23.GetAsUInt32()), - reg_ctx_sp); + if (fct != NULL) { + lldb::addr_t start_addr = + fct->GetAddressRange().GetBaseAddress().GetFileAddress(); + if (((first_pc_addr >= start_addr) && + (first_pc_addr < (start_addr + 16))) || + PCIsInstructionReturn(fct, first_pc_addr)) { + prev_frame->cfa++; + RegisterValue reg_r23; + reg_ctx_sp->ReadRegister(reg_ctx_sp->GetRegisterInfoByName("r23"), + reg_r23); + SetFrame(&prev_frame, first_r22_value, FORMAT_PC(reg_r23.GetAsUInt32()), + reg_ctx_sp); + } } while (true) {