2010-06-09 00:52:24 +08:00
|
|
|
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-04-07 02:12:24 +08:00
|
|
|
#include "lldb/Utility/VMRange.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-04-07 02:12:24 +08:00
|
|
|
#include "lldb/lldb-types.h" // for addr_t
|
|
|
|
|
2010-06-09 16:50:27 +08:00
|
|
|
#include <algorithm>
|
2017-04-07 02:12:24 +08:00
|
|
|
#include <iterator> // for distance
|
|
|
|
#include <vector> // for const_iterator
|
|
|
|
|
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for UINT32_MAX, uint32_t
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool VMRange::ContainsValue(const VMRange::collection &coll,
|
|
|
|
lldb::addr_t value) {
|
|
|
|
ValueInRangeUnaryPredicate in_range_predicate(value);
|
2017-06-10 03:14:59 +08:00
|
|
|
return llvm::find_if(coll, in_range_predicate) != coll.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool VMRange::ContainsRange(const VMRange::collection &coll,
|
|
|
|
const VMRange &range) {
|
|
|
|
RangeInRangeUnaryPredicate in_range_predicate(range);
|
2017-06-10 03:14:59 +08:00
|
|
|
return llvm::find_if(coll, in_range_predicate) != coll.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t VMRange::FindRangeIndexThatContainsValue(const VMRange::collection &coll,
|
|
|
|
lldb::addr_t value) {
|
|
|
|
ValueInRangeUnaryPredicate in_range_predicate(value);
|
|
|
|
VMRange::const_iterator begin = coll.begin();
|
|
|
|
VMRange::const_iterator end = coll.end();
|
|
|
|
VMRange::const_iterator pos = std::find_if(begin, end, in_range_predicate);
|
|
|
|
if (pos != end)
|
|
|
|
return std::distance(begin, pos);
|
|
|
|
return UINT32_MAX;
|
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
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
|
|
|
|
s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(),
|
|
|
|
addr_width);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
return lhs.GetBaseAddress() == rhs.GetBaseAddress() &&
|
|
|
|
lhs.GetEndAddress() == rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
return lhs.GetBaseAddress() != rhs.GetBaseAddress() ||
|
|
|
|
lhs.GetEndAddress() != rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
|
|
return true;
|
|
|
|
else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
|
|
return false;
|
|
|
|
return lhs.GetEndAddress() < rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
|
|
return true;
|
|
|
|
else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
|
|
return false;
|
|
|
|
return lhs.GetEndAddress() <= rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
|
|
return true;
|
|
|
|
else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
|
|
return false;
|
|
|
|
return lhs.GetEndAddress() > rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
|
|
|
|
if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
|
|
|
|
return true;
|
|
|
|
else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
|
|
|
|
return false;
|
|
|
|
return lhs.GetEndAddress() >= rhs.GetEndAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|