diff options
author | dim <dim@FreeBSD.org> | 2017-09-26 19:56:36 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2018-02-21 15:12:19 -0300 |
commit | 1dcd2e8d24b295bc73e513acec2ed1514bb66be4 (patch) | |
tree | 4bd13a34c251e980e1a6b13584ca1f63b0dfe670 /contrib/llvm/tools/lldb/source/API | |
parent | f45541ca2a56a1ba1202f94c080b04e96c1fa239 (diff) | |
download | FreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.zip FreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.tar.gz |
Merge clang, llvm, lld, lldb, compiler-rt and libc++ 5.0.0 release.
MFC r309126 (by emaste):
Correct lld llvm-tblgen dependency file name
MFC r309169:
Get rid of separate Subversion mergeinfo properties for llvm-dwarfdump
and llvm-lto. The mergeinfo confuses Subversion enormously, and these
directories will just use the mergeinfo for llvm itself.
MFC r312765:
Pull in r276136 from upstream llvm trunk (by Wei Mi):
Use ValueOffsetPair to enhance value reuse during SCEV expansion.
In D12090, the ExprValueMap was added to reuse existing value during
SCEV expansion. However, const folding and sext/zext distribution can
make the reuse still difficult.
A simplified case is: suppose we know S1 expands to V1 in
ExprValueMap, and
S1 = S2 + C_a
S3 = S2 + C_b
where C_a and C_b are different SCEVConstants. Then we'd like to
expand S3 as V1 - C_a + C_b instead of expanding S2 literally. It is
helpful when S2 is a complex SCEV expr and S2 has no entry in
ExprValueMap, which is usually caused by the fact that S3 is
generated from S1 after const folding.
In order to do that, we represent ExprValueMap as a mapping from SCEV
to ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a}
into the ExprValueMap when we create SCEV for V1. When S3 is
expanded, it will first expand S2 to V1 - C_a because of S2->{V1,
C_a} in the map, then expand S3 to V1 - C_a + C_b.
Differential Revision: https://reviews.llvm.org/D21313
This should fix assertion failures when building OpenCV >= 3.1.
PR: 215649
MFC r312831:
Revert r312765 for now, since it causes assertions when building
lang/spidermonkey24.
Reported by: antoine
PR: 215649
MFC r316511 (by jhb):
Add an implementation of __ffssi2() derived from __ffsdi2().
Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code. This is true for at
least GCC 6.2 when compiling world for mips and mips64.
Reviewed by: jmallett, dim
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10086
MFC r318601 (by adrian):
[libcompiler-rt] add bswapdi2/bswapsi2
This is required for mips gcc 6.3 userland to build/run.
Reviewed by: emaste, dim
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D10838
MFC r318884 (by emaste):
lldb: map TRAP_CAP to a trace trap
In the absense of a more specific handler for TRAP_CAP (generated by
ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace
trap.
Example usage (testing the bug in PR219173):
% proccontrol -m trapcap lldb usr.bin/hexdump/obj/hexdump -- -Cv -s 1 /bin/ls
...
(lldb) run
Process 12980 launching
Process 12980 launched: '.../usr.bin/hexdump/obj/hexdump' (x86_64)
Process 12980 stopped
* thread #1, stop reason = trace
frame #0: 0x0000004b80c65f1a libc.so.7`__sys_lseek + 10
...
In the future we should have LLDB control the trapcap procctl itself
(as it does with ASLR), as well as report a specific stop reason.
This change eliminates an assertion failure from LLDB for now.
MFC r319796:
Remove a few unneeded files from libllvm, libclang and liblldb.
MFC r319885 (by emaste):
lld: ELF: Fix ICF crash on absolute symbol relocations.
If two sections contained relocations to absolute symbols with the same
value we would crash when trying to access their sections. Add a check that
both symbols point to sections before accessing their sections, and treat
absolute symbols as equal if their values are equal.
Obtained from: LLD commit r292578
MFC r319918:
Revert r319796 for now, it can cause undefined references when linking
in some circumstances.
Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
MFC r319957 (by emaste):
lld: Add armelf emulation mode
Obtained from: LLD r305375
MFC r321369:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 (trunk r308421). Upstream has branched for the 5.0.0 release,
which should be in about a month. Please report bugs and regressions,
so we can get them into the release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
MFC r321420:
Add a few more object files to liblldb, which should solve errors when
linking the lldb executable in some cases. In particular, when the
-ffunction-sections -fdata-sections options are turned off, or
ineffective.
Reported by: Shawn Webb, Mark Millard
MFC r321433:
Cleanup stale Options.inc files from the previous libllvm build for
clang 4.0.0. Otherwise, these can get included before the two newly
generated ones (which are different) for clang 5.0.0.
Reported by: Mark Millard
MFC r321439 (by bdrewery):
Move llvm Options.inc hack from r321433 for NO_CLEAN to lib/clang/libllvm.
The files are only ever generated to .OBJDIR, not to WORLDTMP (as a
sysroot) and are only ever included from a compilation. So using
a beforebuild target here removes the file before the compilation
tries to include it.
MFC r321664:
Pull in r308891 from upstream llvm trunk (by Benjamin Kramer):
[CodeGenPrepare] Cut off FindAllMemoryUses if there are too many uses.
This avoids excessive compile time. The case I'm looking at is
Function.cpp from an old version of LLVM that still had the giant
memcmp string matcher in it. Before r308322 this compiled in about 2
minutes, after it, clang takes infinite* time to compile it. With
this patch we're at 5 min, which is still bad but this is a
pathological case.
The cut off at 20 uses was chosen by looking at other cut-offs in LLVM
for user scanning. It's probably too high, but does the job and is
very unlikely to regress anything.
Fixes PR33900.
* I'm impatient and aborted after 15 minutes, on the bug report it was
killed after 2h.
Pull in r308986 from upstream llvm trunk (by Simon Pilgrim):
[X86][CGP] Reduce memcmp() expansion to 2 load pairs (PR33914)
D35067/rL308322 attempted to support up to 4 load pairs for memcmp
inlining which resulted in regressions for some optimized libc memcmp
implementations (PR33914).
Until we can match these more optimal cases, this patch reduces the
memcmp expansion to a maximum of 2 load pairs (which matches what we
do for -Os).
This patch should be considered for the 5.0.0 release branch as well
Differential Revision: https://reviews.llvm.org/D35830
These fix a hang (or extremely long compile time) when building older
LLVM ports.
Reported by: antoine
PR: 219139
MFC r321719:
Pull in r309503 from upstream clang trunk (by Richard Smith):
PR33902: Invalidate line number cache when adding more text to
existing buffer.
This led to crashes as the line number cache would report a bogus
line number for a line of code, and we'd try to find a nonexistent
column within the line when printing diagnostics.
This fixes an assertion when building the graphics/champlain port.
Reported by: antoine, kwm
PR: 219139
MFC r321723:
Upgrade our copies of clang, llvm, lld and lldb to r309439 from the
upstream release_50 branch. This is just after upstream's 5.0.0-rc1.
MFC r322320:
Upgrade our copies of clang, llvm and libc++ to r310316 from the
upstream release_50 branch.
MFC r322326 (by emaste):
lldb: Make i386-*-freebsd expression work on JIT path
* Enable i386 ABI creation for freebsd
* Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap
syscall
* Unlike linux, the last argument of mmap is actually 64-bit(off_t).
This requires us to push an additional word for the higher order bits.
* Prior to this change, ktrace dump will show mmap failures due to
invalid argument coming from the 6th mmap argument.
Submitted by: Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D34776
MFC r322360 (by emaste):
lldb: Report inferior signals as signals, not exceptions, on FreeBSD
This is the FreeBSD equivalent of LLVM r238549.
This serves 2 purposes:
* LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/
SIGFPE the way it is suppose to be handled. Prior to this fix these
signals will neither create a coredump, nor exit from the debugger
or work for signal handling scenario.
* eInvalidCrashReason need not report "unknown crash reason" if we have
a valid si_signo
llvm.org/pr23699
Patch by Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D35223
Submitted by: Karnajit Wangkhem
Obtained from: LLVM r310591
MFC r322474 (by emaste):
lld: Add `-z muldefs` option.
Obtained from: LLVM r310757
MFC r322740:
Upgrade our copies of clang, llvm, lld and libc++ to r311219 from the
upstream release_50 branch.
MFC r322855:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r311606 from
the upstream release_50 branch.
As of this version, lib/msun's trig test should also work correctly
again (see bug 220989 for more information).
PR: 220989
MFC r323112:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r312293 from
the upstream release_50 branch. This corresponds to 5.0.0 rc4.
As of this version, the cad/stepcode port should now compile in a more
reasonable time on i386 (see bug 221836 for more information).
PR: 221836
MFC r323245:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 release (upstream r312559).
Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/5.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
(cherry picked from commit 12cd91cf4c6b96a24427c0de5374916f2808d263)
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API')
49 files changed, 905 insertions, 635 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBAddress.cpp b/contrib/llvm/tools/lldb/source/API/SBAddress.cpp index 0ef374f..a3493d7 100644 --- a/contrib/llvm/tools/lldb/source/API/SBAddress.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBAddress.cpp @@ -12,11 +12,11 @@ #include "lldb/API/SBSection.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Address.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" -#include "lldb/Core/StreamString.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -55,6 +55,12 @@ const SBAddress &SBAddress::operator=(const SBAddress &rhs) { return *this; } +bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { + if (lhs.IsValid() && rhs.IsValid()) + return lhs.ref() == rhs.ref(); + return false; +} + bool SBAddress::IsValid() const { return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); } diff --git a/contrib/llvm/tools/lldb/source/API/SBBlock.cpp b/contrib/llvm/tools/lldb/source/API/SBBlock.cpp index 471b7fb..cd45387 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBlock.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBBlock.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" #include "lldb/Core/AddressRange.h" -#include "lldb/Core/Log.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" @@ -22,6 +21,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp b/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp index 0eab2c2..bf96032 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp @@ -26,8 +26,6 @@ #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Address.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" @@ -36,6 +34,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/lldb-enumerations.h" @@ -59,83 +59,74 @@ public: } }; -SBBreakpoint::SBBreakpoint() : m_opaque_sp() {} +SBBreakpoint::SBBreakpoint() {} SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_wp(rhs.m_opaque_wp) {} SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp) - : m_opaque_sp(bp_sp) {} + : m_opaque_wp(bp_sp) {} SBBreakpoint::~SBBreakpoint() = default; const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) { - if (this != &rhs) - m_opaque_sp = rhs.m_opaque_sp; + m_opaque_wp = rhs.m_opaque_wp; return *this; } bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) { - if (m_opaque_sp && rhs.m_opaque_sp) - return m_opaque_sp.get() == rhs.m_opaque_sp.get(); - return false; + return m_opaque_wp.lock() == rhs.m_opaque_wp.lock(); } bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) { - if (m_opaque_sp && rhs.m_opaque_sp) - return m_opaque_sp.get() != rhs.m_opaque_sp.get(); - return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp); + return m_opaque_wp.lock() != rhs.m_opaque_wp.lock(); } break_id_t SBBreakpoint::GetID() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); break_id_t break_id = LLDB_INVALID_BREAK_ID; - if (m_opaque_sp) - break_id = m_opaque_sp->GetID(); - - if (log) { - if (break_id == LLDB_INVALID_BREAK_ID) - log->Printf("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", - static_cast<void *>(m_opaque_sp.get())); - else - log->Printf("SBBreakpoint(%p)::GetID () => %u", - static_cast<void *>(m_opaque_sp.get()), break_id); - } + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) + break_id = bkpt_sp->GetID(); + LLDB_LOG(log, "breakpoint = {0}, id = {1}", bkpt_sp.get(), break_id); return break_id; } bool SBBreakpoint::IsValid() const { - if (!m_opaque_sp) + BreakpointSP bkpt_sp = GetSP(); + if (!bkpt_sp) return false; - else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID())) + else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID())) return true; else return false; } void SBBreakpoint::ClearAllBreakpointSites() { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->ClearAllBreakpointSites(); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->ClearAllBreakpointSites(); } } SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { SBBreakpointLocation sb_bp_location; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { if (vm_addr != LLDB_INVALID_ADDRESS) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); Address address; - Target &target = m_opaque_sp->GetTarget(); + Target &target = bkpt_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress(vm_addr); } - sb_bp_location.SetLocation(m_opaque_sp->FindLocationByAddress(address)); + sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address)); } } return sb_bp_location; @@ -143,16 +134,17 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { break_id_t break_id = LLDB_INVALID_BREAK_ID; + BreakpointSP bkpt_sp = GetSP(); - if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) { + if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); Address address; - Target &target = m_opaque_sp->GetTarget(); + Target &target = bkpt_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress(vm_addr); } - break_id = m_opaque_sp->FindLocationIDByAddress(address); + break_id = bkpt_sp->FindLocationIDByAddress(address); } return break_id; @@ -160,11 +152,12 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { SBBreakpointLocation sb_bp_location; + BreakpointSP bkpt_sp = GetSP(); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - sb_bp_location.SetLocation(m_opaque_sp->FindLocationByID(bp_loc_id)); + bkpt_sp->GetTarget().GetAPIMutex()); + sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id)); } return sb_bp_location; @@ -172,11 +165,12 @@ SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { SBBreakpointLocation sb_bp_location; + BreakpointSP bkpt_sp = GetSP(); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - sb_bp_location.SetLocation(m_opaque_sp->GetLocationAtIndex(index)); + bkpt_sp->GetTarget().GetAPIMutex()); + sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index)); } return sb_bp_location; @@ -184,290 +178,282 @@ SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { void SBBreakpoint::SetEnabled(bool enable) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); - if (log) - log->Printf("SBBreakpoint(%p)::SetEnabled (enabled=%i)", - static_cast<void *>(m_opaque_sp.get()), enable); + LLDB_LOG(log, "breakpoint = {0}, enable = {1}", bkpt_sp.get(), enable); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetEnabled(enable); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->SetEnabled(enable); } } bool SBBreakpoint::IsEnabled() { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->IsEnabled(); + bkpt_sp->GetTarget().GetAPIMutex()); + return bkpt_sp->IsEnabled(); } else return false; } void SBBreakpoint::SetOneShot(bool one_shot) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); - if (log) - log->Printf("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", - static_cast<void *>(m_opaque_sp.get()), one_shot); + LLDB_LOG(log, "breakpoint = {0}, one_shot = {1}", bkpt_sp.get(), one_shot); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetOneShot(one_shot); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->SetOneShot(one_shot); } } bool SBBreakpoint::IsOneShot() const { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->IsOneShot(); + bkpt_sp->GetTarget().GetAPIMutex()); + return bkpt_sp->IsOneShot(); } else return false; } bool SBBreakpoint::IsInternal() { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->IsInternal(); + bkpt_sp->GetTarget().GetAPIMutex()); + return bkpt_sp->IsInternal(); } else return false; } void SBBreakpoint::SetIgnoreCount(uint32_t count) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); - if (log) - log->Printf("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", - static_cast<void *>(m_opaque_sp.get()), count); + LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetIgnoreCount(count); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->SetIgnoreCount(count); } } void SBBreakpoint::SetCondition(const char *condition) { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetCondition(condition); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->SetCondition(condition); } } const char *SBBreakpoint::GetCondition() { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetConditionText(); + bkpt_sp->GetTarget().GetAPIMutex()); + return bkpt_sp->GetConditionText(); } return nullptr; } uint32_t SBBreakpoint::GetHitCount() const { uint32_t count = 0; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - count = m_opaque_sp->GetHitCount(); + bkpt_sp->GetTarget().GetAPIMutex()); + count = bkpt_sp->GetHitCount(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetHitCount () => %u", - static_cast<void *>(m_opaque_sp.get()), count); + LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); return count; } uint32_t SBBreakpoint::GetIgnoreCount() const { uint32_t count = 0; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - count = m_opaque_sp->GetIgnoreCount(); + bkpt_sp->GetTarget().GetAPIMutex()); + count = bkpt_sp->GetIgnoreCount(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetIgnoreCount () => %u", - static_cast<void *>(m_opaque_sp.get()), count); + LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); return count; } void SBBreakpoint::SetThreadID(tid_t tid) { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetThreadID(tid); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->SetThreadID(tid); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", - static_cast<void *>(m_opaque_sp.get()), tid); + LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid); } tid_t SBBreakpoint::GetThreadID() { tid_t tid = LLDB_INVALID_THREAD_ID; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - tid = m_opaque_sp->GetThreadID(); + bkpt_sp->GetTarget().GetAPIMutex()); + tid = bkpt_sp->GetThreadID(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, - static_cast<void *>(m_opaque_sp.get()), tid); + LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid); return tid; } void SBBreakpoint::SetThreadIndex(uint32_t index) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::SetThreadIndex (%u)", - static_cast<void *>(m_opaque_sp.get()), index); - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), index); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex(index); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index); } } uint32_t SBBreakpoint::GetThreadIndex() const { uint32_t thread_idx = UINT32_MAX; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetThreadIndex () => %u", - static_cast<void *>(m_opaque_sp.get()), thread_idx); + LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), thread_idx); return thread_idx; } void SBBreakpoint::SetThreadName(const char *thread_name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::SetThreadName (%s)", - static_cast<void *>(m_opaque_sp.get()), thread_name); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), thread_name); - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetOptions()->GetThreadSpec()->SetName(thread_name); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name); } } const char *SBBreakpoint::GetThreadName() const { const char *name = nullptr; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) name = thread_spec->GetName(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetThreadName () => %s", - static_cast<void *>(m_opaque_sp.get()), name); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); return name; } void SBBreakpoint::SetQueueName(const char *queue_name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::SetQueueName (%s)", - static_cast<void *>(m_opaque_sp.get()), queue_name); - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, queue_name = {1}", bkpt_sp.get(), + queue_name); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name); } } const char *SBBreakpoint::GetQueueName() const { const char *name = nullptr; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec) name = thread_spec->GetQueueName(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetQueueName () => %s", - static_cast<void *>(m_opaque_sp.get()), name); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); return name; } size_t SBBreakpoint::GetNumResolvedLocations() const { size_t num_resolved = 0; - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - num_resolved = m_opaque_sp->GetNumResolvedLocations(); + bkpt_sp->GetTarget().GetAPIMutex()); + num_resolved = bkpt_sp->GetNumResolvedLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, - static_cast<void *>(m_opaque_sp.get()), - static_cast<uint64_t>(num_resolved)); + LLDB_LOG(log, "breakpoint = {0}, num_resolved = {1}", bkpt_sp.get(), + num_resolved); return num_resolved; } size_t SBBreakpoint::GetNumLocations() const { + BreakpointSP bkpt_sp = GetSP(); size_t num_locs = 0; - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - num_locs = m_opaque_sp->GetNumLocations(); + bkpt_sp->GetTarget().GetAPIMutex()); + num_locs = bkpt_sp->GetNumLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, - static_cast<void *>(m_opaque_sp.get()), - static_cast<uint64_t>(num_locs)); + LLDB_LOG(log, "breakpoint = {0}, num_locs = {1}", bkpt_sp.get(), num_locs); return num_locs; } void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { - if (!m_opaque_sp) + BreakpointSP bkpt_sp = GetSP(); + if (!bkpt_sp) return; if (commands.GetSize() == 0) return; std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up( new BreakpointOptions::CommandData(*commands, eScriptLanguageNone)); - m_opaque_sp->GetOptions()->SetCommandDataCallback(cmd_data_up); + bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up); } bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { - if (!m_opaque_sp) + BreakpointSP bkpt_sp = GetSP(); + if (!bkpt_sp) return false; StringList command_list; bool has_commands = - m_opaque_sp->GetOptions()->GetCommandLineCallbacks(command_list); + bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list); if (has_commands) commands.AppendList(command_list); return has_commands; @@ -478,14 +464,15 @@ bool SBBreakpoint::GetDescription(SBStream &s) { } bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { - if (m_opaque_sp) { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); - m_opaque_sp->GetResolverDescription(s.get()); - m_opaque_sp->GetFilterDescription(s.get()); + bkpt_sp->GetTarget().GetAPIMutex()); + s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID()); + bkpt_sp->GetResolverDescription(s.get()); + bkpt_sp->GetFilterDescription(s.get()); if (include_locations) { - const size_t num_locations = m_opaque_sp->GetNumLocations(); + const size_t num_locations = bkpt_sp->GetNumLocations(); s.Printf(", locations = %" PRIu64, (uint64_t)num_locations); } return true; @@ -526,36 +513,31 @@ bool SBBreakpoint::PrivateBreakpointHitCallback(void *baton, void SBBreakpoint::SetCallback(BreakpointHitCallback callback, void *baton) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, callback = {1}, baton = {2}", bkpt_sp.get(), + callback, baton); - if (log) { - void *pointer = &callback; - log->Printf("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", - static_cast<void *>(m_opaque_sp.get()), - *static_cast<void **>(&pointer), static_cast<void *>(baton)); - } - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton)); - m_opaque_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback, - baton_sp, false); + bkpt_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, + false); } } void SBBreakpoint::SetScriptCallbackFunction( const char *callback_function_name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, callback = {1}", bkpt_sp.get(), + callback_function_name); - if (log) - log->Printf("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)", - static_cast<void *>(m_opaque_sp.get()), callback_function_name); - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); - m_opaque_sp->GetTarget() + bkpt_sp->GetTarget().GetAPIMutex()); + BreakpointOptions *bp_options = bkpt_sp->GetOptions(); + bkpt_sp->GetTarget() .GetDebugger() .GetCommandInterpreter() .GetScriptInterpreter() @@ -566,18 +548,17 @@ void SBBreakpoint::SetScriptCallbackFunction( SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)", - static_cast<void *>(m_opaque_sp.get()), callback_body_text); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, callback body:\n{1}", bkpt_sp.get(), + callback_body_text); SBError sb_error; - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); - Error error = - m_opaque_sp->GetTarget() + bkpt_sp->GetTarget().GetAPIMutex()); + BreakpointOptions *bp_options = bkpt_sp->GetOptions(); + Status error = + bkpt_sp->GetTarget() .GetDebugger() .GetCommandInterpreter() .GetScriptInterpreter() @@ -591,17 +572,15 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { bool SBBreakpoint::AddName(const char *new_name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), new_name); - if (log) - log->Printf("SBBreakpoint(%p)::AddName (name=%s)", - static_cast<void *>(m_opaque_sp.get()), new_name); - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - Error error; // Think I'm just going to swallow the error here, it's - // probably more annoying to have to provide it. - return m_opaque_sp->AddName(new_name, error); + bkpt_sp->GetTarget().GetAPIMutex()); + Status error; // Think I'm just going to swallow the error here, it's + // probably more annoying to have to provide it. + return bkpt_sp->AddName(new_name, error); } return false; @@ -609,29 +588,25 @@ bool SBBreakpoint::AddName(const char *new_name) { void SBBreakpoint::RemoveName(const char *name_to_remove) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name_to_remove); - if (log) - log->Printf("SBBreakpoint(%p)::RemoveName (name=%s)", - static_cast<void *>(m_opaque_sp.get()), name_to_remove); - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->RemoveName(name_to_remove); + bkpt_sp->GetTarget().GetAPIMutex()); + bkpt_sp->RemoveName(name_to_remove); } } bool SBBreakpoint::MatchesName(const char *name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); - if (log) - log->Printf("SBBreakpoint(%p)::MatchesName (name=%s)", - static_cast<void *>(m_opaque_sp.get()), name); - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->MatchesName(name); + bkpt_sp->GetTarget().GetAPIMutex()); + return bkpt_sp->MatchesName(name); } return false; @@ -639,36 +614,20 @@ bool SBBreakpoint::MatchesName(const char *name) { void SBBreakpoint::GetNames(SBStringList &names) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointSP bkpt_sp = GetSP(); + LLDB_LOG(log, "breakpoint = {0}", bkpt_sp.get()); - if (log) - log->Printf("SBBreakpoint(%p)::GetNames ()", - static_cast<void *>(m_opaque_sp.get())); - - if (m_opaque_sp) { + if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); + bkpt_sp->GetTarget().GetAPIMutex()); std::vector<std::string> names_vec; - m_opaque_sp->GetNames(names_vec); + bkpt_sp->GetNames(names_vec); for (std::string name : names_vec) { names.AppendString(name.c_str()); } } } -lldb_private::Breakpoint *SBBreakpoint::operator->() const { - return m_opaque_sp.get(); -} - -lldb_private::Breakpoint *SBBreakpoint::get() const { - return m_opaque_sp.get(); -} - -lldb::BreakpointSP &SBBreakpoint::operator*() { return m_opaque_sp; } - -const lldb::BreakpointSP &SBBreakpoint::operator*() const { - return m_opaque_sp; -} - bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) { return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr; @@ -683,11 +642,10 @@ SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) { } SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) { - SBBreakpoint sb_breakpoint; if (event.IsValid()) - sb_breakpoint.m_opaque_sp = - Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP()); - return sb_breakpoint; + return SBBreakpoint( + Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP())); + return SBBreakpoint(); } SBBreakpointLocation @@ -711,6 +669,8 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { return num_locations; } +BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); } + // This is simple collection of breakpoint id's and their target. class SBBreakpointListImpl { public: @@ -745,28 +705,28 @@ public: return BreakpointSP(); } - bool Append(Breakpoint &bkpt) { + bool Append(BreakpointSP bkpt) { TargetSP target_sp = m_target_wp.lock(); - if (!target_sp) + if (!target_sp || !bkpt) return false; - if (bkpt.GetTargetSP() != target_sp) + if (bkpt->GetTargetSP() != target_sp) return false; - m_break_ids.push_back(bkpt.GetID()); + m_break_ids.push_back(bkpt->GetID()); return true; } - bool AppendIfUnique(Breakpoint &bkpt) { + bool AppendIfUnique(BreakpointSP bkpt) { TargetSP target_sp = m_target_wp.lock(); - if (!target_sp) + if (!target_sp || !bkpt) return false; - if (bkpt.GetTargetSP() != target_sp) + if (bkpt->GetTargetSP() != target_sp) return false; - lldb::break_id_t bp_id = bkpt.GetID(); + lldb::break_id_t bp_id = bkpt->GetID(); if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) == m_break_ids.end()) return false; - m_break_ids.push_back(bkpt.GetID()); + m_break_ids.push_back(bkpt->GetID()); return true; } @@ -827,7 +787,7 @@ void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) { return; if (!m_opaque_sp) return; - m_opaque_sp->Append(*sb_bkpt.get()); + m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock()); } void SBBreakpointList::AppendByID(lldb::break_id_t id) { @@ -841,7 +801,7 @@ bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) { return false; if (!m_opaque_sp) return false; - return m_opaque_sp->AppendIfUnique(*sb_bkpt.get()); + return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP()); } void SBBreakpointList::Clear() { diff --git a/contrib/llvm/tools/lldb/source/API/SBBreakpointLocation.cpp b/contrib/llvm/tools/lldb/source/API/SBBreakpointLocation.cpp index c7fac76..dc9c00d 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBreakpointLocation.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBBreakpointLocation.cpp @@ -16,118 +16,124 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" using namespace lldb; using namespace lldb_private; -SBBreakpointLocation::SBBreakpointLocation() : m_opaque_sp() {} +SBBreakpointLocation::SBBreakpointLocation() {} SBBreakpointLocation::SBBreakpointLocation( const lldb::BreakpointLocationSP &break_loc_sp) - : m_opaque_sp(break_loc_sp) { + : m_opaque_wp(break_loc_sp) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) { SBStream sstr; GetDescription(sstr, lldb::eDescriptionLevelBrief); - log->Printf("SBBreakpointLocation::SBBreakpointLocaiton (const " - "lldb::BreakpointLocationsSP &break_loc_sp" - "=%p) => this.sp = %p (%s)", - static_cast<void *>(break_loc_sp.get()), - static_cast<void *>(m_opaque_sp.get()), sstr.GetData()); + LLDB_LOG(log, "location = {0} ({1})", break_loc_sp.get(), sstr.GetData()); } } SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_wp(rhs.m_opaque_wp) {} const SBBreakpointLocation &SBBreakpointLocation:: operator=(const SBBreakpointLocation &rhs) { - if (this != &rhs) - m_opaque_sp = rhs.m_opaque_sp; + m_opaque_wp = rhs.m_opaque_wp; return *this; } SBBreakpointLocation::~SBBreakpointLocation() {} -bool SBBreakpointLocation::IsValid() const { return m_opaque_sp.get() != NULL; } +BreakpointLocationSP SBBreakpointLocation::GetSP() const { + return m_opaque_wp.lock(); +} + +bool SBBreakpointLocation::IsValid() const { return bool(GetSP()); } SBAddress SBBreakpointLocation::GetAddress() { - if (m_opaque_sp) - return SBAddress(&m_opaque_sp->GetAddress()); + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) + return SBAddress(&loc_sp->GetAddress()); else return SBAddress(); } addr_t SBBreakpointLocation::GetLoadAddress() { addr_t ret_addr = LLDB_INVALID_ADDRESS; + BreakpointLocationSP loc_sp = GetSP(); - if (m_opaque_sp) { + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - ret_addr = m_opaque_sp->GetLoadAddress(); + loc_sp->GetTarget().GetAPIMutex()); + ret_addr = loc_sp->GetLoadAddress(); } return ret_addr; } void SBBreakpointLocation::SetEnabled(bool enabled) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetEnabled(enabled); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetEnabled(enabled); } } bool SBBreakpointLocation::IsEnabled() { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->IsEnabled(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->IsEnabled(); } else return false; } uint32_t SBBreakpointLocation::GetIgnoreCount() { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetIgnoreCount(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetIgnoreCount(); } else return 0; } void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetIgnoreCount(n); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetIgnoreCount(n); } } void SBBreakpointLocation::SetCondition(const char *condition) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetCondition(condition); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetCondition(condition); } } const char *SBBreakpointLocation::GetCondition() { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetConditionText(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetConditionText(); } return NULL; } @@ -135,17 +141,15 @@ const char *SBBreakpointLocation::GetCondition() { void SBBreakpointLocation::SetScriptCallbackFunction( const char *callback_function_name) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + BreakpointLocationSP loc_sp = GetSP(); + LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(), + callback_function_name); - if (log) - log->Printf( - "SBBreakpointLocation(%p)::SetScriptCallbackFunction (callback=%s)", - static_cast<void *>(m_opaque_sp.get()), callback_function_name); - - if (m_opaque_sp) { + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); - m_opaque_sp->GetBreakpoint() + loc_sp->GetTarget().GetAPIMutex()); + BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); + loc_sp->GetBreakpoint() .GetTarget() .GetDebugger() .GetCommandInterpreter() @@ -158,18 +162,17 @@ void SBBreakpointLocation::SetScriptCallbackFunction( SBError SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)", - static_cast<void *>(m_opaque_sp.get()), callback_body_text); + BreakpointLocationSP loc_sp = GetSP(); + LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(), + callback_body_text); SBError sb_error; - if (m_opaque_sp) { + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); - Error error = - m_opaque_sp->GetBreakpoint() + loc_sp->GetTarget().GetAPIMutex()); + BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); + Status error = + loc_sp->GetBreakpoint() .GetTarget() .GetDebugger() .GetCommandInterpreter() @@ -183,80 +186,89 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { } void SBBreakpointLocation::SetThreadID(tid_t thread_id) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetThreadID(thread_id); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetThreadID(thread_id); } } tid_t SBBreakpointLocation::GetThreadID() { tid_t tid = LLDB_INVALID_THREAD_ID; - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetThreadID(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetThreadID(); } return tid; } void SBBreakpointLocation::SetThreadIndex(uint32_t index) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetThreadIndex(index); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetThreadIndex(index); } } uint32_t SBBreakpointLocation::GetThreadIndex() const { uint32_t thread_idx = UINT32_MAX; - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetThreadIndex(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetThreadIndex(); } return thread_idx; } void SBBreakpointLocation::SetThreadName(const char *thread_name) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetThreadName(thread_name); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetThreadName(thread_name); } } const char *SBBreakpointLocation::GetThreadName() const { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetThreadName(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetThreadName(); } return NULL; } void SBBreakpointLocation::SetQueueName(const char *queue_name) { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetQueueName(queue_name); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->SetQueueName(queue_name); } } const char *SBBreakpointLocation::GetQueueName() const { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetQueueName(); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->GetQueueName(); } return NULL; } bool SBBreakpointLocation::IsResolved() { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->IsResolved(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->IsResolved(); } return false; } @@ -264,17 +276,18 @@ bool SBBreakpointLocation::IsResolved() { void SBBreakpointLocation::SetLocation( const lldb::BreakpointLocationSP &break_loc_sp) { // Uninstall the callbacks? - m_opaque_sp = break_loc_sp; + m_opaque_wp = break_loc_sp; } bool SBBreakpointLocation::GetDescription(SBStream &description, DescriptionLevel level) { Stream &strm = description.ref(); + BreakpointLocationSP loc_sp = GetSP(); - if (m_opaque_sp) { + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetDescription(&strm, level); + loc_sp->GetTarget().GetAPIMutex()); + loc_sp->GetDescription(&strm, level); strm.EOL(); } else strm.PutCString("No value"); @@ -283,34 +296,31 @@ bool SBBreakpointLocation::GetDescription(SBStream &description, } break_id_t SBBreakpointLocation::GetID() { - if (m_opaque_sp) { + BreakpointLocationSP loc_sp = GetSP(); + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetID(); + loc_sp->GetTarget().GetAPIMutex()); + return loc_sp->GetID(); } else return LLDB_INVALID_BREAK_ID; } SBBreakpoint SBBreakpointLocation::GetBreakpoint() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - // if (log) - // log->Printf ("SBBreakpointLocation::GetBreakpoint ()"); + BreakpointLocationSP loc_sp = GetSP(); SBBreakpoint sb_bp; - if (m_opaque_sp) { + if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( - m_opaque_sp->GetTarget().GetAPIMutex()); - *sb_bp = m_opaque_sp->GetBreakpoint().shared_from_this(); + loc_sp->GetTarget().GetAPIMutex()); + sb_bp = loc_sp->GetBreakpoint().shared_from_this(); } if (log) { SBStream sstr; sb_bp.GetDescription(sstr); - log->Printf( - "SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(sb_bp.get()), sstr.GetData()); + LLDB_LOG(log, "location = {0}, breakpoint = {1} ({2})", loc_sp.get(), + sb_bp.GetSP().get(), sstr.GetData()); } return sb_bp; } diff --git a/contrib/llvm/tools/lldb/source/API/SBBroadcaster.cpp b/contrib/llvm/tools/lldb/source/API/SBBroadcaster.cpp index 5189dd7..278576b 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBroadcaster.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBBroadcaster.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/Broadcaster.h" -#include "lldb/Core/Log.h" +#include "lldb/Utility/Log.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBEvent.h" @@ -22,25 +22,15 @@ SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {} SBBroadcaster::SBBroadcaster(const char *name) : m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) { m_opaque_ptr = m_opaque_sp.get(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - - if (log) - log->Printf( - "SBBroadcaster::SBBroadcaster (name=\"%s\") => SBBroadcaster(%p)", name, - static_cast<void *>(m_opaque_ptr)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_LOGV(log, "(name=\"{0}\") => SBBroadcaster({1})", name, m_opaque_ptr); } SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns) : m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - - if (log) - log->Printf("SBBroadcaster::SBBroadcaster (broadcaster=%p, bool owns=%i) " - "=> SBBroadcaster(%p)", - static_cast<void *>(broadcaster), owns, - static_cast<void *>(m_opaque_ptr)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_LOGV(log, "(broadcaster={0}, owns={1}) => SBBroadcaster({2})", + broadcaster, owns, m_opaque_ptr); } SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs) diff --git a/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp b/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp index 41d5147..5a8909b 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp @@ -15,9 +15,10 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/Log.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" using namespace lldb; using namespace lldb_private; @@ -181,7 +182,7 @@ bool SBCommandReturnObject::GetDescription(SBStream &description) { Stream &strm = description.ref(); if (m_opaque_ap) { - description.Printf("Status: "); + description.Printf("Error: "); lldb::ReturnStatus status = m_opaque_ap->GetStatus(); if (status == lldb::eReturnStatusStarted) strm.PutCString("Started"); @@ -270,7 +271,7 @@ void SBCommandReturnObject::SetError(lldb::SBError &error, if (error.IsValid()) m_opaque_ap->SetError(error.ref(), fallback_error_cstr); else if (fallback_error_cstr) - m_opaque_ap->SetError(Error(), fallback_error_cstr); + m_opaque_ap->SetError(Status(), fallback_error_cstr); } } diff --git a/contrib/llvm/tools/lldb/source/API/SBCommunication.cpp b/contrib/llvm/tools/lldb/source/API/SBCommunication.cpp index 9519c02..63b672e 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCommunication.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBCommunication.cpp @@ -10,8 +10,9 @@ #include "lldb/API/SBCommunication.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/Core/Communication.h" -#include "lldb/Core/Log.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/Host.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; @@ -51,7 +52,7 @@ void SBCommunication::SetCloseOnEOF(bool b) { ConnectionStatus SBCommunication::Connect(const char *url) { if (m_opaque) { if (!m_opaque->HasConnection()) - m_opaque->SetConnection(Connection::CreateDefaultConnection(url)); + m_opaque->SetConnection(Host::CreateDefaultConnection(url).release()); return m_opaque->Connect(url, NULL); } return eConnectionStatusNoConnection; diff --git a/contrib/llvm/tools/lldb/source/API/SBCompileUnit.cpp b/contrib/llvm/tools/lldb/source/API/SBCompileUnit.cpp index 12aed59..149d587 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCompileUnit.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBCompileUnit.cpp @@ -10,13 +10,13 @@ #include "lldb/API/SBCompileUnit.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Type.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBData.cpp b/contrib/llvm/tools/lldb/source/API/SBData.cpp index d905d3f..a8ba580 100644 --- a/contrib/llvm/tools/lldb/source/API/SBData.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBData.cpp @@ -13,10 +13,11 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" +#include "lldb/Core/DumpDataExtractor.h" +#include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; @@ -347,7 +348,7 @@ bool SBData::GetDescription(lldb::SBStream &description, Stream &strm = description.ref(); if (m_opaque_sp) { - m_opaque_sp->Dump(&strm, 0, lldb::eFormatBytesWithASCII, 1, + DumpDataExtractor(*m_opaque_sp, &strm, 0, lldb::eFormatBytesWithASCII, 1, m_opaque_sp->GetByteSize(), 16, base_addr, 0, 0); } else strm.PutCString("No value"); @@ -383,7 +384,11 @@ void SBData::SetData(lldb::SBError &error, const void *buf, size_t size, if (!m_opaque_sp.get()) m_opaque_sp.reset(new DataExtractor(buf, size, endian, addr_size)); else + { m_opaque_sp->SetData(buf, size, endian); + m_opaque_sp->SetAddressByteSize(addr_size); + } + if (log) log->Printf("SBData::SetData (error=%p,buf=%p,size=%" PRIu64 ",endian=%d,addr_size=%c) => " diff --git a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp index 97e6f7b..3cdb6bb 100644 --- a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp @@ -57,7 +57,7 @@ using namespace lldb_private; static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, - Error &error) { + Status &error) { llvm::sys::DynamicLibrary dynlib = llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); if (dynlib.isValid()) { @@ -551,7 +551,7 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, TargetSP target_sp; if (m_opaque_sp) { const bool add_dependent_modules = true; - Error error(m_opaque_sp->GetTargetList().CreateTarget( + Status error(m_opaque_sp->GetTargetList().CreateTarget( *m_opaque_sp, filename, target_triple, add_dependent_modules, nullptr, target_sp)); sb_target.SetSP(target_sp); @@ -574,7 +574,7 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { - Error error; + Status error; const bool add_dependent_modules = true; error = m_opaque_sp->GetTargetList().CreateTarget( @@ -600,7 +600,7 @@ SBTarget SBDebugger::CreateTarget(const char *filename) { SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { - Error error; + Status error; const bool add_dependent_modules = true; error = m_opaque_sp->GetTargetList().CreateTarget( *m_opaque_sp, filename, "", add_dependent_modules, nullptr, target_sp); @@ -873,7 +873,7 @@ SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, SBError sb_error; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); - Error error; + Status error; if (debugger_sp) { ExecutionContext exe_ctx( debugger_sp->GetCommandInterpreter().GetExecutionContext()); @@ -894,7 +894,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name, SBStringList ret_value; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); - Error error; + Status error; if (debugger_sp) { ExecutionContext exe_ctx( debugger_sp->GetCommandInterpreter().GetExecutionContext()); @@ -1120,13 +1120,23 @@ SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { } #endif // LLDB_DISABLE_PYTHON +static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { + if (categories == nullptr) + return {}; + size_t len = 0; + while (categories[len] != nullptr) + ++len; + return llvm::makeArrayRef(categories, len); +} + bool SBDebugger::EnableLog(const char *channel, const char **categories) { if (m_opaque_sp) { uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; - StreamString errors; - return m_opaque_sp->EnableLog(channel, categories, nullptr, log_options, - errors); + std::string error; + llvm::raw_string_ostream error_stream(error); + return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "", + log_options, error_stream); } else return false; } diff --git a/contrib/llvm/tools/lldb/source/API/SBDeclaration.cpp b/contrib/llvm/tools/lldb/source/API/SBDeclaration.cpp index fc21f83..d6e61e3 100644 --- a/contrib/llvm/tools/lldb/source/API/SBDeclaration.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBDeclaration.cpp @@ -1,5 +1,4 @@ -//===-- SBDeclaration.cpp -----------------------------------------*- C++ -//-*-===// +//===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -10,9 +9,10 @@ #include "lldb/API/SBDeclaration.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" +#include "lldb/Host/PosixApi.h" #include "lldb/Symbol/Declaration.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include <limits.h> diff --git a/contrib/llvm/tools/lldb/source/API/SBError.cpp b/contrib/llvm/tools/lldb/source/API/SBError.cpp index 451c0a7..b2811d0 100644 --- a/contrib/llvm/tools/lldb/source/API/SBError.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBError.cpp @@ -9,8 +9,8 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/Log.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include <stdarg.h> @@ -21,7 +21,7 @@ SBError::SBError() : m_opaque_ap() {} SBError::SBError(const SBError &rhs) : m_opaque_ap() { if (rhs.IsValid()) - m_opaque_ap.reset(new Error(*rhs)); + m_opaque_ap.reset(new Status(*rhs)); } SBError::~SBError() {} @@ -31,7 +31,7 @@ const SBError &SBError::operator=(const SBError &rhs) { if (m_opaque_ap.get()) *m_opaque_ap = *rhs; else - m_opaque_ap.reset(new Error(*rhs)); + m_opaque_ap.reset(new Status(*rhs)); } else m_opaque_ap.reset(); @@ -108,7 +108,7 @@ void SBError::SetError(uint32_t err, ErrorType type) { m_opaque_ap->SetError(err, type); } -void SBError::SetError(const Error &lldb_error) { +void SBError::SetError(const Status &lldb_error) { CreateIfNeeded(); *m_opaque_ap = lldb_error; } @@ -141,19 +141,19 @@ bool SBError::IsValid() const { return m_opaque_ap.get() != NULL; } void SBError::CreateIfNeeded() { if (m_opaque_ap.get() == NULL) - m_opaque_ap.reset(new Error()); + m_opaque_ap.reset(new Status()); } -lldb_private::Error *SBError::operator->() { return m_opaque_ap.get(); } +lldb_private::Status *SBError::operator->() { return m_opaque_ap.get(); } -lldb_private::Error *SBError::get() { return m_opaque_ap.get(); } +lldb_private::Status *SBError::get() { return m_opaque_ap.get(); } -lldb_private::Error &SBError::ref() { +lldb_private::Status &SBError::ref() { CreateIfNeeded(); return *m_opaque_ap; } -const lldb_private::Error &SBError::operator*() const { +const lldb_private::Status &SBError::operator*() const { // Be sure to call "IsValid()" before calling this function or it will crash return *m_opaque_ap; } diff --git a/contrib/llvm/tools/lldb/source/API/SBEvent.cpp b/contrib/llvm/tools/lldb/source/API/SBEvent.cpp index e0bb68c..17a16ff 100644 --- a/contrib/llvm/tools/lldb/source/API/SBEvent.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBEvent.cpp @@ -12,12 +12,12 @@ #include "lldb/API/SBStream.h" #include "lldb/Breakpoint/Breakpoint.h" -#include "lldb/Core/ConstString.h" #include "lldb/Core/Event.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; @@ -109,13 +109,9 @@ bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) { // For logging, this gets a little chatty so only enable this when verbose // logging is on - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API | - LIBLLDB_LOG_VERBOSE)); - if (log) - log->Printf( - "SBEvent(%p)::BroadcasterMatchesRef (SBBroadcaster(%p): %s) => %i", - static_cast<void *>(get()), static_cast<void *>(broadcaster.get()), - broadcaster.GetName(), success); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(), + broadcaster.get(), broadcaster.GetName(), success); return success; } diff --git a/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp b/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp index 88baf3b..011b882 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBFileSpec.cpp @@ -12,9 +12,10 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" -#include "lldb/Host/FileSpec.h" +#include "lldb/Host/PosixApi.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "llvm/ADT/SmallString.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBFileSpecList.cpp b/contrib/llvm/tools/lldb/source/API/SBFileSpecList.cpp index 8ed3f6f..67d28dc 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFileSpecList.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBFileSpecList.cpp @@ -13,9 +13,10 @@ #include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBStream.h" #include "lldb/Core/FileSpecList.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" -#include "lldb/Host/FileSpec.h" +#include "lldb/Host/PosixApi.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBFrame.cpp b/contrib/llvm/tools/lldb/source/API/SBFrame.cpp index 8d8cb48..684a707 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFrame.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBFrame.cpp @@ -21,9 +21,6 @@ #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/Address.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectVariable.h" @@ -42,6 +39,9 @@ #include "lldb/Target/StackID.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" @@ -606,7 +606,7 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path, frame = exe_ctx.GetFramePtr(); if (frame) { VariableSP var_sp; - Error error; + Status error; ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath( var_path, eNoDynamicValues, StackFrame::eExpressionPathOptionCheckPtrVsMember | @@ -1370,6 +1370,25 @@ const char *SBFrame::GetFunctionName() { return static_cast<const SBFrame *>(this)->GetFunctionName(); } +lldb::LanguageType SBFrame::GuessLanguage() const { + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); + + StackFrame *frame = nullptr; + Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); + if (target && process) { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&process->GetRunLock())) { + frame = exe_ctx.GetFramePtr(); + if (frame) { + return frame->GuessLanguage(); + } + } + } + return eLanguageTypeUnknown; +} + const char *SBFrame::GetFunctionName() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); const char *name = nullptr; diff --git a/contrib/llvm/tools/lldb/source/API/SBFunction.cpp b/contrib/llvm/tools/lldb/source/API/SBFunction.cpp index 9065cc3..6a24f64 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFunction.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBFunction.cpp @@ -11,7 +11,6 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" @@ -19,6 +18,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBHostOS.cpp b/contrib/llvm/tools/lldb/source/API/SBHostOS.cpp index 8df74d9..90b75a6 100644 --- a/contrib/llvm/tools/lldb/source/API/SBHostOS.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBHostOS.cpp @@ -9,13 +9,13 @@ #include "lldb/API/SBHostOS.h" #include "lldb/API/SBError.h" -#include "lldb/Core/Log.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Path.h" @@ -80,7 +80,7 @@ lldb::thread_t SBHostOS::ThreadCreate(const char *name, void SBHostOS::ThreadCreated(const char *name) {} bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { - Error error; + Status error; HostThread host_thread(thread); error = host_thread.Cancel(); if (error_ptr) @@ -90,7 +90,7 @@ bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { } bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { - Error error; + Status error; #if defined(_WIN32) if (error_ptr) error_ptr->SetErrorString("ThreadDetach is not supported on this platform"); @@ -106,7 +106,7 @@ bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) { - Error error; + Status error; HostThread host_thread(thread); error = host_thread.Join(result); if (error_ptr) diff --git a/contrib/llvm/tools/lldb/source/API/SBInstruction.cpp b/contrib/llvm/tools/lldb/source/API/SBInstruction.cpp index 8c616da..8b7deb7 100644 --- a/contrib/llvm/tools/lldb/source/API/SBInstruction.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBInstruction.cpp @@ -16,8 +16,6 @@ #include "lldb/API/SBTarget.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/Module.h" @@ -25,6 +23,8 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/DataExtractor.h" //---------------------------------------------------------------------- // We recently fixed a leak in one of the Instruction subclasses where @@ -176,6 +176,13 @@ bool SBInstruction::HasDelaySlot() { return false; } +bool SBInstruction::CanSetBreakpoint () { + lldb::InstructionSP inst_sp(GetOpaque()); + if (inst_sp) + return inst_sp->CanSetBreakpoint(); + return false; +} + lldb::InstructionSP SBInstruction::GetOpaque() { if (m_opaque_sp) return m_opaque_sp->GetSP(); diff --git a/contrib/llvm/tools/lldb/source/API/SBInstructionList.cpp b/contrib/llvm/tools/lldb/source/API/SBInstructionList.cpp index 8ab3aca..3edb9ea 100644 --- a/contrib/llvm/tools/lldb/source/API/SBInstructionList.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBInstructionList.cpp @@ -9,11 +9,12 @@ #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBInstruction.h" +#include "lldb/API/SBAddress.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Stream.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; @@ -49,6 +50,31 @@ SBInstruction SBInstructionList::GetInstructionAtIndex(uint32_t idx) { return inst; } +size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, + const SBAddress &end, + bool canSetBreakpoint) { + size_t num_instructions = GetSize(); + size_t i = 0; + SBAddress addr; + size_t lower_index = 0; + size_t upper_index = 0; + size_t instructions_to_skip = 0; + for (i = 0; i < num_instructions; ++i) { + addr = GetInstructionAtIndex(i).GetAddress(); + if (start == addr) + lower_index = i; + if (end == addr) + upper_index = i; + } + if (canSetBreakpoint) + for (i = lower_index; i <= upper_index; ++i) { + SBInstruction insn = GetInstructionAtIndex(i); + if (!insn.CanSetBreakpoint()) + ++instructions_to_skip; + } + return upper_index - lower_index - instructions_to_skip; +} + void SBInstructionList::Clear() { m_opaque_sp.reset(); } void SBInstructionList::AppendInstruction(SBInstruction insn) {} diff --git a/contrib/llvm/tools/lldb/source/API/SBLineEntry.cpp b/contrib/llvm/tools/lldb/source/API/SBLineEntry.cpp index 3469cec..7341d36 100644 --- a/contrib/llvm/tools/lldb/source/API/SBLineEntry.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBLineEntry.cpp @@ -11,9 +11,10 @@ #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/StreamString.h" +#include "lldb/Host/PosixApi.h" #include "lldb/Symbol/LineEntry.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBListener.cpp b/contrib/llvm/tools/lldb/source/API/SBListener.cpp index 501535a..50fed4e 100644 --- a/contrib/llvm/tools/lldb/source/API/SBListener.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBListener.cpp @@ -15,8 +15,8 @@ #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Listener.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/StreamString.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -302,6 +302,8 @@ bool SBListener::HandleBroadcastEvent(const SBEvent &event) { return false; } +lldb::ListenerSP SBListener::GetSP() { return m_opaque_sp; } + Listener *SBListener::operator->() const { return m_opaque_sp.get(); } Listener *SBListener::get() const { return m_opaque_sp.get(); } diff --git a/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp b/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp index 3e72276..c4dbaec 100644 --- a/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp @@ -11,8 +11,8 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/StreamString.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfoList.cpp b/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfoList.cpp index f7ce81a..fff4044 100644 --- a/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfoList.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfoList.cpp @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBMemoryRegionInfoList.h" +#include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/Log.h" #include <vector> diff --git a/contrib/llvm/tools/lldb/source/API/SBModule.cpp b/contrib/llvm/tools/lldb/source/API/SBModule.cpp index 8964303..17f3dcc 100644 --- a/contrib/llvm/tools/lldb/source/API/SBModule.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBModule.cpp @@ -14,10 +14,8 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBSymbolContextList.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Symbol/ObjectFile.h" @@ -27,6 +25,8 @@ #include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -37,8 +37,8 @@ SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {} SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() { ModuleSP module_sp; - Error error = ModuleList::GetSharedModule(*module_spec.m_opaque_ap, module_sp, - NULL, NULL, NULL); + Status error = ModuleList::GetSharedModule(*module_spec.m_opaque_ap, + module_sp, NULL, NULL, NULL); if (module_sp) SetSP(module_sp); } diff --git a/contrib/llvm/tools/lldb/source/API/SBModuleSpec.cpp b/contrib/llvm/tools/lldb/source/API/SBModuleSpec.cpp index b82b822..a1c0886 100644 --- a/contrib/llvm/tools/lldb/source/API/SBModuleSpec.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBModuleSpec.cpp @@ -11,9 +11,9 @@ #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Stream.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp index 6085cef..87cbc45 100644 --- a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp @@ -13,11 +13,13 @@ #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBUnixSignals.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/Error.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/Args.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Status.h" + +#include "llvm/Support/FileSystem.h" #include <functional> @@ -203,7 +205,7 @@ const char *SBPlatformShellCommand::GetOutput() { SBPlatform::SBPlatform() : m_opaque_sp() {} SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { - Error error; + Status error; if (platform_name && platform_name[0]) m_opaque_sp = Platform::Create(ConstString(platform_name), error); } @@ -363,7 +365,7 @@ SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { if (src.Exists()) { uint32_t permissions = src.ref().GetPermissions(); if (permissions == 0) { - if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory) + if (llvm::sys::fs::is_directory(src.ref().GetPath())) permissions = eFilePermissionsDirectoryDefault; else permissions = eFilePermissionsFileDefault; @@ -372,7 +374,7 @@ SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { return platform_sp->PutFile(src.ref(), dst.ref(), permissions); } - Error error; + Status error; error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str()); return error; @@ -384,7 +386,7 @@ SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) { if (src.Exists()) return platform_sp->Install(src.ref(), dst.ref()); - Error error; + Status error; error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str()); return error; @@ -395,7 +397,7 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { const char *command = shell_command.GetCommand(); if (!command) - return Error("invalid shell command (empty)"); + return Status("invalid shell command (empty)"); const char *working_dir = shell_command.GetWorkingDirectory(); if (working_dir == NULL) { @@ -425,7 +427,7 @@ SBError SBPlatform::Kill(const lldb::pid_t pid) { } SBError SBPlatform::ExecuteConnected( - const std::function<Error(const lldb::PlatformSP &)> &func) { + const std::function<Status(const lldb::PlatformSP &)> &func) { SBError sb_error; const auto platform_sp(GetSP()); if (platform_sp) { diff --git a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp index 59dd569..caf07db 100644 --- a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp @@ -16,11 +16,9 @@ #include "lldb/lldb-types.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/Args.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -29,6 +27,8 @@ #include "lldb/Target/SystemRuntime.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" // Project includes @@ -44,6 +44,8 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBThreadCollection.h" +#include "lldb/API/SBTrace.h" +#include "lldb/API/SBTraceOptions.h" #include "lldb/API/SBUnixSignals.h" using namespace lldb; @@ -279,7 +281,7 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { size_t ret_val = 0; ProcessSP process_sp(GetSP()); if (process_sp) { - Error error; + Status error; ret_val = process_sp->PutSTDIN(src, src_len, error); } @@ -296,7 +298,7 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { - Error error; + Status error; bytes_read = process_sp->GetSTDOUT(dst, dst_len, error); } @@ -315,7 +317,7 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { - Error error; + Status error; bytes_read = process_sp->GetSTDERR(dst, dst_len, error); } @@ -334,7 +336,7 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { - Error error; + Status error; bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error); } @@ -349,6 +351,25 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { return bytes_read; } +lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options, + lldb::SBError &error) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + ProcessSP process_sp(GetSP()); + error.Clear(); + SBTrace trace_instance; + trace_instance.SetSP(process_sp); + lldb::user_id_t uid = LLDB_INVALID_UID; + + if (!process_sp) { + error.SetErrorString("invalid process"); + } else { + uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref()); + trace_instance.SetTraceUID(uid); + LLDB_LOG(log, "SBProcess::returned uid - {0}", uid); + } + return trace_instance; +} + void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const { if (out == NULL) return; @@ -1135,22 +1156,34 @@ uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec, uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec, const lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { + if (log) + log->Printf("SBProcess(%p)::LoadImage() => calling Platform::LoadImage" + "for: %s", + static_cast<void *>(process_sp.get()), + sb_local_image_spec.GetFilename()); + std::lock_guard<std::recursive_mutex> guard( - process_sp->GetTarget().GetAPIMutex()); + process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec, *sb_remote_image_spec, sb_error.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) log->Printf("SBProcess(%p)::LoadImage() => error: process is running", static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } + } else { + if (log) + log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid" + " process", + static_cast<void *>(process_sp.get())); + sb_error.SetErrorString("process is invalid"); } return LLDB_INVALID_IMAGE_TOKEN; } diff --git a/contrib/llvm/tools/lldb/source/API/SBQueue.cpp b/contrib/llvm/tools/lldb/source/API/SBQueue.cpp index c6f5305..5f85211 100644 --- a/contrib/llvm/tools/lldb/source/API/SBQueue.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBQueue.cpp @@ -15,11 +15,11 @@ #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBThread.h" -#include "lldb/Core/Log.h" #include "lldb/Target/Process.h" #include "lldb/Target/Queue.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp b/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp index 2e06bc8..87ba73f9 100644 --- a/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp @@ -13,10 +13,10 @@ #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBThread.h" #include "lldb/Core/Address.h" -#include "lldb/Core/Log.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBSection.cpp b/contrib/llvm/tools/lldb/source/API/SBSection.cpp index 8124fe9..9da5d17 100644 --- a/contrib/llvm/tools/lldb/source/API/SBSection.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBSection.cpp @@ -10,13 +10,14 @@ #include "lldb/API/SBSection.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" -#include "lldb/Core/DataBuffer.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" -#include "lldb/Core/StreamString.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/DataBuffer.h" +#include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -165,8 +166,8 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { else file_size = 0; } - DataBufferSP data_buffer_sp( - objfile->GetFileSpec().ReadFileContents(file_offset, file_size)); + auto data_buffer_sp = DataBufferLLVM::CreateSliceFromPath( + objfile->GetFileSpec().GetPath(), file_size, file_offset); if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) { DataExtractorSP data_extractor_sp( new DataExtractor(data_buffer_sp, objfile->GetByteOrder(), diff --git a/contrib/llvm/tools/lldb/source/API/SBSourceManager.cpp b/contrib/llvm/tools/lldb/source/API/SBSourceManager.cpp index ecf532c..5804c22 100644 --- a/contrib/llvm/tools/lldb/source/API/SBSourceManager.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBSourceManager.cpp @@ -15,8 +15,8 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Utility/Stream.h" #include "lldb/Target/Target.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBStream.cpp b/contrib/llvm/tools/lldb/source/API/SBStream.cpp index 858e949..159ec07 100644 --- a/contrib/llvm/tools/lldb/source/API/SBStream.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBStream.cpp @@ -9,10 +9,10 @@ #include "lldb/API/SBStream.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StreamString.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBStringList.cpp b/contrib/llvm/tools/lldb/source/API/SBStringList.cpp index 075ee0d..9ac69b1 100644 --- a/contrib/llvm/tools/lldb/source/API/SBStringList.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBStringList.cpp @@ -9,7 +9,7 @@ #include "lldb/API/SBStringList.h" -#include "lldb/Core/StringList.h" +#include "lldb/Utility/StringList.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBStructuredData.cpp b/contrib/llvm/tools/lldb/source/API/SBStructuredData.cpp index d9ea072..d506410 100644 --- a/contrib/llvm/tools/lldb/source/API/SBStructuredData.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBStructuredData.cpp @@ -10,80 +10,17 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Error.h" #include "lldb/Core/Event.h" -#include "lldb/Core/Stream.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" using namespace lldb; using namespace lldb_private; #pragma mark-- -#pragma mark StructuredDataImpl - -class StructuredDataImpl { -public: - StructuredDataImpl() : m_plugin_wp(), m_data_sp() {} - - StructuredDataImpl(const StructuredDataImpl &rhs) = default; - - StructuredDataImpl(const EventSP &event_sp) - : m_plugin_wp( - EventDataStructuredData::GetPluginFromEvent(event_sp.get())), - m_data_sp(EventDataStructuredData::GetObjectFromEvent(event_sp.get())) { - } - - ~StructuredDataImpl() = default; - - StructuredDataImpl &operator=(const StructuredDataImpl &rhs) = default; - - bool IsValid() const { return m_data_sp.get() != nullptr; } - - void Clear() { - m_plugin_wp.reset(); - m_data_sp.reset(); - } - - SBError GetAsJSON(lldb_private::Stream &stream) const { - SBError sb_error; - - if (!m_data_sp) { - sb_error.SetErrorString("No structured data."); - return sb_error; - } - - m_data_sp->Dump(stream); - return sb_error; - } - - Error GetDescription(lldb_private::Stream &stream) const { - Error error; - - if (!m_data_sp) { - error.SetErrorString("Cannot pretty print structured data: " - "no data to print."); - return error; - } - - // Grab the plugin. - auto plugin_sp = StructuredDataPluginSP(m_plugin_wp); - if (!plugin_sp) { - error.SetErrorString("Cannot pretty print structured data: " - "plugin doesn't exist."); - return error; - } - - // Get the data's description. - return plugin_sp->GetDescription(m_data_sp, stream); - } - -private: - StructuredDataPluginWP m_plugin_wp; - StructuredData::ObjectSP m_data_sp; -}; - -#pragma mark-- #pragma mark SBStructuredData SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) {} @@ -102,17 +39,73 @@ operator=(const lldb::SBStructuredData &rhs) { return *this; } +lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { + lldb::SBError error; + std::string json_str(stream.GetData()); + + StructuredData::ObjectSP json_obj = StructuredData::ParseJSON(json_str); + m_impl_up->SetObjectSP(json_obj); + + if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary) + error.SetErrorString("Invalid Syntax"); + return error; +} + bool SBStructuredData::IsValid() const { return m_impl_up->IsValid(); } void SBStructuredData::Clear() { m_impl_up->Clear(); } SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const { - return m_impl_up->GetAsJSON(stream.ref()); + SBError error; + error.SetError(m_impl_up->GetAsJSON(stream.ref())); + return error; } lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const { - Error error = m_impl_up->GetDescription(stream.ref()); + Status error = m_impl_up->GetDescription(stream.ref()); SBError sb_error; sb_error.SetError(error); return sb_error; } + +StructuredDataType SBStructuredData::GetType() const { + return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid); +} + +size_t SBStructuredData::GetSize() const { + return (m_impl_up ? m_impl_up->GetSize() : 0); +} + +lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { + if (!m_impl_up) + return SBStructuredData(); + + SBStructuredData result; + result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key)); + return result; +} + +lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const { + if (!m_impl_up) + return SBStructuredData(); + + SBStructuredData result; + result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx)); + return result; +} + +uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const { + return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value); +} + +double SBStructuredData::GetFloatValue(double fail_value) const { + return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value); +} + +bool SBStructuredData::GetBooleanValue(bool fail_value) const { + return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value); +} + +size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { + return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0); +} diff --git a/contrib/llvm/tools/lldb/source/API/SBSymbol.cpp b/contrib/llvm/tools/lldb/source/API/SBSymbol.cpp index a4cc525..5be20a1 100644 --- a/contrib/llvm/tools/lldb/source/API/SBSymbol.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBSymbol.cpp @@ -10,11 +10,11 @@ #include "lldb/API/SBSymbol.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBSymbolContext.cpp b/contrib/llvm/tools/lldb/source/API/SBSymbolContext.cpp index 4748836..45dfffd 100644 --- a/contrib/llvm/tools/lldb/source/API/SBSymbolContext.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBSymbolContext.cpp @@ -9,11 +9,11 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp index c000bf9..c706344 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp @@ -34,17 +34,14 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Core/STLUtils.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" #include "lldb/Symbol/ClangASTContext.h" @@ -61,6 +58,9 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/TargetList.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/RegularExpression.h" #include "../source/Commands/CommandObjectBreakpoint.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -74,7 +74,7 @@ using namespace lldb_private; namespace { -Error AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { +Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex()); auto process_sp = target.GetProcessSP(); @@ -85,8 +85,8 @@ Error AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { // listener, so if a valid listener is supplied, we need to error out // to let the client know. if (attach_info.GetListener()) - return Error("process is connected and already has a listener, pass " - "empty listener"); + return Status("process is connected and already has a listener, pass " + "empty listener"); } } @@ -686,7 +686,7 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, if (sb_module_list.GetSize() > 0) { module_list = sb_module_list.get(); } - *sb_bp = target_sp->CreateBreakpoint( + sb_bp = target_sp->CreateBreakpoint( module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue, internal, hardware, move_to_nearest_code); } @@ -699,7 +699,7 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => " "SBBreakpoint(%p): %s", static_cast<void *>(target_sp.get()), path, line, - static_cast<void *>(sb_bp.get()), sstr.GetData()); + static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData()); } return sb_bp; @@ -721,11 +721,11 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, if (module_name && module_name[0]) { FileSpecList module_spec_list; module_spec_list.Append(FileSpec(module_name, false)); - *sb_bp = target_sp->CreateBreakpoint( + sb_bp = target_sp->CreateBreakpoint( &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); } else { - *sb_bp = target_sp->CreateBreakpoint( + sb_bp = target_sp->CreateBreakpoint( NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); } @@ -735,7 +735,7 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", " "module=\"%s\") => SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), symbol_name, module_name, - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -771,7 +771,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - *sb_bp = target_sp->CreateBreakpoint( + sb_bp = target_sp->CreateBreakpoint( module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask, symbol_language, 0, skip_prologue, internal, hardware); } @@ -780,7 +780,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", " "name_type: %d) => SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), symbol_name, - name_type_mask, static_cast<void *>(sb_bp.get())); + name_type_mask, static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -815,7 +815,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; - *sb_bp = target_sp->CreateBreakpoint( + sb_bp = target_sp->CreateBreakpoint( module_list.get(), comp_unit_list.get(), symbol_names, num_names, name_type_mask, symbol_language, offset, skip_prologue, internal, hardware); @@ -836,7 +836,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( log->Printf("\"<NULL>\"%c ", sep); } log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask, - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); } return sb_bp; @@ -875,7 +875,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; - *sb_bp = target_sp->CreateFuncRegexBreakpoint( + sb_bp = target_sp->CreateFuncRegexBreakpoint( module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware); } @@ -884,7 +884,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") " "=> SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), symbol_name_regex, - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -897,7 +897,7 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; - *sb_bp = target_sp->CreateBreakpoint(address, false, hardware); + sb_bp = target_sp->CreateBreakpoint(address, false, hardware); } if (log) @@ -905,7 +905,7 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { ") => SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), static_cast<uint64_t>(address), - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -926,7 +926,7 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; - *sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); + sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); } if (log) { @@ -935,7 +935,7 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => " "SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), s.GetData(), - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); } return sb_bp; @@ -985,7 +985,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( func_names_set.insert(func_names.GetStringAtIndex(i)); } - *sb_bp = target_sp->CreateSourceRegexBreakpoint( + sb_bp = target_sp->CreateSourceRegexBreakpoint( module_list.get(), source_file_list.get(), func_names_set, regexp, false, hardware, move_to_nearest_code); } @@ -994,7 +994,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") " "=> SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), source_regex, - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -1009,7 +1009,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; - *sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp, + sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp, hardware); } @@ -1019,7 +1019,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, static_cast<void *>(target_sp.get()), Language::GetNameForLanguageType(language), catch_bp ? "on" : "off", throw_bp ? "on" : "off", - static_cast<void *>(sb_bp.get())); + static_cast<void *>(sb_bp.GetSP().get())); return sb_bp; } @@ -1038,7 +1038,7 @@ SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { TargetSP target_sp(GetSP()); if (target_sp) { // The breakpoint list is thread safe, no need to lock - *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); + sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); } return sb_breakpoint; } @@ -1068,14 +1068,14 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { TargetSP target_sp(GetSP()); if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - *sb_breakpoint = target_sp->GetBreakpointByID(bp_id); + sb_breakpoint = target_sp->GetBreakpointByID(bp_id); } if (log) log->Printf( "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id), - static_cast<void *>(sb_breakpoint.get())); + static_cast<void *>(sb_breakpoint.GetSP().get())); return sb_breakpoint; } @@ -1279,7 +1279,7 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, } // Target::CreateWatchpoint() is thread safe. - Error cw_error; + Status cw_error; // This API doesn't take in a type, so we can't figure out what it is. CompilerType *type = NULL; watchpoint_sp = @@ -1863,7 +1863,7 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, DataBufferHeap data( target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); bool prefer_file_cache = false; - lldb_private::Error error; + lldb_private::Status error; lldb::addr_t load_addr = LLDB_INVALID_ADDRESS; const size_t bytes_read = target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), @@ -2170,7 +2170,7 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() { if (process_sp) abi_sp = process_sp->GetABI(); else - abi_sp = ABI::FindPlugin(target_sp->GetArchitecture()); + abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture()); if (abi_sp) return abi_sp->GetRedZoneSize(); } diff --git a/contrib/llvm/tools/lldb/source/API/SBThread.cpp b/contrib/llvm/tools/lldb/source/API/SBThread.cpp index fbde6dd..b344896 100644 --- a/contrib/llvm/tools/lldb/source/API/SBThread.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBThread.cpp @@ -15,9 +15,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" @@ -34,6 +32,8 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" @@ -43,6 +43,7 @@ #include "lldb/API/SBThreadCollection.h" #include "lldb/API/SBThreadPlan.h" #include "lldb/API/SBValue.h" +#include "lldb/lldb-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -292,10 +293,6 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { ThreadCollectionSP threads; threads.reset(new ThreadCollection()); - // We currently only support ThreadSanitizer. - if (type != eInstrumentationRuntimeTypeThreadSanitizer) - return threads; - std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -561,26 +558,26 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { StructuredData::ObjectSP node = info_root_sp->GetObjectForDotSeparatedPath(path); if (node) { - if (node->GetType() == StructuredData::Type::eTypeString) { - strm.Printf("%s", node->GetAsString()->GetValue().c_str()); + if (node->GetType() == eStructuredDataTypeString) { + strm.Printf("%s", node->GetAsString()->GetValue().str().c_str()); success = true; } - if (node->GetType() == StructuredData::Type::eTypeInteger) { + if (node->GetType() == eStructuredDataTypeInteger) { strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue()); success = true; } - if (node->GetType() == StructuredData::Type::eTypeFloat) { + if (node->GetType() == eStructuredDataTypeFloat) { strm.Printf("0x%f", node->GetAsFloat()->GetValue()); success = true; } - if (node->GetType() == StructuredData::Type::eTypeBoolean) { + if (node->GetType() == eStructuredDataTypeBoolean) { if (node->GetAsBoolean()->GetValue() == true) strm.Printf("true"); else strm.Printf("false"); success = true; } - if (node->GetType() == StructuredData::Type::eTypeNull) { + if (node->GetType() == eStructuredDataTypeNull) { strm.Printf("null"); success = true; } @@ -595,8 +592,8 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { } if (log) - log->Printf("SBThread(%p)::GetInfoItemByPathAsString () => %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), strm.GetData()); + log->Printf("SBThread(%p)::GetInfoItemByPathAsString (\"%s\") => \"%s\"", + static_cast<void *>(exe_ctx.GetThreadPtr()), path, strm.GetData()); return success; } @@ -1037,7 +1034,7 @@ SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { Thread *thread = exe_ctx.GetThreadPtr(); - Error err = thread->JumpToLine(file_spec.get(), line, true); + Status err = thread->JumpToLine(file_spec.get(), line, true); sb_error.SetError(err); return sb_error; } diff --git a/contrib/llvm/tools/lldb/source/API/SBThreadPlan.cpp b/contrib/llvm/tools/lldb/source/API/SBThreadPlan.cpp index 74cabf7..a19023f 100644 --- a/contrib/llvm/tools/lldb/source/API/SBThreadPlan.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBThreadPlan.cpp @@ -15,9 +15,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/SymbolContext.h" @@ -28,12 +26,13 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" -#include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanPython.h" #include "lldb/Target/ThreadPlanStepInRange.h" #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBTrace.cpp b/contrib/llvm/tools/lldb/source/API/SBTrace.cpp new file mode 100644 index 0000000..9a5fa4e --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/SBTrace.cpp @@ -0,0 +1,109 @@ +//===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/Process.h" +#include "lldb/Utility/Log.h" + +#include "lldb/API/SBTrace.h" +#include "lldb/API/SBTraceOptions.h" + +using namespace lldb; +using namespace lldb_private; + +class TraceImpl { +public: + lldb::user_id_t uid; +}; + +lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); } + +size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size, + size_t offset, lldb::tid_t thread_id) { + ProcessSP process_sp(GetSP()); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); + error.Clear(); + + if (!process_sp) { + error.SetErrorString("invalid process"); + } else { + error.SetError( + process_sp->GetData(GetTraceUID(), thread_id, buffer, offset)); + LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size()); + } + return buffer.size(); +} + +size_t SBTrace::GetMetaData(SBError &error, void *buf, size_t size, + size_t offset, lldb::tid_t thread_id) { + ProcessSP process_sp(GetSP()); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); + error.Clear(); + + if (!process_sp) { + error.SetErrorString("invalid process"); + } else { + + error.SetError( + process_sp->GetMetaData(GetTraceUID(), thread_id, buffer, offset)); + LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size()); + } + return buffer.size(); +} + +void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) { + ProcessSP process_sp(GetSP()); + error.Clear(); + + if (!process_sp) { + error.SetErrorString("invalid process"); + return; + } + error.SetError(process_sp->StopTrace(GetTraceUID(), thread_id)); +} + +void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) { + ProcessSP process_sp(GetSP()); + error.Clear(); + + if (!process_sp) { + error.SetErrorString("invalid process"); + } else { + error.SetError(process_sp->GetTraceConfig(GetTraceUID(), + *(options.m_traceoptions_sp))); + } +} + +lldb::user_id_t SBTrace::GetTraceUID() { + if (m_trace_impl_sp) + return m_trace_impl_sp->uid; + return LLDB_INVALID_UID; +} + +void SBTrace::SetTraceUID(lldb::user_id_t uid) { + if (m_trace_impl_sp) + m_trace_impl_sp->uid = uid; +} + +SBTrace::SBTrace() { + m_trace_impl_sp.reset(new TraceImpl); + if (m_trace_impl_sp) + m_trace_impl_sp->uid = LLDB_INVALID_UID; +} + +void SBTrace::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; } + +bool SBTrace::IsValid() { + if (!m_trace_impl_sp) + return false; + if (!GetSP()) + return false; + return true; +} diff --git a/contrib/llvm/tools/lldb/source/API/SBTraceOptions.cpp b/contrib/llvm/tools/lldb/source/API/SBTraceOptions.cpp new file mode 100644 index 0000000..20a8f25 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/SBTraceOptions.cpp @@ -0,0 +1,94 @@ +//===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTraceOptions.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/Core/StructuredDataImpl.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/TraceOptions.h" + +using namespace lldb; +using namespace lldb_private; + +SBTraceOptions::SBTraceOptions() { + m_traceoptions_sp.reset(new TraceOptions()); +} + +lldb::TraceType SBTraceOptions::getType() const { + if (m_traceoptions_sp) + return m_traceoptions_sp->getType(); + return lldb::TraceType::eTraceTypeNone; +} + +uint64_t SBTraceOptions::getTraceBufferSize() const { + if (m_traceoptions_sp) + return m_traceoptions_sp->getTraceBufferSize(); + return 0; +} + +lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { + error.Clear(); + const lldb_private::StructuredData::DictionarySP dict_obj = + m_traceoptions_sp->getTraceParams(); + lldb::SBStructuredData structData; + if (dict_obj && structData.m_impl_up) + structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); + else + error.SetErrorString("Empty trace params"); + return structData; +} + +uint64_t SBTraceOptions::getMetaDataBufferSize() const { + if (m_traceoptions_sp) + return m_traceoptions_sp->getTraceBufferSize(); + return 0; +} + +void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { + if (m_traceoptions_sp && params.m_impl_up) { + StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); + if (obj_sp && obj_sp->GetAsDictionary() != nullptr) + m_traceoptions_sp->setTraceParams( + std::static_pointer_cast<StructuredData::Dictionary>(obj_sp)); + } + return; +} + +void SBTraceOptions::setType(lldb::TraceType type) { + if (m_traceoptions_sp) + m_traceoptions_sp->setType(type); +} + +void SBTraceOptions::setTraceBufferSize(uint64_t size) { + if (m_traceoptions_sp) + m_traceoptions_sp->setTraceBufferSize(size); +} + +void SBTraceOptions::setMetaDataBufferSize(uint64_t size) { + if (m_traceoptions_sp) + m_traceoptions_sp->setMetaDataBufferSize(size); +} + +bool SBTraceOptions::IsValid() { + if (m_traceoptions_sp) + return true; + return false; +} + +void SBTraceOptions::setThreadID(lldb::tid_t thread_id) { + if (m_traceoptions_sp) + m_traceoptions_sp->setThreadID(thread_id); +} + +lldb::tid_t SBTraceOptions::getThreadID() { + if (m_traceoptions_sp) + return m_traceoptions_sp->getThreadID(); + return LLDB_INVALID_THREAD_ID; +} diff --git a/contrib/llvm/tools/lldb/source/API/SBType.cpp b/contrib/llvm/tools/lldb/source/API/SBType.cpp index ca63a87..e2ef07c 100644 --- a/contrib/llvm/tools/lldb/source/API/SBType.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBType.cpp @@ -11,13 +11,13 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTypeEnumMember.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Mangled.h" -#include "lldb/Core/Stream.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeSystem.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "llvm/ADT/APSInt.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp index 787a46b..5ca9db7 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "lldb/API/SBType.h" +#include "lldb/API/SBTypeEnumMember.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" -#include "lldb/API/SBTypeEnumMember.h" -#include "lldb/Core/Stream.h" +#include "lldb/API/SBType.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" +#include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/API/SBUnixSignals.cpp b/contrib/llvm/tools/lldb/source/API/SBUnixSignals.cpp index bb85912..14bdd39 100644 --- a/contrib/llvm/tools/lldb/source/API/SBUnixSignals.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBUnixSignals.cpp @@ -8,10 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/Log.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/Log.h" #include "lldb/lldb-defines.h" #include "lldb/API/SBUnixSignals.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBValue.cpp b/contrib/llvm/tools/lldb/source/API/SBValue.cpp index 0531a3f..b6f044c 100644 --- a/contrib/llvm/tools/lldb/source/API/SBValue.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBValue.cpp @@ -17,12 +17,9 @@ #include "lldb/API/SBTypeSynthetic.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" @@ -39,6 +36,9 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBExpressionOptions.h" @@ -112,7 +112,7 @@ public: lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock<std::recursive_mutex> &lock, - Error &error) { + Status &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!m_valobj_sp) { error.SetErrorString("invalid value object"); @@ -218,12 +218,12 @@ public: return in_value.GetSP(m_stop_locker, m_lock, m_lock_error); } - Error &GetError() { return m_lock_error; } + Status &GetError() { return m_lock_error; } private: Process::StopLocker m_stop_locker; std::unique_lock<std::recursive_mutex> m_lock; - Error m_lock_error; + Status m_lock_error; }; SBValue::SBValue() : m_opaque_sp() {} @@ -1112,7 +1112,7 @@ SBValue SBValue::Dereference() { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { - Error error; + Status error; sb_value = value_sp->Dereference(error); } Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1336,7 +1336,7 @@ lldb::SBValue SBValue::AddressOf() { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { - Error error; + Status error; sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(), GetPreferSyntheticValue()); } @@ -1445,7 +1445,7 @@ lldb::SBData SBValue::GetData() { lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { DataExtractorSP data_sp(new DataExtractor()); - Error error; + Status error; value_sp->GetData(*data_sp, error); if (error.Success()) *sb_data = data_sp; @@ -1475,7 +1475,7 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) { error.SetErrorString("No data to set"); ret = false; } else { - Error set_error; + Status set_error; value_sp->SetData(*data_extractor, set_error); @@ -1541,7 +1541,7 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, if (write) watch_type |= LLDB_WATCH_TYPE_WRITE; - Error rc; + Status rc; CompilerType type(value_sp->GetCompilerType()); WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc); diff --git a/contrib/llvm/tools/lldb/source/API/SBValueList.cpp b/contrib/llvm/tools/lldb/source/API/SBValueList.cpp index 16289d9..0adf3bb 100644 --- a/contrib/llvm/tools/lldb/source/API/SBValueList.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBValueList.cpp @@ -10,8 +10,8 @@ #include "lldb/API/SBValueList.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" -#include "lldb/Core/Log.h" #include "lldb/Core/ValueObjectList.h" +#include "lldb/Utility/Log.h" #include <vector> diff --git a/contrib/llvm/tools/lldb/source/API/SBWatchpoint.cpp b/contrib/llvm/tools/lldb/source/API/SBWatchpoint.cpp index 50153c8..b775537 100644 --- a/contrib/llvm/tools/lldb/source/API/SBWatchpoint.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBWatchpoint.cpp @@ -16,39 +16,35 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Breakpoint/WatchpointList.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" using namespace lldb; using namespace lldb_private; -SBWatchpoint::SBWatchpoint() : m_opaque_sp() {} +SBWatchpoint::SBWatchpoint() {} SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp) - : m_opaque_sp(wp_sp) { + : m_opaque_wp(wp_sp) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) { SBStream sstr; GetDescription(sstr, lldb::eDescriptionLevelBrief); - log->Printf("SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp" - "=%p) => this.sp = %p (%s)", - static_cast<void *>(wp_sp.get()), - static_cast<void *>(m_opaque_sp.get()), sstr.GetData()); + LLDB_LOG(log, "watchpoint = {0} ({1})", wp_sp.get(), sstr.GetData()); } } SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_wp(rhs.m_opaque_wp) {} const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) { - if (this != &rhs) - m_opaque_sp = rhs.m_opaque_sp; + m_opaque_wp = rhs.m_opaque_wp; return *this; } @@ -74,7 +70,7 @@ watch_id_t SBWatchpoint::GetID() { return watch_id; } -bool SBWatchpoint::IsValid() const { return (bool)m_opaque_sp; } +bool SBWatchpoint::IsValid() const { return bool(m_opaque_wp.lock()); } SBError SBWatchpoint::GetError() { SBError sb_error; @@ -223,11 +219,11 @@ bool SBWatchpoint::GetDescription(SBStream &description, return true; } -void SBWatchpoint::Clear() { m_opaque_sp.reset(); } +void SBWatchpoint::Clear() { m_opaque_wp.reset(); } -lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_sp; } +lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_wp.lock(); } -void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_sp = sp; } +void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_wp = sp; } bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) { return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) != @@ -245,7 +241,7 @@ SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) { SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) { SBWatchpoint sb_watchpoint; if (event.IsValid()) - sb_watchpoint.m_opaque_sp = + sb_watchpoint = Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP()); return sb_watchpoint; } diff --git a/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp b/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp index e7faac5..eb1bc2f 100644 --- a/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp +++ b/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp @@ -20,7 +20,6 @@ #endif #include "lldb/Core/Debugger.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -28,6 +27,7 @@ #include "lldb/Symbol/GoASTContext.h" //#include "lldb/Symbol/JavaASTContext.h" #include "lldb/Symbol/OCamlASTContext.h" +#include "lldb/Utility/Timer.h" //#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" //#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h" @@ -49,8 +49,10 @@ #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" //#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" -#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h" -//#include "Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h" +#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h" +//#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h" +#include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h" +#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h" #include "Plugins/JITLoader/GDB/JITLoaderGDB.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" //#include "Plugins/Language/Go/GoLanguage.h" @@ -74,6 +76,7 @@ //#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" //#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" //#include "Plugins/Platform/NetBSD/PlatformNetBSD.h" +//#include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h" //#include "Plugins/Platform/Windows/PlatformWindows.h" #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" #include "Plugins/Process/elf-core/ProcessElfCore.h" @@ -266,6 +269,7 @@ void SystemInitializerFull::Initialize() { platform_freebsd::PlatformFreeBSD::Initialize(); //platform_linux::PlatformLinux::Initialize(); //platform_netbsd::PlatformNetBSD::Initialize(); +//platform_openbsd::PlatformOpenBSD::Initialize(); //PlatformWindows::Initialize(); //PlatformKalimba::Initialize(); //platform_android::PlatformAndroid::Initialize(); @@ -308,6 +312,8 @@ void SystemInitializerFull::Initialize() { MemoryHistoryASan::Initialize(); AddressSanitizerRuntime::Initialize(); //ThreadSanitizerRuntime::Initialize(); + UndefinedBehaviorSanitizerRuntime::Initialize(); + MainThreadCheckerRuntime::Initialize(); SymbolVendorELF::Initialize(); SymbolFileDWARF::Initialize(); @@ -398,7 +404,8 @@ void SystemInitializerFull::InitializeSWIG() { } void SystemInitializerFull::Terminate() { - Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION); + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); + Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); Debugger::SettingsTerminate(); @@ -431,6 +438,8 @@ void SystemInitializerFull::Terminate() { MemoryHistoryASan::Terminate(); AddressSanitizerRuntime::Terminate(); //ThreadSanitizerRuntime::Terminate(); + UndefinedBehaviorSanitizerRuntime::Terminate(); + MainThreadCheckerRuntime::Terminate(); SymbolVendorELF::Terminate(); SymbolFileDWARF::Terminate(); //SymbolFilePDB::Terminate(); @@ -485,13 +494,14 @@ void SystemInitializerFull::Terminate() { //OperatingSystemGo::Terminate(); platform_freebsd::PlatformFreeBSD::Terminate(); -// platform_linux::PlatformLinux::Terminate(); -// platform_netbsd::PlatformNetBSD::Terminate(); -// PlatformWindows::Terminate(); -// PlatformKalimba::Terminate(); -// platform_android::PlatformAndroid::Terminate(); -// PlatformMacOSX::Terminate(); -// PlatformRemoteiOS::Terminate(); +//platform_linux::PlatformLinux::Terminate(); +//platform_netbsd::PlatformNetBSD::Terminate(); +//platform_openbsd::PlatformOpenBSD::Terminate(); +//PlatformWindows::Terminate(); +//PlatformKalimba::Terminate(); +//platform_android::PlatformAndroid::Terminate(); +//PlatformMacOSX::Terminate(); +//PlatformRemoteiOS::Terminate(); #if defined(__APPLE__) PlatformiOSSimulator::Terminate(); PlatformDarwinKernel::Terminate(); |