2010-06-08 16:52:24 +00:00
|
|
|
//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
|
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2010-06-09 07:44:37 +00:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2019-03-06 00:06:00 +00:00
|
|
|
#include "SBReproducerPrivate.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2011-03-24 21:19:54 +00:00
|
|
|
#include "lldb/lldb-public.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2011-06-29 22:09:02 +00:00
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
|
#include "lldb/API/SBEvent.h"
|
2013-01-04 18:10:18 +00:00
|
|
|
#include "lldb/API/SBExpressionOptions.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2011-06-29 22:09:02 +00:00
|
|
|
#include "lldb/API/SBListener.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/API/SBModule.h"
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-08 22:22:41 +00:00
|
|
|
#include "lldb/API/SBModuleSpec.h"
|
2011-06-29 22:09:02 +00:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2011-09-13 00:29:56 +00:00
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2010-09-20 05:20:02 +00:00
|
|
|
#include "lldb/API/SBStream.h"
|
2016-04-28 01:40:57 +00:00
|
|
|
#include "lldb/API/SBStringList.h"
|
2018-04-16 22:55:34 +00:00
|
|
|
#include "lldb/API/SBStructuredData.h"
|
2011-06-21 01:34:41 +00:00
|
|
|
#include "lldb/API/SBSymbolContextList.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointID.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointIDList.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointList.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
|
#include "lldb/Core/Address.h"
|
|
|
|
|
#include "lldb/Core/AddressResolver.h"
|
|
|
|
|
#include "lldb/Core/AddressResolverName.h"
|
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/STLUtils.h"
|
|
|
|
|
#include "lldb/Core/SearchFilter.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Core/Section.h"
|
2018-04-16 22:55:34 +00:00
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
2013-10-08 21:49:02 +00:00
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2011-06-29 22:09:02 +00:00
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
2011-02-01 01:31:41 +00:00
|
|
|
#include "lldb/Host/Host.h"
|
2015-03-03 23:11:11 +00:00
|
|
|
#include "lldb/Symbol/DeclVendor.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2016-02-10 21:28:13 +00:00
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2011-07-29 19:53:35 +00:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
2019-07-31 20:47:38 +00:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2011-06-29 22:09:02 +00:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2015-03-03 19:23:09 +00:00
|
|
|
#include "lldb/Target/ABI.h"
|
2015-09-02 01:06:46 +00:00
|
|
|
#include "lldb/Target/Language.h"
|
2012-03-06 00:37:27 +00:00
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Process.h"
|
2015-03-04 21:33:45 +00:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
#include "lldb/Target/TargetList.h"
|
2017-11-13 16:16:33 +00:00
|
|
|
#include "lldb/Utility/ArchSpec.h"
|
2018-04-17 18:53:35 +00:00
|
|
|
#include "lldb/Utility/Args.h"
|
2017-03-22 18:40:07 +00:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
Move ProcessInfo from Host to Utility.
There are set of classes in Target that describe the parameters of a
process - e.g. it's PID, name, user id, and similar. However, since it
is a bare description of a process and contains no actual functionality,
there's nothing specifically that makes this appropriate for being in
Target -- it could just as well be describing a process on the host, or
some hypothetical virtual process that doesn't even exist.
To cement this, I'm moving these classes to Utility. It's possible that
we can find a better place for it in the future, but as it is neither
Host specific nor Target specific, Utility seems like the most appropriate
place for the time being.
After this there is only 2 remaining references to Target from Host,
which I'll address in a followup.
Differential Revision: https://reviews.llvm.org/D58842
llvm-svn: 355342
2019-03-04 21:51:03 +00:00
|
|
|
#include "lldb/Utility/ProcessInfo.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/RegularExpression.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2018-05-22 22:53:50 +00:00
|
|
|
#include "Commands/CommandObjectBreakpoint.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2016-12-14 21:31:31 +00:00
|
|
|
#include "llvm/Support/PrettyStackTrace.h"
|
2014-09-19 19:38:19 +00:00
|
|
|
#include "llvm/Support/Regex.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_DISASM_BYTE_SIZE 32
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
namespace {
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
|
2015-02-10 22:49:57 +00:00
|
|
|
|
|
|
|
|
auto process_sp = target.GetProcessSP();
|
|
|
|
|
if (process_sp) {
|
|
|
|
|
const auto state = process_sp->GetState();
|
|
|
|
|
if (process_sp->IsAlive() && state == eStateConnected) {
|
|
|
|
|
// If we are already connected, then we have already specified the
|
2018-04-30 16:49:04 +00:00
|
|
|
// listener, so if a valid listener is supplied, we need to error out to
|
|
|
|
|
// let the client know.
|
2015-02-10 22:49:57 +00:00
|
|
|
if (attach_info.GetListener())
|
2017-05-12 04:51:55 +00:00
|
|
|
return Status("process is connected and already has a listener, pass "
|
|
|
|
|
"empty listener");
|
2015-02-10 22:49:57 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-02-10 22:49:57 +00:00
|
|
|
|
|
|
|
|
return target.Attach(attach_info, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// SBTarget constructor
|
2019-03-06 00:06:00 +00:00
|
|
|
SBTarget::SBTarget() : m_opaque_sp() {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget);
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs);
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBTarget &,
|
|
|
|
|
SBTarget, operator=,(const lldb::SBTarget &), rhs);
|
|
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
if (this != &rhs)
|
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
2019-04-03 21:31:22 +00:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-11-05 23:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// Destructor
|
|
|
|
|
SBTarget::~SBTarget() {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
|
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
|
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
Target::TargetEventData::GetTargetFromEvent(event.get()));
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
|
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
const ModuleList module_list =
|
|
|
|
|
Target::TargetEventData::GetModuleListFromEvent(event.get());
|
|
|
|
|
return module_list.GetSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
|
|
|
|
|
const SBEvent &event) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent,
|
|
|
|
|
(const uint32_t, const lldb::SBEvent &), idx,
|
|
|
|
|
event);
|
|
|
|
|
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
const ModuleList module_list =
|
|
|
|
|
Target::TargetEventData::GetModuleListFromEvent(event.get());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *SBTarget::GetBroadcasterClassName() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget,
|
|
|
|
|
GetBroadcasterClassName);
|
|
|
|
|
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-10 21:59:55 +00:00
|
|
|
return Target::GetStaticBroadcasterClass().AsCString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-16 06:50:00 +00:00
|
|
|
bool SBTarget::IsValid() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
|
}
|
|
|
|
|
SBTarget::operator bool() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
|
2012-02-16 06:50:00 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBProcess SBTarget::GetProcess() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBProcess sb_process;
|
2012-01-30 07:41:31 +00:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2010-06-08 16:52:24 +00:00
|
|
|
if (target_sp) {
|
2012-05-19 09:59:08 +00:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 07:41:31 +00:00
|
|
|
sb_process.SetSP(process_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBPlatform SBTarget::GetPlatform() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBPlatform());
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
SBPlatform platform;
|
2014-04-04 04:06:10 +00:00
|
|
|
platform.m_opaque_sp = target_sp->GetPlatform();
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(platform);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
SBDebugger SBTarget::GetDebugger() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger);
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
SBDebugger debugger;
|
2014-10-22 07:22:56 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
|
|
|
|
debugger.reset(target_sp->GetDebugger().shared_from_this());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(debugger);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-10-22 07:22:56 +00:00
|
|
|
|
2018-04-16 22:55:34 +00:00
|
|
|
SBStructuredData SBTarget::GetStatistics() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics);
|
|
|
|
|
|
2018-04-16 22:55:34 +00:00
|
|
|
SBStructuredData data;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2018-04-16 22:55:34 +00:00
|
|
|
|
2019-08-14 22:19:23 +00:00
|
|
|
auto stats_up = std::make_unique<StructuredData::Dictionary>();
|
2018-04-16 22:55:34 +00:00
|
|
|
int i = 0;
|
|
|
|
|
for (auto &Entry : target_sp->GetStatistics()) {
|
|
|
|
|
std::string Desc = lldb_private::GetStatDescription(
|
|
|
|
|
static_cast<lldb_private::StatisticKind>(i));
|
|
|
|
|
stats_up->AddIntegerItem(Desc, Entry);
|
|
|
|
|
i += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.m_impl_up->SetObjectSP(std::move(stats_up));
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(data);
|
2018-04-16 22:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-28 23:27:54 +00:00
|
|
|
void SBTarget::SetCollectingStats(bool v) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v);
|
|
|
|
|
|
2018-09-28 23:27:54 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
|
|
|
|
return;
|
|
|
|
|
return target_sp->SetCollectingStats(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTarget::GetCollectingStats() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats);
|
|
|
|
|
|
2018-09-28 23:27:54 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
|
|
|
|
return false;
|
|
|
|
|
return target_sp->GetCollectingStats();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
SBProcess SBTarget::LoadCore(const char *core_file) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *),
|
|
|
|
|
core_file);
|
|
|
|
|
|
2018-06-11 21:19:26 +00:00
|
|
|
lldb::SBError error; // Ignored
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(LoadCore(core_file, error));
|
2018-06-11 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore,
|
|
|
|
|
(const char *, lldb::SBError &), core_file, error);
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
SBProcess sb_process;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
2012-01-30 09:04:36 +00:00
|
|
|
if (target_sp) {
|
2018-11-01 21:05:36 +00:00
|
|
|
FileSpec filespec(core_file);
|
|
|
|
|
FileSystem::Instance().Resolve(filespec);
|
2014-10-22 07:22:56 +00:00
|
|
|
ProcessSP process_sp(target_sp->CreateProcess(
|
2016-11-17 21:15:14 +00:00
|
|
|
target_sp->GetDebugger().GetListener(), "", &filespec));
|
2013-03-25 22:40:51 +00:00
|
|
|
if (process_sp) {
|
2018-06-11 21:19:26 +00:00
|
|
|
error.SetError(process_sp->LoadCore());
|
|
|
|
|
if (error.Success())
|
|
|
|
|
sb_process.SetSP(process_sp);
|
|
|
|
|
} else {
|
|
|
|
|
error.SetErrorString("Failed to create the process");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2018-06-11 21:19:26 +00:00
|
|
|
} else {
|
|
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-10-22 07:22:56 +00:00
|
|
|
|
|
|
|
|
SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
|
2011-03-31 00:01:24 +00:00
|
|
|
const char *working_directory) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
|
|
|
|
|
(const char **, const char **, const char *), argv, envp,
|
|
|
|
|
working_directory);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
char *stdin_path = nullptr;
|
|
|
|
|
char *stdout_path = nullptr;
|
|
|
|
|
char *stderr_path = nullptr;
|
2011-03-31 00:01:24 +00:00
|
|
|
uint32_t launch_flags = 0;
|
|
|
|
|
bool stop_at_entry = false;
|
2014-10-22 07:22:56 +00:00
|
|
|
SBError error;
|
2011-03-31 00:01:24 +00:00
|
|
|
SBListener listener = GetDebugger().GetListener();
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
|
|
|
|
|
stdout_path, stderr_path, working_directory,
|
|
|
|
|
launch_flags, stop_at_entry, error));
|
2014-10-22 07:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
SBError SBTarget::Install() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install);
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
SBError sb_error;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
sb_error.ref() = target_sp->Install(nullptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2010-06-23 01:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-25 22:40:51 +00:00
|
|
|
SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
|
|
|
|
|
char const **envp, const char *stdin_path,
|
2013-03-02 00:26:47 +00:00
|
|
|
const char *stdout_path, const char *stderr_path,
|
2013-03-25 22:40:51 +00:00
|
|
|
const char *working_directory,
|
|
|
|
|
uint32_t launch_flags, // See LaunchFlags
|
|
|
|
|
bool stop_at_entry, lldb::SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
|
|
|
|
|
(lldb::SBListener &, const char **, const char **,
|
|
|
|
|
const char *, const char *, const char *, const char *,
|
|
|
|
|
uint32_t, bool, lldb::SBError &),
|
|
|
|
|
listener, argv, envp, stdin_path, stdout_path, stderr_path,
|
|
|
|
|
working_directory, launch_flags, stop_at_entry, error);
|
|
|
|
|
|
2013-03-25 22:40:51 +00:00
|
|
|
SBProcess sb_process;
|
2012-01-30 07:41:31 +00:00
|
|
|
ProcessSP process_sp;
|
2013-03-25 22:40:51 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-03-25 22:40:51 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-02 18:50:01 +00:00
|
|
|
if (stop_at_entry)
|
|
|
|
|
launch_flags |= eLaunchFlagStopAtEntry;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-01-27 01:01:10 +00:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
|
|
|
|
|
launch_flags |= eLaunchFlagDisableASLR;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-04-30 01:09:13 +00:00
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 09:04:36 +00:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 07:41:31 +00:00
|
|
|
if (process_sp) {
|
|
|
|
|
state = process_sp->GetState();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected) {
|
2011-04-30 01:09:13 +00:00
|
|
|
if (state == eStateAttaching)
|
|
|
|
|
error.SetErrorString("process attach is in progress");
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2011-04-30 01:09:13 +00:00
|
|
|
error.SetErrorString("a process is already being debugged");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-30 01:09:13 +00:00
|
|
|
if (state == eStateConnected) {
|
|
|
|
|
// If we are already connected, then we have already specified the
|
2018-04-30 16:49:04 +00:00
|
|
|
// listener, so if a valid listener is supplied, we need to error out to
|
|
|
|
|
// let the client know.
|
2013-03-25 22:40:51 +00:00
|
|
|
if (listener.IsValid()) {
|
|
|
|
|
error.SetErrorString("process is connected and already has a listener, "
|
2011-04-30 01:09:13 +00:00
|
|
|
"pass empty listener");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-25 22:40:51 +00:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
|
2013-12-13 17:20:18 +00:00
|
|
|
launch_flags |= eLaunchFlagDisableSTDIO;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-11-01 21:05:36 +00:00
|
|
|
ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
|
|
|
|
|
FileSpec(stderr_path),
|
|
|
|
|
FileSpec(working_directory), launch_flags);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
|
|
|
|
if (exe_module)
|
2013-03-25 22:40:51 +00:00
|
|
|
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
|
|
|
|
|
if (argv)
|
|
|
|
|
launch_info.GetArguments().AppendArguments(argv);
|
2013-12-13 17:20:18 +00:00
|
|
|
if (envp)
|
Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.
This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
Instead of trying to maintain a constantly up-to-date envp view, it
provides a function which creates a envp view on demand, with the
expectation that this will be called as the very last thing before
handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
into "KEY=VALUE" representation.
With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.
(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)
Reviewers: zturner, davide, jingham, clayborg
Subscribers: emaste, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D41359
llvm-svn: 322174
2018-01-10 11:57:31 +00:00
|
|
|
launch_info.GetEnvironment() = Environment(envp);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-04-30 01:09:13 +00:00
|
|
|
if (listener.IsValid())
|
2013-03-25 22:40:51 +00:00
|
|
|
launch_info.SetListener(listener.GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
error.SetError(target_sp->Launch(launch_info, nullptr));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2010-10-06 22:10:17 +00:00
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
|
|
|
|
|
(lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info,
|
|
|
|
|
error);
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
SBProcess sb_process;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
if (target_sp) {
|
2013-03-25 22:40:51 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2011-04-30 01:09:13 +00:00
|
|
|
StateType state = eStateInvalid;
|
2016-09-06 20:57:50 +00:00
|
|
|
{
|
2013-03-25 22:40:51 +00:00
|
|
|
ProcessSP process_sp = target_sp->GetProcessSP();
|
|
|
|
|
if (process_sp) {
|
|
|
|
|
state = process_sp->GetState();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-03-25 22:40:51 +00:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected) {
|
2011-04-30 01:09:13 +00:00
|
|
|
if (state == eStateAttaching)
|
2013-03-25 22:40:51 +00:00
|
|
|
error.SetErrorString("process attach is in progress");
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2011-04-30 01:09:13 +00:00
|
|
|
error.SetErrorString("a process is already being debugged");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2013-03-25 22:40:51 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-03-25 22:40:51 +00:00
|
|
|
}
|
2012-01-30 09:04:36 +00:00
|
|
|
|
Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.
This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
Instead of trying to maintain a constantly up-to-date envp view, it
provides a function which creates a envp view on demand, with the
expectation that this will be called as the very last thing before
handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
into "KEY=VALUE" representation.
With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.
(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)
Reviewers: zturner, davide, jingham, clayborg
Subscribers: emaste, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D41359
llvm-svn: 322174
2018-01-10 11:57:31 +00:00
|
|
|
lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
|
2012-01-30 09:04:36 +00:00
|
|
|
|
|
|
|
|
if (!launch_info.GetExecutableFile()) {
|
2016-05-19 05:13:57 +00:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
2011-01-27 01:01:10 +00:00
|
|
|
if (exe_module)
|
|
|
|
|
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
|
2014-04-04 04:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-30 01:09:13 +00:00
|
|
|
const ArchSpec &arch_spec = target_sp->GetArchitecture();
|
|
|
|
|
if (arch_spec.IsValid())
|
|
|
|
|
launch_info.GetArchitecture() = arch_spec;
|
2011-01-27 01:01:10 +00:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
error.SetError(target_sp->Launch(launch_info, nullptr));
|
Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.
This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
Instead of trying to maintain a constantly up-to-date envp view, it
provides a function which creates a envp view on demand, with the
expectation that this will be called as the very last thing before
handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
into "KEY=VALUE" representation.
With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.
(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)
Reviewers: zturner, davide, jingham, clayborg
Subscribers: emaste, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D41359
llvm-svn: 322174
2018-01-10 11:57:31 +00:00
|
|
|
sb_launch_info.set_ref(launch_info);
|
2013-12-13 17:20:18 +00:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2013-12-13 17:20:18 +00:00
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-01-27 01:01:10 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-12-13 17:20:18 +00:00
|
|
|
|
2014-11-17 19:39:20 +00:00
|
|
|
lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach,
|
|
|
|
|
(lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info,
|
|
|
|
|
error);
|
|
|
|
|
|
2014-11-17 19:39:20 +00:00
|
|
|
SBProcess sb_process;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
2013-12-13 17:20:18 +00:00
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
if (target_sp) {
|
2013-12-13 17:20:18 +00:00
|
|
|
ProcessAttachInfo &attach_info = sb_attach_info.ref();
|
|
|
|
|
if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
|
|
|
|
|
PlatformSP platform_sp = target_sp->GetPlatform();
|
2010-10-06 22:10:17 +00:00
|
|
|
// See if we can pre-verify if a process exists or not
|
|
|
|
|
if (platform_sp && platform_sp->IsConnected()) {
|
|
|
|
|
lldb::pid_t attach_pid = attach_info.GetProcessID();
|
2015-02-10 22:49:57 +00:00
|
|
|
ProcessInstanceInfo instance_info;
|
|
|
|
|
if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
|
|
|
|
|
attach_info.SetUserID(instance_info.GetEffectiveUserID());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2010-10-06 22:10:17 +00:00
|
|
|
error.ref().SetErrorStringWithFormat(
|
2015-02-10 22:49:57 +00:00
|
|
|
"no process found with process ID %" PRIu64, attach_pid);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-06 22:10:17 +00:00
|
|
|
}
|
2015-02-10 22:49:57 +00:00
|
|
|
error.SetError(AttachToProcess(attach_info, *target_sp));
|
|
|
|
|
if (error.Success())
|
2013-12-13 17:20:18 +00:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-02-24 05:03:03 +00:00
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2010-10-06 22:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-02 02:10:57 +00:00
|
|
|
lldb::SBProcess SBTarget::AttachToProcessWithID(
|
|
|
|
|
SBListener &listener,
|
2010-10-06 22:10:17 +00:00
|
|
|
lldb::pid_t pid, // The process ID to attach to
|
2012-02-24 05:03:03 +00:00
|
|
|
SBError &error // An error explaining what went wrong if attach fails
|
2019-03-06 00:06:00 +00:00
|
|
|
) {
|
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
|
|
|
|
|
(lldb::SBListener &, lldb::pid_t, lldb::SBError &),
|
|
|
|
|
listener, pid, error);
|
|
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
SBProcess sb_process;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
if (target_sp) {
|
2012-02-24 05:03:03 +00:00
|
|
|
ProcessAttachInfo attach_info;
|
2015-02-10 22:49:57 +00:00
|
|
|
attach_info.SetProcessID(pid);
|
2013-12-13 17:20:18 +00:00
|
|
|
if (listener.IsValid())
|
2012-02-24 05:03:03 +00:00
|
|
|
attach_info.SetListener(listener.GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
ProcessInstanceInfo instance_info;
|
2015-02-10 22:49:57 +00:00
|
|
|
if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
|
|
|
|
|
attach_info.SetUserID(instance_info.GetEffectiveUserID());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
error.SetError(AttachToProcess(attach_info, *target_sp));
|
|
|
|
|
if (error.Success())
|
2012-02-24 05:03:03 +00:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
|
|
|
|
} else
|
|
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-07 04:19:01 +00:00
|
|
|
lldb::SBProcess SBTarget::AttachToProcessWithName(
|
2011-12-02 02:10:57 +00:00
|
|
|
SBListener &listener,
|
2014-05-07 20:16:06 +00:00
|
|
|
const char *name, // basename of process to attach to
|
2010-10-06 22:10:17 +00:00
|
|
|
bool wait_for, // if true wait for a new instance of "name" to be launched
|
|
|
|
|
SBError &error // An error explaining what went wrong if attach fails
|
2019-03-06 00:06:00 +00:00
|
|
|
) {
|
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName,
|
|
|
|
|
(lldb::SBListener &, const char *, bool, lldb::SBError &),
|
|
|
|
|
listener, name, wait_for, error);
|
|
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
SBProcess sb_process;
|
2014-05-07 20:16:06 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
if (name && target_sp) {
|
2014-05-07 20:16:06 +00:00
|
|
|
ProcessAttachInfo attach_info;
|
2018-11-01 21:05:36 +00:00
|
|
|
attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
|
2015-02-10 22:49:57 +00:00
|
|
|
attach_info.SetWaitForLaunch(wait_for);
|
|
|
|
|
if (listener.IsValid())
|
|
|
|
|
attach_info.SetListener(listener.GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-05-07 20:16:06 +00:00
|
|
|
error.SetError(AttachToProcess(attach_info, *target_sp));
|
2015-02-10 22:49:57 +00:00
|
|
|
if (error.Success())
|
2014-05-07 20:16:06 +00:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
|
|
|
|
} else
|
|
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2014-05-07 20:16:06 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-03-02 00:26:47 +00:00
|
|
|
lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
|
2011-03-04 00:31:13 +00:00
|
|
|
const char *plugin_name,
|
2012-06-04 23:19:54 +00:00
|
|
|
SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBProcess, SBTarget, ConnectRemote,
|
|
|
|
|
(lldb::SBListener &, const char *, const char *, lldb::SBError &),
|
|
|
|
|
listener, url, plugin_name, error);
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
SBProcess sb_process;
|
2012-01-30 07:41:31 +00:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2015-02-10 22:49:57 +00:00
|
|
|
if (listener.IsValid())
|
2016-03-07 21:50:25 +00:00
|
|
|
process_sp =
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2016-03-07 21:50:25 +00:00
|
|
|
process_sp = target_sp->CreateProcess(
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
|
2012-02-24 20:59:25 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
if (process_sp) {
|
2013-12-13 17:20:18 +00:00
|
|
|
sb_process.SetSP(process_sp);
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
error.SetError(process_sp->ConnectRemote(nullptr, url));
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2013-12-13 17:20:18 +00:00
|
|
|
error.SetErrorString("unable to create lldb_private::Process");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2013-12-13 17:20:18 +00:00
|
|
|
error.SetErrorString("SBTarget is invalid");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-02-24 20:59:25 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_process);
|
2014-05-07 20:16:06 +00:00
|
|
|
}
|
2013-12-13 17:20:18 +00:00
|
|
|
|
|
|
|
|
SBFileSpec SBTarget::GetExecutable() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable);
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2014-11-17 19:39:20 +00:00
|
|
|
SBFileSpec exe_file_spec;
|
2013-12-13 17:20:18 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-02-24 05:03:03 +00:00
|
|
|
if (target_sp) {
|
|
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
|
|
|
|
if (exe_module)
|
|
|
|
|
exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
|
|
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(exe_file_spec);
|
2012-02-24 05:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTarget::operator==(const SBTarget &rhs) const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
bool SBTarget::operator!=(const SBTarget &rhs) const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
|
|
|
|
lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
|
|
|
|
|
m_opaque_sp = target_sp;
|
2012-02-24 05:03:03 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-10-20 00:21:31 +00:00
|
|
|
lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
|
|
|
|
|
(lldb::addr_t), vm_addr);
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
lldb::SBAddress sb_addr;
|
2012-10-20 00:21:31 +00:00
|
|
|
Address &addr = sb_addr.ref();
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-10-20 00:21:31 +00:00
|
|
|
if (target_sp) {
|
2014-04-04 04:06:10 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2015-02-10 22:49:57 +00:00
|
|
|
if (target_sp->ResolveLoadAddress(vm_addr, addr))
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-02-24 05:03:03 +00:00
|
|
|
// We have a load address that isn't in a section, just return an address
|
2011-07-22 16:46:35 +00:00
|
|
|
// with the offset filled in (the address) and the section set to NULL
|
2012-02-24 01:59:29 +00:00
|
|
|
addr.SetRawAddress(vm_addr);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2012-02-24 05:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
|
|
|
|
|
(lldb::addr_t), file_addr);
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
|
Address &addr = sb_addr.ref();
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2014-10-22 07:22:56 +00:00
|
|
|
if (target_sp->ResolveFileAddress(file_addr, addr))
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-02-24 05:03:03 +00:00
|
|
|
|
2011-12-02 02:10:57 +00:00
|
|
|
addr.SetRawAddress(file_addr);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2011-12-02 02:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
|
|
|
|
|
lldb::addr_t vm_addr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
|
|
|
|
|
(uint32_t, lldb::addr_t), stop_id, vm_addr);
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
lldb::SBAddress sb_addr;
|
2011-12-02 02:10:57 +00:00
|
|
|
Address &addr = sb_addr.ref();
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2011-12-02 02:10:57 +00:00
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
if (target_sp->ResolveLoadAddress(vm_addr, addr))
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
// We have a load address that isn't in a section, just return an address
|
2011-12-02 02:10:57 +00:00
|
|
|
// with the offset filled in (the address) and the section set to NULL
|
2012-02-24 01:59:29 +00:00
|
|
|
addr.SetRawAddress(vm_addr);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-10-06 22:10:17 +00:00
|
|
|
|
|
|
|
|
SBSymbolContext
|
2010-10-07 04:19:01 +00:00
|
|
|
SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
|
2010-10-06 22:10:17 +00:00
|
|
|
uint32_t resolve_scope) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget,
|
|
|
|
|
ResolveSymbolContextForAddress,
|
|
|
|
|
(const lldb::SBAddress &, uint32_t), addr, resolve_scope);
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
SBSymbolContext sc;
|
2018-10-25 20:45:19 +00:00
|
|
|
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
|
2013-03-27 23:08:40 +00:00
|
|
|
if (addr.IsValid()) {
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
2018-10-25 20:45:19 +00:00
|
|
|
target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
|
|
|
|
|
sc.ref());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sc);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-10-20 00:21:31 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
|
|
|
|
|
lldb::SBError &error) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory,
|
|
|
|
|
(const lldb::SBAddress, void *, size_t, lldb::SBError &),
|
|
|
|
|
addr, buf, size, error);
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
SBError sb_error;
|
|
|
|
|
size_t bytes_read = 0;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2015-02-10 22:49:57 +00:00
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2014-10-22 07:22:56 +00:00
|
|
|
bytes_read =
|
Fixed SBTarget::ReadMemory() to work correctly and the TestTargetAPI.py test case that was reading target memory in TargetAPITestCase.test_read_memory_with_dsym and TargetAPITestCase.test_read_memory_with_dwarf.
The problem was that SBTarget::ReadMemory() was making a new section offset lldb_private::Address by doing:
size_t
SBTarget::ReadMemory (const SBAddress addr,
void *buf,
size_t size,
lldb::SBError &error)
{
...
lldb_private::Address addr_priv(addr.GetFileAddress(), NULL);
bytes_read = target_sp->ReadMemory(addr_priv, false, buf, size, err_priv);
This is wrong. If you get the file addresss from the "addr" argument and try to read memory using that, it will think the file address is a load address and it will try to resolve it accordingly. This will work fine if your executable is loaded at the same address (no slide), but it won't work if there is a slide.
The fix is to just pass along the "addr.ref()" instead of making a new addr_priv as this will pass along the lldb_private::Address that is inside the SBAddress (which is what we want), and not always change it into something that becomes a load address (if we are running), or abmigious file address (think address zero when you have 150 shared libraries that have sections that start at zero, which one would you pick). The main reason for passing a section offset address to SBTarget::ReadMemory() is so you _can_ read from the actual section + offset that is specified in the SBAddress.
llvm-svn: 221213
2014-11-04 00:56:30 +00:00
|
|
|
target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
|
2015-02-10 22:49:57 +00:00
|
|
|
} else {
|
|
|
|
|
sb_error.SetErrorString("invalid target");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
return bytes_read;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
|
|
|
|
|
uint32_t line) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
|
|
|
|
|
(const char *, uint32_t), file, line);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint
|
2015-02-10 22:49:57 +00:00
|
|
|
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
|
|
|
|
|
uint32_t line) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint
|
2013-10-11 19:48:25 +00:00
|
|
|
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
|
2013-12-06 01:12:00 +00:00
|
|
|
uint32_t line, lldb::addr_t offset) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, lldb::addr_t),
|
|
|
|
|
sb_file_spec, line, offset);
|
|
|
|
|
|
2016-09-20 22:54:49 +00:00
|
|
|
SBFileSpecList empty_list;
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
|
2016-09-20 22:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
|
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
|
|
|
|
|
uint32_t line, lldb::addr_t offset,
|
|
|
|
|
SBFileSpecList &sb_module_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
|
|
|
|
|
lldb::SBFileSpecList &),
|
|
|
|
|
sb_file_spec, line, offset, sb_module_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
|
|
|
|
|
offset, sb_module_list));
|
2018-08-30 15:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBBreakpoint SBTarget::BreakpointCreateByLocation(
|
|
|
|
|
const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
|
|
|
|
|
lldb::addr_t offset, SBFileSpecList &sb_module_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t,
|
|
|
|
|
lldb::addr_t, lldb::SBFileSpecList &),
|
|
|
|
|
sb_file_spec, line, column, offset, sb_module_list);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp && line != 0) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
const LazyBool check_inlines = eLazyBoolCalculate;
|
2012-05-22 00:12:20 +00:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
const bool internal = false;
|
2013-10-11 19:48:25 +00:00
|
|
|
const bool hardware = false;
|
2015-05-18 13:41:01 +00:00
|
|
|
const LazyBool move_to_nearest_code = eLazyBoolCalculate;
|
2016-09-20 22:54:49 +00:00
|
|
|
const FileSpecList *module_list = nullptr;
|
|
|
|
|
if (sb_module_list.GetSize() > 0) {
|
|
|
|
|
module_list = sb_module_list.get();
|
|
|
|
|
}
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(
|
2018-08-30 15:11:00 +00:00
|
|
|
module_list, *sb_file_spec, line, column, offset, check_inlines,
|
|
|
|
|
skip_prologue, internal, hardware, move_to_nearest_code);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
|
|
|
|
|
const char *module_name) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, const char *), symbol_name, module_name);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp.get()) {
|
2010-10-06 22:10:17 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
const bool internal = false;
|
2013-10-11 19:48:25 +00:00
|
|
|
const bool hardware = false;
|
2010-10-06 22:10:17 +00:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2016-03-09 18:59:13 +00:00
|
|
|
const lldb::addr_t offset = 0;
|
2010-06-08 16:52:24 +00:00
|
|
|
if (module_name && module_name[0]) {
|
2011-09-21 01:17:13 +00:00
|
|
|
FileSpecList module_spec_list;
|
2018-11-01 21:05:36 +00:00
|
|
|
module_spec_list.Append(FileSpec(module_name));
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
&module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto,
|
2016-03-09 18:59:13 +00:00
|
|
|
eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
|
2010-10-06 22:10:17 +00:00
|
|
|
} else {
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
|
|
|
|
|
eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
lldb::SBBreakpoint
|
2010-10-07 04:19:01 +00:00
|
|
|
SBTarget::BreakpointCreateByName(const char *symbol_name,
|
2011-02-03 21:28:34 +00:00
|
|
|
const SBFileSpecList &module_list,
|
2013-10-11 19:48:25 +00:00
|
|
|
const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_name, module_list, comp_unit_list);
|
|
|
|
|
|
2018-10-25 20:45:40 +00:00
|
|
|
lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
|
|
|
|
|
module_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 01:44:54 +00:00
|
|
|
const char *symbol_name, uint32_t name_type_mask,
|
2013-10-11 19:48:25 +00:00
|
|
|
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, uint32_t, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_name, name_type_mask, module_list, comp_unit_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
|
|
|
|
|
module_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
|
2011-02-03 21:28:34 +00:00
|
|
|
const char *symbol_name, uint32_t name_type_mask,
|
2016-03-09 18:59:13 +00:00
|
|
|
LanguageType symbol_language, const SBFileSpecList &module_list,
|
2013-10-11 19:48:25 +00:00
|
|
|
const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, uint32_t, lldb::LanguageType,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_name, name_type_mask, symbol_language, module_list,
|
|
|
|
|
comp_unit_list);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2010-10-06 22:10:17 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp && symbol_name && symbol_name[0]) {
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
const bool internal = false;
|
2010-10-06 22:10:17 +00:00
|
|
|
const bool hardware = false;
|
2012-05-22 00:12:20 +00:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2010-10-06 22:10:17 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2018-10-25 20:45:40 +00:00
|
|
|
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
|
|
|
|
|
sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(),
|
|
|
|
|
symbol_name, mask, symbol_language, 0,
|
|
|
|
|
skip_prologue, internal, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
|
2010-10-06 22:10:17 +00:00
|
|
|
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
|
|
|
|
|
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_names, num_names, name_type_mask, module_list, comp_unit_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateByNames(
|
|
|
|
|
symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
|
|
|
|
|
module_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
|
|
|
|
|
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
|
|
|
|
|
LanguageType symbol_language, const SBFileSpecList &module_list,
|
|
|
|
|
const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t, lldb::LanguageType,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_names, num_names, name_type_mask, symbol_language,
|
|
|
|
|
module_list, comp_unit_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateByNames(
|
|
|
|
|
symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
|
|
|
|
|
module_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
|
|
|
|
|
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
|
2016-03-09 18:59:13 +00:00
|
|
|
LanguageType symbol_language, lldb::addr_t offset,
|
2010-10-06 22:10:17 +00:00
|
|
|
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t, lldb::LanguageType,
|
|
|
|
|
lldb::addr_t, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_names, num_names, name_type_mask, symbol_language,
|
|
|
|
|
offset, module_list, comp_unit_list);
|
|
|
|
|
|
2010-10-06 22:10:17 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-03-06 00:37:27 +00:00
|
|
|
if (target_sp && num_names > 0) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
const bool internal = false;
|
2013-10-11 19:48:25 +00:00
|
|
|
const bool hardware = false;
|
2018-10-25 20:45:40 +00:00
|
|
|
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
|
2012-05-22 00:12:20 +00:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(
|
2018-10-25 20:45:40 +00:00
|
|
|
module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask,
|
|
|
|
|
symbol_language, offset, skip_prologue, internal, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
|
|
|
|
|
const char *module_name) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, const char *), symbol_name_regex,
|
|
|
|
|
module_name);
|
|
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
SBFileSpecList module_spec_list;
|
|
|
|
|
SBFileSpecList comp_unit_list;
|
2010-06-08 16:52:24 +00:00
|
|
|
if (module_name && module_name[0]) {
|
2018-11-01 21:05:36 +00:00
|
|
|
module_spec_list.Append(FileSpec(module_name));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
|
|
|
|
|
module_spec_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
lldb::SBBreakpoint
|
2013-10-11 19:48:25 +00:00
|
|
|
SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
|
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
|
const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_name_regex, module_list, comp_unit_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateByRegex(
|
|
|
|
|
symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
|
2016-03-09 18:59:13 +00:00
|
|
|
const char *symbol_name_regex, LanguageType symbol_language,
|
2013-10-11 19:48:25 +00:00
|
|
|
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, lldb::LanguageType, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
symbol_name_regex, symbol_language, module_list, comp_unit_list);
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2016-09-21 16:01:28 +00:00
|
|
|
RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
|
2012-05-22 00:12:20 +00:00
|
|
|
const bool internal = false;
|
2013-10-11 19:48:25 +00:00
|
|
|
const bool hardware = false;
|
2012-05-22 00:12:20 +00:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateFuncRegexBreakpoint(
|
2019-09-04 09:47:18 +00:00
|
|
|
module_list.get(), comp_unit_list.get(), std::move(regexp),
|
|
|
|
|
symbol_language, skip_prologue, internal, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress,
|
|
|
|
|
(lldb::addr_t), address);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-10-22 07:22:56 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2013-10-11 19:48:25 +00:00
|
|
|
const bool hardware = false;
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 03:39:13 +00:00
|
|
|
SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress,
|
|
|
|
|
(lldb::SBAddress &), sb_address);
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2015-11-17 03:39:13 +00:00
|
|
|
if (!sb_address.IsValid()) {
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
if (target_sp) {
|
2015-02-10 22:49:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2010-10-06 22:10:17 +00:00
|
|
|
const bool hardware = false;
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-04 00:31:13 +00:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
|
SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
|
|
|
|
|
const lldb::SBFileSpec &source_file,
|
|
|
|
|
const char *module_name) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpec &, const char *),
|
|
|
|
|
source_regex, source_file, module_name);
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
SBFileSpecList module_spec_list;
|
2014-04-04 04:06:10 +00:00
|
|
|
|
|
|
|
|
if (module_name && module_name[0]) {
|
2018-11-01 21:05:36 +00:00
|
|
|
module_spec_list.Append(FileSpec(module_name));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
SBFileSpecList source_file_list;
|
2011-03-04 00:31:13 +00:00
|
|
|
if (source_file.IsValid()) {
|
2016-03-07 21:50:25 +00:00
|
|
|
source_file_list.Append(source_file);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
|
|
|
|
|
source_regex, module_spec_list, source_file_list));
|
2011-03-04 00:31:13 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-10-20 00:21:31 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
|
|
|
|
|
const char *source_regex, const SBFileSpecList &module_list,
|
2014-04-04 04:06:10 +00:00
|
|
|
const lldb::SBFileSpecList &source_file_list) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &),
|
|
|
|
|
source_regex, module_list, source_file_list);
|
|
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
|
|
|
|
|
source_regex, module_list, source_file_list, SBStringList()));
|
2011-03-04 00:31:13 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
|
2015-11-06 22:48:59 +00:00
|
|
|
const char *source_regex, const SBFileSpecList &module_list,
|
2010-06-08 16:52:24 +00:00
|
|
|
const lldb::SBFileSpecList &source_file_list,
|
|
|
|
|
const SBStringList &func_names) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &, const lldb::SBStringList &),
|
|
|
|
|
source_regex, module_list, source_file_list, func_names);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp && source_regex && source_regex[0]) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
const bool hardware = false;
|
|
|
|
|
const LazyBool move_to_nearest_code = eLazyBoolCalculate;
|
2016-09-21 16:01:28 +00:00
|
|
|
RegularExpression regexp((llvm::StringRef(source_regex)));
|
2012-01-30 09:04:36 +00:00
|
|
|
std::unordered_set<std::string> func_names_set;
|
2011-08-11 02:48:45 +00:00
|
|
|
for (size_t i = 0; i < func_names.GetSize(); i++) {
|
|
|
|
|
func_names_set.insert(func_names.GetStringAtIndex(i));
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateSourceRegexBreakpoint(
|
2019-09-04 09:47:18 +00:00
|
|
|
module_list.get(), source_file_list.get(), func_names_set,
|
|
|
|
|
std::move(regexp), false, hardware, move_to_nearest_code);
|
2010-10-26 03:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBBreakpoint
|
2012-03-06 00:37:27 +00:00
|
|
|
SBTarget::BreakpointCreateForException(lldb::LanguageType language,
|
2010-06-08 16:52:24 +00:00
|
|
|
bool catch_bp, bool throw_bp) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException,
|
|
|
|
|
(lldb::LanguageType, bool, bool), language, catch_bp,
|
|
|
|
|
throw_bp);
|
|
|
|
|
|
2012-03-06 00:37:27 +00:00
|
|
|
SBBreakpoint sb_bp;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
2010-06-08 16:52:24 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2010-06-08 16:52:24 +00:00
|
|
|
const bool hardware = false;
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
|
2015-11-06 22:48:59 +00:00
|
|
|
hardware);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript(
|
|
|
|
|
const char *class_name, SBStructuredData &extra_args,
|
|
|
|
|
const SBFileSpecList &module_list, const SBFileSpecList &file_list,
|
|
|
|
|
bool request_hardware) {
|
|
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
|
|
|
|
|
(const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &, bool),
|
|
|
|
|
class_name, extra_args, module_list, file_list, request_hardware);
|
|
|
|
|
|
2018-09-13 21:35:32 +00:00
|
|
|
SBBreakpoint sb_bp;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
Status error;
|
2019-03-07 22:47:13 +00:00
|
|
|
|
2018-09-13 21:35:32 +00:00
|
|
|
StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
|
|
|
|
|
sb_bp =
|
|
|
|
|
target_sp->CreateScriptedBreakpoint(class_name,
|
|
|
|
|
module_list.get(),
|
|
|
|
|
file_list.get(),
|
|
|
|
|
false, /* internal */
|
|
|
|
|
request_hardware,
|
|
|
|
|
obj_sp,
|
|
|
|
|
&error);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp);
|
2018-09-13 21:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
uint32_t SBTarget::GetNumBreakpoints() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2012-01-30 09:04:36 +00:00
|
|
|
return target_sp->GetBreakpointList().GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex,
|
|
|
|
|
(uint32_t), idx);
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
SBBreakpoint sb_breakpoint;
|
2010-06-23 01:19:29 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2011-09-26 22:40:50 +00:00
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_breakpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
bool SBTarget::BreakpointDelete(break_id_t bp_id) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t),
|
|
|
|
|
bp_id);
|
|
|
|
|
|
2010-06-23 01:19:29 +00:00
|
|
|
bool result = false;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2010-06-23 01:19:29 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2012-01-30 09:04:36 +00:00
|
|
|
result = target_sp->RemoveBreakpointByID(bp_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
return result;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
|
|
|
|
|
(lldb::break_id_t), bp_id);
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
SBBreakpoint sb_breakpoint;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2010-06-23 01:19:29 +00:00
|
|
|
if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2017-02-27 11:05:34 +00:00
|
|
|
sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_breakpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-21 01:21:19 +00:00
|
|
|
bool SBTarget::FindBreakpointsByName(const char *name,
|
|
|
|
|
SBBreakpointList &bkpts) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName,
|
|
|
|
|
(const char *, lldb::SBBreakpointList &), name, bkpts);
|
|
|
|
|
|
2016-09-21 01:21:19 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
BreakpointList bkpt_list(false);
|
|
|
|
|
bool is_valid =
|
|
|
|
|
target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
|
|
|
|
|
if (!is_valid)
|
|
|
|
|
return false;
|
|
|
|
|
for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
|
|
|
|
|
bkpts.AppendByID(bkpt_sp->GetID());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
void SBTarget::GetBreakpointNames(SBStringList &names) {
|
|
|
|
|
LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &),
|
|
|
|
|
names);
|
|
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
names.Clear();
|
|
|
|
|
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> name_vec;
|
|
|
|
|
target_sp->GetBreakpointNames(name_vec);
|
|
|
|
|
for (auto name : name_vec)
|
|
|
|
|
names.AppendString(name.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
void SBTarget::DeleteBreakpointName(const char *name) {
|
|
|
|
|
LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
|
|
|
|
|
name);
|
|
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
target_sp->DeleteBreakpointName(ConstString(name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
bool SBTarget::EnableAllBreakpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2017-09-14 20:22:49 +00:00
|
|
|
target_sp->EnableAllowedBreakpoints();
|
2010-06-23 01:19:29 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return false;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
bool SBTarget::DisableAllBreakpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints);
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2011-10-01 02:59:24 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2017-09-14 20:22:49 +00:00
|
|
|
target_sp->DisableAllowedBreakpoints();
|
2011-10-01 02:59:24 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return false;
|
2011-10-01 02:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
bool SBTarget::DeleteAllBreakpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints);
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2017-09-14 20:22:49 +00:00
|
|
|
target_sp->RemoveAllowedBreakpoints();
|
2011-09-26 22:40:50 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-01-30 07:41:31 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
|
|
|
|
|
SBBreakpointList &new_bps) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBBreakpointList &),
|
|
|
|
|
source_file, new_bps);
|
|
|
|
|
|
2016-09-22 22:20:28 +00:00
|
|
|
SBStringList empty_name_list;
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
|
2016-09-22 22:20:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
|
|
|
|
|
SBStringList &matching_names,
|
|
|
|
|
SBBreakpointList &new_bps) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
|
lldb::SBError, SBTarget, BreakpointsCreateFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &),
|
|
|
|
|
source_file, matching_names, new_bps);
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
SBError sberr;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp) {
|
|
|
|
|
sberr.SetErrorString(
|
|
|
|
|
"BreakpointCreateFromFile called with invalid target.");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
|
|
|
|
|
BreakpointIDList bp_ids;
|
2016-09-22 22:20:28 +00:00
|
|
|
|
|
|
|
|
std::vector<std::string> name_vector;
|
|
|
|
|
size_t num_names = matching_names.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_names; i++)
|
|
|
|
|
name_vector.push_back(matching_names.GetStringAtIndex(i));
|
|
|
|
|
|
|
|
|
|
sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
|
|
|
|
|
name_vector, bp_ids);
|
2016-09-14 19:07:35 +00:00
|
|
|
if (sberr.Fail())
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
|
|
|
|
|
size_t num_bkpts = bp_ids.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_bkpts; i++) {
|
|
|
|
|
BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
|
|
|
|
|
new_bps.AppendByID(bp_id.GetBreakpointID());
|
|
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
|
|
|
|
|
(lldb::SBFileSpec &), dest_file);
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
SBError sberr;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp) {
|
|
|
|
|
sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
SBBreakpointList bkpt_list(*this);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
|
2016-09-22 23:42:42 +00:00
|
|
|
SBBreakpointList &bkpt_list,
|
|
|
|
|
bool append) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBBreakpointList &, bool),
|
|
|
|
|
dest_file, bkpt_list, append);
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
SBError sberr;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp) {
|
|
|
|
|
sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
BreakpointIDList bp_id_list;
|
|
|
|
|
bkpt_list.CopyToBreakpointIDList(bp_id_list);
|
2016-09-22 23:42:42 +00:00
|
|
|
sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
|
|
|
|
|
bp_id_list, append);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sberr);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
uint32_t SBTarget::GetNumWatchpoints() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints);
|
|
|
|
|
|
2015-11-17 03:39:13 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2011-10-14 00:42:25 +00:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-01-30 09:04:36 +00:00
|
|
|
return target_sp->GetWatchpointList().GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 18:08:26 +00:00
|
|
|
SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex,
|
|
|
|
|
(uint32_t), idx);
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2015-11-17 03:39:13 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2011-10-14 00:42:25 +00:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-02-04 02:27:34 +00:00
|
|
|
sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_watchpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 18:08:26 +00:00
|
|
|
bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t),
|
|
|
|
|
wp_id);
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
bool result = false;
|
2015-11-17 03:39:13 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(lock);
|
2012-01-30 09:04:36 +00:00
|
|
|
result = target_sp->RemoveWatchpointByID(wp_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 22:40:50 +00:00
|
|
|
return result;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 18:08:26 +00:00
|
|
|
SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
|
|
|
|
|
(lldb::watch_id_t), wp_id);
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-01-30 07:41:31 +00:00
|
|
|
lldb::WatchpointSP watchpoint_sp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2010-06-08 16:52:24 +00:00
|
|
|
if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2010-06-23 01:19:29 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2016-05-19 05:13:57 +00:00
|
|
|
target_sp->GetWatchpointList().GetListMutex(lock);
|
2010-06-23 01:19:29 +00:00
|
|
|
watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
|
2012-02-04 02:27:34 +00:00
|
|
|
sb_watchpoint.SetSP(watchpoint_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_watchpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-04 23:19:54 +00:00
|
|
|
lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
|
|
|
|
|
bool read, bool write,
|
|
|
|
|
SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
|
|
|
|
|
(lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
|
|
|
|
|
size, read, write, error);
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2010-06-23 01:19:29 +00:00
|
|
|
lldb::WatchpointSP watchpoint_sp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-02-04 02:27:34 +00:00
|
|
|
if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
|
|
|
|
|
size > 0) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2012-02-04 02:27:34 +00:00
|
|
|
uint32_t watch_type = 0;
|
|
|
|
|
if (read)
|
|
|
|
|
watch_type |= LLDB_WATCH_TYPE_READ;
|
|
|
|
|
if (write)
|
|
|
|
|
watch_type |= LLDB_WATCH_TYPE_WRITE;
|
2013-06-18 21:52:48 +00:00
|
|
|
if (watch_type == 0) {
|
|
|
|
|
error.SetErrorString(
|
|
|
|
|
"Can't create a watchpoint that is neither read nor write.");
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_watchpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-31 22:56:36 +00:00
|
|
|
// Target::CreateWatchpoint() is thread safe.
|
2017-05-12 04:51:55 +00:00
|
|
|
Status cw_error;
|
2012-10-23 07:20:06 +00:00
|
|
|
// This API doesn't take in a type, so we can't figure out what it is.
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
CompilerType *type = nullptr;
|
2012-02-04 02:27:34 +00:00
|
|
|
watchpoint_sp =
|
2012-10-23 07:20:06 +00:00
|
|
|
target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
|
2012-06-04 23:19:54 +00:00
|
|
|
error.SetError(cw_error);
|
2012-02-04 02:27:34 +00:00
|
|
|
sb_watchpoint.SetSP(watchpoint_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_watchpoint);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 18:08:26 +00:00
|
|
|
bool SBTarget::EnableAllWatchpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints);
|
|
|
|
|
|
2012-03-06 00:37:27 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(lock);
|
2012-01-30 09:04:36 +00:00
|
|
|
target_sp->EnableAllWatchpoints();
|
2011-09-26 22:40:50 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return false;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
bool SBTarget::DisableAllWatchpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(lock);
|
2012-01-30 09:04:36 +00:00
|
|
|
target_sp->DisableAllWatchpoints();
|
2011-09-26 22:40:50 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-08 21:49:02 +00:00
|
|
|
SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
|
|
|
|
|
SBType type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
|
|
|
|
|
(const char *, lldb::SBAddress, lldb::SBType), name, addr,
|
|
|
|
|
type);
|
|
|
|
|
|
2013-10-08 21:49:02 +00:00
|
|
|
SBValue sb_value;
|
|
|
|
|
lldb::ValueObjectSP new_value_sp;
|
|
|
|
|
if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
|
2014-12-17 21:18:43 +00:00
|
|
|
lldb::addr_t load_addr(addr.GetLoadAddress(*this));
|
|
|
|
|
ExecutionContext exe_ctx(
|
|
|
|
|
ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
|
2015-08-11 22:53:00 +00:00
|
|
|
CompilerType ast_type(type.GetSP()->GetCompilerType(true));
|
2014-12-17 21:18:43 +00:00
|
|
|
new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
|
|
|
|
|
exe_ctx, ast_type);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-10-08 21:49:02 +00:00
|
|
|
sb_value.SetSP(new_value_sp);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-17 21:18:43 +00:00
|
|
|
lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
|
|
|
|
|
lldb::SBType type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
|
|
|
|
|
(const char *, lldb::SBData, lldb::SBType), name, data,
|
|
|
|
|
type);
|
|
|
|
|
|
2013-10-08 21:49:02 +00:00
|
|
|
SBValue sb_value;
|
|
|
|
|
lldb::ValueObjectSP new_value_sp;
|
2014-12-17 21:18:43 +00:00
|
|
|
if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
|
|
|
|
|
DataExtractorSP extractor(*data);
|
|
|
|
|
ExecutionContext exe_ctx(
|
|
|
|
|
ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
|
2015-08-11 22:53:00 +00:00
|
|
|
CompilerType ast_type(type.GetSP()->GetCompilerType(true));
|
2014-12-17 21:18:43 +00:00
|
|
|
new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
|
|
|
|
|
exe_ctx, ast_type);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-10-08 21:49:02 +00:00
|
|
|
sb_value.SetSP(new_value_sp);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-17 21:18:43 +00:00
|
|
|
lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
|
|
|
|
|
const char *expr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
|
|
|
|
|
(const char *, const char *), name, expr);
|
|
|
|
|
|
2013-10-08 21:49:02 +00:00
|
|
|
SBValue sb_value;
|
|
|
|
|
lldb::ValueObjectSP new_value_sp;
|
2014-12-17 21:18:43 +00:00
|
|
|
if (IsValid() && name && *name && expr && *expr) {
|
|
|
|
|
ExecutionContext exe_ctx(
|
|
|
|
|
ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
|
|
|
|
|
new_value_sp =
|
|
|
|
|
ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-10-08 21:49:02 +00:00
|
|
|
sb_value.SetSP(new_value_sp);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 18:08:26 +00:00
|
|
|
bool SBTarget::DeleteAllWatchpoints() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2013-12-06 01:12:00 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2016-05-19 05:13:57 +00:00
|
|
|
target_sp->GetWatchpointList().GetListMutex(lock);
|
2013-12-06 01:12:00 +00:00
|
|
|
target_sp->RemoveAllWatchpoints();
|
2011-07-22 16:46:35 +00:00
|
|
|
return true;
|
2010-12-20 20:49:23 +00:00
|
|
|
}
|
2011-09-26 22:40:50 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-12-12 19:25:26 +00:00
|
|
|
|
2018-08-07 20:23:57 +00:00
|
|
|
void SBTarget::AppendImageSearchPath(const char *from, const char *to,
|
|
|
|
|
lldb::SBError &error) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath,
|
|
|
|
|
(const char *, const char *, lldb::SBError &), from, to,
|
|
|
|
|
error);
|
|
|
|
|
|
2018-08-07 20:23:57 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
|
|
|
|
return error.SetErrorString("invalid target");
|
|
|
|
|
|
|
|
|
|
const ConstString csFrom(from), csTo(to);
|
|
|
|
|
if (!csFrom)
|
|
|
|
|
return error.SetErrorString("<from> path can't be empty");
|
|
|
|
|
if (!csTo)
|
|
|
|
|
return error.SetErrorString("<to> path can't be empty");
|
|
|
|
|
|
|
|
|
|
target_sp->GetImageSearchPathList().Append(csFrom, csTo, true);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
|
|
|
|
|
const char *uuid_cstr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const char *, const char *, const char *), path, triple,
|
|
|
|
|
uuid_cstr);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
|
2010-12-12 19:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
|
|
|
|
|
const char *uuid_cstr, const char *symfile) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const char *, const char *, const char *, const char *),
|
|
|
|
|
path, triple, uuid_cstr, symfile);
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
lldb::SBModule sb_module;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2012-02-26 05:51:37 +00:00
|
|
|
ModuleSpec module_spec;
|
2011-09-24 00:52:29 +00:00
|
|
|
if (path)
|
2018-11-01 21:05:36 +00:00
|
|
|
module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
if (uuid_cstr)
|
2018-06-21 15:24:39 +00:00
|
|
|
module_spec.GetUUID().SetFromStringRef(uuid_cstr);
|
2014-10-22 07:22:56 +00:00
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
if (triple)
|
2017-10-31 10:56:03 +00:00
|
|
|
module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
|
|
|
|
|
target_sp->GetPlatform().get(), triple);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2013-09-11 21:25:46 +00:00
|
|
|
module_spec.GetArchitecture() = target_sp->GetArchitecture();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-04-23 20:23:39 +00:00
|
|
|
if (symfile)
|
2018-11-01 21:05:36 +00:00
|
|
|
module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2014-10-22 07:22:56 +00:00
|
|
|
}
|
2013-12-06 01:12:00 +00:00
|
|
|
|
|
|
|
|
lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const lldb::SBModuleSpec &), module_spec);
|
|
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
lldb::SBModule sb_module;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
2019-04-08 23:03:02 +00:00
|
|
|
sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
|
|
|
|
|
true /* notify */));
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2013-12-06 01:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
bool SBTarget::AddModule(lldb::SBModule &module) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
target_sp->GetImages().AppendIfNeeded(module.GetSP());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-03-02 21:34:46 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
uint32_t SBTarget::GetNumModules() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules);
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
uint32_t num = 0;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
Fixed SBTarget::ReadMemory() to work correctly and the TestTargetAPI.py test case that was reading target memory in TargetAPITestCase.test_read_memory_with_dsym and TargetAPITestCase.test_read_memory_with_dwarf.
The problem was that SBTarget::ReadMemory() was making a new section offset lldb_private::Address by doing:
size_t
SBTarget::ReadMemory (const SBAddress addr,
void *buf,
size_t size,
lldb::SBError &error)
{
...
lldb_private::Address addr_priv(addr.GetFileAddress(), NULL);
bytes_read = target_sp->ReadMemory(addr_priv, false, buf, size, err_priv);
This is wrong. If you get the file addresss from the "addr" argument and try to read memory using that, it will think the file address is a load address and it will try to resolve it accordingly. This will work fine if your executable is loaded at the same address (no slide), but it won't work if there is a slide.
The fix is to just pass along the "addr.ref()" instead of making a new addr_priv as this will pass along the lldb_private::Address that is inside the SBAddress (which is what we want), and not always change it into something that becomes a load address (if we are running), or abmigious file address (think address zero when you have 150 shared libraries that have sections that start at zero, which one would you pick). The main reason for passing a section offset address to SBTarget::ReadMemory() is so you _can_ read from the actual section + offset that is specified in the SBAddress.
llvm-svn: 221213
2014-11-04 00:56:30 +00:00
|
|
|
// The module list is thread safe, no need to lock
|
|
|
|
|
num = target_sp->GetImages().GetSize();
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
return num;
|
|
|
|
|
}
|
2011-03-02 21:34:46 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void SBTarget::Clear() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear);
|
|
|
|
|
|
2010-11-08 00:28:40 +00:00
|
|
|
m_opaque_sp.reset();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule,
|
|
|
|
|
(const lldb::SBFileSpec &), sb_file_spec);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBModule sb_module;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2013-10-11 19:48:25 +00:00
|
|
|
if (target_sp && sb_file_spec.IsValid()) {
|
2016-03-09 18:59:13 +00:00
|
|
|
ModuleSpec module_spec(*sb_file_spec);
|
|
|
|
|
// The module list is thread safe, no need to lock
|
|
|
|
|
sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2016-03-09 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
|
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
|
|
|
|
|
(const lldb::SBFileSpec &), sb_file_spec);
|
|
|
|
|
|
2018-07-03 14:22:44 +00:00
|
|
|
SBSymbolContextList sb_sc_list;
|
|
|
|
|
const TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp && sb_file_spec.IsValid()) {
|
|
|
|
|
const bool append = true;
|
|
|
|
|
target_sp->GetImages().FindCompileUnits(*sb_file_spec,
|
|
|
|
|
append, *sb_sc_list);
|
|
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2018-07-03 14:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::ByteOrder SBTarget::GetByteOrder() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2016-03-09 18:59:13 +00:00
|
|
|
if (target_sp)
|
|
|
|
|
return target_sp->GetArchitecture().GetByteOrder();
|
2013-03-27 23:08:40 +00:00
|
|
|
return eByteOrderInvalid;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
const char *SBTarget::GetTriple() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::string triple(target_sp->GetArchitecture().GetTriple().str());
|
2018-04-30 16:49:04 +00:00
|
|
|
// Unique the string so we don't run into ownership issues since the const
|
|
|
|
|
// strings put the string into the string pool once and the strings never
|
|
|
|
|
// comes out
|
2015-05-18 13:41:01 +00:00
|
|
|
ConstString const_triple(triple.c_str());
|
2016-03-09 18:59:13 +00:00
|
|
|
return const_triple.GetCString();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return nullptr;
|
2010-12-20 20:49:23 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
uint32_t SBTarget::GetDataByteSize() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize);
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
return target_sp->GetArchitecture().GetDataByteSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-07-23 23:33:17 +00:00
|
|
|
return 0;
|
2010-10-26 03:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
uint32_t SBTarget::GetCodeByteSize() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
return target_sp->GetArchitecture().GetCodeByteSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-07-23 23:33:17 +00:00
|
|
|
return 0;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
uint32_t SBTarget::GetAddressByteSize() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize);
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
2013-03-27 23:08:40 +00:00
|
|
|
return target_sp->GetArchitecture().GetAddressByteSize();
|
|
|
|
|
return sizeof(void *);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t),
|
|
|
|
|
idx);
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SBModule sb_module;
|
|
|
|
|
ModuleSP module_sp;
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2010-12-20 20:49:23 +00:00
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 09:04:36 +00:00
|
|
|
module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
|
2012-02-26 05:51:37 +00:00
|
|
|
sb_module.SetSP(module_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
bool SBTarget::RemoveModule(lldb::SBModule module) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2016-05-19 05:13:57 +00:00
|
|
|
if (target_sp)
|
|
|
|
|
return target_sp->GetImages().Remove(module.GetSP());
|
2012-05-22 00:12:20 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
SBBroadcaster SBTarget::GetBroadcaster() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget,
|
|
|
|
|
GetBroadcaster);
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
SBBroadcaster broadcaster(target_sp.get(), false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(broadcaster);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
bool SBTarget::GetDescription(SBStream &description,
|
2010-10-26 03:11:13 +00:00
|
|
|
lldb::DescriptionLevel description_level) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTarget, GetDescription,
|
|
|
|
|
(lldb::SBStream &, lldb::DescriptionLevel), description,
|
|
|
|
|
description_level);
|
|
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
Stream &strm = description.ref();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
target_sp->Dump(&strm, description_level);
|
2012-05-22 00:12:20 +00:00
|
|
|
} else
|
2011-11-13 06:57:31 +00:00
|
|
|
strm.PutCString("No value");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
|
|
|
|
|
uint32_t name_type_mask) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
|
|
|
|
|
(const char *, uint32_t), name, name_type_mask);
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBSymbolContextList sb_sc_list;
|
2018-10-25 20:45:40 +00:00
|
|
|
if (!name | !name[0])
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2018-10-25 20:45:40 +00:00
|
|
|
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2018-10-25 20:45:40 +00:00
|
|
|
|
|
|
|
|
const bool symbols_ok = true;
|
|
|
|
|
const bool inlines_ok = true;
|
|
|
|
|
const bool append = true;
|
|
|
|
|
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
|
|
|
|
|
target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
|
|
|
|
|
inlines_ok, append, *sb_sc_list);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
|
2014-09-19 19:38:19 +00:00
|
|
|
uint32_t max_matches,
|
|
|
|
|
MatchType matchtype) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions,
|
|
|
|
|
(const char *, uint32_t, lldb::MatchType), name,
|
|
|
|
|
max_matches, matchtype);
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBSymbolContextList sb_sc_list;
|
2012-01-30 09:04:36 +00:00
|
|
|
if (name && name[0]) {
|
2016-09-21 16:01:28 +00:00
|
|
|
llvm::StringRef name_ref(name);
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2014-09-19 19:38:19 +00:00
|
|
|
std::string regexstr;
|
|
|
|
|
switch (matchtype) {
|
2016-03-09 18:59:13 +00:00
|
|
|
case eMatchTypeRegex:
|
2016-09-21 16:01:28 +00:00
|
|
|
target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
|
2014-09-19 19:38:19 +00:00
|
|
|
true, true, *sb_sc_list);
|
2016-03-09 18:59:13 +00:00
|
|
|
break;
|
|
|
|
|
case eMatchTypeStartsWith:
|
2014-09-19 19:38:19 +00:00
|
|
|
regexstr = llvm::Regex::escape(name) + ".*";
|
2016-09-21 16:01:28 +00:00
|
|
|
target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
|
|
|
|
|
true, true, *sb_sc_list);
|
2016-03-09 18:59:13 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2014-09-19 19:38:19 +00:00
|
|
|
target_sp->GetImages().FindFunctions(ConstString(name),
|
2016-03-09 18:59:13 +00:00
|
|
|
eFunctionNameTypeAny, true, true,
|
2014-09-19 19:38:19 +00:00
|
|
|
true, *sb_sc_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-05 21:24:42 +00:00
|
|
|
lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *),
|
|
|
|
|
typename_cstr);
|
|
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (typename_cstr && typename_cstr[0] && target_sp) {
|
|
|
|
|
ConstString const_typename(typename_cstr);
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
const bool exact_match = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
const ModuleList &module_list = target_sp->GetImages();
|
2012-12-05 21:24:42 +00:00
|
|
|
size_t count = module_list.GetSize();
|
2011-07-29 19:53:35 +00:00
|
|
|
for (size_t idx = 0; idx < count; idx++) {
|
2012-12-05 21:24:42 +00:00
|
|
|
ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
|
|
|
|
|
if (module_sp) {
|
|
|
|
|
TypeSP type_sp(
|
|
|
|
|
module_sp->FindFirstType(sc, const_typename, exact_match));
|
|
|
|
|
if (type_sp)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBType(type_sp));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 20:33:09 +00:00
|
|
|
// Didn't find the type in the symbols; Try the loaded language runtimes
|
|
|
|
|
if (auto process_sp = target_sp->GetProcessSP()) {
|
|
|
|
|
for (auto *runtime : process_sp->GetLanguageRuntimes()) {
|
|
|
|
|
if (auto vendor = runtime->GetDeclVendor()) {
|
2019-07-02 19:53:07 +00:00
|
|
|
auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
|
|
|
|
|
if (!types.empty())
|
|
|
|
|
return LLDB_RECORD_RESULT(SBType(types.front()));
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
// No matches, search for basic typename matches
|
2019-07-31 20:47:38 +00:00
|
|
|
for (auto *type_system : target_sp->GetScratchTypeSystems())
|
|
|
|
|
if (auto type = type_system->GetBuiltinTypeByName(const_typename))
|
|
|
|
|
return LLDB_RECORD_RESULT(SBType(type));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-07-31 20:47:38 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBType());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-05 21:24:42 +00:00
|
|
|
SBType SBTarget::GetBasicType(lldb::BasicType type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType),
|
|
|
|
|
type);
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-08 22:22:41 +00:00
|
|
|
if (target_sp) {
|
2019-07-31 20:47:38 +00:00
|
|
|
for (auto *type_system : target_sp->GetScratchTypeSystems())
|
|
|
|
|
if (auto compiler_type = type_system->GetBasicTypeFromAST(type))
|
|
|
|
|
return LLDB_RECORD_RESULT(SBType(compiler_type));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBType());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *),
|
|
|
|
|
typename_cstr);
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
SBTypeList sb_type_list;
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-08 22:22:41 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (typename_cstr && typename_cstr[0] && target_sp) {
|
2016-03-09 18:59:13 +00:00
|
|
|
ModuleList &images = target_sp->GetImages();
|
2012-12-05 21:24:42 +00:00
|
|
|
ConstString const_typename(typename_cstr);
|
2016-03-09 18:59:13 +00:00
|
|
|
bool exact_match = false;
|
2011-07-29 19:53:35 +00:00
|
|
|
TypeList type_list;
|
2016-03-09 18:59:13 +00:00
|
|
|
llvm::DenseSet<SymbolFile *> searched_symbol_files;
|
|
|
|
|
uint32_t num_matches =
|
2019-01-14 22:41:21 +00:00
|
|
|
images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
|
2016-03-09 18:59:13 +00:00
|
|
|
searched_symbol_files, type_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
if (num_matches > 0) {
|
2012-12-05 21:24:42 +00:00
|
|
|
for (size_t idx = 0; idx < num_matches; idx++) {
|
|
|
|
|
TypeSP type_sp(type_list.GetTypeAtIndex(idx));
|
|
|
|
|
if (type_sp)
|
|
|
|
|
sb_type_list.Append(SBType(type_sp));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 20:33:09 +00:00
|
|
|
// Try the loaded language runtimes
|
|
|
|
|
if (auto process_sp = target_sp->GetProcessSP()) {
|
|
|
|
|
for (auto *runtime : process_sp->GetLanguageRuntimes()) {
|
|
|
|
|
if (auto *vendor = runtime->GetDeclVendor()) {
|
2019-07-02 19:53:07 +00:00
|
|
|
auto types =
|
|
|
|
|
vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
|
|
|
|
|
for (auto type : types)
|
|
|
|
|
sb_type_list.Append(SBType(type));
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2010-10-26 03:11:13 +00:00
|
|
|
if (sb_type_list.GetSize() == 0) {
|
2014-04-04 04:06:10 +00:00
|
|
|
// No matches, search for basic typename matches
|
2019-07-31 20:47:38 +00:00
|
|
|
for (auto *type_system : target_sp->GetScratchTypeSystems())
|
|
|
|
|
if (auto compiler_type =
|
|
|
|
|
type_system->GetBuiltinTypeByName(const_typename))
|
|
|
|
|
sb_type_list.Append(SBType(compiler_type));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_type_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
SBValueList SBTarget::FindGlobalVariables(const char *name,
|
|
|
|
|
uint32_t max_matches) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
|
|
|
|
|
(const char *, uint32_t), name, max_matches);
|
|
|
|
|
|
2011-06-29 22:09:02 +00:00
|
|
|
SBValueList sb_value_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 04:06:10 +00:00
|
|
|
if (name && target_sp) {
|
2011-06-29 22:09:02 +00:00
|
|
|
VariableList variable_list;
|
2012-01-30 09:04:36 +00:00
|
|
|
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
|
2018-05-31 09:46:26 +00:00
|
|
|
ConstString(name), max_matches, variable_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
if (match_count > 0) {
|
2012-01-30 09:04:36 +00:00
|
|
|
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
if (exe_scope == nullptr)
|
2012-01-30 09:04:36 +00:00
|
|
|
exe_scope = target_sp.get();
|
2014-09-19 19:38:19 +00:00
|
|
|
for (uint32_t i = 0; i < match_count; ++i) {
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
|
2011-06-29 22:09:02 +00:00
|
|
|
exe_scope, variable_list.GetVariableAtIndex(i)));
|
|
|
|
|
if (valobj_sp)
|
2013-02-07 18:23:56 +00:00
|
|
|
sb_value_list.Append(SBValue(valobj_sp));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-19 19:38:19 +00:00
|
|
|
SBValueList SBTarget::FindGlobalVariables(const char *name,
|
|
|
|
|
uint32_t max_matches,
|
|
|
|
|
MatchType matchtype) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
|
|
|
|
|
(const char *, uint32_t, lldb::MatchType), name,
|
|
|
|
|
max_matches, matchtype);
|
|
|
|
|
|
2011-06-29 22:09:02 +00:00
|
|
|
SBValueList sb_value_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 04:06:10 +00:00
|
|
|
if (name && target_sp) {
|
2016-09-21 16:01:28 +00:00
|
|
|
llvm::StringRef name_ref(name);
|
2011-06-29 22:09:02 +00:00
|
|
|
VariableList variable_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-19 19:38:19 +00:00
|
|
|
std::string regexstr;
|
|
|
|
|
uint32_t match_count;
|
|
|
|
|
switch (matchtype) {
|
|
|
|
|
case eMatchTypeNormal:
|
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(
|
2018-05-31 09:46:26 +00:00
|
|
|
ConstString(name), max_matches, variable_list);
|
2014-04-04 04:06:10 +00:00
|
|
|
break;
|
2014-09-19 19:38:19 +00:00
|
|
|
case eMatchTypeRegex:
|
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(
|
2018-05-31 09:46:26 +00:00
|
|
|
RegularExpression(name_ref), max_matches, variable_list);
|
2014-04-04 04:06:10 +00:00
|
|
|
break;
|
2014-09-19 19:38:19 +00:00
|
|
|
case eMatchTypeStartsWith:
|
|
|
|
|
regexstr = llvm::Regex::escape(name) + ".*";
|
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(
|
2018-05-31 09:46:26 +00:00
|
|
|
RegularExpression(regexstr), max_matches, variable_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:02 +00:00
|
|
|
if (match_count > 0) {
|
2012-01-30 09:04:36 +00:00
|
|
|
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
if (exe_scope == nullptr)
|
2012-01-30 09:04:36 +00:00
|
|
|
exe_scope = target_sp.get();
|
2014-09-19 19:38:19 +00:00
|
|
|
for (uint32_t i = 0; i < match_count; ++i) {
|
|
|
|
|
lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
|
2011-06-29 22:09:02 +00:00
|
|
|
exe_scope, variable_list.GetVariableAtIndex(i)));
|
|
|
|
|
if (valobj_sp)
|
2013-02-07 18:23:56 +00:00
|
|
|
sb_value_list.Append(SBValue(valobj_sp));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
|
|
|
|
|
(const char *), name);
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
SBValueList sb_value_list(FindGlobalVariables(name, 1));
|
|
|
|
|
if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
|
|
|
|
|
return LLDB_RECORD_RESULT(SBValue());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-13 00:29:56 +00:00
|
|
|
SBSourceManager SBTarget::GetSourceManager() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager);
|
|
|
|
|
|
2011-09-13 00:29:56 +00:00
|
|
|
SBSourceManager source_manager(*this);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(source_manager);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
|
2012-03-06 22:24:44 +00:00
|
|
|
uint32_t count) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
|
|
|
|
|
(lldb::SBAddress, uint32_t), base_addr, count);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-02 00:26:47 +00:00
|
|
|
lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
|
|
|
|
|
uint32_t count,
|
2014-04-04 04:06:10 +00:00
|
|
|
const char *flavor_string) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
|
|
|
|
|
(lldb::SBAddress, uint32_t, const char *), base_addr,
|
|
|
|
|
count, flavor_string);
|
|
|
|
|
|
2012-03-06 22:24:44 +00:00
|
|
|
SBInstructionList sb_instructions;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 04:06:10 +00:00
|
|
|
if (target_sp) {
|
2012-03-06 22:24:44 +00:00
|
|
|
Address *addr_ptr = base_addr.get();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-03-06 22:24:44 +00:00
|
|
|
if (addr_ptr) {
|
|
|
|
|
DataBufferHeap data(
|
|
|
|
|
target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
|
2014-04-04 04:06:10 +00:00
|
|
|
bool prefer_file_cache = false;
|
2017-05-12 04:51:55 +00:00
|
|
|
lldb_private::Status error;
|
2013-03-28 23:42:53 +00:00
|
|
|
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
const size_t bytes_read =
|
2014-04-04 04:06:10 +00:00
|
|
|
target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
|
2012-06-04 23:19:54 +00:00
|
|
|
data.GetByteSize(), error, &load_addr);
|
2014-04-04 04:06:10 +00:00
|
|
|
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
|
|
|
|
|
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr,
|
2014-04-04 04:06:10 +00:00
|
|
|
data.GetBytes(), bytes_read, count, data_from_file));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_instructions);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-10-26 03:11:13 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
|
2011-12-14 23:49:37 +00:00
|
|
|
const void *buf,
|
|
|
|
|
size_t size) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
|
|
|
|
|
(lldb::SBAddress, const void *, size_t), base_addr, buf,
|
|
|
|
|
size);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
lldb::SBInstructionList
|
|
|
|
|
SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
|
2013-10-11 19:48:25 +00:00
|
|
|
const char *flavor_string, const void *buf,
|
2011-10-11 01:18:55 +00:00
|
|
|
size_t size) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
|
|
|
|
|
GetInstructionsWithFlavor,
|
|
|
|
|
(lldb::SBAddress, const char *, const void *, size_t),
|
|
|
|
|
base_addr, flavor_string, buf, size);
|
|
|
|
|
|
2011-10-11 01:18:55 +00:00
|
|
|
SBInstructionList sb_instructions;
|
|
|
|
|
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
2015-11-06 22:48:59 +00:00
|
|
|
Address addr;
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
if (base_addr.get())
|
|
|
|
|
addr = *base_addr.get();
|
2011-09-23 00:54:11 +00:00
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
const bool data_from_file = true;
|
2014-04-04 04:06:10 +00:00
|
|
|
|
|
|
|
|
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
|
2014-04-04 04:06:10 +00:00
|
|
|
UINT32_MAX, data_from_file));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-09-23 00:54:11 +00:00
|
|
|
|
|
|
|
|
return sb_instructions;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 00:37:27 +00:00
|
|
|
lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
|
|
|
|
|
const void *buf,
|
|
|
|
|
size_t size) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
|
|
|
|
|
(lldb::addr_t, const void *, size_t), base_addr, buf, size);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
|
2015-11-06 22:48:59 +00:00
|
|
|
size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
|
SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
|
|
|
|
|
const char *flavor_string, const void *buf,
|
|
|
|
|
size_t size) {
|
2019-03-08 19:09:27 +00:00
|
|
|
LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
|
|
|
|
|
GetInstructionsWithFlavor,
|
|
|
|
|
(lldb::addr_t, const char *, const void *, size_t),
|
|
|
|
|
base_addr, flavor_string, buf, size);
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
|
|
|
|
|
buf, size);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
|
|
|
|
|
lldb::addr_t section_base_addr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
|
|
|
|
|
(lldb::SBSection, lldb::addr_t), section,
|
|
|
|
|
section_base_addr);
|
|
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
SBError sb_error;
|
2016-03-09 18:59:13 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-09-19 19:38:19 +00:00
|
|
|
if (target_sp) {
|
2011-09-24 00:52:29 +00:00
|
|
|
if (!section.IsValid()) {
|
2016-03-09 18:59:13 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid section");
|
|
|
|
|
} else {
|
2012-03-27 21:10:07 +00:00
|
|
|
SectionSP section_sp(section.GetSP());
|
|
|
|
|
if (section_sp) {
|
2016-03-09 18:59:13 +00:00
|
|
|
if (section_sp->IsThreadSpecific()) {
|
2011-09-24 00:52:29 +00:00
|
|
|
sb_error.SetErrorString(
|
2016-03-09 18:59:13 +00:00
|
|
|
"thread specific sections are not yet supported");
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-12-19 23:05:01 +00:00
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
2016-03-09 18:59:13 +00:00
|
|
|
if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
|
2016-05-16 21:14:44 +00:00
|
|
|
ModuleSP module_sp(section_sp->GetModule());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (module_sp) {
|
2016-03-09 18:59:13 +00:00
|
|
|
ModuleList module_list;
|
|
|
|
|
module_list.Append(module_sp);
|
|
|
|
|
target_sp->ModulesDidLoad(module_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2016-03-09 18:59:13 +00:00
|
|
|
// Flush info in the process (stack frames, etc)
|
2012-12-19 23:05:01 +00:00
|
|
|
if (process_sp)
|
2013-01-29 01:17:09 +00:00
|
|
|
process_sp->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-03-27 21:10:07 +00:00
|
|
|
sb_error.SetErrorString("invalid target");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2016-03-09 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
|
|
|
|
|
(lldb::SBSection), section);
|
|
|
|
|
|
2012-05-22 00:12:20 +00:00
|
|
|
SBError sb_error;
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (target_sp) {
|
2012-03-06 00:37:27 +00:00
|
|
|
if (!section.IsValid()) {
|
2011-09-24 00:52:29 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid section");
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-03-27 21:10:07 +00:00
|
|
|
SectionSP section_sp(section.GetSP());
|
2012-03-06 00:37:27 +00:00
|
|
|
if (section_sp) {
|
2012-12-19 23:05:01 +00:00
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
2014-04-04 04:06:10 +00:00
|
|
|
if (target_sp->SetSectionUnloaded(section_sp)) {
|
2016-05-16 21:14:44 +00:00
|
|
|
ModuleSP module_sp(section_sp->GetModule());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (module_sp) {
|
2016-05-16 21:14:44 +00:00
|
|
|
ModuleList module_list;
|
|
|
|
|
module_list.Append(module_sp);
|
2014-04-04 04:06:10 +00:00
|
|
|
target_sp->ModulesDidUnload(module_list, false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-04-04 04:06:10 +00:00
|
|
|
// Flush info in the process (stack frames, etc)
|
2012-12-19 23:05:01 +00:00
|
|
|
if (process_sp)
|
2013-01-29 01:17:09 +00:00
|
|
|
process_sp->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2014-04-04 04:06:10 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid section");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2011-09-24 00:52:29 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid target");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
|
|
|
|
|
int64_t slide_offset) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
|
|
|
|
|
(lldb::SBModule, int64_t), module, slide_offset);
|
|
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
SBError sb_error;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-04-04 04:06:10 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
ModuleSP module_sp(module.GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (module_sp) {
|
2012-03-27 21:10:07 +00:00
|
|
|
bool changed = false;
|
2014-02-07 22:54:47 +00:00
|
|
|
if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
|
2014-04-04 04:06:10 +00:00
|
|
|
// The load was successful, make sure that at least some sections
|
2012-03-27 21:10:07 +00:00
|
|
|
// changed before we notify that our module was loaded.
|
2012-03-06 00:37:27 +00:00
|
|
|
if (changed) {
|
2016-05-16 21:14:44 +00:00
|
|
|
ModuleList module_list;
|
|
|
|
|
module_list.Append(module_sp);
|
|
|
|
|
target_sp->ModulesDidLoad(module_list);
|
2012-03-06 00:37:27 +00:00
|
|
|
// Flush info in the process (stack frames, etc)
|
2012-12-19 23:05:01 +00:00
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
|
|
|
|
if (process_sp)
|
2013-01-29 01:17:09 +00:00
|
|
|
process_sp->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-01-30 09:04:36 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid module");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
2011-09-24 00:52:29 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid target");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
|
|
|
|
|
(lldb::SBModule), module);
|
|
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
SBError sb_error;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
char path[PATH_MAX];
|
2012-01-30 09:04:36 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (target_sp) {
|
2012-01-30 09:04:36 +00:00
|
|
|
ModuleSP module_sp(module.GetSP());
|
2012-12-05 21:24:42 +00:00
|
|
|
if (module_sp) {
|
2012-01-30 09:04:36 +00:00
|
|
|
ObjectFile *objfile = module_sp->GetObjectFile();
|
2011-09-24 00:52:29 +00:00
|
|
|
if (objfile) {
|
|
|
|
|
SectionList *section_list = objfile->GetSectionList();
|
|
|
|
|
if (section_list) {
|
2012-12-19 23:05:01 +00:00
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-03-27 21:10:07 +00:00
|
|
|
bool changed = false;
|
2011-09-24 00:52:29 +00:00
|
|
|
const size_t num_sections = section_list->GetSize();
|
2012-03-06 00:37:27 +00:00
|
|
|
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
|
|
|
|
|
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
|
2012-03-27 21:10:07 +00:00
|
|
|
if (section_sp)
|
2012-03-06 00:37:27 +00:00
|
|
|
changed |= target_sp->SetSectionUnloaded(section_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-03-06 00:37:27 +00:00
|
|
|
if (changed) {
|
2016-05-16 21:14:44 +00:00
|
|
|
ModuleList module_list;
|
|
|
|
|
module_list.Append(module_sp);
|
|
|
|
|
target_sp->ModulesDidUnload(module_list, false);
|
2012-03-06 00:37:27 +00:00
|
|
|
// Flush info in the process (stack frames, etc)
|
|
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
2012-12-19 23:05:01 +00:00
|
|
|
if (process_sp)
|
2013-01-29 01:17:09 +00:00
|
|
|
process_sp->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-03-06 00:37:27 +00:00
|
|
|
} else {
|
|
|
|
|
module_sp->GetFileSpec().GetPath(path, sizeof(path));
|
|
|
|
|
sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
|
|
|
|
|
path);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2014-04-04 04:06:10 +00:00
|
|
|
module_sp->GetFileSpec().GetPath(path, sizeof(path));
|
|
|
|
|
sb_error.SetErrorStringWithFormat("no object file for module '%s'",
|
2016-09-06 20:57:50 +00:00
|
|
|
path);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2014-04-04 04:06:10 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid module");
|
2012-03-06 00:37:27 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2011-09-24 00:52:29 +00:00
|
|
|
sb_error.SetErrorStringWithFormat("invalid target");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2012-03-06 00:37:27 +00:00
|
|
|
}
|
2011-09-23 00:54:11 +00:00
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
|
|
|
|
|
lldb::SymbolType symbol_type) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
|
|
|
|
|
(const char *, lldb::SymbolType), name, symbol_type);
|
|
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
SBSymbolContextList sb_sc_list;
|
|
|
|
|
if (name && name[0]) {
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
bool append = true;
|
|
|
|
|
target_sp->GetImages().FindSymbolsWithNameAndType(
|
|
|
|
|
ConstString(name), symbol_type, *sb_sc_list, append);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc_list);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
|
|
|
|
|
(const char *), expr);
|
|
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (!target_sp)
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(SBValue());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
SBExpressionOptions options;
|
|
|
|
|
lldb::DynamicValueType fetch_dynamic_value =
|
|
|
|
|
target_sp->GetPreferDynamicValue();
|
2015-07-07 22:12:17 +00:00
|
|
|
options.SetFetchDynamicValue(fetch_dynamic_value);
|
2015-11-06 22:48:59 +00:00
|
|
|
options.SetUnwindOnError(true);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
|
2015-11-06 22:48:59 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
|
2012-01-29 06:07:39 +00:00
|
|
|
const SBExpressionOptions &options) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
|
|
|
|
|
(const char *, const lldb::SBExpressionOptions &), expr,
|
|
|
|
|
options);
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
2013-01-04 18:10:18 +00:00
|
|
|
SBValue expr_result;
|
|
|
|
|
ValueObjectSP expr_value_sp;
|
|
|
|
|
TargetSP target_sp(GetSP());
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
StackFrame *frame = nullptr;
|
2013-01-04 18:10:18 +00:00
|
|
|
if (target_sp) {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
if (expr == nullptr || expr[0] == '\0') {
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(expr_result);
|
2013-01-04 18:10:18 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2013-01-04 18:10:18 +00:00
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get());
|
2014-04-04 04:06:10 +00:00
|
|
|
|
|
|
|
|
|
2013-01-04 18:10:18 +00:00
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2013-01-04 18:10:18 +00:00
|
|
|
if (target) {
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
|
StreamString frame_description;
|
|
|
|
|
if (frame)
|
|
|
|
|
frame->DumpUsingSettingsFormat(&frame_description);
|
2016-12-15 00:30:30 +00:00
|
|
|
llvm::PrettyStackTraceFormat stack_trace(
|
2013-01-04 18:10:18 +00:00
|
|
|
"SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
|
|
|
|
|
"%u) %s",
|
|
|
|
|
expr, options.GetFetchDynamicValue(),
|
2016-11-16 21:15:24 +00:00
|
|
|
frame_description.GetString().str().c_str());
|
2013-01-04 18:10:18 +00:00
|
|
|
#endif
|
2019-03-18 16:04:46 +00:00
|
|
|
target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
|
2013-01-04 18:10:18 +00:00
|
|
|
|
|
|
|
|
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(expr_log,
|
|
|
|
|
"** [SBTarget::EvaluateExpression] Expression result is "
|
|
|
|
|
"%s, summary %s **",
|
|
|
|
|
expr_result.GetValue(), expr_result.GetSummary());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(expr_result);
|
2013-01-04 18:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-01 00:47:49 +00:00
|
|
|
lldb::addr_t SBTarget::GetStackRedZoneSize() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize);
|
|
|
|
|
|
2013-02-01 00:47:49 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp) {
|
|
|
|
|
ABISP abi_sp;
|
|
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
|
|
|
|
if (process_sp)
|
|
|
|
|
abi_sp = process_sp->GetABI();
|
|
|
|
|
else
|
2017-06-29 02:57:03 +00:00
|
|
|
abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
|
2013-02-01 00:47:49 +00:00
|
|
|
if (abi_sp)
|
|
|
|
|
return abi_sp->GetRedZoneSize();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-02-13 14:31:06 +00:00
|
|
|
|
|
|
|
|
lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
|
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 11:14:47 +00:00
|
|
|
lldb::SBLaunchInfo launch_info(nullptr);
|
2015-02-13 14:31:06 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.
This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
Instead of trying to maintain a constantly up-to-date envp view, it
provides a function which creates a envp view on demand, with the
expectation that this will be called as the very last thing before
handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
into "KEY=VALUE" representation.
With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.
(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)
Reviewers: zturner, davide, jingham, clayborg
Subscribers: emaste, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D41359
llvm-svn: 322174
2018-01-10 11:57:31 +00:00
|
|
|
launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(launch_info);
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo,
|
|
|
|
|
(const lldb::SBLaunchInfo &), launch_info);
|
|
|
|
|
|
2015-02-13 14:31:06 +00:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
if (target_sp)
|
|
|
|
|
m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
|
|
|
|
|
}
|
2019-03-19 17:13:13 +00:00
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
void RegisterMethods<SBTarget>(Registry &R) {
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTarget, ());
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &));
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &));
|
|
|
|
|
LLDB_REGISTER_METHOD(const lldb::SBTarget &,
|
|
|
|
|
SBTarget, operator=,(const lldb::SBTarget &));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
|
|
|
|
|
(const lldb::SBEvent &));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
|
|
|
|
|
(const lldb::SBEvent &));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
|
|
|
|
|
(const lldb::SBEvent &));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget,
|
|
|
|
|
GetModuleAtIndexFromEvent,
|
|
|
|
|
(const uint32_t, const lldb::SBEvent &));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName,
|
|
|
|
|
());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore,
|
|
|
|
|
(const char *, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
|
|
|
|
|
(const char **, const char **, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
|
|
|
|
|
(lldb::SBListener &, const char **, const char **,
|
|
|
|
|
const char *, const char *, const char *,
|
|
|
|
|
const char *, uint32_t, bool, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
|
|
|
|
|
(lldb::SBLaunchInfo &, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach,
|
|
|
|
|
(lldb::SBAttachInfo &, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
|
|
|
|
|
(lldb::SBListener &, lldb::pid_t, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBProcess, SBTarget, AttachToProcessWithName,
|
|
|
|
|
(lldb::SBListener &, const char *, bool, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBProcess, SBTarget, ConnectRemote,
|
|
|
|
|
(lldb::SBListener &, const char *, const char *, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool,
|
|
|
|
|
SBTarget, operator==,(const lldb::SBTarget &));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool,
|
|
|
|
|
SBTarget, operator!=,(const lldb::SBTarget &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
|
|
|
|
|
(lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
|
|
|
|
|
(lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
|
|
|
|
|
(uint32_t, lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget,
|
|
|
|
|
ResolveSymbolContextForAddress,
|
|
|
|
|
(const lldb::SBAddress &, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByLocation, (const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
|
|
|
|
|
lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByLocation,
|
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t,
|
|
|
|
|
lldb::addr_t, lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, uint32_t, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
|
|
|
|
|
(const char *, uint32_t, lldb::LanguageType,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t, lldb::LanguageType,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
|
|
|
|
|
(const char **, uint32_t, uint32_t, lldb::LanguageType,
|
|
|
|
|
lldb::addr_t, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
|
|
|
|
|
(const char *, lldb::LanguageType,
|
|
|
|
|
const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateByAddress, (lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateBySBAddress, (lldb::SBAddress &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpec &, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
|
|
|
|
|
(const char *, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &, const lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
BreakpointCreateForException,
|
|
|
|
|
(lldb::LanguageType, bool, bool));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
|
|
|
|
|
(const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
|
|
|
|
|
const lldb::SBFileSpecList &, bool));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget,
|
|
|
|
|
GetBreakpointAtIndex, (uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
|
|
|
|
|
(lldb::break_id_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName,
|
|
|
|
|
(const char *, lldb::SBBreakpointList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames,
|
|
|
|
|
(lldb::SBStringList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBBreakpointList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBError, SBTarget, BreakpointsCreateFromFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
|
|
|
|
|
(lldb::SBFileSpec &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
|
|
|
|
|
(lldb::SBFileSpec &, lldb::SBBreakpointList &, bool));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget,
|
|
|
|
|
GetWatchpointAtIndex, (uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
|
|
|
|
|
(lldb::watch_id_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
|
|
|
|
|
(lldb::addr_t, size_t, bool, bool, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
|
|
|
|
|
(const char *, lldb::SBAddress, lldb::SBType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
|
|
|
|
|
(const char *, lldb::SBData, lldb::SBType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
|
|
|
|
|
(const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath,
|
|
|
|
|
(const char *, const char *, lldb::SBError &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const char *, const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const char *, const char *, const char *, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
|
|
|
|
|
(const lldb::SBModuleSpec &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, Clear, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule,
|
|
|
|
|
(const lldb::SBFileSpec &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
|
|
|
|
|
(const lldb::SBFileSpec &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex,
|
|
|
|
|
(uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster,
|
|
|
|
|
());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription,
|
|
|
|
|
(lldb::SBStream &, lldb::DescriptionLevel));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
|
|
|
|
|
(const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget,
|
|
|
|
|
FindGlobalFunctions,
|
|
|
|
|
(const char *, uint32_t, lldb::MatchType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType,
|
|
|
|
|
(lldb::BasicType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
|
|
|
|
|
(const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
|
|
|
|
|
(const char *, uint32_t, lldb::MatchType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
|
|
|
|
|
(const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
|
|
|
|
|
(lldb::SBAddress, uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
|
|
|
|
|
(lldb::SBAddress, uint32_t, const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
|
|
|
|
|
(lldb::SBSection, lldb::addr_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
|
|
|
|
|
(lldb::SBSection));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
|
|
|
|
|
(lldb::SBModule, int64_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
|
|
|
|
|
(lldb::SBModule));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
|
|
|
|
|
(const char *, lldb::SymbolType));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
|
|
|
|
|
(const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
|
|
|
|
|
(const char *, const lldb::SBExpressionOptions &));
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
|
|
|
|
|
(const lldb::SBLaunchInfo &));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|