[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- Block.cpp ---------------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Symbol/Block.h"
|
2011-09-30 07:41:34 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/Section.h"
|
2011-09-30 07:41:34 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2011-08-06 07:43:37 +08:00
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-12 07:13:08 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2010-08-21 10:22:51 +08:00
|
|
|
Block::Block(lldb::user_id_t uid)
|
2014-04-20 21:17:36 +08:00
|
|
|
: UserID(uid), m_parent_scope(nullptr), m_children(), m_ranges(),
|
2010-08-21 10:22:51 +08:00
|
|
|
m_inlineInfoSP(), m_variable_list_sp(), m_parsed_block_info(false),
|
|
|
|
m_parsed_block_variables(false), m_parsed_child_blocks(false) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-07-03 02:27:37 +08:00
|
|
|
Block::~Block() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-15 07:36:40 +08:00
|
|
|
void Block::GetDescription(Stream *s, Function *function,
|
|
|
|
lldb::DescriptionLevel level, Target *target) const {
|
2010-09-10 09:30:46 +08:00
|
|
|
*s << "id = " << ((const UserID &)*this);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
size_t num_ranges = m_ranges.GetSize();
|
|
|
|
if (num_ranges > 0) {
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-29 05:30:43 +08:00
|
|
|
addr_t base_addr = LLDB_INVALID_ADDRESS;
|
2010-09-15 07:36:40 +08:00
|
|
|
if (target)
|
|
|
|
base_addr =
|
|
|
|
function->GetAddressRange().GetBaseAddress().GetLoadAddress(target);
|
2010-06-29 05:30:43 +08:00
|
|
|
if (base_addr == LLDB_INVALID_ADDRESS)
|
2010-08-21 10:22:51 +08:00
|
|
|
base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-10 09:30:46 +08:00
|
|
|
s->Printf(", range%s = ", num_ranges > 1 ? "s" : "");
|
2011-10-08 08:49:15 +08:00
|
|
|
for (size_t i = 0; i < num_ranges; ++i) {
|
|
|
|
const Range &range = m_ranges.GetEntryRef(i);
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(),
|
|
|
|
base_addr + range.GetRangeEnd(), 4);
|
2010-09-15 13:51:24 +08:00
|
|
|
}
|
2010-06-29 05:30:43 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_inlineInfoSP.get() != nullptr) {
|
|
|
|
bool show_fullpaths = (level == eDescriptionLevelVerbose);
|
2010-09-15 13:51:24 +08:00
|
|
|
m_inlineInfoSP->Dump(s, show_fullpaths);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void Block::Dump(Stream *s, addr_t base_addr, int32_t depth,
|
|
|
|
bool show_context) const {
|
|
|
|
if (depth < 0) {
|
2010-08-21 10:22:51 +08:00
|
|
|
Block *parent = GetParent();
|
|
|
|
if (parent) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// We have a depth that is less than zero, print our parent blocks first
|
2010-08-21 10:22:51 +08:00
|
|
|
parent->Dump(s, base_addr, depth + 1, show_context);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
s->Printf("%p: ", static_cast<const void *>(this));
|
2010-06-09 00:52:24 +08:00
|
|
|
s->Indent();
|
2014-04-04 12:06:10 +08:00
|
|
|
*s << "Block" << static_cast<const UserID &>(*this);
|
2010-06-29 05:30:43 +08:00
|
|
|
const Block *parent_block = GetParent();
|
|
|
|
if (parent_block) {
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf(", parent = {0x%8.8" PRIx64 "}", parent_block->GetID());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-20 21:17:36 +08:00
|
|
|
if (m_inlineInfoSP.get() != nullptr) {
|
2010-09-15 13:51:24 +08:00
|
|
|
bool show_fullpaths = false;
|
|
|
|
m_inlineInfoSP->Dump(s, show_fullpaths);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
if (!m_ranges.IsEmpty()) {
|
2010-06-09 00:52:24 +08:00
|
|
|
*s << ", ranges =";
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
size_t num_ranges = m_ranges.GetSize();
|
2011-10-08 08:49:15 +08:00
|
|
|
for (size_t i = 0; i < num_ranges; ++i) {
|
2014-04-04 12:06:10 +08:00
|
|
|
const Range &range = m_ranges.GetEntryRef(i);
|
2018-12-15 08:15:33 +08:00
|
|
|
if (parent_block != nullptr && !parent_block->Contains(range))
|
2010-06-09 00:52:24 +08:00
|
|
|
*s << '!';
|
|
|
|
else
|
|
|
|
*s << ' ';
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(),
|
|
|
|
base_addr + range.GetRangeEnd(), 4);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
s->EOL();
|
|
|
|
|
|
|
|
if (depth > 0) {
|
|
|
|
s->IndentMore();
|
|
|
|
|
2010-08-25 05:05:24 +08:00
|
|
|
if (m_variable_list_sp.get()) {
|
|
|
|
m_variable_list_sp->Dump(s, show_context);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-30 05:19:25 +08:00
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos)
|
2010-08-25 05:05:24 +08:00
|
|
|
(*pos)->Dump(s, base_addr, depth - 1, show_context);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
s->IndentLess();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Block *Block::FindBlockByID(user_id_t block_id) {
|
|
|
|
if (block_id == GetID())
|
2014-04-20 21:17:36 +08:00
|
|
|
return this;
|
2011-08-13 05:40:01 +08:00
|
|
|
|
|
|
|
Block *matching_block = nullptr;
|
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos) {
|
|
|
|
matching_block = (*pos)->FindBlockByID(block_id);
|
2010-08-21 10:22:51 +08:00
|
|
|
if (matching_block)
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-04-20 21:17:36 +08:00
|
|
|
return matching_block;
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
2021-11-06 11:44:15 +08:00
|
|
|
Block *Block::FindInnermostBlockByOffset(const lldb::addr_t offset) {
|
|
|
|
if (!Contains(offset))
|
|
|
|
return nullptr;
|
|
|
|
for (const BlockSP &block_sp : m_children) {
|
|
|
|
if (Block *block = block_sp->FindInnermostBlockByOffset(offset))
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
void Block::CalculateSymbolContext(SymbolContext *sc) {
|
|
|
|
if (m_parent_scope)
|
|
|
|
m_parent_scope->CalculateSymbolContext(sc);
|
|
|
|
sc->block = this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
lldb::ModuleSP Block::CalculateSymbolContextModule() {
|
|
|
|
if (m_parent_scope)
|
2011-08-13 05:40:01 +08:00
|
|
|
return m_parent_scope->CalculateSymbolContextModule();
|
2010-09-20 13:20:02 +08:00
|
|
|
return lldb::ModuleSP();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
CompileUnit *Block::CalculateSymbolContextCompileUnit() {
|
2014-04-20 21:17:36 +08:00
|
|
|
if (m_parent_scope)
|
|
|
|
return m_parent_scope->CalculateSymbolContextCompileUnit();
|
|
|
|
return nullptr;
|
2010-09-03 05:44:10 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
Function *Block::CalculateSymbolContextFunction() {
|
|
|
|
if (m_parent_scope)
|
2014-04-20 21:17:36 +08:00
|
|
|
return m_parent_scope->CalculateSymbolContextFunction();
|
|
|
|
return nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
Block *Block::CalculateSymbolContextBlock() { return this; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-08-25 05:05:24 +08:00
|
|
|
void Block::DumpSymbolContext(Stream *s) {
|
2010-09-07 12:20:48 +08:00
|
|
|
Function *function = CalculateSymbolContextFunction();
|
|
|
|
if (function)
|
2010-08-25 05:05:24 +08:00
|
|
|
function->DumpSymbolContext(s);
|
|
|
|
s->Printf(", Block{0x%8.8" PRIx64 "}", GetID());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Block::DumpAddressRanges(Stream *s, lldb::addr_t base_addr) {
|
|
|
|
if (!m_ranges.IsEmpty()) {
|
|
|
|
size_t num_ranges = m_ranges.GetSize();
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
for (size_t i = 0; i < num_ranges; ++i) {
|
|
|
|
const Range &range = m_ranges.GetEntryRef(i);
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(),
|
|
|
|
base_addr + range.GetRangeEnd(), 4);
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
bool Block::Contains(addr_t range_offset) const {
|
|
|
|
return m_ranges.FindEntryThatContains(range_offset) != nullptr;
|
2010-08-25 05:05:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
bool Block::Contains(const Block *block) const {
|
|
|
|
if (this == block)
|
2010-09-14 11:16:58 +08:00
|
|
|
return false; // This block doesn't contain itself...
|
2010-08-25 05:05:24 +08:00
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
// Walk the parent chain for "block" and see if any if them match this block
|
2011-08-13 05:40:01 +08:00
|
|
|
const Block *block_parent;
|
2011-10-08 08:49:15 +08:00
|
|
|
for (block_parent = block->GetParent(); block_parent != nullptr;
|
|
|
|
block_parent = block_parent->GetParent()) {
|
|
|
|
if (this == block_parent)
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
return true; // One of the parents of "block" is this object!
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-01 07:49:32 +08:00
|
|
|
bool Block::Contains(const Range &range) const {
|
|
|
|
return m_ranges.FindEntryThatContains(range) != nullptr;
|
|
|
|
}
|
|
|
|
|
2010-08-21 10:22:51 +08:00
|
|
|
Block *Block::GetParent() const {
|
2011-08-13 05:40:01 +08:00
|
|
|
if (m_parent_scope)
|
|
|
|
return m_parent_scope->CalculateSymbolContextBlock();
|
2014-04-20 21:17:36 +08:00
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-09-01 07:49:32 +08:00
|
|
|
|
2013-04-30 01:25:54 +08:00
|
|
|
Block *Block::GetContainingInlinedBlock() {
|
2010-09-07 12:20:48 +08:00
|
|
|
if (GetInlinedFunctionInfo())
|
2010-08-21 10:22:51 +08:00
|
|
|
return this;
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
return GetInlinedParent();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-04-30 01:25:54 +08:00
|
|
|
Block *Block::GetInlinedParent() {
|
2011-09-30 07:41:34 +08:00
|
|
|
Block *parent_block = GetParent();
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
if (parent_block) {
|
2010-09-07 12:20:48 +08:00
|
|
|
if (parent_block->GetInlinedFunctionInfo())
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
return parent_block;
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
return parent_block->GetInlinedParent();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-20 21:17:36 +08:00
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-05-07 04:01:21 +08:00
|
|
|
Block *Block::GetContainingInlinedBlockWithCallSite(
|
|
|
|
const Declaration &find_call_site) {
|
2019-06-29 08:55:13 +08:00
|
|
|
Block *inlined_block = GetContainingInlinedBlock();
|
2019-05-07 04:01:21 +08:00
|
|
|
|
|
|
|
while (inlined_block) {
|
2019-06-29 08:55:13 +08:00
|
|
|
const auto *function_info = inlined_block->GetInlinedFunctionInfo();
|
2019-05-07 04:01:21 +08:00
|
|
|
|
|
|
|
if (function_info &&
|
|
|
|
function_info->GetCallSite().FileAndLineEqual(find_call_site))
|
|
|
|
return inlined_block;
|
|
|
|
inlined_block = inlined_block->GetInlinedParent();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
bool Block::GetRangeContainingOffset(const addr_t offset, Range &range) {
|
|
|
|
const Range *range_ptr = m_ranges.FindEntryThatContains(offset);
|
|
|
|
if (range_ptr) {
|
|
|
|
range = *range_ptr;
|
2010-09-14 11:16:58 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-08-25 05:05:24 +08:00
|
|
|
range.Clear();
|
2010-09-14 11:16:58 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
bool Block::GetRangeContainingAddress(const Address &addr,
|
|
|
|
AddressRange &range) {
|
|
|
|
Function *function = CalculateSymbolContextFunction();
|
|
|
|
if (function) {
|
|
|
|
const AddressRange &func_range = function->GetAddressRange();
|
|
|
|
if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) {
|
|
|
|
const addr_t addr_offset = addr.GetOffset();
|
|
|
|
const addr_t func_offset = func_range.GetBaseAddress().GetOffset();
|
|
|
|
if (addr_offset >= func_offset &&
|
|
|
|
addr_offset < func_offset + func_range.GetByteSize()) {
|
|
|
|
addr_t offset = addr_offset - func_offset;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
const Range *range_ptr = m_ranges.FindEntryThatContains(offset);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
if (range_ptr) {
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
range.GetBaseAddress() = func_range.GetBaseAddress();
|
2011-10-08 08:49:15 +08:00
|
|
|
range.GetBaseAddress().SetOffset(func_offset +
|
|
|
|
range_ptr->GetRangeBase());
|
|
|
|
range.SetByteSize(range_ptr->GetByteSize());
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-10-08 08:49:15 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-08-25 05:05:24 +08:00
|
|
|
range.Clear();
|
2011-10-08 08:49:15 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-23 10:04:55 +08:00
|
|
|
bool Block::GetRangeContainingLoadAddress(lldb::addr_t load_addr,
|
|
|
|
Target &target, AddressRange &range) {
|
2012-09-01 07:49:32 +08:00
|
|
|
Address load_address;
|
|
|
|
load_address.SetLoadAddress(load_addr, &target);
|
|
|
|
AddressRange containing_range;
|
2011-04-23 10:04:55 +08:00
|
|
|
return GetRangeContainingAddress(load_address, containing_range);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-04-23 10:04:55 +08:00
|
|
|
uint32_t Block::GetRangeIndexContainingAddress(const Address &addr) {
|
2011-08-13 05:40:01 +08:00
|
|
|
Function *function = CalculateSymbolContextFunction();
|
|
|
|
if (function) {
|
2011-10-08 08:49:15 +08:00
|
|
|
const AddressRange &func_range = function->GetAddressRange();
|
2011-08-13 05:40:01 +08:00
|
|
|
if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) {
|
|
|
|
const addr_t addr_offset = addr.GetOffset();
|
2011-10-08 08:49:15 +08:00
|
|
|
const addr_t func_offset = func_range.GetBaseAddress().GetOffset();
|
|
|
|
if (addr_offset >= func_offset &&
|
|
|
|
addr_offset < func_offset + func_range.GetByteSize()) {
|
|
|
|
addr_t offset = addr_offset - func_offset;
|
2011-04-23 10:04:55 +08:00
|
|
|
return m_ranges.FindEntryIndexThatContains(offset);
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-04-23 10:04:55 +08:00
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
2010-11-14 08:22:48 +08:00
|
|
|
|
|
|
|
bool Block::GetRangeAtIndex(uint32_t range_idx, AddressRange &range) {
|
2011-10-08 08:49:15 +08:00
|
|
|
if (range_idx < m_ranges.GetSize()) {
|
2011-08-13 05:40:01 +08:00
|
|
|
Function *function = CalculateSymbolContextFunction();
|
|
|
|
if (function) {
|
2011-10-08 08:49:15 +08:00
|
|
|
const Range &vm_range = m_ranges.GetEntryRef(range_idx);
|
2011-08-13 05:40:01 +08:00
|
|
|
range.GetBaseAddress() = function->GetAddressRange().GetBaseAddress();
|
2011-10-08 08:49:15 +08:00
|
|
|
range.GetBaseAddress().Slide(vm_range.GetRangeBase());
|
|
|
|
range.SetByteSize(vm_range.GetByteSize());
|
2010-11-14 08:22:48 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-11-14 08:22:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
bool Block::GetStartAddress(Address &addr) {
|
|
|
|
if (m_ranges.IsEmpty())
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
Function *function = CalculateSymbolContextFunction();
|
2011-10-08 08:49:15 +08:00
|
|
|
if (function) {
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
addr = function->GetAddressRange().GetBaseAddress();
|
2011-10-08 08:49:15 +08:00
|
|
|
addr.Slide(m_ranges.GetEntryRef(0).GetRangeBase());
|
2010-08-25 05:05:24 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-10-08 08:49:15 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
void Block::FinalizeRanges() {
|
|
|
|
m_ranges.Sort();
|
|
|
|
m_ranges.CombineConsecutiveRanges();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 08:49:15 +08:00
|
|
|
void Block::AddRange(const Range &range) {
|
2011-09-30 07:41:34 +08:00
|
|
|
Block *parent_block = GetParent();
|
2011-10-08 08:49:15 +08:00
|
|
|
if (parent_block && !parent_block->Contains(range)) {
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS));
|
2011-09-30 07:41:34 +08:00
|
|
|
if (log) {
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp(m_parent_scope->CalculateSymbolContextModule());
|
2011-09-30 07:41:34 +08:00
|
|
|
Function *function = m_parent_scope->CalculateSymbolContextFunction();
|
|
|
|
const addr_t function_file_addr =
|
|
|
|
function->GetAddressRange().GetBaseAddress().GetFileAddress();
|
2011-10-08 08:49:15 +08:00
|
|
|
const addr_t block_start_addr = function_file_addr + range.GetRangeBase();
|
|
|
|
const addr_t block_end_addr = function_file_addr + range.GetRangeEnd();
|
2011-09-30 07:41:34 +08:00
|
|
|
Type *func_type = function->GetType();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-30 07:41:34 +08:00
|
|
|
const Declaration &func_decl = func_type->GetDeclaration();
|
|
|
|
if (func_decl.GetLine()) {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"warning: %s:%u block {0x%8.8" PRIx64
|
|
|
|
"} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
|
|
|
|
") which is not contained in parent block {0x%8.8" PRIx64
|
|
|
|
"} in function {0x%8.8" PRIx64 "} from %s",
|
|
|
|
func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(),
|
|
|
|
GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
|
|
|
|
block_end_addr, parent_block->GetID(), function->GetID(),
|
|
|
|
module_sp->GetFileSpec().GetPath().c_str());
|
2011-09-30 07:41:34 +08:00
|
|
|
} else {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"warning: block {0x%8.8" PRIx64 "} has range[%u] [0x%" PRIx64
|
|
|
|
" - 0x%" PRIx64
|
|
|
|
") which is not contained in parent block {0x%8.8" PRIx64
|
|
|
|
"} in function {0x%8.8" PRIx64 "} from %s",
|
|
|
|
GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
|
|
|
|
block_end_addr, parent_block->GetID(), function->GetID(),
|
|
|
|
module_sp->GetFileSpec().GetPath().c_str());
|
2011-09-30 07:41:34 +08:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 08:49:15 +08:00
|
|
|
parent_block->AddRange(range);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-10-08 08:49:15 +08:00
|
|
|
m_ranges.Append(range);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the current number of bytes that this object occupies in memory
|
|
|
|
size_t Block::MemorySize() const {
|
2011-10-08 08:49:15 +08:00
|
|
|
size_t mem_size = sizeof(Block) + m_ranges.GetSize() * sizeof(Range);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_inlineInfoSP.get())
|
|
|
|
mem_size += m_inlineInfoSP->MemorySize();
|
2010-08-25 05:05:24 +08:00
|
|
|
if (m_variable_list_sp.get())
|
|
|
|
mem_size += m_variable_list_sp->MemorySize();
|
2010-06-09 00:52:24 +08:00
|
|
|
return mem_size;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-08-21 10:22:51 +08:00
|
|
|
void Block::AddChild(const BlockSP &child_block_sp) {
|
|
|
|
if (child_block_sp) {
|
|
|
|
child_block_sp->SetParentScope(this);
|
2011-06-18 06:10:16 +08:00
|
|
|
m_children.push_back(child_block_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-21 10:22:51 +08:00
|
|
|
void Block::SetInlinedFunctionInfo(const char *name, const char *mangled,
|
2010-06-09 00:52:24 +08:00
|
|
|
const Declaration *decl_ptr,
|
|
|
|
const Declaration *call_decl_ptr) {
|
2019-02-12 07:13:08 +08:00
|
|
|
m_inlineInfoSP = std::make_shared<InlineFunctionInfo>(name, mangled, decl_ptr,
|
|
|
|
call_decl_ptr);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-06-18 06:10:16 +08:00
|
|
|
VariableListSP Block::GetBlockVariableList(bool can_create) {
|
2018-12-15 08:15:33 +08:00
|
|
|
if (!m_parsed_block_variables) {
|
2010-08-21 10:22:51 +08:00
|
|
|
if (m_variable_list_sp.get() == nullptr && can_create) {
|
|
|
|
m_parsed_block_variables = true;
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
assert(sc.module_sp);
|
2019-08-06 17:12:42 +08:00
|
|
|
sc.module_sp->GetSymbolFile()->ParseVariablesForContext(sc);
|
2010-08-21 10:22:51 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-06-18 06:10:16 +08:00
|
|
|
return m_variable_list_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Block::AppendBlockVariables(bool can_create, bool get_child_block_variables,
|
|
|
|
bool stop_if_child_block_is_inlined_function,
|
|
|
|
const std::function<bool(Variable *)> &filter,
|
|
|
|
VariableList *variable_list) {
|
|
|
|
uint32_t num_variables_added = 0;
|
|
|
|
VariableList *block_var_list = GetBlockVariableList(can_create).get();
|
|
|
|
if (block_var_list) {
|
2019-11-25 22:03:46 +08:00
|
|
|
for (const VariableSP &var_sp : *block_var_list) {
|
|
|
|
if (filter(var_sp.get())) {
|
2010-06-09 00:52:24 +08:00
|
|
|
num_variables_added++;
|
2019-11-25 22:03:46 +08:00
|
|
|
variable_list->AddVariable(var_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-06-18 06:10:16 +08:00
|
|
|
if (get_child_block_variables) {
|
2011-09-30 05:19:25 +08:00
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos) {
|
|
|
|
Block *child_block = pos->get();
|
2018-12-15 08:15:33 +08:00
|
|
|
if (!stop_if_child_block_is_inlined_function ||
|
2014-04-20 21:17:36 +08:00
|
|
|
child_block->GetInlinedFunctionInfo() == nullptr) {
|
2011-06-18 06:10:16 +08:00
|
|
|
num_variables_added += child_block->AppendBlockVariables(
|
|
|
|
can_create, get_child_block_variables,
|
|
|
|
stop_if_child_block_is_inlined_function, filter, variable_list);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-18 06:10:16 +08:00
|
|
|
return num_variables_added;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-02-25 20:23:37 +08:00
|
|
|
uint32_t Block::AppendVariables(bool can_create, bool get_parent_variables,
|
2011-06-18 06:10:16 +08:00
|
|
|
bool stop_if_block_is_inlined_function,
|
2016-02-25 20:23:37 +08:00
|
|
|
const std::function<bool(Variable *)> &filter,
|
2011-06-18 06:10:16 +08:00
|
|
|
VariableList *variable_list) {
|
|
|
|
uint32_t num_variables_added = 0;
|
|
|
|
VariableListSP variable_list_sp(GetBlockVariableList(can_create));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-04-20 21:17:36 +08:00
|
|
|
bool is_inlined_function = GetInlinedFunctionInfo() != nullptr;
|
2016-02-25 20:23:37 +08:00
|
|
|
if (variable_list_sp) {
|
|
|
|
for (size_t i = 0; i < variable_list_sp->GetSize(); ++i) {
|
|
|
|
VariableSP variable = variable_list_sp->GetVariableAtIndex(i);
|
|
|
|
if (filter(variable.get())) {
|
|
|
|
num_variables_added++;
|
|
|
|
variable_list->AddVariable(variable);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-19 03:29:16 +08:00
|
|
|
|
|
|
|
if (get_parent_variables) {
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
|
|
|
if (stop_if_block_is_inlined_function && is_inlined_function)
|
2011-06-18 06:10:16 +08:00
|
|
|
return num_variables_added;
|
2010-08-19 03:29:16 +08:00
|
|
|
|
|
|
|
Block *parent_block = GetParent();
|
2011-06-18 06:10:16 +08:00
|
|
|
if (parent_block)
|
2016-02-25 20:23:37 +08:00
|
|
|
num_variables_added += parent_block->AppendVariables(
|
2011-06-18 06:10:16 +08:00
|
|
|
can_create, get_parent_variables, stop_if_block_is_inlined_function,
|
2014-04-20 21:17:36 +08:00
|
|
|
filter, variable_list);
|
2010-08-21 10:22:51 +08:00
|
|
|
}
|
2011-06-18 06:10:16 +08:00
|
|
|
return num_variables_added;
|
|
|
|
}
|
2010-08-19 03:29:16 +08:00
|
|
|
|
2018-10-06 07:23:15 +08:00
|
|
|
SymbolFile *Block::GetSymbolFile() {
|
|
|
|
if (ModuleSP module_sp = CalculateSymbolContextModule())
|
2019-08-02 16:16:35 +08:00
|
|
|
return module_sp->GetSymbolFile();
|
2018-10-06 07:23:15 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
2016-02-25 20:23:37 +08:00
|
|
|
|
2018-10-06 07:23:15 +08:00
|
|
|
CompilerDeclContext Block::GetDeclContext() {
|
|
|
|
if (SymbolFile *sym_file = GetSymbolFile())
|
|
|
|
return sym_file->GetDeclContextForUID(GetID());
|
2015-08-25 07:46:31 +08:00
|
|
|
return CompilerDeclContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-06-18 06:10:16 +08:00
|
|
|
|
|
|
|
void Block::SetBlockInfoHasBeenParsed(bool b, bool set_children) {
|
|
|
|
m_parsed_block_info = b;
|
|
|
|
if (set_children) {
|
2010-08-21 10:22:51 +08:00
|
|
|
m_parsed_child_blocks = true;
|
2011-09-30 05:19:25 +08:00
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos)
|
|
|
|
(*pos)->SetBlockInfoHasBeenParsed(b, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-21 10:22:51 +08:00
|
|
|
void Block::SetDidParseVariables(bool b, bool set_children) {
|
|
|
|
m_parsed_block_variables = b;
|
|
|
|
if (set_children) {
|
2011-09-30 05:19:25 +08:00
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos)
|
|
|
|
(*pos)->SetDidParseVariables(b, true);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2011-09-30 05:19:25 +08:00
|
|
|
|
|
|
|
Block *Block::GetSibling() const {
|
|
|
|
if (m_parent_scope) {
|
2011-09-30 07:41:34 +08:00
|
|
|
Block *parent_block = GetParent();
|
2011-09-30 05:19:25 +08:00
|
|
|
if (parent_block)
|
|
|
|
return parent_block->GetSiblingForChild(this);
|
2011-06-18 06:10:16 +08:00
|
|
|
}
|
2014-04-20 21:17:36 +08:00
|
|
|
return nullptr;
|
2011-09-30 05:19:25 +08:00
|
|
|
}
|
|
|
|
// A parent of child blocks can be asked to find a sibling block given
|
|
|
|
// one of its child blocks
|
|
|
|
Block *Block::GetSiblingForChild(const Block *child_block) const {
|
|
|
|
if (!m_children.empty()) {
|
|
|
|
collection::const_iterator pos, end = m_children.end();
|
|
|
|
for (pos = m_children.begin(); pos != end; ++pos) {
|
|
|
|
if (pos->get() == child_block) {
|
|
|
|
if (++pos != end)
|
|
|
|
return pos->get();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-20 21:17:36 +08:00
|
|
|
return nullptr;
|
2011-06-18 06:10:16 +08:00
|
|
|
}
|