Index: include/lldb/Breakpoint/BreakpointResolverName.h =================================================================== --- include/lldb/Breakpoint/BreakpointResolverName.h +++ include/lldb/Breakpoint/BreakpointResolverName.h @@ -18,6 +18,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Core/Architecture.h" #include "lldb/Core/Module.h" namespace lldb_private { @@ -54,6 +55,12 @@ lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); + // Computes the breakpoint address. + void ComputeBreakpointAddress(Architecture *arch, + SymbolContext sc, + Address &break_addr, + bool m_skip_prologue); + static BreakpointResolver * CreateFromStructuredData(Breakpoint *bkpt, const StructuredData::Dictionary &data_dict, Index: lit/Breakpoint/Inputs/ppc64-call-function.cpp =================================================================== --- /dev/null +++ lit/Breakpoint/Inputs/ppc64-call-function.cpp @@ -0,0 +1,22 @@ +//===-- call-function.cpp ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +namespace ns +{ + int func1(void) { printf("In func1\n"); return 1; } + int func2(void) { printf("In func2\n"); return 2; } +} + +int x; +int main(int argc, char const *argv[]) { + x = ns::func1() + ns::func2(); + return 0; +} Index: lit/Breakpoint/ppc64-call-function.test =================================================================== --- /dev/null +++ lit/Breakpoint/ppc64-call-function.test @@ -0,0 +1,13 @@ +# REQUIRES: powerpc +# +# RUN: %cxx %p/Inputs/ppc64-call-function.cpp -g -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -n ns::func1 --skip-prologue 0 +# CHECK-LABEL: breakpoint set -n ns::func1 --skip-prologue 0 +# CHECK: Address: {{.*}}`ns::func1() + 8 + +breakpoint set -n ns::func2 +# CHECK-LABEL: breakpoint set -n ns::func2 +# CHECK: Address: {{.*}}`ns::func2() + 28 + Index: source/Breakpoint/BreakpointResolverName.cpp =================================================================== --- source/Breakpoint/BreakpointResolverName.cpp +++ source/Breakpoint/BreakpointResolverName.cpp @@ -335,6 +335,7 @@ // Remove any duplicates between the function list and the symbol list SymbolContext sc; if (func_list.GetSize()) { + Architecture *arch = m_breakpoint->GetTarget().GetArchitecturePlugin(); for (i = 0; i < func_list.GetSize(); i++) { if (func_list.GetContextAtIndex(i, sc)) { bool is_reexported = false; @@ -344,12 +345,7 @@ break_addr.Clear(); } else if (sc.function) { break_addr = sc.function->GetAddressRange().GetBaseAddress(); - if (m_skip_prologue && break_addr.IsValid()) { - const uint32_t prologue_byte_size = - sc.function->GetPrologueByteSize(); - if (prologue_byte_size) - break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size); - } + ComputeBreakpointAddress(arch, sc, break_addr, m_skip_prologue); } else if (sc.symbol) { if (sc.symbol->GetType() == eSymbolTypeReExported) { const Symbol *actual_symbol = @@ -362,19 +358,8 @@ break_addr = sc.symbol->GetAddress(); } - if (m_skip_prologue && break_addr.IsValid()) { - const uint32_t prologue_byte_size = - sc.symbol->GetPrologueByteSize(); - if (prologue_byte_size) - break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size); - else { - Architecture *arch = - m_breakpoint->GetTarget().GetArchitecturePlugin(); - if (arch) - arch->AdjustBreakpointAddress(*sc.symbol, break_addr); - } - } - } + ComputeBreakpointAddress(arch, sc, break_addr, m_skip_prologue); + } if (break_addr.IsValid()) { if (filter.AddressPasses(break_addr)) { @@ -397,6 +382,24 @@ return Searcher::eCallbackReturnContinue; } +void BreakpointResolverName::ComputeBreakpointAddress(Architecture *arch, + SymbolContext sc, + Address &break_addr, + bool m_skip_prologue) { + uint32_t prologue_byte_size = 0; + + if (break_addr.IsValid()) { + if (sc.function) prologue_byte_size = sc.function->GetPrologueByteSize(); + else if (sc.symbol) prologue_byte_size = sc.symbol->GetPrologueByteSize(); + + if (prologue_byte_size && m_skip_prologue) { + break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size); + } else if (arch) { + arch->AdjustBreakpointAddress(*sc.symbol, break_addr); + } + } +} + Searcher::Depth BreakpointResolverName::GetDepth() { return Searcher::eDepthModule; }