[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- Target.cpp --------------------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
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
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2018-12-14 15:59:49 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2015-09-25 20:35:58 +00:00
|
|
|
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
|
2016-09-14 19:07:35 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointIDList.h"
|
2019-06-21 19:43:07 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointPrecondition.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolver.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointResolverAddress.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
|
2011-09-21 01:17:13 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolverFileRegex.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolverName.h"
|
2018-09-13 21:35:32 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolverScripted.h"
|
2011-10-14 00:42:25 +00:00
|
|
|
#include "lldb/Breakpoint/Watchpoint.h"
|
2010-12-14 02:59:59 +00:00
|
|
|
#include "lldb/Core/Debugger.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"
|
2017-10-25 21:05:31 +00:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2018-09-13 21:35:32 +00:00
|
|
|
#include "lldb/Core/SearchFilter.h"
|
2018-12-14 15:59:49 +00:00
|
|
|
#include "lldb/Core/Section.h"
|
2013-03-19 00:20:55 +00:00
|
|
|
#include "lldb/Core/SourceManager.h"
|
2014-01-27 23:43:24 +00:00
|
|
|
#include "lldb/Core/StreamFile.h"
|
2018-09-13 21:35:32 +00:00
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
2010-12-14 02:59:59 +00:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2020-01-16 22:43:07 -08:00
|
|
|
#include "lldb/Expression/ExpressionVariable.h"
|
2015-10-19 23:11:07 +00:00
|
|
|
#include "lldb/Expression/REPL.h"
|
2015-09-15 21:13:50 +00:00
|
|
|
#include "lldb/Expression/UserExpression.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Host/Host.h"
|
2017-07-18 13:14:01 +00:00
|
|
|
#include "lldb/Host/PosixApi.h"
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2012-06-04 23:19:54 +00:00
|
|
|
#include "lldb/Interpreter/OptionGroupWatchpoint.h"
|
2012-08-22 17:17:09 +00:00
|
|
|
#include "lldb/Interpreter/OptionValues.h"
|
|
|
|
|
#include "lldb/Interpreter/Property.h"
|
2015-08-26 06:04:54 +00:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2015-08-26 06:04:54 +00:00
|
|
|
#include "lldb/Symbol/Symbol.h"
|
2015-09-15 21:13:50 +00:00
|
|
|
#include "lldb/Target/Language.h"
|
2015-03-03 23:11:11 +00:00
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-06 01:12:00 +00:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2013-11-04 09:33:30 +00:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2020-07-17 08:36:38 +02:00
|
|
|
#include "lldb/Target/StackFrameRecognizer.h"
|
2013-11-05 03:57:19 +00:00
|
|
|
#include "lldb/Target/SystemRuntime.h"
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2018-12-14 15:59:49 +00:00
|
|
|
#include "lldb/Utility/Event.h"
|
2017-03-22 18:40:07 +00:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
2015-10-21 00:36:34 +00:00
|
|
|
#include "lldb/Utility/LLDBAssert.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-08-07 11:07:21 +00:00
|
|
|
#include "lldb/Utility/State.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2017-06-29 14:32:17 +00:00
|
|
|
#include "lldb/Utility/Timer.h"
|
2019-02-11 23:13:08 +00:00
|
|
|
|
2019-06-10 21:13:37 +00:00
|
|
|
#include "llvm/ADT/ScopeExit.h"
|
|
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <memory>
|
2018-12-14 15:59:49 +00:00
|
|
|
#include <mutex>
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2016-12-06 11:24:51 +00:00
|
|
|
constexpr std::chrono::milliseconds EvaluateExpressionOptions::default_timeout;
|
|
|
|
|
|
2017-10-25 21:05:31 +00:00
|
|
|
Target::Arch::Arch(const ArchSpec &spec)
|
|
|
|
|
: m_spec(spec),
|
|
|
|
|
m_plugin_up(PluginManager::CreateArchitectureInstance(spec)) {}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
const Target::Arch &Target::Arch::operator=(const ArchSpec &spec) {
|
2017-10-25 21:05:31 +00:00
|
|
|
m_spec = spec;
|
|
|
|
|
m_plugin_up = PluginManager::CreateArchitectureInstance(spec);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-16 06:50:00 +00:00
|
|
|
ConstString &Target::GetStaticBroadcasterClass() {
|
|
|
|
|
static ConstString class_name("lldb.target");
|
|
|
|
|
return class_name;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
Target::Target(Debugger &debugger, const ArchSpec &target_arch,
|
|
|
|
|
const lldb::PlatformSP &platform_sp, bool is_dummy_target)
|
|
|
|
|
: TargetProperties(this),
|
|
|
|
|
Broadcaster(debugger.GetBroadcasterManager(),
|
|
|
|
|
Target::GetStaticBroadcasterClass().AsCString()),
|
|
|
|
|
ExecutionContextScope(), m_debugger(debugger), m_platform_sp(platform_sp),
|
2018-04-13 18:02:39 +00:00
|
|
|
m_mutex(), m_arch(target_arch), m_images(this), m_section_load_history(),
|
|
|
|
|
m_breakpoint_list(false), m_internal_breakpoint_list(true),
|
|
|
|
|
m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
|
2020-01-23 13:49:54 -08:00
|
|
|
m_image_search_paths(ImageSearchPathsChanged, this),
|
2019-02-13 06:25:41 +00:00
|
|
|
m_source_manager_up(), m_stop_hooks(), m_stop_hook_next_id(0),
|
2018-04-13 18:02:39 +00:00
|
|
|
m_valid(true), m_suppress_stop_hooks(false),
|
|
|
|
|
m_is_dummy_target(is_dummy_target),
|
2020-07-17 08:36:38 +02:00
|
|
|
m_frame_recognizer_manager_up(
|
|
|
|
|
std::make_unique<StackFrameRecognizerManager>()),
|
2018-04-13 18:02:39 +00:00
|
|
|
m_stats_storage(static_cast<int>(StatisticKind::StatisticMax))
|
2016-05-19 05:13:57 +00:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
SetEventName(eBroadcastBitBreakpointChanged, "breakpoint-changed");
|
|
|
|
|
SetEventName(eBroadcastBitModulesLoaded, "modules-loaded");
|
|
|
|
|
SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded");
|
|
|
|
|
SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed");
|
|
|
|
|
SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-02-16 06:50:00 +00:00
|
|
|
CheckInWithManager();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-23 17:03:37 +00:00
|
|
|
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT),
|
|
|
|
|
"{0} Target::Target()", static_cast<void *>(this));
|
2017-10-25 21:05:31 +00:00
|
|
|
if (target_arch.IsValid()) {
|
2019-07-22 23:48:01 +00:00
|
|
|
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
|
2019-07-23 17:03:37 +00:00
|
|
|
"Target::Target created with architecture {0} ({1})",
|
2019-07-22 23:48:01 +00:00
|
|
|
target_arch.GetArchitectureName(),
|
|
|
|
|
target_arch.GetTriple().getTriple().c_str());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2020-03-11 10:26:03 -07:00
|
|
|
|
|
|
|
|
UpdateLaunchInfoFromProperties();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
Target::~Target() {
|
2016-05-19 05:13:57 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
|
2019-07-23 17:03:37 +00:00
|
|
|
LLDB_LOG(log, "{0} Target::~Target()", static_cast<void *>(this));
|
2015-10-23 18:39:37 +00:00
|
|
|
DeleteCurrentProcess();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-22 01:42:44 +00:00
|
|
|
void Target::PrimeFromDummyTarget(Target *target) {
|
|
|
|
|
if (!target)
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
2014-11-22 01:42:44 +00:00
|
|
|
m_stop_hooks = target->m_stop_hooks;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-02-13 16:48:38 +03:00
|
|
|
for (const auto &breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
|
2014-12-06 01:28:03 +00:00
|
|
|
if (breakpoint_sp->IsInternal())
|
|
|
|
|
continue;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-02-13 15:51:13 +03:00
|
|
|
BreakpointSP new_bp(
|
|
|
|
|
Breakpoint::CopyFromBreakpoint(shared_from_this(), *breakpoint_sp));
|
2020-02-13 16:48:38 +03:00
|
|
|
AddBreakpoint(std::move(new_bp), false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-07-19 00:56:26 +00:00
|
|
|
|
|
|
|
|
for (auto bp_name_entry : target->m_breakpoint_names) {
|
|
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
BreakpointName *new_bp_name = new BreakpointName(*bp_name_entry.second);
|
|
|
|
|
AddBreakpointName(new_bp_name);
|
|
|
|
|
}
|
2020-07-17 08:36:38 +02:00
|
|
|
|
|
|
|
|
m_frame_recognizer_manager_up = std::make_unique<StackFrameRecognizerManager>(
|
|
|
|
|
*target->m_frame_recognizer_manager_up);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-26 03:11:13 +00:00
|
|
|
void Target::Dump(Stream *s, lldb::DescriptionLevel description_level) {
|
2010-10-08 00:21:05 +00:00
|
|
|
// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
|
2010-10-26 03:11:13 +00:00
|
|
|
if (description_level != lldb::eDescriptionLevelBrief) {
|
|
|
|
|
s->Indent();
|
|
|
|
|
s->PutCString("Target\n");
|
|
|
|
|
s->IndentMore();
|
2010-10-29 04:59:35 +00:00
|
|
|
m_images.Dump(s);
|
|
|
|
|
m_breakpoint_list.Dump(s);
|
|
|
|
|
m_internal_breakpoint_list.Dump(s);
|
|
|
|
|
s->IndentLess();
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2011-08-11 02:48:45 +00:00
|
|
|
Module *exe_module = GetExecutableModulePointer();
|
|
|
|
|
if (exe_module)
|
|
|
|
|
s->PutCString(exe_module->GetFileSpec().GetFilename().GetCString());
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2011-05-12 01:12:28 +00:00
|
|
|
s->PutCString("No executable module.");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-05 00:16:59 +00:00
|
|
|
void Target::CleanupProcess() {
|
|
|
|
|
// Do any cleanup of the target we need to do between process instances.
|
|
|
|
|
// NB It is better to do this before destroying the process in case the
|
|
|
|
|
// clean up needs some help from the process.
|
|
|
|
|
m_breakpoint_list.ClearAllBreakpointSites();
|
|
|
|
|
m_internal_breakpoint_list.ClearAllBreakpointSites();
|
|
|
|
|
// Disable watchpoints just on the debugger side.
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
this->GetWatchpointList().GetListMutex(lock);
|
2012-12-05 00:16:59 +00:00
|
|
|
DisableAllWatchpoints(false);
|
|
|
|
|
ClearAllWatchpointHitCounts();
|
2015-02-11 00:37:54 +00:00
|
|
|
ClearAllWatchpointHistoricValues();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::DeleteCurrentProcess() {
|
2015-12-11 19:52:15 +00:00
|
|
|
if (m_process_sp) {
|
2013-12-06 01:12:00 +00:00
|
|
|
m_section_load_history.Clear();
|
2010-06-08 16:52:24 +00:00
|
|
|
if (m_process_sp->IsAlive())
|
2015-04-17 05:01:58 +00:00
|
|
|
m_process_sp->Destroy(false);
|
2014-04-04 04:06:10 +00:00
|
|
|
|
2012-02-16 06:50:00 +00:00
|
|
|
m_process_sp->Finalize();
|
2010-10-31 03:01:06 +00:00
|
|
|
|
2016-05-19 05:13:57 +00:00
|
|
|
CleanupProcess();
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
m_process_sp.reset();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-10-23 18:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp,
|
2016-11-17 21:15:14 +00:00
|
|
|
llvm::StringRef plugin_name,
|
2014-12-06 01:28:03 +00:00
|
|
|
const FileSpec *crash_file) {
|
2019-01-07 10:59:57 +00:00
|
|
|
if (!listener_sp)
|
|
|
|
|
listener_sp = GetDebugger().GetListener();
|
2014-12-06 01:28:03 +00:00
|
|
|
DeleteCurrentProcess();
|
|
|
|
|
m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name,
|
|
|
|
|
listener_sp, crash_file);
|
|
|
|
|
return m_process_sp;
|
2014-11-22 01:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-26 03:11:13 +00:00
|
|
|
const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
|
2012-12-05 00:16:59 +00:00
|
|
|
const char *repl_options, bool can_create) {
|
2016-05-19 05:13:57 +00:00
|
|
|
if (language == eLanguageTypeUnknown) {
|
2019-08-22 21:45:58 +00:00
|
|
|
LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-08-22 21:45:58 +00:00
|
|
|
if (auto single_lang = repl_languages.GetSingularLanguage()) {
|
|
|
|
|
language = *single_lang;
|
|
|
|
|
} else if (repl_languages.Empty()) {
|
2010-06-08 16:52:24 +00:00
|
|
|
err.SetErrorStringWithFormat(
|
2016-04-21 00:56:08 +00:00
|
|
|
"LLDB isn't configured with REPL support for any languages.");
|
2015-10-21 19:31:17 +00:00
|
|
|
return REPLSP();
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2016-04-21 00:56:08 +00:00
|
|
|
err.SetErrorStringWithFormat(
|
2010-06-08 16:52:24 +00:00
|
|
|
"Multiple possible REPL languages. Please specify a language.");
|
2015-10-21 19:31:17 +00:00
|
|
|
return REPLSP();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-07 21:50:25 +00:00
|
|
|
REPLMap::iterator pos = m_repl_map.find(language);
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
if (pos != m_repl_map.end()) {
|
|
|
|
|
return pos->second;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-20 00:23:46 +00:00
|
|
|
if (!can_create) {
|
2015-10-21 19:14:33 +00:00
|
|
|
err.SetErrorStringWithFormat(
|
2015-10-20 00:23:46 +00:00
|
|
|
"Couldn't find an existing REPL for %s, and can't create a new one",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
|
|
|
|
return lldb::REPLSP();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 00:28:44 +00:00
|
|
|
Debugger *const debugger = nullptr;
|
|
|
|
|
lldb::REPLSP ret = REPL::Create(err, language, debugger, this, repl_options);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
|
|
|
|
if (ret) {
|
2015-10-19 23:11:07 +00:00
|
|
|
m_repl_map[language] = ret;
|
|
|
|
|
return m_repl_map[language];
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-20 00:23:46 +00:00
|
|
|
if (err.Success()) {
|
|
|
|
|
err.SetErrorStringWithFormat("Couldn't create a REPL for %s",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 23:11:07 +00:00
|
|
|
return lldb::REPLSP();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 00:36:34 +00:00
|
|
|
void Target::SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp) {
|
|
|
|
|
lldbassert(!m_repl_map.count(language));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-21 00:36:34 +00:00
|
|
|
m_repl_map[language] = repl_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-10 02:10:13 +00:00
|
|
|
void Target::Destroy() {
|
2016-05-19 05:13:57 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2012-05-19 09:59:08 +00:00
|
|
|
m_valid = false;
|
2010-06-08 16:52:24 +00:00
|
|
|
DeleteCurrentProcess();
|
2011-08-10 02:10:13 +00:00
|
|
|
m_platform_sp.reset();
|
2017-10-25 21:05:31 +00:00
|
|
|
m_arch = ArchSpec();
|
2013-11-09 00:03:31 +00:00
|
|
|
ClearModules(true);
|
2013-12-06 01:12:00 +00:00
|
|
|
m_section_load_history.Clear();
|
2011-08-10 02:10:13 +00:00
|
|
|
const bool notify = false;
|
|
|
|
|
m_breakpoint_list.RemoveAll(notify);
|
|
|
|
|
m_internal_breakpoint_list.RemoveAll(notify);
|
|
|
|
|
m_last_created_breakpoint.reset();
|
2011-10-14 00:42:25 +00:00
|
|
|
m_last_created_watchpoint.reset();
|
2011-08-10 02:10:13 +00:00
|
|
|
m_search_filter_sp.reset();
|
|
|
|
|
m_image_search_paths.Clear(notify);
|
|
|
|
|
m_stop_hooks.clear();
|
|
|
|
|
m_stop_hook_next_id = 0;
|
|
|
|
|
m_suppress_stop_hooks = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
BreakpointList &Target::GetBreakpointList(bool internal) {
|
|
|
|
|
if (internal)
|
|
|
|
|
return m_internal_breakpoint_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_breakpoint_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
const BreakpointList &Target::GetBreakpointList(bool internal) const {
|
|
|
|
|
if (internal)
|
|
|
|
|
return m_internal_breakpoint_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_breakpoint_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
BreakpointSP Target::GetBreakpointByID(break_id_t break_id) {
|
|
|
|
|
BreakpointSP bp_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
|
|
|
|
|
bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2010-06-08 16:52:24 +00:00
|
|
|
bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
return bp_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-10 23:46:59 +00:00
|
|
|
BreakpointSP Target::CreateSourceRegexBreakpoint(
|
2011-09-23 00:54:11 +00:00
|
|
|
const FileSpecList *containingModules,
|
<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 FileSpecList *source_file_spec_list,
|
2016-04-28 01:40:57 +00:00
|
|
|
const std::unordered_set<std::string> &function_names,
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression source_regex, bool internal, bool hardware,
|
2015-05-18 13:41:01 +00:00
|
|
|
LazyBool move_to_nearest_code) {
|
2011-09-23 00:54:11 +00:00
|
|
|
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
|
|
|
|
|
containingModules, source_file_spec_list));
|
2015-05-18 13:41:01 +00:00
|
|
|
if (move_to_nearest_code == eLazyBoolCalculate)
|
|
|
|
|
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
|
2016-04-28 01:40:57 +00:00
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex(
|
2019-09-04 09:47:18 +00:00
|
|
|
nullptr, std::move(source_regex), function_names,
|
2016-04-28 01:40:57 +00:00
|
|
|
!static_cast<bool>(move_to_nearest_code)));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-01-10 23:46:59 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
BreakpointSP Target::CreateBreakpoint(const FileSpecList *containingModules,
|
2016-03-07 21:50:25 +00:00
|
|
|
const FileSpec &file, uint32_t line_no,
|
2018-08-30 15:11:00 +00:00
|
|
|
uint32_t column, lldb::addr_t offset,
|
<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
|
|
|
LazyBool check_inlines,
|
2015-04-22 19:42:18 +00:00
|
|
|
LazyBool skip_prologue, bool internal,
|
2015-05-18 13:41:01 +00:00
|
|
|
bool hardware,
|
|
|
|
|
LazyBool move_to_nearest_code) {
|
2016-03-04 11:26:44 +00:00
|
|
|
FileSpec remapped_file;
|
2018-05-21 14:14:36 +00:00
|
|
|
if (!GetSourcePathMap().ReverseRemapPath(file, remapped_file))
|
2016-03-04 11:26:44 +00:00
|
|
|
remapped_file = file;
|
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
|
|
|
if (check_inlines == eLazyBoolCalculate) {
|
|
|
|
|
const InlineStrategy inline_strategy = GetInlineStrategy();
|
|
|
|
|
switch (inline_strategy) {
|
|
|
|
|
case eInlineBreakpointsNever:
|
|
|
|
|
check_inlines = eLazyBoolNo;
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
|
<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
|
|
|
case eInlineBreakpointsHeaders:
|
2016-03-04 11:26:44 +00:00
|
|
|
if (remapped_file.IsSourceImplementationFile())
|
<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
|
|
|
check_inlines = eLazyBoolNo;
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
<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
|
|
|
check_inlines = eLazyBoolYes;
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
|
<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
|
|
|
case eInlineBreakpointsAlways:
|
|
|
|
|
check_inlines = eLazyBoolYes;
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-07 23:48:57 +00:00
|
|
|
SearchFilterSP filter_sp;
|
|
|
|
|
if (check_inlines == eLazyBoolNo) {
|
|
|
|
|
// Not checking for inlines, we are looking only for matching compile units
|
|
|
|
|
FileSpecList compile_unit_list;
|
2016-03-04 11:26:44 +00:00
|
|
|
compile_unit_list.Append(remapped_file);
|
2012-09-07 23:48:57 +00:00
|
|
|
filter_sp = GetSearchFilterForModuleAndCUList(containingModules,
|
|
|
|
|
&compile_unit_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-09-07 23:48:57 +00:00
|
|
|
filter_sp = GetSearchFilterForModuleList(containingModules);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-04-19 21:31:16 +00:00
|
|
|
if (skip_prologue == eLazyBoolCalculate)
|
|
|
|
|
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
|
2015-05-18 13:41:01 +00:00
|
|
|
if (move_to_nearest_code == eLazyBoolCalculate)
|
|
|
|
|
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine(
|
2018-08-30 15:11:00 +00:00
|
|
|
nullptr, remapped_file, line_no, column, offset, check_inlines,
|
|
|
|
|
skip_prologue, !static_cast<bool>(move_to_nearest_code)));
|
2014-01-10 23:46:59 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:48:25 +00:00
|
|
|
BreakpointSP Target::CreateBreakpoint(lldb::addr_t addr, bool internal,
|
|
|
|
|
bool hardware) {
|
2010-06-08 16:52:24 +00:00
|
|
|
Address so_addr;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-08-26 06:04:54 +00:00
|
|
|
// Check for any reason we want to move this breakpoint to other address.
|
|
|
|
|
addr = GetBreakableLoadAddress(addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Attempt to resolve our load address if possible, though it is ok if it
|
|
|
|
|
// doesn't resolve to section/offset.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 00:45:41 +00:00
|
|
|
// Try and resolve as a load address if possible
|
2013-12-06 01:12:00 +00:00
|
|
|
GetSectionLoadList().ResolveLoadAddress(addr, so_addr);
|
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 00:45:41 +00:00
|
|
|
if (!so_addr.IsValid()) {
|
|
|
|
|
// The address didn't resolve, so just set this as an absolute address
|
|
|
|
|
so_addr.SetOffset(addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-10-11 19:48:25 +00:00
|
|
|
BreakpointSP bp_sp(CreateBreakpoint(so_addr, internal, hardware));
|
2010-06-08 16:52:24 +00:00
|
|
|
return bp_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 03:39:13 +00:00
|
|
|
BreakpointSP Target::CreateBreakpoint(const Address &addr, bool internal,
|
2013-10-11 19:48:25 +00:00
|
|
|
bool hardware) {
|
2011-09-23 00:54:11 +00:00
|
|
|
SearchFilterSP filter_sp(
|
2014-12-06 01:28:03 +00:00
|
|
|
new SearchFilterForUnconstrainedSearches(shared_from_this()));
|
2016-03-09 18:59:13 +00:00
|
|
|
BreakpointResolverSP resolver_sp(
|
2015-12-11 19:52:15 +00:00
|
|
|
new BreakpointResolverAddress(nullptr, addr));
|
2014-01-10 23:46:59 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, false);
|
2015-10-19 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 00:36:34 +00:00
|
|
|
lldb::BreakpointSP
|
|
|
|
|
Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal,
|
2011-08-10 02:10:13 +00:00
|
|
|
const FileSpec *file_spec,
|
2011-10-14 00:42:25 +00:00
|
|
|
bool request_hardware) {
|
|
|
|
|
SearchFilterSP filter_sp(
|
2011-08-10 02:10:13 +00:00
|
|
|
new SearchFilterForUnconstrainedSearches(shared_from_this()));
|
2019-11-28 17:02:07 +01:00
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(
|
|
|
|
|
nullptr, file_addr, file_spec ? *file_spec : FileSpec()));
|
2010-06-08 16:52:24 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, request_hardware,
|
|
|
|
|
false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-25 20:45:40 +00:00
|
|
|
BreakpointSP Target::CreateBreakpoint(
|
|
|
|
|
const FileSpecList *containingModules,
|
|
|
|
|
const FileSpecList *containingSourceFiles, const char *func_name,
|
|
|
|
|
FunctionNameType func_name_type_mask, LanguageType language,
|
|
|
|
|
lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) {
|
2011-09-23 00:54:11 +00:00
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
if (func_name) {
|
|
|
|
|
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
|
|
|
|
|
containingModules, containingSourceFiles));
|
2011-09-21 01:17:13 +00:00
|
|
|
|
2013-04-19 21:31:16 +00:00
|
|
|
if (skip_prologue == eLazyBoolCalculate)
|
|
|
|
|
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
|
2013-10-11 19:48:25 +00:00
|
|
|
if (language == lldb::eLanguageTypeUnknown)
|
2013-12-06 01:12:00 +00:00
|
|
|
language = GetLanguage();
|
2015-11-17 03:39:13 +00:00
|
|
|
|
2015-12-11 19:52:15 +00:00
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverName(
|
2016-03-09 18:59:13 +00:00
|
|
|
nullptr, func_name, func_name_type_mask, language, Breakpoint::Exact,
|
2012-05-22 00:12:20 +00:00
|
|
|
offset, skip_prologue));
|
2016-03-09 18:59:13 +00:00
|
|
|
bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2010-06-28 21:30:43 +00:00
|
|
|
}
|
|
|
|
|
return bp_sp;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-06 00:37:27 +00:00
|
|
|
lldb::BreakpointSP
|
|
|
|
|
Target::CreateBreakpoint(const FileSpecList *containingModules,
|
2012-05-15 02:33:01 +00:00
|
|
|
const FileSpecList *containingSourceFiles,
|
|
|
|
|
const std::vector<std::string> &func_names,
|
2018-10-25 20:45:40 +00:00
|
|
|
FunctionNameType func_name_type_mask,
|
|
|
|
|
LanguageType language, lldb::addr_t offset,
|
|
|
|
|
LazyBool skip_prologue, bool internal, bool hardware) {
|
2012-03-06 00:37:27 +00:00
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
size_t num_names = func_names.size();
|
2016-03-09 18:59:13 +00:00
|
|
|
if (num_names > 0) {
|
2014-01-10 23:46:59 +00:00
|
|
|
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
|
|
|
|
|
containingModules, containingSourceFiles));
|
2012-03-06 00:37:27 +00:00
|
|
|
|
2012-03-03 02:05:11 +00:00
|
|
|
if (skip_prologue == eLazyBoolCalculate)
|
|
|
|
|
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
|
2015-07-21 22:05:07 +00:00
|
|
|
if (language == lldb::eLanguageTypeUnknown)
|
2016-03-09 18:59:13 +00:00
|
|
|
language = GetLanguage();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
BreakpointResolverSP resolver_sp(
|
|
|
|
|
new BreakpointResolverName(nullptr, func_names, func_name_type_mask,
|
2012-05-22 00:12:20 +00:00
|
|
|
language, offset, skip_prologue));
|
2012-03-03 02:05:11 +00:00
|
|
|
bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-03-03 02:05:11 +00:00
|
|
|
return bp_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-25 20:45:40 +00:00
|
|
|
BreakpointSP
|
|
|
|
|
Target::CreateBreakpoint(const FileSpecList *containingModules,
|
|
|
|
|
const FileSpecList *containingSourceFiles,
|
|
|
|
|
const char *func_names[], size_t num_names,
|
|
|
|
|
FunctionNameType func_name_type_mask,
|
|
|
|
|
LanguageType language, lldb::addr_t offset,
|
|
|
|
|
LazyBool skip_prologue, bool internal, bool hardware) {
|
2010-06-28 21:30:43 +00:00
|
|
|
BreakpointSP bp_sp;
|
2016-03-09 18:59:13 +00:00
|
|
|
if (num_names > 0) {
|
|
|
|
|
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
|
|
|
|
|
containingModules, containingSourceFiles));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-03-09 18:59:13 +00:00
|
|
|
if (skip_prologue == eLazyBoolCalculate) {
|
|
|
|
|
if (offset == 0)
|
|
|
|
|
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
|
2015-07-21 22:05:07 +00:00
|
|
|
else
|
2016-03-09 18:59:13 +00:00
|
|
|
skip_prologue = eLazyBoolNo;
|
2012-03-03 02:05:11 +00:00
|
|
|
}
|
2015-07-21 22:05:07 +00:00
|
|
|
if (language == lldb::eLanguageTypeUnknown)
|
2012-03-03 02:05:11 +00:00
|
|
|
language = GetLanguage();
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverName(
|
|
|
|
|
nullptr, func_names, num_names, func_name_type_mask, language, offset,
|
2012-01-29 20:56:30 +00:00
|
|
|
skip_prologue));
|
|
|
|
|
resolver_sp->SetOffset(offset);
|
|
|
|
|
bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
return bp_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-21 01:17:13 +00:00
|
|
|
SearchFilterSP
|
|
|
|
|
Target::GetSearchFilterForModule(const FileSpec *containingModule) {
|
|
|
|
|
SearchFilterSP filter_sp;
|
|
|
|
|
if (containingModule != nullptr) {
|
|
|
|
|
// TODO: We should look into sharing module based search filters
|
|
|
|
|
// across many breakpoints like we do for the simple target based one
|
2019-02-11 23:13:08 +00:00
|
|
|
filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
|
|
|
|
|
*containingModule);
|
2011-09-21 01:17:13 +00:00
|
|
|
} else {
|
2015-12-11 19:52:15 +00:00
|
|
|
if (!m_search_filter_sp)
|
2019-02-11 23:13:08 +00:00
|
|
|
m_search_filter_sp =
|
|
|
|
|
std::make_shared<SearchFilterForUnconstrainedSearches>(
|
|
|
|
|
shared_from_this());
|
2011-09-21 01:17:13 +00:00
|
|
|
filter_sp = m_search_filter_sp;
|
|
|
|
|
}
|
|
|
|
|
return filter_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
SearchFilterSP
|
2012-05-22 00:12:20 +00:00
|
|
|
Target::GetSearchFilterForModuleList(const FileSpecList *containingModules) {
|
|
|
|
|
SearchFilterSP filter_sp;
|
2015-12-11 19:52:15 +00:00
|
|
|
if (containingModules && containingModules->GetSize() != 0) {
|
|
|
|
|
// TODO: We should look into sharing module based search filters
|
2011-09-23 00:54:11 +00:00
|
|
|
// across many breakpoints like we do for the simple target based one
|
2019-02-11 23:13:08 +00:00
|
|
|
filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
|
|
|
|
|
*containingModules);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-12-11 19:52:15 +00:00
|
|
|
if (!m_search_filter_sp)
|
2019-02-11 23:13:08 +00:00
|
|
|
m_search_filter_sp =
|
|
|
|
|
std::make_shared<SearchFilterForUnconstrainedSearches>(
|
|
|
|
|
shared_from_this());
|
2011-09-23 00:54:11 +00:00
|
|
|
filter_sp = m_search_filter_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-11-17 03:39:13 +00:00
|
|
|
return filter_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
SearchFilterSP Target::GetSearchFilterForModuleAndCUList(
|
2015-12-11 19:52:15 +00:00
|
|
|
const FileSpecList *containingModules,
|
2012-03-03 02:05:11 +00:00
|
|
|
const FileSpecList *containingSourceFiles) {
|
2015-12-11 19:52:15 +00:00
|
|
|
if (containingSourceFiles == nullptr || containingSourceFiles->GetSize() == 0)
|
2011-09-23 00:54:11 +00:00
|
|
|
return GetSearchFilterForModuleList(containingModules);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SearchFilterSP filter_sp;
|
2011-09-23 00:54:11 +00:00
|
|
|
if (containingModules == nullptr) {
|
|
|
|
|
// We could make a special "CU List only SearchFilter". Better yet was if
|
2018-04-30 16:49:04 +00:00
|
|
|
// these could be composable, but that will take a little reworking.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
|
|
|
|
|
shared_from_this(), FileSpecList(), *containingSourceFiles);
|
2011-09-23 00:54:11 +00:00
|
|
|
} else {
|
2019-02-11 23:13:08 +00:00
|
|
|
filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
|
|
|
|
|
shared_from_this(), *containingModules, *containingSourceFiles);
|
2011-09-23 00:54:11 +00:00
|
|
|
}
|
|
|
|
|
return filter_sp;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
BreakpointSP Target::CreateFuncRegexBreakpoint(
|
|
|
|
|
const FileSpecList *containingModules,
|
2019-09-04 09:47:18 +00:00
|
|
|
const FileSpecList *containingSourceFiles, RegularExpression func_regex,
|
2015-11-06 22:48:59 +00:00
|
|
|
lldb::LanguageType requested_language, LazyBool skip_prologue,
|
2013-10-11 19:48:25 +00:00
|
|
|
bool internal, bool hardware) {
|
2011-09-23 00:54:11 +00:00
|
|
|
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
|
|
|
|
|
containingModules, containingSourceFiles));
|
2014-07-23 01:53:52 +00:00
|
|
|
bool skip = (skip_prologue == eLazyBoolCalculate)
|
|
|
|
|
? GetSkipPrologue()
|
|
|
|
|
: static_cast<bool>(skip_prologue);
|
2016-03-09 18:59:13 +00:00
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverName(
|
2019-09-04 09:47:18 +00:00
|
|
|
nullptr, std::move(func_regex), requested_language, 0, skip));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-01-10 23:46:59 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-05 04:47:34 +00:00
|
|
|
lldb::BreakpointSP
|
2015-04-22 19:42:18 +00:00
|
|
|
Target::CreateExceptionBreakpoint(enum lldb::LanguageType language,
|
|
|
|
|
bool catch_bp, bool throw_bp, bool internal,
|
2017-05-12 04:51:55 +00:00
|
|
|
Args *additional_args, Status *error) {
|
2015-04-22 19:42:18 +00:00
|
|
|
BreakpointSP exc_bkpt_sp = LanguageRuntime::CreateExceptionBreakpoint(
|
|
|
|
|
*this, language, catch_bp, throw_bp, internal);
|
|
|
|
|
if (exc_bkpt_sp && additional_args) {
|
2019-06-21 19:43:07 +00:00
|
|
|
BreakpointPreconditionSP precondition_sp = exc_bkpt_sp->GetPrecondition();
|
2015-04-22 19:42:18 +00:00
|
|
|
if (precondition_sp && additional_args) {
|
|
|
|
|
if (error)
|
|
|
|
|
*error = precondition_sp->ConfigurePrecondition(*additional_args);
|
|
|
|
|
else
|
|
|
|
|
precondition_sp->ConfigurePrecondition(*additional_args);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-04-22 19:42:18 +00:00
|
|
|
return exc_bkpt_sp;
|
2012-03-05 04:47:34 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
lldb::BreakpointSP Target::CreateScriptedBreakpoint(
|
|
|
|
|
const llvm::StringRef class_name, const FileSpecList *containingModules,
|
|
|
|
|
const FileSpecList *containingSourceFiles, bool internal,
|
|
|
|
|
bool request_hardware, StructuredData::ObjectSP extra_args_sp,
|
|
|
|
|
Status *creation_error) {
|
2018-09-13 21:35:32 +00:00
|
|
|
SearchFilterSP filter_sp;
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2018-09-13 21:35:32 +00:00
|
|
|
lldb::SearchDepth depth = lldb::eSearchDepthTarget;
|
2019-07-19 00:56:26 +00:00
|
|
|
bool has_files =
|
|
|
|
|
containingSourceFiles && containingSourceFiles->GetSize() > 0;
|
2018-09-13 21:35:32 +00:00
|
|
|
bool has_modules = containingModules && containingModules->GetSize() > 0;
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2018-09-13 21:35:32 +00:00
|
|
|
if (has_files && has_modules) {
|
2019-07-19 00:56:26 +00:00
|
|
|
filter_sp = GetSearchFilterForModuleAndCUList(containingModules,
|
|
|
|
|
containingSourceFiles);
|
2018-09-13 21:35:32 +00:00
|
|
|
} else if (has_files) {
|
2019-07-19 00:56:26 +00:00
|
|
|
filter_sp =
|
|
|
|
|
GetSearchFilterForModuleAndCUList(nullptr, containingSourceFiles);
|
2018-09-13 21:35:32 +00:00
|
|
|
} else if (has_modules) {
|
|
|
|
|
filter_sp = GetSearchFilterForModuleList(containingModules);
|
|
|
|
|
} else {
|
2019-02-11 23:13:08 +00:00
|
|
|
filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
|
|
|
|
|
shared_from_this());
|
2018-09-13 21:35:32 +00:00
|
|
|
}
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2018-09-13 21:35:32 +00:00
|
|
|
StructuredDataImpl *extra_args_impl = new StructuredDataImpl();
|
|
|
|
|
if (extra_args_sp)
|
|
|
|
|
extra_args_impl->SetObjectSP(extra_args_sp);
|
2019-04-26 22:43:16 +00:00
|
|
|
|
|
|
|
|
BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
|
2019-10-10 17:44:50 +00:00
|
|
|
nullptr, class_name, depth, extra_args_impl));
|
2018-09-13 21:35:32 +00:00
|
|
|
return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-10 23:46:59 +00:00
|
|
|
BreakpointSP Target::CreateBreakpoint(SearchFilterSP &filter_sp,
|
|
|
|
|
BreakpointResolverSP &resolver_sp,
|
|
|
|
|
bool internal, bool request_hardware,
|
|
|
|
|
bool resolve_indirect_symbols) {
|
2010-06-08 16:52:24 +00:00
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
if (filter_sp && resolver_sp) {
|
2018-11-15 01:18:15 +00:00
|
|
|
const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
|
|
|
|
|
bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
|
2014-01-10 23:46:59 +00:00
|
|
|
resolve_indirect_symbols));
|
2020-03-03 13:29:12 +03:00
|
|
|
resolver_sp->SetBreakpoint(bp_sp);
|
2014-12-06 01:28:03 +00:00
|
|
|
AddBreakpoint(bp_sp, internal);
|
|
|
|
|
}
|
|
|
|
|
return bp_sp;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) {
|
|
|
|
|
if (!bp_sp)
|
|
|
|
|
return;
|
|
|
|
|
if (internal)
|
|
|
|
|
m_internal_breakpoint_list.Add(bp_sp, false);
|
|
|
|
|
else
|
|
|
|
|
m_breakpoint_list.Add(bp_sp, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
|
|
|
|
if (log) {
|
|
|
|
|
StreamString s;
|
|
|
|
|
bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (internal = %s) => break_id = %s\n",
|
|
|
|
|
__FUNCTION__, bp_sp->IsInternal() ? "yes" : "no", s.GetData());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
bp_sp->ResolveBreakpoint();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
if (!internal) {
|
2010-10-14 23:45:03 +00:00
|
|
|
m_last_created_breakpoint = bp_sp;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void Target::AddNameToBreakpoint(BreakpointID &id, const char *name,
|
|
|
|
|
Status &error) {
|
|
|
|
|
BreakpointSP bp_sp =
|
|
|
|
|
m_breakpoint_list.FindBreakpointByID(id.GetBreakpointID());
|
|
|
|
|
if (!bp_sp) {
|
|
|
|
|
StreamString s;
|
|
|
|
|
id.GetDescription(&s, eDescriptionLevelBrief);
|
|
|
|
|
error.SetErrorStringWithFormat("Could not find breakpoint %s", s.GetData());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AddNameToBreakpoint(bp_sp, name, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::AddNameToBreakpoint(BreakpointSP &bp_sp, const char *name,
|
|
|
|
|
Status &error) {
|
|
|
|
|
if (!bp_sp)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BreakpointName *bp_name = FindBreakpointName(ConstString(name), true, error);
|
|
|
|
|
if (!bp_name)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bp_name->ConfigureBreakpoint(bp_sp);
|
|
|
|
|
bp_sp->AddName(name);
|
|
|
|
|
}
|
2017-09-14 20:22:49 +00:00
|
|
|
|
|
|
|
|
void Target::AddBreakpointName(BreakpointName *bp_name) {
|
|
|
|
|
m_breakpoint_names.insert(std::make_pair(bp_name->GetName(), bp_name));
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
BreakpointName *Target::FindBreakpointName(ConstString name, bool can_create,
|
|
|
|
|
Status &error) {
|
2017-09-14 20:22:49 +00:00
|
|
|
BreakpointID::StringIsBreakpointName(name.GetStringRef(), error);
|
|
|
|
|
if (!error.Success())
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
|
|
|
|
|
if (iter == m_breakpoint_names.end()) {
|
2019-07-19 00:56:26 +00:00
|
|
|
if (!can_create) {
|
2017-09-14 20:22:49 +00:00
|
|
|
error.SetErrorStringWithFormat("Breakpoint name \"%s\" doesn't exist and "
|
2019-07-19 00:56:26 +00:00
|
|
|
"can_create is false.",
|
|
|
|
|
name.AsCString());
|
2017-09-14 20:22:49 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
iter = m_breakpoint_names
|
|
|
|
|
.insert(std::make_pair(name, new BreakpointName(name)))
|
|
|
|
|
.first;
|
2017-09-14 20:22:49 +00:00
|
|
|
}
|
|
|
|
|
return (iter->second);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void Target::DeleteBreakpointName(ConstString name) {
|
2017-09-14 20:22:49 +00:00
|
|
|
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
if (iter != m_breakpoint_names.end()) {
|
|
|
|
|
const char *name_cstr = name.AsCString();
|
|
|
|
|
m_breakpoint_names.erase(iter);
|
|
|
|
|
for (auto bp_sp : m_breakpoint_list.Breakpoints())
|
|
|
|
|
bp_sp->RemoveName(name_cstr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
|
2019-07-19 00:56:26 +00:00
|
|
|
ConstString name) {
|
2017-09-14 20:22:49 +00:00
|
|
|
bp_sp->RemoveName(name.AsCString());
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void Target::ConfigureBreakpointName(
|
|
|
|
|
BreakpointName &bp_name, const BreakpointOptions &new_options,
|
|
|
|
|
const BreakpointName::Permissions &new_permissions) {
|
2017-09-14 20:22:49 +00:00
|
|
|
bp_name.GetOptions().CopyOverSetOptions(new_options);
|
|
|
|
|
bp_name.GetPermissions().MergeInto(new_permissions);
|
|
|
|
|
ApplyNameToBreakpoints(bp_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) {
|
2019-11-22 12:59:46 -05:00
|
|
|
llvm::Expected<std::vector<BreakpointSP>> expected_vector =
|
|
|
|
|
m_breakpoint_list.FindBreakpointsByName(bp_name.GetName().AsCString());
|
2017-09-14 20:22:49 +00:00
|
|
|
|
2019-11-22 12:59:46 -05:00
|
|
|
if (!expected_vector) {
|
|
|
|
|
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS),
|
|
|
|
|
"invalid breakpoint name: {}",
|
|
|
|
|
llvm::toString(expected_vector.takeError()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto bp_sp : *expected_vector)
|
2017-09-14 20:22:49 +00:00
|
|
|
bp_name.ConfigureBreakpoint(bp_sp);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void Target::GetBreakpointNames(std::vector<std::string> &names) {
|
2017-09-14 20:22:49 +00:00
|
|
|
names.clear();
|
|
|
|
|
for (auto bp_name : m_breakpoint_names) {
|
|
|
|
|
names.push_back(bp_name.first.AsCString());
|
|
|
|
|
}
|
2019-01-08 23:25:06 +00:00
|
|
|
llvm::sort(names.begin(), names.end());
|
2017-09-14 20:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-20 23:28:55 +00:00
|
|
|
bool Target::ProcessIsValid() {
|
|
|
|
|
return (m_process_sp && m_process_sp->IsAlive());
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-11-09 22:33:26 +00:00
|
|
|
static bool CheckIfWatchpointsSupported(Target *target, Status &error) {
|
2012-06-04 23:19:54 +00:00
|
|
|
uint32_t num_supported_hardware_watchpoints;
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = target->GetProcessSP()->GetWatchpointSupportInfo(
|
2012-06-04 23:19:54 +00:00
|
|
|
num_supported_hardware_watchpoints);
|
2018-11-09 22:33:26 +00:00
|
|
|
|
|
|
|
|
// If unable to determine the # of watchpoints available,
|
|
|
|
|
// assume they are supported.
|
|
|
|
|
if (rc.Fail())
|
|
|
|
|
return true;
|
|
|
|
|
|
2016-06-27 12:35:41 +00:00
|
|
|
if (num_supported_hardware_watchpoints == 0) {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Target supports (%u) hardware watchpoint slots.\n",
|
|
|
|
|
num_supported_hardware_watchpoints);
|
|
|
|
|
return false;
|
2012-06-04 23:19:54 +00:00
|
|
|
}
|
2016-06-27 12:35:41 +00:00
|
|
|
return true;
|
2012-06-04 23:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// See also Watchpoint::SetWatchpointType(uint32_t type) and the
|
|
|
|
|
// OptionGroupWatchpoint::WatchType enum type.
|
2015-08-11 22:53:00 +00:00
|
|
|
WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
|
|
|
|
|
const CompilerType *type, uint32_t kind,
|
2017-05-12 04:51:55 +00:00
|
|
|
Status &error) {
|
2012-06-04 23:19:54 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Target::%s (addr = 0x%8.8" PRIx64 " size = %" PRIu64
|
|
|
|
|
" type = %u)\n",
|
|
|
|
|
__FUNCTION__, addr, (uint64_t)size, kind);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp;
|
2013-06-18 21:52:48 +00:00
|
|
|
if (!ProcessIsValid()) {
|
2012-12-18 02:03:49 +00:00
|
|
|
error.SetErrorString("process is not alive");
|
|
|
|
|
return wp_sp;
|
2011-09-14 22:20:15 +00:00
|
|
|
}
|
2011-09-14 20:23:45 +00:00
|
|
|
|
2012-06-04 23:19:54 +00:00
|
|
|
if (addr == LLDB_INVALID_ADDRESS || size == 0) {
|
2016-06-27 12:35:41 +00:00
|
|
|
if (size == 0)
|
|
|
|
|
error.SetErrorString("cannot set a watchpoint with watch_size of 0");
|
2011-09-27 20:29:45 +00:00
|
|
|
else
|
2011-10-14 00:42:25 +00:00
|
|
|
error.SetErrorStringWithFormat("invalid watch address: %" PRIu64, addr);
|
|
|
|
|
return wp_sp;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-27 23:08:40 +00:00
|
|
|
if (!LLDB_WATCH_TYPE_IS_VALID(kind)) {
|
|
|
|
|
error.SetErrorStringWithFormat("invalid watchpoint type: %d", kind);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-09 22:33:26 +00:00
|
|
|
if (!CheckIfWatchpointsSupported(this, error))
|
2010-06-08 16:52:24 +00:00
|
|
|
return wp_sp;
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Currently we only support one watchpoint per address, with total number of
|
|
|
|
|
// watchpoints limited by the hardware which the inferior is running on.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-05-31 22:56:36 +00:00
|
|
|
// Grab the list mutex while doing operations.
|
2012-12-18 02:03:49 +00:00
|
|
|
const bool notify = false; // Don't notify about all the state changes we do
|
|
|
|
|
// on creating the watchpoint.
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
this->GetWatchpointList().GetListMutex(lock);
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
|
2010-06-08 16:52:24 +00:00
|
|
|
if (matched_sp) {
|
|
|
|
|
size_t old_size = matched_sp->GetByteSize();
|
2011-09-13 23:29:31 +00:00
|
|
|
uint32_t old_type =
|
2011-09-14 20:23:45 +00:00
|
|
|
(matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
|
|
|
|
|
(matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
|
2011-10-14 00:42:25 +00:00
|
|
|
// Return the existing watchpoint if both size and type match.
|
2013-06-18 21:52:48 +00:00
|
|
|
if (size == old_size && kind == old_type) {
|
2011-10-14 00:42:25 +00:00
|
|
|
wp_sp = matched_sp;
|
2012-12-18 02:03:49 +00:00
|
|
|
wp_sp->SetEnabled(false, notify);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2011-10-14 00:42:25 +00:00
|
|
|
// Nil the matched watchpoint; we will be creating a new one.
|
2012-12-18 02:03:49 +00:00
|
|
|
m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
|
|
|
|
|
m_watchpoint_list.Remove(matched_sp->GetID(), true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-05 23:07:34 +00:00
|
|
|
if (!wp_sp) {
|
2019-02-11 23:13:08 +00:00
|
|
|
wp_sp = std::make_shared<Watchpoint>(*this, addr, size, type);
|
2012-12-18 02:03:49 +00:00
|
|
|
wp_sp->SetWatchpointType(kind, notify);
|
|
|
|
|
m_watchpoint_list.Add(wp_sp, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-18 02:03:49 +00:00
|
|
|
error = m_process_sp->EnableWatchpoint(wp_sp.get(), notify);
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (creation of watchpoint %s with id = %u)\n",
|
|
|
|
|
__FUNCTION__, error.Success() ? "succeeded" : "failed",
|
|
|
|
|
wp_sp->GetID());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-12-05 23:07:34 +00:00
|
|
|
if (error.Fail()) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// Enabling the watchpoint on the device side failed. Remove the said
|
|
|
|
|
// watchpoint from the list maintained by the target instance.
|
2012-12-18 02:03:49 +00:00
|
|
|
m_watchpoint_list.Remove(wp_sp->GetID(), true);
|
2012-06-04 23:19:54 +00:00
|
|
|
// See if we could provide more helpful error message.
|
2016-06-27 12:35:41 +00:00
|
|
|
if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2016-06-27 12:35:41 +00:00
|
|
|
"watch size of %" PRIu64 " is not supported", (uint64_t)size);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
wp_sp.reset();
|
2016-09-06 20:57:50 +00:00
|
|
|
} else
|
2013-07-02 02:09:46 +00:00
|
|
|
m_last_created_watchpoint = wp_sp;
|
2011-10-14 00:42:25 +00:00
|
|
|
return wp_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void Target::RemoveAllowedBreakpoints() {
|
2017-09-14 20:22:49 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s \n", __FUNCTION__);
|
2017-09-14 20:22:49 +00:00
|
|
|
|
|
|
|
|
m_breakpoint_list.RemoveAllowed(true);
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
m_last_created_breakpoint.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::RemoveAllBreakpoints(bool internal_also) {
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
|
|
|
|
|
internal_also ? "yes" : "no");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
m_breakpoint_list.RemoveAll(true);
|
2010-06-08 16:52:24 +00:00
|
|
|
if (internal_also)
|
|
|
|
|
m_internal_breakpoint_list.RemoveAll(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-10-14 23:45:03 +00:00
|
|
|
m_last_created_breakpoint.reset();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::DisableAllBreakpoints(bool internal_also) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
|
|
|
|
|
internal_also ? "yes" : "no");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
m_breakpoint_list.SetEnabledAll(false);
|
|
|
|
|
if (internal_also)
|
|
|
|
|
m_internal_breakpoint_list.SetEnabledAll(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
void Target::DisableAllowedBreakpoints() {
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s", __FUNCTION__);
|
2017-09-14 20:22:49 +00:00
|
|
|
|
|
|
|
|
m_breakpoint_list.SetEnabledAllowed(false);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::EnableAllBreakpoints(bool internal_also) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (internal_also = %s)\n", __FUNCTION__,
|
|
|
|
|
internal_also ? "yes" : "no");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
m_breakpoint_list.SetEnabledAll(true);
|
|
|
|
|
if (internal_also)
|
|
|
|
|
m_internal_breakpoint_list.SetEnabledAll(true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 20:22:49 +00:00
|
|
|
void Target::EnableAllowedBreakpoints() {
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s", __FUNCTION__);
|
2017-09-14 20:22:49 +00:00
|
|
|
|
|
|
|
|
m_breakpoint_list.SetEnabledAllowed(true);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
bool Target::RemoveBreakpointByID(break_id_t break_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
|
|
|
|
|
break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (DisableBreakpointByID(break_id)) {
|
|
|
|
|
if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
|
2010-07-23 23:33:17 +00:00
|
|
|
m_internal_breakpoint_list.Remove(break_id, false);
|
2010-06-08 16:52:24 +00:00
|
|
|
else {
|
2011-01-24 23:35:47 +00:00
|
|
|
if (m_last_created_breakpoint) {
|
|
|
|
|
if (m_last_created_breakpoint->GetID() == break_id)
|
|
|
|
|
m_last_created_breakpoint.reset();
|
|
|
|
|
}
|
2010-07-23 23:33:17 +00:00
|
|
|
m_breakpoint_list.Remove(break_id, true);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::DisableBreakpointByID(break_id_t break_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
|
|
|
|
|
break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
|
|
|
|
|
if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
|
|
|
|
|
bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
|
|
|
|
|
else
|
|
|
|
|
bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
|
|
|
|
|
if (bp_sp) {
|
|
|
|
|
bp_sp->SetEnabled(false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::EnableBreakpointByID(break_id_t break_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
|
|
|
|
|
break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
|
|
|
|
|
if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
|
|
|
|
|
bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
|
|
|
|
|
else
|
|
|
|
|
bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
|
|
|
|
|
|
|
|
|
|
if (bp_sp) {
|
|
|
|
|
bp_sp->SetEnabled(true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::SerializeBreakpointsToFile(const FileSpec &file,
|
|
|
|
|
const BreakpointIDList &bp_ids,
|
|
|
|
|
bool append) {
|
|
|
|
|
Status error;
|
2016-09-14 19:07:35 +00:00
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
|
error.SetErrorString("Invalid FileSpec.");
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string path(file.GetPath());
|
2016-09-22 23:42:42 +00:00
|
|
|
StructuredData::ObjectSP input_data_sp;
|
|
|
|
|
|
|
|
|
|
StructuredData::ArraySP break_store_sp;
|
|
|
|
|
StructuredData::Array *break_store_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
if (append) {
|
|
|
|
|
input_data_sp = StructuredData::ParseJSONFromFile(file, error);
|
|
|
|
|
if (error.Success()) {
|
|
|
|
|
break_store_ptr = input_data_sp->GetAsArray();
|
|
|
|
|
if (!break_store_ptr) {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Tried to append to invalid input file %s", path.c_str());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!break_store_ptr) {
|
2019-02-11 23:13:08 +00:00
|
|
|
break_store_sp = std::make_shared<StructuredData::Array>();
|
2016-09-22 23:42:42 +00:00
|
|
|
break_store_ptr = break_store_sp.get();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
StreamFile out_file(path.c_str(),
|
2019-10-14 20:15:34 +00:00
|
|
|
File::eOpenOptionTruncate | File::eOpenOptionWrite |
|
|
|
|
|
File::eOpenOptionCanCreate |
|
|
|
|
|
File::eOpenOptionCloseOnExec,
|
2016-09-14 19:07:35 +00:00
|
|
|
lldb::eFilePermissionsFileDefault);
|
|
|
|
|
if (!out_file.GetFile().IsValid()) {
|
|
|
|
|
error.SetErrorStringWithFormat("Unable to open output file: %s.",
|
|
|
|
|
path.c_str());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
GetBreakpointList().GetListMutex(lock);
|
|
|
|
|
|
|
|
|
|
if (bp_ids.GetSize() == 0) {
|
|
|
|
|
const BreakpointList &breakpoints = GetBreakpointList();
|
|
|
|
|
|
|
|
|
|
size_t num_breakpoints = breakpoints.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_breakpoints; i++) {
|
|
|
|
|
Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get();
|
|
|
|
|
StructuredData::ObjectSP bkpt_save_sp = bp->SerializeToStructuredData();
|
|
|
|
|
// If a breakpoint can't serialize it, just ignore it for now:
|
|
|
|
|
if (bkpt_save_sp)
|
2016-09-22 23:42:42 +00:00
|
|
|
break_store_ptr->AddItem(bkpt_save_sp);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
std::unordered_set<lldb::break_id_t> processed_bkpts;
|
|
|
|
|
const size_t count = bp_ids.GetSize();
|
|
|
|
|
for (size_t i = 0; i < count; ++i) {
|
|
|
|
|
BreakpointID cur_bp_id = bp_ids.GetBreakpointIDAtIndex(i);
|
|
|
|
|
lldb::break_id_t bp_id = cur_bp_id.GetBreakpointID();
|
|
|
|
|
|
|
|
|
|
if (bp_id != LLDB_INVALID_BREAK_ID) {
|
|
|
|
|
// Only do each breakpoint once:
|
|
|
|
|
std::pair<std::unordered_set<lldb::break_id_t>::iterator, bool>
|
|
|
|
|
insert_result = processed_bkpts.insert(bp_id);
|
|
|
|
|
if (!insert_result.second)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
Breakpoint *bp = GetBreakpointByID(bp_id).get();
|
|
|
|
|
StructuredData::ObjectSP bkpt_save_sp = bp->SerializeToStructuredData();
|
|
|
|
|
// If the user explicitly asked to serialize a breakpoint, and we
|
2018-04-30 16:49:04 +00:00
|
|
|
// can't, then raise an error:
|
2016-09-14 19:07:35 +00:00
|
|
|
if (!bkpt_save_sp) {
|
|
|
|
|
error.SetErrorStringWithFormat("Unable to serialize breakpoint %d",
|
|
|
|
|
bp_id);
|
|
|
|
|
return error;
|
|
|
|
|
}
|
2016-09-22 23:42:42 +00:00
|
|
|
break_store_ptr->AddItem(bkpt_save_sp);
|
2016-09-14 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-22 23:42:42 +00:00
|
|
|
break_store_ptr->Dump(out_file, false);
|
2016-09-14 19:07:35 +00:00
|
|
|
out_file.PutChar('\n');
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::CreateBreakpointsFromFile(const FileSpec &file,
|
|
|
|
|
BreakpointIDList &new_bps) {
|
2016-09-22 22:20:28 +00:00
|
|
|
std::vector<std::string> no_names;
|
|
|
|
|
return CreateBreakpointsFromFile(file, no_names, new_bps);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::CreateBreakpointsFromFile(const FileSpec &file,
|
|
|
|
|
std::vector<std::string> &names,
|
|
|
|
|
BreakpointIDList &new_bps) {
|
2016-09-14 19:07:35 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
|
GetBreakpointList().GetListMutex(lock);
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2016-09-14 19:07:35 +00:00
|
|
|
StructuredData::ObjectSP input_data_sp =
|
|
|
|
|
StructuredData::ParseJSONFromFile(file, error);
|
|
|
|
|
if (!error.Success()) {
|
|
|
|
|
return error;
|
|
|
|
|
} else if (!input_data_sp || !input_data_sp->IsValid()) {
|
|
|
|
|
error.SetErrorStringWithFormat("Invalid JSON from input file: %s.",
|
|
|
|
|
file.GetPath().c_str());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructuredData::Array *bkpt_array = input_data_sp->GetAsArray();
|
|
|
|
|
if (!bkpt_array) {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Invalid breakpoint data from input file: %s.", file.GetPath().c_str());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t num_bkpts = bkpt_array->GetSize();
|
2016-09-22 22:20:28 +00:00
|
|
|
size_t num_names = names.size();
|
|
|
|
|
|
2016-09-14 19:07:35 +00:00
|
|
|
for (size_t i = 0; i < num_bkpts; i++) {
|
|
|
|
|
StructuredData::ObjectSP bkpt_object_sp = bkpt_array->GetItemAtIndex(i);
|
|
|
|
|
// Peel off the breakpoint key, and feed the rest to the Breakpoint:
|
|
|
|
|
StructuredData::Dictionary *bkpt_dict = bkpt_object_sp->GetAsDictionary();
|
|
|
|
|
if (!bkpt_dict) {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Invalid breakpoint data for element %zu from input file: %s.", i,
|
|
|
|
|
file.GetPath().c_str());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
StructuredData::ObjectSP bkpt_data_sp =
|
|
|
|
|
bkpt_dict->GetValueForKey(Breakpoint::GetSerializationKey());
|
2016-09-22 22:20:28 +00:00
|
|
|
if (num_names &&
|
|
|
|
|
!Breakpoint::SerializedBreakpointMatchesNames(bkpt_data_sp, names))
|
|
|
|
|
continue;
|
|
|
|
|
|
2020-02-13 15:51:13 +03:00
|
|
|
BreakpointSP bkpt_sp = Breakpoint::CreateFromStructuredData(
|
|
|
|
|
shared_from_this(), bkpt_data_sp, error);
|
2016-09-14 19:07:35 +00:00
|
|
|
if (!error.Success()) {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Error restoring breakpoint %zu from %s: %s.", i,
|
|
|
|
|
file.GetPath().c_str(), error.AsCString());
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
new_bps.AddBreakpointID(BreakpointID(bkpt_sp->GetID()));
|
|
|
|
|
}
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-23 21:21:43 +00:00
|
|
|
// The flag 'end_to_end', default to true, signifies that the operation is
|
|
|
|
|
// performed end to end, for both the debugger and the debuggee.
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end
|
|
|
|
|
// to end operations.
|
|
|
|
|
bool Target::RemoveAllWatchpoints(bool end_to_end) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2011-09-20 23:28:55 +00:00
|
|
|
|
2011-09-23 21:21:43 +00:00
|
|
|
if (!end_to_end) {
|
2012-12-18 02:03:49 +00:00
|
|
|
m_watchpoint_list.RemoveAll(true);
|
2011-09-23 21:21:43 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Otherwise, it's an end to end operation.
|
|
|
|
|
|
2011-09-20 23:28:55 +00:00
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
2011-09-20 23:28:55 +00:00
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
2011-09-20 23:28:55 +00:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
|
2011-09-20 23:28:55 +00:00
|
|
|
if (rc.Fail())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-12-18 02:03:49 +00:00
|
|
|
m_watchpoint_list.RemoveAll(true);
|
2013-07-02 02:09:46 +00:00
|
|
|
m_last_created_watchpoint.reset();
|
2011-09-20 23:28:55 +00:00
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end
|
|
|
|
|
// to end operations.
|
2011-10-14 00:42:25 +00:00
|
|
|
bool Target::DisableAllWatchpoints(bool end_to_end) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2011-09-20 23:28:55 +00:00
|
|
|
|
2011-09-23 21:21:43 +00:00
|
|
|
if (!end_to_end) {
|
2011-10-14 00:42:25 +00:00
|
|
|
m_watchpoint_list.SetEnabledAll(false);
|
2011-09-23 21:21:43 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Otherwise, it's an end to end operation.
|
|
|
|
|
|
2011-09-20 23:28:55 +00:00
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
2011-09-20 23:28:55 +00:00
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
2011-09-20 23:28:55 +00:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
|
2011-09-20 23:28:55 +00:00
|
|
|
if (rc.Fail())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end
|
|
|
|
|
// to end operations.
|
2011-10-14 00:42:25 +00:00
|
|
|
bool Target::EnableAllWatchpoints(bool end_to_end) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2011-09-20 23:28:55 +00:00
|
|
|
|
2011-09-23 21:21:43 +00:00
|
|
|
if (!end_to_end) {
|
2011-10-14 00:42:25 +00:00
|
|
|
m_watchpoint_list.SetEnabledAll(true);
|
2011-09-23 21:21:43 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Otherwise, it's an end to end operation.
|
|
|
|
|
|
2011-09-20 23:28:55 +00:00
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
2011-09-20 23:28:55 +00:00
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
2011-09-20 23:28:55 +00:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = m_process_sp->EnableWatchpoint(wp_sp.get());
|
2011-09-20 23:28:55 +00:00
|
|
|
if (rc.Fail())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-25 06:44:30 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::ClearAllWatchpointHitCounts() {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2012-02-25 06:44:30 +00:00
|
|
|
|
|
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
|
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
wp_sp->ResetHitCount();
|
|
|
|
|
}
|
|
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 00:37:54 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::ClearAllWatchpointHistoricValues() {
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-11 00:37:54 +00:00
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
|
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
|
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-11 00:37:54 +00:00
|
|
|
wp_sp->ResetHistoricValues();
|
|
|
|
|
}
|
|
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list during
|
|
|
|
|
// these operations.
|
2011-10-14 00:42:25 +00:00
|
|
|
bool Target::IgnoreAllWatchpoints(uint32_t ignore_count) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
|
2011-10-05 21:35:46 +00:00
|
|
|
|
|
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
size_t num_watchpoints = m_watchpoint_list.GetSize();
|
2011-10-05 21:35:46 +00:00
|
|
|
for (size_t i = 0; i < num_watchpoints; ++i) {
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
|
|
|
|
|
if (!wp_sp)
|
2011-10-05 21:35:46 +00:00
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
wp_sp->SetIgnoreCount(ignore_count);
|
2011-10-05 21:35:46 +00:00
|
|
|
}
|
|
|
|
|
return true; // Success!
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::DisableWatchpointByID(lldb::watch_id_t watch_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
|
2011-09-20 23:28:55 +00:00
|
|
|
|
|
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
|
|
|
|
|
if (wp_sp) {
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
|
2011-09-22 18:04:58 +00:00
|
|
|
if (rc.Success())
|
|
|
|
|
return true;
|
2011-09-20 23:28:55 +00:00
|
|
|
|
2011-09-22 18:04:58 +00:00
|
|
|
// Else, fallthrough.
|
2011-09-20 23:28:55 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::EnableWatchpointByID(lldb::watch_id_t watch_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
|
2011-09-20 23:28:55 +00:00
|
|
|
|
|
|
|
|
if (!ProcessIsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
|
|
|
|
|
if (wp_sp) {
|
2017-05-12 04:51:55 +00:00
|
|
|
Status rc = m_process_sp->EnableWatchpoint(wp_sp.get());
|
2011-09-22 18:04:58 +00:00
|
|
|
if (rc.Success())
|
|
|
|
|
return true;
|
2011-09-20 23:28:55 +00:00
|
|
|
|
2011-09-22 18:04:58 +00:00
|
|
|
// Else, fallthrough.
|
2011-09-20 23:28:55 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::RemoveWatchpointByID(lldb::watch_id_t watch_id) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-07-02 02:09:46 +00:00
|
|
|
WatchpointSP watch_to_remove_sp = m_watchpoint_list.FindByID(watch_id);
|
|
|
|
|
if (watch_to_remove_sp == m_last_created_watchpoint)
|
|
|
|
|
m_last_created_watchpoint.reset();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
if (DisableWatchpointByID(watch_id)) {
|
2012-12-18 02:03:49 +00:00
|
|
|
m_watchpoint_list.Remove(watch_id, true);
|
2011-09-20 23:28:55 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
|
|
|
|
|
bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id,
|
|
|
|
|
uint32_t ignore_count) {
|
2013-03-27 23:08:40 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
|
2011-10-05 21:35:46 +00:00
|
|
|
|
2011-10-14 00:42:25 +00:00
|
|
|
if (!ProcessIsValid())
|
2011-10-05 21:35:46 +00:00
|
|
|
return false;
|
|
|
|
|
|
2015-05-08 09:36:31 +00:00
|
|
|
WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
|
|
|
|
|
if (wp_sp) {
|
|
|
|
|
wp_sp->SetIgnoreCount(ignore_count);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2011-08-11 02:48:45 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-08-11 02:48:45 +00:00
|
|
|
ModuleSP Target::GetExecutableModule() {
|
2015-05-08 09:36:31 +00:00
|
|
|
// search for the first executable in the module list
|
|
|
|
|
for (size_t i = 0; i < m_images.GetSize(); ++i) {
|
2012-11-08 02:22:02 +00:00
|
|
|
ModuleSP module_sp = m_images.GetModuleAtIndex(i);
|
2013-05-21 00:00:30 +00:00
|
|
|
lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
|
|
|
|
|
if (obj == nullptr)
|
|
|
|
|
continue;
|
|
|
|
|
if (obj->GetType() == ObjectFile::Type::eTypeExecutable)
|
|
|
|
|
return module_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-01-27 23:43:24 +00:00
|
|
|
// as fall back return the first module loaded
|
2013-11-09 00:03:31 +00:00
|
|
|
return m_images.GetModuleAtIndex(0);
|
2013-11-05 23:28:00 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-11-09 00:03:31 +00:00
|
|
|
Module *Target::GetExecutableModulePointer() {
|
2013-11-05 23:28:00 +00:00
|
|
|
return GetExecutableModule().get();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-05 23:28:00 +00:00
|
|
|
static void LoadScriptingResourceForModule(const ModuleSP &module_sp,
|
|
|
|
|
Target *target) {
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2013-11-05 23:28:00 +00:00
|
|
|
StreamString feedback_stream;
|
2019-07-19 00:56:26 +00:00
|
|
|
if (module_sp && !module_sp->LoadScriptingResourceInTarget(
|
|
|
|
|
target, error, &feedback_stream)) {
|
2013-04-29 17:25:54 +00:00
|
|
|
if (error.AsCString())
|
remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.
My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects. These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods. Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.
In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch. In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)
However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)
In order for SBFile to use shared_ptr<File>, everything else should
as well.
If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.
Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67891
llvm-svn: 373090
2019-09-27 14:33:35 +00:00
|
|
|
target->GetDebugger().GetErrorStream().Printf(
|
2010-08-09 23:31:02 +00:00
|
|
|
"unable to load scripting data for module %s - error reported was "
|
2012-12-05 00:25:49 +00:00
|
|
|
"%s\n",
|
|
|
|
|
module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
|
|
|
|
|
error.AsCString());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-12-05 00:25:49 +00:00
|
|
|
if (feedback_stream.GetSize())
|
remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.
My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects. These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods. Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.
In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch. In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)
However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)
In order for SBFile to use shared_ptr<File>, everything else should
as well.
If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.
Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67891
llvm-svn: 373090
2019-09-27 14:33:35 +00:00
|
|
|
target->GetDebugger().GetErrorStream().Printf("%s\n",
|
|
|
|
|
feedback_stream.GetData());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::ClearModules(bool delete_locations) {
|
2012-02-26 05:51:37 +00:00
|
|
|
ModulesDidUnload(m_images, delete_locations);
|
2010-06-08 16:52:24 +00:00
|
|
|
m_section_load_history.Clear();
|
|
|
|
|
m_images.Clear();
|
2010-08-09 23:31:02 +00:00
|
|
|
m_scratch_type_system_map.Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-09 23:31:02 +00:00
|
|
|
void Target::DidExec() {
|
|
|
|
|
// When a process exec's we need to know about it so we can do some cleanup.
|
2017-10-25 21:05:31 +00:00
|
|
|
m_breakpoint_list.RemoveInvalidLocations(m_arch.GetSpec());
|
|
|
|
|
m_internal_breakpoint_list.RemoveInvalidLocations(m_arch.GetSpec());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 04:11:37 +00:00
|
|
|
void Target::SetExecutableModule(ModuleSP &executable_sp,
|
2018-09-20 09:09:05 +00:00
|
|
|
LoadDependentFiles load_dependent_files) {
|
2015-11-10 04:11:37 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
|
|
|
|
|
ClearModules(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-11-10 04:11:37 +00:00
|
|
|
if (executable_sp) {
|
2017-05-15 13:02:37 +00:00
|
|
|
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
|
|
|
|
|
Timer scoped_timer(func_cat,
|
2015-11-10 04:11:37 +00:00
|
|
|
"Target::SetExecutableModule (executable = '%s')",
|
|
|
|
|
executable_sp->GetFileSpec().GetPath().c_str());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
const bool notify = true;
|
2019-07-19 00:56:26 +00:00
|
|
|
m_images.Append(executable_sp,
|
|
|
|
|
notify); // The first image is our executable file
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-11-10 04:11:37 +00:00
|
|
|
// If we haven't set an architecture yet, reset our architecture based on
|
|
|
|
|
// what we found in the executable module.
|
2017-10-25 21:05:31 +00:00
|
|
|
if (!m_arch.GetSpec().IsValid()) {
|
2015-11-10 04:11:37 +00:00
|
|
|
m_arch = executable_sp->GetArchitecture();
|
2017-10-25 21:05:31 +00:00
|
|
|
LLDB_LOG(log,
|
|
|
|
|
"setting architecture to {0} ({1}) based on executable file",
|
|
|
|
|
m_arch.GetSpec().GetArchitectureName(),
|
|
|
|
|
m_arch.GetSpec().GetTriple().getTriple());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 04:11:37 +00:00
|
|
|
FileSpecList dependent_files;
|
|
|
|
|
ObjectFile *executable_objfile = executable_sp->GetObjectFile();
|
2018-09-27 06:59:15 +00:00
|
|
|
bool load_dependents = true;
|
2018-09-20 09:09:05 +00:00
|
|
|
switch (load_dependent_files) {
|
|
|
|
|
case eLoadDependentsDefault:
|
2018-09-27 06:59:15 +00:00
|
|
|
load_dependents = executable_sp->IsExecutable();
|
2018-09-20 09:09:05 +00:00
|
|
|
break;
|
|
|
|
|
case eLoadDependentsYes:
|
2018-09-27 06:59:15 +00:00
|
|
|
load_dependents = true;
|
2018-09-20 09:09:05 +00:00
|
|
|
break;
|
|
|
|
|
case eLoadDependentsNo:
|
2018-09-27 06:59:15 +00:00
|
|
|
load_dependents = false;
|
2018-09-20 09:09:05 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-09-27 06:59:15 +00:00
|
|
|
if (executable_objfile && load_dependents) {
|
2019-04-08 23:03:02 +00:00
|
|
|
ModuleList added_modules;
|
2015-11-10 04:11:37 +00:00
|
|
|
executable_objfile->GetDependentModules(dependent_files);
|
2015-03-13 10:32:42 +00:00
|
|
|
for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
|
2019-11-28 17:02:07 +01:00
|
|
|
FileSpec dependent_file_spec(dependent_files.GetFileSpecAtIndex(i));
|
2011-03-19 01:12:21 +00:00
|
|
|
FileSpec platform_dependent_file_spec;
|
2015-03-13 10:32:42 +00:00
|
|
|
if (m_platform_sp)
|
|
|
|
|
m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr,
|
|
|
|
|
platform_dependent_file_spec);
|
|
|
|
|
else
|
|
|
|
|
platform_dependent_file_spec = dependent_file_spec;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-10-25 21:05:31 +00:00
|
|
|
ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
|
2019-07-19 00:56:26 +00:00
|
|
|
ModuleSP image_module_sp(
|
|
|
|
|
GetOrCreateModule(module_spec, false /* notify */));
|
2015-12-11 19:52:15 +00:00
|
|
|
if (image_module_sp) {
|
2019-07-19 00:56:26 +00:00
|
|
|
added_modules.AppendIfNeeded(image_module_sp, false);
|
2015-03-13 10:32:42 +00:00
|
|
|
ObjectFile *objfile = image_module_sp->GetObjectFile();
|
2010-06-08 16:52:24 +00:00
|
|
|
if (objfile)
|
|
|
|
|
objfile->GetDependentModules(dependent_files);
|
2015-03-13 10:32:42 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-04-08 23:03:02 +00:00
|
|
|
ModulesDidLoad(added_modules);
|
2015-03-13 10:32:42 +00:00
|
|
|
}
|
2012-11-08 02:22:02 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-06 16:56:10 +00:00
|
|
|
bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
|
2015-10-15 22:39:55 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
|
2017-10-25 21:05:31 +00:00
|
|
|
bool missing_local_arch = !m_arch.GetSpec().IsValid();
|
2014-03-24 23:10:19 +00:00
|
|
|
bool replace_local_arch = true;
|
|
|
|
|
bool compatible_local_arch = false;
|
|
|
|
|
ArchSpec other(arch_spec);
|
2012-11-08 02:22:02 +00:00
|
|
|
|
2018-08-06 16:56:10 +00:00
|
|
|
// Changing the architecture might mean that the currently selected platform
|
|
|
|
|
// isn't compatible. Set the platform correctly if we are asked to do so,
|
|
|
|
|
// otherwise assume the user will set the platform manually.
|
|
|
|
|
if (set_platform) {
|
|
|
|
|
if (other.IsValid()) {
|
|
|
|
|
auto platform_sp = GetPlatform();
|
|
|
|
|
if (!platform_sp ||
|
|
|
|
|
!platform_sp->IsCompatibleArchitecture(other, false, nullptr)) {
|
|
|
|
|
ArchSpec platform_arch;
|
|
|
|
|
auto arch_platform_sp =
|
|
|
|
|
Platform::GetPlatformForArchitecture(other, &platform_arch);
|
|
|
|
|
if (arch_platform_sp) {
|
|
|
|
|
SetPlatform(arch_platform_sp);
|
|
|
|
|
if (platform_arch.IsValid())
|
|
|
|
|
other = platform_arch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-08 19:16:03 +00:00
|
|
|
if (!missing_local_arch) {
|
2017-10-25 21:05:31 +00:00
|
|
|
if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
|
|
|
|
|
other.MergeFrom(m_arch.GetSpec());
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2017-10-25 21:05:31 +00:00
|
|
|
if (m_arch.GetSpec().IsCompatibleMatch(other)) {
|
2015-11-10 04:18:12 +00:00
|
|
|
compatible_local_arch = true;
|
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
|
|
|
bool arch_changed, vendor_changed, os_changed, os_ver_changed,
|
|
|
|
|
env_changed;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
|
|
|
|
|
vendor_changed, os_changed,
|
|
|
|
|
os_ver_changed, env_changed);
|
2013-04-05 18:49:06 +00:00
|
|
|
|
2014-03-24 23:10:19 +00:00
|
|
|
if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
|
2015-11-10 04:18:12 +00:00
|
|
|
replace_local_arch = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-11-08 02:22:02 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
if (compatible_local_arch || missing_local_arch) {
|
|
|
|
|
// If we haven't got a valid arch spec, or the architectures are compatible
|
2018-04-30 16:49:04 +00:00
|
|
|
// update the architecture, unless the one we already have is more
|
|
|
|
|
// specified
|
2012-08-22 17:17:09 +00:00
|
|
|
if (replace_local_arch)
|
2014-12-06 01:28:03 +00:00
|
|
|
m_arch = other;
|
2017-10-25 21:05:31 +00:00
|
|
|
LLDB_LOG(log, "set architecture to {0} ({1})",
|
|
|
|
|
m_arch.GetSpec().GetArchitectureName(),
|
|
|
|
|
m_arch.GetSpec().GetTriple().getTriple());
|
2011-01-07 01:57:07 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-02-24 01:59:29 +00:00
|
|
|
|
2011-01-07 01:57:07 +00:00
|
|
|
// If we have an executable file, try to reset the executable to the desired
|
|
|
|
|
// architecture
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::SetArchitecture changing architecture to %s (%s)",
|
|
|
|
|
arch_spec.GetArchitectureName(),
|
|
|
|
|
arch_spec.GetTriple().getTriple().c_str());
|
2015-11-10 04:11:37 +00:00
|
|
|
m_arch = other;
|
2016-06-27 23:21:49 +00:00
|
|
|
ModuleSP executable_sp = GetExecutableModule();
|
2010-06-30 23:03:03 +00:00
|
|
|
|
2011-01-07 01:57:07 +00:00
|
|
|
ClearModules(true);
|
2011-07-12 17:06:17 +00:00
|
|
|
// Need to do something about unsetting breakpoints.
|
2011-07-11 05:12:02 +00:00
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
if (executable_sp) {
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Target::SetArchitecture Trying to select executable file "
|
|
|
|
|
"architecture %s (%s)",
|
|
|
|
|
arch_spec.GetArchitectureName(),
|
|
|
|
|
arch_spec.GetTriple().getTriple().c_str());
|
2011-01-07 01:57:07 +00:00
|
|
|
ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
|
2019-04-23 20:17:04 +00:00
|
|
|
FileSpecList search_paths = GetExecutableSearchPaths();
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error = ModuleList::GetSharedModule(module_spec, executable_sp,
|
2019-07-19 00:56:26 +00:00
|
|
|
&search_paths, nullptr, nullptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-01-07 01:57:07 +00:00
|
|
|
if (!error.Fail() && executable_sp) {
|
2018-09-20 09:09:05 +00:00
|
|
|
SetExecutableModule(executable_sp, eLoadDependentsYes);
|
2011-10-05 21:35:46 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-05 21:35:46 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-13 10:32:42 +00:00
|
|
|
bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
|
2018-10-23 23:45:56 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
|
2011-01-07 01:57:07 +00:00
|
|
|
if (arch_spec.IsValid()) {
|
2017-10-25 21:05:31 +00:00
|
|
|
if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// The current target arch is compatible with "arch_spec", see if we can
|
|
|
|
|
// improve our current architecture using bits from "arch_spec"
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Target::MergeArchitecture target has arch %s, merging with "
|
|
|
|
|
"arch %s",
|
|
|
|
|
m_arch.GetSpec().GetTriple().getTriple().c_str(),
|
|
|
|
|
arch_spec.GetTriple().getTriple().c_str());
|
2018-10-23 23:45:56 +00:00
|
|
|
|
2015-03-13 10:32:42 +00:00
|
|
|
// Merge bits from arch_spec into "merged_arch" and set our architecture
|
2017-10-25 21:05:31 +00:00
|
|
|
ArchSpec merged_arch(m_arch.GetSpec());
|
2015-03-13 10:32:42 +00:00
|
|
|
merged_arch.MergeFrom(arch_spec);
|
|
|
|
|
return SetArchitecture(merged_arch);
|
2011-01-07 01:57:07 +00:00
|
|
|
} else {
|
|
|
|
|
// The new architecture is different, we just need to replace it
|
2012-08-22 17:17:09 +00:00
|
|
|
return SetArchitecture(arch_spec);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-05 21:35:46 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
void Target::NotifyWillClearList(const ModuleList &module_list) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
void Target::NotifyModuleAdded(const ModuleList &module_list,
|
2019-07-19 00:56:26 +00:00
|
|
|
const ModuleSP &module_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
// A module is being added to this target for the first time
|
2014-03-24 23:10:19 +00:00
|
|
|
if (m_valid) {
|
|
|
|
|
ModuleList my_module_list;
|
|
|
|
|
my_module_list.Append(module_sp);
|
|
|
|
|
ModulesDidLoad(my_module_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
void Target::NotifyModuleRemoved(const ModuleList &module_list,
|
2019-07-19 00:56:26 +00:00
|
|
|
const ModuleSP &module_sp) {
|
2015-10-15 22:39:55 +00:00
|
|
|
// A module is being removed from this target.
|
2014-03-24 23:10:19 +00:00
|
|
|
if (m_valid) {
|
|
|
|
|
ModuleList my_module_list;
|
|
|
|
|
my_module_list.Append(module_sp);
|
|
|
|
|
ModulesDidUnload(my_module_list, false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
void Target::NotifyModuleUpdated(const ModuleList &module_list,
|
2019-07-19 00:56:26 +00:00
|
|
|
const ModuleSP &old_module_sp,
|
|
|
|
|
const ModuleSP &new_module_sp) {
|
2011-08-03 01:00:06 +00:00
|
|
|
// A module is replacing an already added module
|
2014-03-24 23:10:19 +00:00
|
|
|
if (m_valid) {
|
2011-01-07 01:57:07 +00:00
|
|
|
m_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp,
|
2014-03-24 23:10:19 +00:00
|
|
|
new_module_sp);
|
2015-11-10 04:18:12 +00:00
|
|
|
m_internal_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(
|
2014-03-24 23:10:19 +00:00
|
|
|
old_module_sp, new_module_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) {
|
2019-07-19 00:56:26 +00:00
|
|
|
ModulesDidUnload(module_list, false);
|
2019-04-08 23:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Target::ModulesDidLoad(ModuleList &module_list) {
|
2019-04-22 22:42:29 +00:00
|
|
|
const size_t num_images = module_list.GetSize();
|
|
|
|
|
if (m_valid && num_images) {
|
2019-04-08 23:03:02 +00:00
|
|
|
for (size_t idx = 0; idx < num_images; ++idx) {
|
2019-04-22 22:42:29 +00:00
|
|
|
ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
|
2019-04-08 23:03:02 +00:00
|
|
|
LoadScriptingResourceForModule(module_sp, this);
|
|
|
|
|
}
|
2013-11-05 23:28:00 +00:00
|
|
|
m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
|
2015-11-10 04:18:12 +00:00
|
|
|
m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
|
2011-01-07 01:57:07 +00:00
|
|
|
if (m_process_sp) {
|
2014-03-13 09:37:02 +00:00
|
|
|
m_process_sp->ModulesDidLoad(module_list);
|
2016-09-06 20:57:50 +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
|
|
|
BroadcastEvent(eBroadcastBitModulesLoaded,
|
|
|
|
|
new TargetEventData(this->shared_from_this(), module_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-05 18:49:06 +00:00
|
|
|
void Target::SymbolsDidLoad(ModuleList &module_list) {
|
2014-03-24 23:10:19 +00:00
|
|
|
if (m_valid && module_list.GetSize()) {
|
2013-11-05 03:57:19 +00:00
|
|
|
if (m_process_sp) {
|
2019-06-03 23:12:11 +00:00
|
|
|
for (LanguageRuntime *runtime : m_process_sp->GetLanguageRuntimes()) {
|
|
|
|
|
runtime->SymbolsDidLoad(module_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 23:28:00 +00:00
|
|
|
m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
|
2015-11-10 04:18:12 +00:00
|
|
|
m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
|
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
|
|
|
BroadcastEvent(eBroadcastBitSymbolsLoaded,
|
|
|
|
|
new TargetEventData(this->shared_from_this(), module_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 23:28:00 +00:00
|
|
|
void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
|
2014-03-24 23:10:19 +00:00
|
|
|
if (m_valid && module_list.GetSize()) {
|
2014-11-17 19:39:20 +00:00
|
|
|
UnloadModuleSections(module_list);
|
2013-11-05 23:28:00 +00:00
|
|
|
m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
|
2015-11-10 04:18:12 +00:00
|
|
|
m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
|
2011-01-07 01:57:07 +00:00
|
|
|
delete_locations);
|
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
|
|
|
BroadcastEvent(eBroadcastBitModulesUnloaded,
|
2011-01-07 01:57:07 +00:00
|
|
|
new TargetEventData(this->shared_from_this(), module_list));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
bool Target::ModuleIsExcludedForUnconstrainedSearches(
|
2013-11-20 21:07:01 +00:00
|
|
|
const FileSpec &module_file_spec) {
|
2012-08-22 17:17:09 +00:00
|
|
|
if (GetBreakpointsConsultPlatformAvoidList()) {
|
2011-10-28 23:14:11 +00:00
|
|
|
ModuleList matchingModules;
|
2012-02-26 05:51:37 +00:00
|
|
|
ModuleSpec module_spec(module_file_spec);
|
2019-10-17 19:56:40 +00:00
|
|
|
GetImages().FindModules(module_spec, matchingModules);
|
|
|
|
|
size_t num_modules = matchingModules.GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-10-17 19:56:40 +00:00
|
|
|
// If there is more than one module for this file spec, only
|
|
|
|
|
// return true if ALL the modules are on the black list.
|
2011-10-28 23:14:11 +00:00
|
|
|
if (num_modules > 0) {
|
2013-06-19 19:04:53 +00:00
|
|
|
for (size_t i = 0; i < num_modules; i++) {
|
2014-12-06 01:28:03 +00:00
|
|
|
if (!ModuleIsExcludedForUnconstrainedSearches(
|
|
|
|
|
matchingModules.GetModuleAtIndex(i)))
|
2012-05-08 01:45:38 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-08-09 23:31:02 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-08 01:45:38 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
bool Target::ModuleIsExcludedForUnconstrainedSearches(
|
|
|
|
|
const lldb::ModuleSP &module_sp) {
|
2012-08-22 17:17:09 +00:00
|
|
|
if (GetBreakpointsConsultPlatformAvoidList()) {
|
2011-03-19 01:12:21 +00:00
|
|
|
if (m_platform_sp)
|
2014-12-06 01:28:03 +00:00
|
|
|
return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*this,
|
2014-03-24 23:10:19 +00:00
|
|
|
module_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-05-08 01:45:38 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-07 01:57:07 +00:00
|
|
|
size_t Target::ReadMemoryFromFileCache(const Address &addr, void *dst,
|
2017-05-12 04:51:55 +00:00
|
|
|
size_t dst_len, Status &error) {
|
2012-02-24 01:59:29 +00:00
|
|
|
SectionSP section_sp(addr.GetSection());
|
2012-04-25 00:06:56 +00:00
|
|
|
if (section_sp) {
|
2014-07-01 21:22:11 +00:00
|
|
|
// If the contents of this section are encrypted, the on-disk file is
|
|
|
|
|
// unusable. Read only from live memory.
|
2012-04-25 00:06:56 +00:00
|
|
|
if (section_sp->IsEncrypted()) {
|
2012-05-25 17:05:55 +00:00
|
|
|
error.SetErrorString("section is encrypted");
|
2012-04-25 00:06:56 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-02-24 01:59:29 +00:00
|
|
|
ModuleSP module_sp(section_sp->GetModule());
|
|
|
|
|
if (module_sp) {
|
|
|
|
|
ObjectFile *objfile = section_sp->GetModule()->GetObjectFile();
|
2010-06-08 16:52:24 +00:00
|
|
|
if (objfile) {
|
2011-01-07 01:57:07 +00:00
|
|
|
size_t bytes_read = objfile->ReadSectionData(
|
2012-12-12 02:23:56 +00:00
|
|
|
section_sp.get(), addr.GetOffset(), dst, dst_len);
|
2011-01-07 01:57:07 +00:00
|
|
|
if (bytes_read > 0)
|
|
|
|
|
return bytes_read;
|
2010-06-30 23:03:03 +00:00
|
|
|
else
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat("error reading data from section %s",
|
|
|
|
|
section_sp->GetName().GetCString());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorString("address isn't from a object file");
|
2016-09-06 20:57:50 +00:00
|
|
|
} else
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorString("address isn't in a module");
|
2010-06-08 16:52:24 +00:00
|
|
|
} else
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorString("address doesn't contain a section that points to a "
|
|
|
|
|
"section in a object file");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-04-25 00:06:56 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-29 21:49:15 +00:00
|
|
|
size_t Target::ReadMemory(const Address &addr, bool prefer_file_cache,
|
2017-05-12 04:51:55 +00:00
|
|
|
void *dst, size_t dst_len, Status &error,
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
lldb::addr_t *load_addr_ptr) {
|
2013-01-21 19:20:50 +00:00
|
|
|
error.Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// if we end up reading this from process memory, we will fill this with the
|
|
|
|
|
// actual load address
|
2012-11-29 21:49:15 +00:00
|
|
|
if (load_addr_ptr)
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
*load_addr_ptr = LLDB_INVALID_ADDRESS;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-11-29 21:49:15 +00:00
|
|
|
size_t bytes_read = 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-11 05:12:02 +00:00
|
|
|
addr_t load_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
addr_t file_addr = LLDB_INVALID_ADDRESS;
|
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-26 19:14:58 +00:00
|
|
|
Address resolved_addr;
|
2012-11-29 21:49:15 +00:00
|
|
|
if (!addr.IsSectionOffset()) {
|
|
|
|
|
SectionLoadList §ion_load_list = GetSectionLoadList();
|
2013-12-06 01:12:00 +00:00
|
|
|
if (section_load_list.IsEmpty()) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// No sections are loaded, so we must assume we are not running yet and
|
|
|
|
|
// anything we are given is a file address.
|
2012-11-29 21:49:15 +00:00
|
|
|
file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its
|
2011-07-12 17:06:17 +00:00
|
|
|
// offset is the file address
|
2014-10-22 07:22:56 +00:00
|
|
|
m_images.ResolveFileAddress(file_addr, resolved_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2018-04-30 16:49:04 +00:00
|
|
|
// We have at least one section loaded. This can be because we have
|
|
|
|
|
// manually loaded some sections with "target modules load ..." or
|
|
|
|
|
// because we have have a live process that has sections loaded through
|
|
|
|
|
// the dynamic loader
|
2012-11-29 21:49:15 +00:00
|
|
|
load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its
|
2011-07-12 17:06:17 +00:00
|
|
|
// offset is the load address
|
2013-12-06 01:12:00 +00:00
|
|
|
section_load_list.ResolveLoadAddress(load_addr, resolved_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-26 19:14:58 +00:00
|
|
|
if (!resolved_addr.IsValid())
|
|
|
|
|
resolved_addr = addr;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-11 05:12:02 +00:00
|
|
|
if (prefer_file_cache) {
|
2012-11-29 21:49:15 +00:00
|
|
|
bytes_read = ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
|
2010-06-30 23:03:03 +00:00
|
|
|
if (bytes_read > 0)
|
|
|
|
|
return bytes_read;
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-30 23:03:03 +00:00
|
|
|
if (ProcessIsValid()) {
|
|
|
|
|
if (load_addr == LLDB_INVALID_ADDRESS)
|
|
|
|
|
load_addr = resolved_addr.GetLoadAddress(this);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-30 23:03:03 +00:00
|
|
|
if (load_addr == LLDB_INVALID_ADDRESS) {
|
|
|
|
|
ModuleSP addr_module_sp(resolved_addr.GetModule());
|
|
|
|
|
if (addr_module_sp && addr_module_sp->GetFileSpec())
|
2016-12-16 04:27:00 +00:00
|
|
|
error.SetErrorStringWithFormatv(
|
|
|
|
|
"{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
|
|
|
|
|
addr_module_sp->GetFileSpec(), resolved_addr.GetFileAddress());
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2014-07-01 21:22:11 +00:00
|
|
|
error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved",
|
2012-11-29 21:49:15 +00:00
|
|
|
resolved_addr.GetFileAddress());
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2011-01-07 01:57:07 +00:00
|
|
|
bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
|
2014-07-01 21:22:11 +00:00
|
|
|
if (bytes_read != dst_len) {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (error.Success()) {
|
|
|
|
|
if (bytes_read == 0)
|
2014-07-01 21:22:11 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"read memory from 0x%" PRIx64 " failed", load_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"only %" PRIu64 " of %" PRIu64
|
2014-07-01 21:22:11 +00:00
|
|
|
" bytes were read from memory at 0x%" PRIx64,
|
2010-06-30 23:03:03 +00:00
|
|
|
(uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-02-24 01:59:29 +00:00
|
|
|
if (bytes_read) {
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
if (load_addr_ptr)
|
|
|
|
|
*load_addr_ptr = load_addr;
|
2012-02-24 01:59:29 +00:00
|
|
|
return bytes_read;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2018-04-30 16:49:04 +00:00
|
|
|
// If the address is not section offset we have an address that doesn't
|
|
|
|
|
// resolve to any address in any currently loaded shared libraries and we
|
|
|
|
|
// failed to read memory so there isn't anything more we can do. If it is
|
|
|
|
|
// section offset, we might be able to read cached memory from the object
|
|
|
|
|
// file.
|
2010-06-30 23:03:03 +00:00
|
|
|
if (!resolved_addr.IsSectionOffset())
|
2012-04-25 00:06:56 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-11 05:12:02 +00:00
|
|
|
if (!prefer_file_cache && resolved_addr.IsSectionOffset()) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// If we didn't already try and read from the object file cache, then try
|
|
|
|
|
// it after failing to read from the process.
|
2011-01-07 01:57:07 +00:00
|
|
|
return ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
|
2010-06-30 23:03:03 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
|
2017-05-12 04:51:55 +00:00
|
|
|
Status &error) {
|
2013-01-21 19:20:50 +00:00
|
|
|
char buf[256];
|
|
|
|
|
out_str.clear();
|
|
|
|
|
addr_t curr_addr = addr.GetLoadAddress(this);
|
|
|
|
|
Address address(addr);
|
2019-05-24 00:44:33 +00:00
|
|
|
while (true) {
|
2013-01-21 19:20:50 +00:00
|
|
|
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
|
|
|
|
|
if (length == 0)
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
2013-01-21 19:20:50 +00:00
|
|
|
out_str.append(buf, length);
|
2018-04-30 16:49:04 +00:00
|
|
|
// If we got "length - 1" bytes, we didn't get the whole C string, we need
|
|
|
|
|
// to read some more characters
|
2013-01-21 19:20:50 +00:00
|
|
|
if (length == sizeof(buf) - 1)
|
|
|
|
|
curr_addr += length;
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
|
|
|
|
break;
|
2013-01-21 19:20:50 +00:00
|
|
|
address = Address(curr_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-01-21 19:20:50 +00:00
|
|
|
return out_str.size();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
|
2017-05-12 04:51:55 +00:00
|
|
|
size_t dst_max_len, Status &result_error) {
|
2013-01-21 19:20:50 +00:00
|
|
|
size_t total_cstr_len = 0;
|
|
|
|
|
if (dst && dst_max_len) {
|
|
|
|
|
result_error.Clear();
|
|
|
|
|
// NULL out everything just to be safe
|
|
|
|
|
memset(dst, 0, dst_max_len);
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2013-01-21 19:20:50 +00:00
|
|
|
addr_t curr_addr = addr.GetLoadAddress(this);
|
|
|
|
|
Address address(addr);
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// We could call m_process_sp->GetMemoryCacheLineSize() but I don't think
|
|
|
|
|
// this really needs to be tied to the memory cache subsystem's cache line
|
|
|
|
|
// size, so leave this as a fixed constant.
|
2013-01-21 19:20:50 +00:00
|
|
|
const size_t cache_line_size = 512;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
size_t bytes_left = dst_max_len - 1;
|
|
|
|
|
char *curr_dst = dst;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
while (bytes_left > 0) {
|
|
|
|
|
addr_t cache_line_bytes_left =
|
|
|
|
|
cache_line_size - (curr_addr % cache_line_size);
|
|
|
|
|
addr_t bytes_to_read =
|
|
|
|
|
std::min<addr_t>(bytes_left, cache_line_bytes_left);
|
|
|
|
|
size_t bytes_read =
|
|
|
|
|
ReadMemory(address, false, curr_dst, bytes_to_read, error);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
if (bytes_read == 0) {
|
|
|
|
|
result_error = error;
|
|
|
|
|
dst[total_cstr_len] = '\0';
|
|
|
|
|
break;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-01-21 19:20:50 +00:00
|
|
|
const size_t len = strlen(curr_dst);
|
|
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
total_cstr_len += len;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
if (len < bytes_to_read)
|
|
|
|
|
break;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-01-21 19:20:50 +00:00
|
|
|
curr_dst += bytes_read;
|
2011-07-12 17:06:17 +00:00
|
|
|
curr_addr += bytes_read;
|
|
|
|
|
bytes_left -= bytes_read;
|
|
|
|
|
address = Address(curr_addr);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-12-11 19:52:15 +00:00
|
|
|
if (dst == nullptr)
|
2012-11-29 22:16:27 +00:00
|
|
|
result_error.SetErrorString("invalid arguments");
|
2011-07-12 17:06:17 +00:00
|
|
|
else
|
|
|
|
|
result_error.Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-07-12 17:06:17 +00:00
|
|
|
return total_cstr_len;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
size_t Target::ReadScalarIntegerFromMemory(const Address &addr,
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
bool prefer_file_cache,
|
2011-07-12 17:06:17 +00:00
|
|
|
uint32_t byte_size, bool is_signed,
|
2017-05-12 04:51:55 +00:00
|
|
|
Scalar &scalar, Status &error) {
|
2011-07-12 17:06:17 +00:00
|
|
|
uint64_t uval;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
if (byte_size <= sizeof(uval)) {
|
2011-01-07 01:57:07 +00:00
|
|
|
size_t bytes_read =
|
2011-07-12 17:06:17 +00:00
|
|
|
ReadMemory(addr, prefer_file_cache, &uval, byte_size, error);
|
|
|
|
|
if (bytes_read == byte_size) {
|
2017-10-25 21:05:31 +00:00
|
|
|
DataExtractor data(&uval, sizeof(uval), m_arch.GetSpec().GetByteOrder(),
|
|
|
|
|
m_arch.GetSpec().GetAddressByteSize());
|
2011-07-12 17:06:17 +00:00
|
|
|
lldb::offset_t offset = 0;
|
|
|
|
|
if (byte_size <= 4)
|
|
|
|
|
scalar = data.GetMaxU32(&offset, byte_size);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2011-07-12 17:06:17 +00:00
|
|
|
scalar = data.GetMaxU64(&offset, byte_size);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
if (is_signed)
|
|
|
|
|
scalar.SignExtend(byte_size * 8);
|
|
|
|
|
return bytes_read;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2011-07-12 17:06:17 +00:00
|
|
|
"byte size of %u is too large for integer scalar type", byte_size);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-04-25 00:06:56 +00:00
|
|
|
return 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
uint64_t Target::ReadUnsignedIntegerFromMemory(const Address &addr,
|
|
|
|
|
bool prefer_file_cache,
|
|
|
|
|
size_t integer_byte_size,
|
|
|
|
|
uint64_t fail_value,
|
2017-05-12 04:51:55 +00:00
|
|
|
Status &error) {
|
2011-07-12 17:06:17 +00:00
|
|
|
Scalar scalar;
|
|
|
|
|
if (ReadScalarIntegerFromMemory(addr, prefer_file_cache, integer_byte_size,
|
|
|
|
|
false, scalar, error))
|
|
|
|
|
return scalar.ULongLong(fail_value);
|
|
|
|
|
return fail_value;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-12 17:06:17 +00:00
|
|
|
bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
|
2017-05-12 04:51:55 +00:00
|
|
|
Status &error, Address &pointer_addr) {
|
2011-07-12 17:06:17 +00:00
|
|
|
Scalar scalar;
|
|
|
|
|
if (ReadScalarIntegerFromMemory(addr, prefer_file_cache,
|
2019-07-19 00:56:26 +00:00
|
|
|
m_arch.GetSpec().GetAddressByteSize(), false,
|
|
|
|
|
scalar, error)) {
|
2011-07-12 17:06:17 +00:00
|
|
|
addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
|
2011-07-11 05:12:02 +00:00
|
|
|
if (pointer_vm_addr != LLDB_INVALID_ADDRESS) {
|
2011-07-12 17:06:17 +00:00
|
|
|
SectionLoadList §ion_load_list = GetSectionLoadList();
|
2013-12-06 01:12:00 +00:00
|
|
|
if (section_load_list.IsEmpty()) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// No sections are loaded, so we must assume we are not running yet and
|
|
|
|
|
// anything we are given is a file address.
|
2011-07-12 17:06:17 +00:00
|
|
|
m_images.ResolveFileAddress(pointer_vm_addr, pointer_addr);
|
|
|
|
|
} else {
|
2018-04-30 16:49:04 +00:00
|
|
|
// We have at least one section loaded. This can be because we have
|
|
|
|
|
// manually loaded some sections with "target modules load ..." or
|
|
|
|
|
// because we have have a live process that has sections loaded through
|
|
|
|
|
// the dynamic loader
|
2011-07-12 17:06:17 +00:00
|
|
|
section_load_list.ResolveLoadAddress(pointer_vm_addr, pointer_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2018-04-30 16:49:04 +00:00
|
|
|
// We weren't able to resolve the pointer value, so just return an
|
|
|
|
|
// address with no section
|
2011-07-12 17:06:17 +00:00
|
|
|
if (!pointer_addr.IsValid())
|
2013-12-06 01:12:00 +00:00
|
|
|
pointer_addr.SetOffset(pointer_vm_addr);
|
2011-10-28 23:14:11 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-12-06 01:12:00 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-08 23:03:02 +00:00
|
|
|
ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
|
|
|
|
|
Status *error_ptr) {
|
2010-06-08 16:52:24 +00:00
|
|
|
ModuleSP module_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
// First see if we already have this module in our module list. If we do,
|
2018-04-30 16:49:04 +00:00
|
|
|
// then we're done, we don't need to consult the shared modules list. But
|
|
|
|
|
// only do this if we are passed a UUID.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-05-17 18:38:42 +00:00
|
|
|
if (module_spec.GetUUID().IsValid())
|
2011-07-12 17:06:17 +00:00
|
|
|
module_sp = m_images.FindFirstModule(module_spec);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-04-27 00:58:27 +00:00
|
|
|
if (!module_sp) {
|
2011-07-12 17:06:17 +00:00
|
|
|
ModuleSP old_module_sp; // This will get filled in if we have a new version
|
|
|
|
|
// of the library
|
|
|
|
|
bool did_create_module = false;
|
2019-04-23 20:17:04 +00:00
|
|
|
FileSpecList search_paths = GetExecutableSearchPaths();
|
2011-07-12 17:06:17 +00:00
|
|
|
// If there are image search path entries, try to use them first to acquire
|
2012-05-17 18:38:42 +00:00
|
|
|
// a suitable image.
|
2011-07-12 17:06:17 +00:00
|
|
|
if (m_image_search_paths.GetSize()) {
|
|
|
|
|
ModuleSpec transformed_spec(module_spec);
|
|
|
|
|
if (m_image_search_paths.RemapPath(
|
2012-05-17 18:38:42 +00:00
|
|
|
module_spec.GetFileSpec().GetDirectory(),
|
|
|
|
|
transformed_spec.GetFileSpec().GetDirectory())) {
|
|
|
|
|
transformed_spec.GetFileSpec().GetFilename() =
|
2011-07-12 17:06:17 +00:00
|
|
|
module_spec.GetFileSpec().GetFilename();
|
|
|
|
|
error = ModuleList::GetSharedModule(transformed_spec, module_sp,
|
2019-07-19 00:56:26 +00:00
|
|
|
&search_paths, &old_module_sp,
|
|
|
|
|
&did_create_module);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-27 00:58:27 +00:00
|
|
|
if (!module_sp) {
|
2014-07-01 21:22:11 +00:00
|
|
|
// If we have a UUID, we can check our global shared module list in case
|
2011-07-12 17:06:17 +00:00
|
|
|
// we already have it. If we don't have a valid UUID, then we can't since
|
|
|
|
|
// the path in "module_spec" will be a platform path, and we will need to
|
|
|
|
|
// let the platform find that file. For example, we could be asking for
|
|
|
|
|
// "/usr/lib/dyld" and if we do not have a UUID, we don't want to pick
|
|
|
|
|
// the local copy of "/usr/lib/dyld" since our platform could be a remote
|
|
|
|
|
// platform that has its own "/usr/lib/dyld" in an SDK or in a local file
|
|
|
|
|
// cache.
|
2013-12-06 01:12:00 +00:00
|
|
|
if (module_spec.GetUUID().IsValid()) {
|
2011-07-12 17:06:17 +00:00
|
|
|
// We have a UUID, it is OK to check the global module list...
|
2019-07-19 00:56:26 +00:00
|
|
|
error =
|
|
|
|
|
ModuleList::GetSharedModule(module_spec, module_sp, &search_paths,
|
|
|
|
|
&old_module_sp, &did_create_module);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-27 00:58:27 +00:00
|
|
|
if (!module_sp) {
|
2011-07-12 17:06:17 +00:00
|
|
|
// The platform is responsible for finding and caching an appropriate
|
|
|
|
|
// module in the shared module cache.
|
|
|
|
|
if (m_platform_sp) {
|
|
|
|
|
error = m_platform_sp->GetSharedModule(
|
2019-07-19 00:56:26 +00:00
|
|
|
module_spec, m_process_sp.get(), module_sp, &search_paths,
|
|
|
|
|
&old_module_sp, &did_create_module);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2011-07-12 17:06:17 +00:00
|
|
|
error.SetErrorString("no platform is currently set");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-05-17 18:38:42 +00:00
|
|
|
// We found a module that wasn't in our target list. Let's make sure that
|
2018-04-30 16:49:04 +00:00
|
|
|
// there wasn't an equivalent module in the list already, and if there was,
|
|
|
|
|
// let's remove it.
|
2012-05-17 18:38:42 +00:00
|
|
|
if (module_sp) {
|
|
|
|
|
ObjectFile *objfile = module_sp->GetObjectFile();
|
2012-02-24 01:59:29 +00:00
|
|
|
if (objfile) {
|
2012-11-29 22:16:27 +00:00
|
|
|
switch (objfile->GetType()) {
|
2012-05-17 18:38:42 +00:00
|
|
|
case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of
|
|
|
|
|
/// a program's execution state
|
2012-11-29 22:16:27 +00:00
|
|
|
case ObjectFile::eTypeExecutable: /// A normal executable
|
2012-05-17 18:38:42 +00:00
|
|
|
case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker
|
2012-11-29 22:16:27 +00:00
|
|
|
/// executable
|
|
|
|
|
case ObjectFile::eTypeObjectFile: /// An intermediate object file
|
2012-05-17 18:38:42 +00:00
|
|
|
case ObjectFile::eTypeSharedLibrary: /// A shared library that can be
|
|
|
|
|
/// used during execution
|
|
|
|
|
break;
|
|
|
|
|
case ObjectFile::eTypeDebugInfo: /// An object file that contains only
|
|
|
|
|
/// debug information
|
|
|
|
|
if (error_ptr)
|
|
|
|
|
error_ptr->SetErrorString("debug info files aren't valid target "
|
|
|
|
|
"modules, please specify an executable");
|
|
|
|
|
return ModuleSP();
|
|
|
|
|
case ObjectFile::eTypeStubLibrary: /// A library that can be linked
|
|
|
|
|
/// against but not used for
|
2012-11-29 22:16:27 +00:00
|
|
|
/// execution
|
2012-05-17 18:38:42 +00:00
|
|
|
if (error_ptr)
|
|
|
|
|
error_ptr->SetErrorString("stub libraries aren't valid target "
|
|
|
|
|
"modules, please specify an executable");
|
|
|
|
|
return ModuleSP();
|
2016-09-06 20:57:50 +00:00
|
|
|
default:
|
2012-05-17 18:38:42 +00:00
|
|
|
if (error_ptr)
|
|
|
|
|
error_ptr->SetErrorString(
|
|
|
|
|
"unsupported file type, please specify an executable");
|
|
|
|
|
return ModuleSP();
|
2012-04-27 00:58:27 +00:00
|
|
|
}
|
2012-05-17 18:38:42 +00:00
|
|
|
// GetSharedModule is not guaranteed to find the old shared module, for
|
2018-04-30 16:49:04 +00:00
|
|
|
// instance in the common case where you pass in the UUID, it is only
|
|
|
|
|
// going to find the one module matching the UUID. In fact, it has no
|
|
|
|
|
// good way to know what the "old module" relevant to this target is,
|
|
|
|
|
// since there might be many copies of a module with this file spec in
|
|
|
|
|
// various running debug sessions, but only one of them will belong to
|
|
|
|
|
// this target. So let's remove the UUID from the module list, and look
|
|
|
|
|
// in the target's module list. Only do this if there is SOMETHING else
|
|
|
|
|
// in the module spec...
|
2012-05-17 18:38:42 +00:00
|
|
|
if (!old_module_sp) {
|
|
|
|
|
if (module_spec.GetUUID().IsValid() &&
|
2012-11-29 22:16:27 +00:00
|
|
|
!module_spec.GetFileSpec().GetFilename().IsEmpty() &&
|
2012-05-17 18:38:42 +00:00
|
|
|
!module_spec.GetFileSpec().GetDirectory().IsEmpty()) {
|
2015-03-24 11:15:23 +00:00
|
|
|
ModuleSpec module_spec_copy(module_spec.GetFileSpec());
|
2012-05-17 18:38:42 +00:00
|
|
|
module_spec_copy.GetUUID().Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-11-29 22:16:27 +00:00
|
|
|
ModuleList found_modules;
|
2019-10-17 19:56:40 +00:00
|
|
|
m_images.FindModules(module_spec_copy, found_modules);
|
|
|
|
|
if (found_modules.GetSize() == 1)
|
2012-05-17 18:38:42 +00:00
|
|
|
old_module_sp = found_modules.GetModuleAtIndex(0);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-04-27 00:58:27 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2017-04-28 00:51:06 +00:00
|
|
|
// Preload symbols outside of any lock, so hopefully we can do this for
|
|
|
|
|
// each library in parallel.
|
|
|
|
|
if (GetPreloadSymbols())
|
|
|
|
|
module_sp->PreloadSymbols();
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
if (old_module_sp && m_images.GetIndexForModule(old_module_sp.get()) !=
|
|
|
|
|
LLDB_INVALID_INDEX32) {
|
2012-11-29 22:16:27 +00:00
|
|
|
m_images.ReplaceModule(old_module_sp, module_sp);
|
|
|
|
|
Module *old_module_ptr = old_module_sp.get();
|
|
|
|
|
old_module_sp.reset();
|
|
|
|
|
ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr);
|
2019-04-08 23:03:02 +00:00
|
|
|
} else {
|
|
|
|
|
m_images.Append(module_sp, notify);
|
|
|
|
|
}
|
2014-04-07 23:50:17 +00:00
|
|
|
} else
|
|
|
|
|
module_sp.reset();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
if (error_ptr)
|
|
|
|
|
*error_ptr = error;
|
|
|
|
|
return module_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:35:26 +00:00
|
|
|
TargetSP Target::CalculateTarget() { return shared_from_this(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
ProcessSP Target::CalculateProcess() { return m_process_sp; }
|
|
|
|
|
|
|
|
|
|
ThreadSP Target::CalculateThread() { return ThreadSP(); }
|
|
|
|
|
|
2013-11-04 09:33:30 +00:00
|
|
|
StackFrameSP Target::CalculateStackFrame() { return StackFrameSP(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-10-04 01:05:56 +00:00
|
|
|
void Target::CalculateExecutionContext(ExecutionContext &exe_ctx) {
|
2011-09-22 04:58:26 +00:00
|
|
|
exe_ctx.Clear();
|
|
|
|
|
exe_ctx.SetTargetPtr(this);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PathMappingList &Target::GetImageSearchPathList() {
|
|
|
|
|
return m_image_search_paths;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
void Target::ImageSearchPathsChanged(const PathMappingList &path_list,
|
|
|
|
|
void *baton) {
|
2010-06-08 16:52:24 +00:00
|
|
|
Target *target = (Target *)baton;
|
2011-08-11 02:48:45 +00:00
|
|
|
ModuleSP exe_module_sp(target->GetExecutableModule());
|
|
|
|
|
if (exe_module_sp)
|
2018-09-20 09:09:05 +00:00
|
|
|
target->SetExecutableModule(exe_module_sp, eLoadDependentsYes);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
llvm::Expected<TypeSystem &>
|
|
|
|
|
Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
|
|
|
|
|
bool create_on_demand) {
|
2015-10-08 21:04:34 +00:00
|
|
|
if (!m_valid)
|
2019-07-30 22:12:34 +00:00
|
|
|
return llvm::make_error<llvm::StringError>("Invalid Target",
|
|
|
|
|
llvm::inconvertibleErrorCode());
|
2015-10-01 16:28:02 +00:00
|
|
|
|
2015-10-08 21:04:34 +00:00
|
|
|
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
|
|
|
|
|
// assembly code
|
2015-10-02 18:40:30 +00:00
|
|
|
|| language == eLanguageTypeUnknown) {
|
2019-08-22 21:45:58 +00:00
|
|
|
LanguageSet languages_for_expressions =
|
|
|
|
|
Language::GetLanguagesSupportingTypeSystemsForExpressions();
|
2015-09-15 21:13:50 +00:00
|
|
|
|
2019-08-22 21:45:58 +00:00
|
|
|
if (languages_for_expressions[eLanguageTypeC]) {
|
2015-10-02 18:40:30 +00:00
|
|
|
language = eLanguageTypeC; // LLDB's default. Override by setting the
|
|
|
|
|
// target language.
|
|
|
|
|
} else {
|
2019-08-22 21:45:58 +00:00
|
|
|
if (languages_for_expressions.Empty())
|
2019-07-30 22:12:34 +00:00
|
|
|
return llvm::make_error<llvm::StringError>(
|
|
|
|
|
"No expression support for any languages",
|
|
|
|
|
llvm::inconvertibleErrorCode());
|
2019-08-22 21:45:58 +00:00
|
|
|
language = (LanguageType)languages_for_expressions.bitvector.find_first();
|
2015-09-15 21:13:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-10-01 16:28:02 +00:00
|
|
|
|
2015-11-10 22:54:42 +00:00
|
|
|
return m_scratch_type_system_map.GetTypeSystemForLanguage(language, this,
|
|
|
|
|
create_on_demand);
|
2011-11-16 18:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-31 20:47:38 +00:00
|
|
|
std::vector<TypeSystem *> Target::GetScratchTypeSystems(bool create_on_demand) {
|
|
|
|
|
if (!m_valid)
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
std::vector<TypeSystem *> scratch_type_systems;
|
|
|
|
|
|
2019-08-22 21:45:58 +00:00
|
|
|
LanguageSet languages_for_expressions =
|
|
|
|
|
Language::GetLanguagesSupportingTypeSystemsForExpressions();
|
2019-07-31 20:47:38 +00:00
|
|
|
|
2019-08-22 21:45:58 +00:00
|
|
|
for (auto bit : languages_for_expressions.bitvector.set_bits()) {
|
|
|
|
|
auto language = (LanguageType)bit;
|
2019-07-31 20:47:38 +00:00
|
|
|
auto type_system_or_err =
|
2019-08-22 21:45:58 +00:00
|
|
|
GetScratchTypeSystemForLanguage(language, create_on_demand);
|
2019-07-31 20:47:38 +00:00
|
|
|
if (!type_system_or_err)
|
|
|
|
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
|
|
|
|
|
type_system_or_err.takeError(),
|
|
|
|
|
"Language '{}' has expression support but no scratch type "
|
|
|
|
|
"system available",
|
2019-08-22 21:45:58 +00:00
|
|
|
Language::GetNameForLanguageType(language));
|
2019-07-31 20:47:38 +00:00
|
|
|
else
|
|
|
|
|
scratch_type_systems.emplace_back(&type_system_or_err.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return scratch_type_systems;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 18:39:03 +00:00
|
|
|
PersistentExpressionState *
|
2015-04-03 15:39:47 +00:00
|
|
|
Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
|
2019-07-30 22:12:34 +00:00
|
|
|
auto type_system_or_err = GetScratchTypeSystemForLanguage(language, true);
|
2010-12-14 02:59:59 +00:00
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
|
|
|
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
|
|
|
|
|
std::move(err),
|
|
|
|
|
"Unable to get persistent expression state for language {}",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
2015-10-02 18:40:30 +00:00
|
|
|
return nullptr;
|
2010-12-14 02:59:59 +00:00
|
|
|
}
|
2019-07-30 22:12:34 +00:00
|
|
|
|
|
|
|
|
return type_system_or_err->GetPersistentExpressionState();
|
2010-12-14 02:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-08 21:04:34 +00:00
|
|
|
UserExpression *Target::GetUserExpressionForLanguage(
|
2016-11-08 04:52:16 +00:00
|
|
|
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
|
2015-10-08 21:04:34 +00:00
|
|
|
Expression::ResultType desired_type,
|
2019-07-19 00:56:26 +00:00
|
|
|
const EvaluateExpressionOptions &options, ValueObject *ctx_obj,
|
|
|
|
|
Status &error) {
|
2019-07-30 22:12:34 +00:00
|
|
|
auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
|
|
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
"Could not find type system for language %s: %s",
|
|
|
|
|
Language::GetNameForLanguageType(language),
|
2019-07-30 22:12:34 +00:00
|
|
|
llvm::toString(std::move(err)).c_str());
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
return nullptr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
auto *user_expr = type_system_or_err->GetUserExpression(
|
|
|
|
|
expr, prefix, language, desired_type, options, ctx_obj);
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
if (!user_expr)
|
|
|
|
|
error.SetErrorStringWithFormat(
|
2015-09-22 06:36:56 +00:00
|
|
|
"Could not create an expression for language %s",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-22 06:36:56 +00:00
|
|
|
return user_expr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-22 06:36:56 +00:00
|
|
|
FunctionCaller *Target::GetFunctionCallerForLanguage(
|
|
|
|
|
lldb::LanguageType language, const CompilerType &return_type,
|
|
|
|
|
const Address &function_address, const ValueList &arg_value_list,
|
2017-05-12 04:51:55 +00:00
|
|
|
const char *name, Status &error) {
|
2019-07-30 22:12:34 +00:00
|
|
|
auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
|
|
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
2012-11-29 21:49:15 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2015-09-22 06:36:56 +00:00
|
|
|
"Could not find type system for language %s: %s",
|
2015-10-02 18:40:30 +00:00
|
|
|
Language::GetNameForLanguageType(language),
|
2019-07-30 22:12:34 +00:00
|
|
|
llvm::toString(std::move(err)).c_str());
|
|
|
|
|
return nullptr;
|
2015-09-22 06:36:56 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
auto *persistent_fn = type_system_or_err->GetFunctionCaller(
|
|
|
|
|
return_type, function_address, arg_value_list, name);
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
if (!persistent_fn)
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Could not create an expression for language %s",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
|
|
|
|
|
|
|
|
|
return persistent_fn;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 21:13:50 +00:00
|
|
|
UtilityFunction *
|
2015-08-26 06:04:54 +00:00
|
|
|
Target::GetUtilityFunctionForLanguage(const char *text,
|
|
|
|
|
lldb::LanguageType language,
|
2017-05-12 04:51:55 +00:00
|
|
|
const char *name, Status &error) {
|
2019-07-30 22:12:34 +00:00
|
|
|
auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
2016-01-27 10:16:30 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2015-08-26 06:04:54 +00:00
|
|
|
"Could not find type system for language %s: %s",
|
2015-10-02 18:40:30 +00:00
|
|
|
Language::GetNameForLanguageType(language),
|
2019-07-30 22:12:34 +00:00
|
|
|
llvm::toString(std::move(err)).c_str());
|
|
|
|
|
return nullptr;
|
2015-08-26 06:04:54 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-30 22:12:34 +00:00
|
|
|
auto *utility_fn = type_system_or_err->GetUtilityFunction(text, name);
|
2015-08-26 06:04:54 +00:00
|
|
|
if (!utility_fn)
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"Could not create an expression for language %s",
|
|
|
|
|
Language::GetNameForLanguageType(language));
|
|
|
|
|
|
|
|
|
|
return utility_fn;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-27 23:43:24 +00:00
|
|
|
void Target::SettingsInitialize() { Process::SettingsInitialize(); }
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
|
|
|
|
|
void Target::SettingsTerminate() { Process::SettingsTerminate(); }
|
|
|
|
|
|
|
|
|
|
FileSpecList Target::GetDefaultExecutableSearchPaths() {
|
|
|
|
|
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
|
|
|
|
|
if (properties_sp)
|
|
|
|
|
return properties_sp->GetExecutableSearchPaths();
|
|
|
|
|
return FileSpecList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileSpecList Target::GetDefaultDebugFileSearchPaths() {
|
|
|
|
|
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
|
|
|
|
|
if (properties_sp)
|
|
|
|
|
return properties_sp->GetDebugFileSearchPaths();
|
|
|
|
|
return FileSpecList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArchSpec Target::GetDefaultArchitecture() {
|
|
|
|
|
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
|
|
|
|
|
if (properties_sp)
|
|
|
|
|
return properties_sp->GetDefaultArchitecture();
|
|
|
|
|
return ArchSpec();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-03 22:24:48 +00:00
|
|
|
void Target::SetDefaultArchitecture(const ArchSpec &arch) {
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
|
|
|
|
|
if (properties_sp) {
|
2019-07-22 23:48:01 +00:00
|
|
|
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
|
|
|
|
|
"Target::SetDefaultArchitecture setting target's "
|
2019-07-23 17:03:37 +00:00
|
|
|
"default architecture to {0} ({1})",
|
|
|
|
|
arch.GetArchitectureName(), arch.GetTriple().getTriple());
|
2015-05-29 19:52:29 +00:00
|
|
|
return properties_sp->SetDefaultArchitecture(arch);
|
2013-11-20 21:07:01 +00:00
|
|
|
}
|
2013-12-06 01:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 07:22:56 +00:00
|
|
|
Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
|
|
|
|
|
const SymbolContext *sc_ptr) {
|
|
|
|
|
// The target can either exist in the "process" of ExecutionContext, or in
|
|
|
|
|
// the "target_sp" member of SymbolContext. This accessor helper function
|
|
|
|
|
// will get the target from one of these locations.
|
|
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
Target *target = nullptr;
|
|
|
|
|
if (sc_ptr != nullptr)
|
|
|
|
|
target = sc_ptr->target_sp.get();
|
|
|
|
|
if (target == nullptr && exe_ctx_ptr)
|
|
|
|
|
target = exe_ctx_ptr->GetTargetPtr();
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 19:39:20 +00:00
|
|
|
ExpressionResults Target::EvaluateExpression(
|
2016-11-08 04:52:16 +00:00
|
|
|
llvm::StringRef expr, ExecutionContextScope *exe_scope,
|
2014-11-17 19:39:20 +00:00
|
|
|
lldb::ValueObjectSP &result_valobj_sp,
|
2019-02-05 09:14:36 +00:00
|
|
|
const EvaluateExpressionOptions &options, std::string *fixed_expression,
|
|
|
|
|
ValueObject *ctx_obj) {
|
2014-11-17 19:39:20 +00:00
|
|
|
result_valobj_sp.reset();
|
|
|
|
|
|
|
|
|
|
ExpressionResults execution_results = eExpressionSetupError;
|
|
|
|
|
|
2016-11-08 04:52:16 +00:00
|
|
|
if (expr.empty())
|
2013-12-06 01:12:00 +00:00
|
|
|
return execution_results;
|
|
|
|
|
|
2019-06-10 21:13:37 +00:00
|
|
|
// We shouldn't run stop hooks in expressions.
|
2013-12-06 01:12:00 +00:00
|
|
|
bool old_suppress_value = m_suppress_stop_hooks;
|
2011-05-12 02:06:14 +00:00
|
|
|
m_suppress_stop_hooks = true;
|
2019-06-10 21:13:37 +00:00
|
|
|
auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
|
2019-07-19 00:56:26 +00:00
|
|
|
m_suppress_stop_hooks = old_suppress_value;
|
|
|
|
|
});
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
ExecutionContext exe_ctx;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-24 00:52:29 +00:00
|
|
|
if (exe_scope) {
|
2013-12-06 01:12:00 +00:00
|
|
|
exe_scope->CalculateExecutionContext(exe_ctx);
|
|
|
|
|
} else if (m_process_sp) {
|
|
|
|
|
m_process_sp->CalculateExecutionContext(exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2010-12-14 02:59:59 +00:00
|
|
|
CalculateExecutionContext(exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Make sure we aren't just trying to see the value of a persistent variable
|
|
|
|
|
// (something like "$0")
|
2013-12-06 01:12:00 +00:00
|
|
|
// Only check for persistent variables the expression starts with a '$'
|
2019-07-30 22:12:34 +00:00
|
|
|
lldb::ExpressionVariableSP persistent_var_sp;
|
|
|
|
|
if (expr[0] == '$') {
|
|
|
|
|
auto type_system_or_err =
|
|
|
|
|
GetScratchTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
|
|
|
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
|
|
|
|
|
std::move(err), "Unable to get scratch type system");
|
|
|
|
|
} else {
|
|
|
|
|
persistent_var_sp =
|
|
|
|
|
type_system_or_err->GetPersistentExpressionState()->GetVariable(expr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-12 02:04:23 +00:00
|
|
|
if (persistent_var_sp) {
|
2013-12-06 01:12:00 +00:00
|
|
|
result_valobj_sp = persistent_var_sp->GetValueObject();
|
|
|
|
|
execution_results = eExpressionCompleted;
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 10:54:30 +00:00
|
|
|
llvm::StringRef prefix = GetExpressionPrefixContents();
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2020-01-30 23:16:12 -08:00
|
|
|
execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
|
|
|
|
|
result_valobj_sp, error,
|
|
|
|
|
fixed_expression, ctx_obj);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-08 02:13:16 +00:00
|
|
|
return execution_results;
|
2013-12-06 01:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
lldb::ExpressionVariableSP Target::GetPersistentVariable(ConstString name) {
|
2013-12-06 01:12:00 +00:00
|
|
|
lldb::ExpressionVariableSP variable_sp;
|
|
|
|
|
m_scratch_type_system_map.ForEach(
|
2017-03-02 00:05:25 +00:00
|
|
|
[name, &variable_sp](TypeSystem *type_system) -> bool {
|
2015-10-08 21:04:34 +00:00
|
|
|
if (PersistentExpressionState *persistent_state =
|
2013-12-06 01:12:00 +00:00
|
|
|
type_system->GetPersistentExpressionState()) {
|
|
|
|
|
variable_sp = persistent_state->GetVariable(name);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-08 21:04:34 +00:00
|
|
|
if (variable_sp)
|
2013-12-06 01:12:00 +00:00
|
|
|
return false; // Stop iterating the ForEach
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-10-08 21:04:34 +00:00
|
|
|
return true; // Keep iterating the ForEach
|
2016-09-06 20:57:50 +00:00
|
|
|
});
|
2015-10-08 21:04:34 +00:00
|
|
|
return variable_sp;
|
2013-12-06 01:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 21:22:25 +00:00
|
|
|
lldb::addr_t Target::GetPersistentSymbol(ConstString name) {
|
2014-10-09 01:02:08 +00:00
|
|
|
lldb::addr_t address = LLDB_INVALID_ADDRESS;
|
|
|
|
|
|
2013-12-18 02:06:45 +00:00
|
|
|
m_scratch_type_system_map.ForEach(
|
2017-03-02 00:05:25 +00:00
|
|
|
[name, &address](TypeSystem *type_system) -> bool {
|
2014-10-09 01:02:08 +00:00
|
|
|
if (PersistentExpressionState *persistent_state =
|
|
|
|
|
type_system->GetPersistentExpressionState()) {
|
|
|
|
|
address = persistent_state->LookupSymbol(name);
|
|
|
|
|
if (address != LLDB_INVALID_ADDRESS)
|
|
|
|
|
return false; // Stop iterating the ForEach
|
|
|
|
|
}
|
|
|
|
|
return true; // Keep iterating the ForEach
|
|
|
|
|
});
|
2015-10-08 21:04:34 +00:00
|
|
|
return address;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:52:08 +00:00
|
|
|
llvm::Expected<lldb_private::Address> Target::GetEntryPointAddress() {
|
2019-07-18 20:55:24 +00:00
|
|
|
Module *exe_module = GetExecutableModulePointer();
|
2019-07-19 00:52:08 +00:00
|
|
|
llvm::Error error = llvm::Error::success();
|
|
|
|
|
assert(!error); // Check the success value when assertions are enabled.
|
2019-07-18 20:55:24 +00:00
|
|
|
|
|
|
|
|
if (!exe_module || !exe_module->GetObjectFile()) {
|
2019-07-19 00:52:08 +00:00
|
|
|
error = llvm::make_error<llvm::StringError>("No primary executable found",
|
|
|
|
|
llvm::inconvertibleErrorCode());
|
2019-07-18 20:55:24 +00:00
|
|
|
} else {
|
2019-07-19 00:52:08 +00:00
|
|
|
Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress();
|
|
|
|
|
if (entry_addr.IsValid())
|
|
|
|
|
return entry_addr;
|
|
|
|
|
|
|
|
|
|
error = llvm::make_error<llvm::StringError>(
|
|
|
|
|
"Could not find entry point address for executable module \"" +
|
|
|
|
|
exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"",
|
|
|
|
|
llvm::inconvertibleErrorCode());
|
2019-07-18 20:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
const ModuleList &modules = GetImages();
|
|
|
|
|
const size_t num_images = modules.GetSize();
|
|
|
|
|
for (size_t idx = 0; idx < num_images; ++idx) {
|
|
|
|
|
ModuleSP module_sp(modules.GetModuleAtIndex(idx));
|
|
|
|
|
if (!module_sp || !module_sp->GetObjectFile())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
|
|
|
|
|
if (entry_addr.IsValid()) {
|
|
|
|
|
// Discard the error.
|
|
|
|
|
llvm::consumeError(std::move(error));
|
|
|
|
|
return entry_addr;
|
2019-07-18 20:55:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:52:08 +00:00
|
|
|
return std::move(error);
|
2019-07-18 20:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-09 01:02:08 +00:00
|
|
|
lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
|
|
|
|
|
AddressClass addr_class) const {
|
2018-09-21 18:56:44 +00:00
|
|
|
auto arch_plugin = GetArchitecturePlugin();
|
2019-07-19 00:56:26 +00:00
|
|
|
return arch_plugin
|
|
|
|
|
? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
|
|
|
|
|
: load_addr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr,
|
|
|
|
|
AddressClass addr_class) const {
|
2018-09-21 18:56:44 +00:00
|
|
|
auto arch_plugin = GetArchitecturePlugin();
|
2019-07-19 00:56:26 +00:00
|
|
|
return arch_plugin ? arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class)
|
|
|
|
|
: load_addr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-22 22:46:53 +00:00
|
|
|
lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
|
2018-09-21 18:56:44 +00:00
|
|
|
auto arch_plugin = GetArchitecturePlugin();
|
2019-07-19 00:56:26 +00:00
|
|
|
return arch_plugin ? arch_plugin->GetBreakableLoadAddress(addr, *this) : addr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-10-09 01:02:08 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
SourceManager &Target::GetSourceManager() {
|
2019-02-13 06:25:41 +00:00
|
|
|
if (!m_source_manager_up)
|
2020-06-24 17:44:33 -07:00
|
|
|
m_source_manager_up = std::make_unique<SourceManager>(shared_from_this());
|
2019-02-13 06:25:41 +00:00
|
|
|
return *m_source_manager_up;
|
2013-12-13 17:20:18 +00:00
|
|
|
}
|
2014-07-22 23:41:36 +00:00
|
|
|
|
|
|
|
|
ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
|
|
|
|
|
static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended
|
|
|
|
|
// we can make it
|
|
|
|
|
// per-target
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(s_clang_modules_decl_vendor_mutex);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
if (!m_clang_modules_decl_vendor_up) {
|
|
|
|
|
m_clang_modules_decl_vendor_up.reset(
|
2013-12-13 17:20:18 +00:00
|
|
|
ClangModulesDeclVendor::Create(*this));
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-12-13 17:20:18 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
return m_clang_modules_decl_vendor_up.get();
|
2015-03-26 20:41:14 +00:00
|
|
|
}
|
2014-10-09 01:02:08 +00:00
|
|
|
|
2016-07-28 17:32:20 +00:00
|
|
|
Target::StopHookSP Target::CreateStopHook() {
|
|
|
|
|
lldb::user_id_t new_uid = ++m_stop_hook_next_id;
|
|
|
|
|
Target::StopHookSP stop_hook_sp(new StopHook(shared_from_this(), new_uid));
|
|
|
|
|
m_stop_hooks[new_uid] = stop_hook_sp;
|
2014-01-27 23:43:24 +00:00
|
|
|
return stop_hook_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2016-07-28 17:32:20 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
bool Target::RemoveStopHookByID(lldb::user_id_t user_id) {
|
2015-12-11 19:52:15 +00:00
|
|
|
size_t num_removed = m_stop_hooks.erase(user_id);
|
|
|
|
|
return (num_removed != 0);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
void Target::RemoveAllStopHooks() { m_stop_hooks.clear(); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
Target::StopHookSP Target::GetStopHookByID(lldb::user_id_t user_id) {
|
|
|
|
|
StopHookSP found_hook;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
StopHookCollection::iterator specified_hook_iter;
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
specified_hook_iter = m_stop_hooks.find(user_id);
|
|
|
|
|
if (specified_hook_iter != m_stop_hooks.end())
|
|
|
|
|
found_hook = (*specified_hook_iter).second;
|
2014-01-27 23:43:24 +00:00
|
|
|
return found_hook;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
bool Target::SetStopHookActiveStateByID(lldb::user_id_t user_id,
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
bool active_state) {
|
|
|
|
|
StopHookCollection::iterator specified_hook_iter;
|
|
|
|
|
specified_hook_iter = m_stop_hooks.find(user_id);
|
2013-12-13 17:20:18 +00:00
|
|
|
if (specified_hook_iter == m_stop_hooks.end())
|
2015-10-08 21:04:34 +00:00
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 20:41:14 +00:00
|
|
|
(*specified_hook_iter).second->SetIsActive(active_state);
|
|
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-26 20:41:14 +00:00
|
|
|
void Target::SetAllStopHooksActiveState(bool active_state) {
|
|
|
|
|
StopHookCollection::iterator pos, end = m_stop_hooks.end();
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
for (pos = m_stop_hooks.begin(); pos != end; pos++) {
|
2015-03-26 20:41:14 +00:00
|
|
|
(*pos).second->SetIsActive(active_state);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
void Target::RunStopHooks() {
|
2011-05-12 02:06:14 +00:00
|
|
|
if (m_suppress_stop_hooks)
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
2015-03-26 20:41:14 +00:00
|
|
|
if (!m_process_sp)
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2017-12-05 02:34:05 +00:00
|
|
|
// Somebody might have restarted the process:
|
|
|
|
|
if (m_process_sp->GetState() != eStateStopped)
|
|
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-03 22:24:48 +00:00
|
|
|
// <rdar://problem/12027563> make sure we check that we are not stopped
|
2018-04-30 16:49:04 +00:00
|
|
|
// because of us running a user expression since in that case we do not want
|
|
|
|
|
// to run the stop-hooks
|
2015-03-26 20:41:14 +00:00
|
|
|
if (m_process_sp->GetModIDRef().IsLastResumeForUserExpression())
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
2015-03-26 20:41:14 +00:00
|
|
|
if (m_stop_hooks.empty())
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
2016-07-28 17:32:20 +00:00
|
|
|
StopHookCollection::iterator pos, end = m_stop_hooks.end();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-01 18:13:38 +00:00
|
|
|
// If there aren't any active stop hooks, don't bother either.
|
|
|
|
|
// Also see if any of the active hooks want to auto-continue.
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
bool any_active_hooks = false;
|
2019-03-01 18:13:38 +00:00
|
|
|
bool auto_continue = false;
|
|
|
|
|
for (auto hook : m_stop_hooks) {
|
|
|
|
|
if (hook.second->IsActive()) {
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
any_active_hooks = true;
|
2019-03-01 18:13:38 +00:00
|
|
|
auto_continue |= hook.second->GetAutoContinue();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
if (!any_active_hooks)
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
2020-06-09 10:21:09 -07:00
|
|
|
CommandReturnObject result(m_debugger.GetUseColor());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
std::vector<ExecutionContext> exc_ctx_with_reasons;
|
|
|
|
|
std::vector<SymbolContext> sym_ctx_with_reasons;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
ThreadList &cur_threadlist = m_process_sp->GetThreadList();
|
|
|
|
|
size_t num_threads = cur_threadlist.GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_threads; i++) {
|
|
|
|
|
lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex(i);
|
|
|
|
|
if (cur_thread_sp->ThreadStoppedForAReason()) {
|
|
|
|
|
lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
|
|
|
|
|
exc_ctx_with_reasons.push_back(ExecutionContext(
|
|
|
|
|
m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get()));
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
sym_ctx_with_reasons.push_back(
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
cur_frame_sp->GetSymbolContext(eSymbolContextEverything));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
// If no threads stopped for a reason, don't run the stop-hooks.
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
size_t num_exe_ctx = exc_ctx_with_reasons.size();
|
|
|
|
|
if (num_exe_ctx == 0)
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
|
|
|
|
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
result.SetImmediateOutputStream(m_debugger.GetAsyncOutputStream());
|
|
|
|
|
result.SetImmediateErrorStream(m_debugger.GetAsyncErrorStream());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
bool keep_going = true;
|
|
|
|
|
bool hooks_ran = false;
|
2015-03-26 20:41:14 +00:00
|
|
|
bool print_hook_header = (m_stop_hooks.size() != 1);
|
|
|
|
|
bool print_thread_header = (num_exe_ctx != 1);
|
2019-03-01 18:13:38 +00:00
|
|
|
bool did_restart = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-26 20:41:14 +00:00
|
|
|
for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) {
|
|
|
|
|
// result.Clear();
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
StopHookSP cur_hook_sp = (*pos).second;
|
2015-03-26 20:41:14 +00:00
|
|
|
if (!cur_hook_sp->IsActive())
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
continue;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
bool any_thread_matched = false;
|
|
|
|
|
for (size_t i = 0; keep_going && i < num_exe_ctx; i++) {
|
2015-12-11 19:52:15 +00:00
|
|
|
if ((cur_hook_sp->GetSpecifier() == nullptr ||
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
cur_hook_sp->GetSpecifier()->SymbolContextMatches(
|
|
|
|
|
sym_ctx_with_reasons[i])) &&
|
2015-12-11 19:52:15 +00:00
|
|
|
(cur_hook_sp->GetThreadSpecifier() == nullptr ||
|
2015-03-26 20:41:14 +00:00
|
|
|
cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(
|
|
|
|
|
exc_ctx_with_reasons[i].GetThreadRef()))) {
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
if (!hooks_ran) {
|
2015-03-26 20:41:14 +00:00
|
|
|
hooks_ran = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-03-26 20:41:14 +00:00
|
|
|
if (print_hook_header && !any_thread_matched) {
|
2011-10-24 23:01:06 +00:00
|
|
|
const char *cmd =
|
2015-03-26 20:41:14 +00:00
|
|
|
(cur_hook_sp->GetCommands().GetSize() == 1
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
? cur_hook_sp->GetCommands().GetStringAtIndex(0)
|
|
|
|
|
: nullptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
if (cmd)
|
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-23 21:16:25 +00:00
|
|
|
result.AppendMessageWithFormat("\n- Hook %" PRIu64 " (%s)\n",
|
2014-04-30 20:29:09 +00:00
|
|
|
cur_hook_sp->GetID(), cmd);
|
|
|
|
|
else
|
|
|
|
|
result.AppendMessageWithFormat("\n- Hook %" PRIu64 "\n",
|
|
|
|
|
cur_hook_sp->GetID());
|
|
|
|
|
any_thread_matched = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-30 20:29:09 +00:00
|
|
|
if (print_thread_header)
|
|
|
|
|
result.AppendMessageWithFormat(
|
2011-09-22 04:58:26 +00:00
|
|
|
"-- Thread %d\n",
|
2014-04-30 20:29:09 +00:00
|
|
|
exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-04-30 20:29:09 +00:00
|
|
|
CommandInterpreterRunOptions options;
|
|
|
|
|
options.SetStopOnContinue(true);
|
|
|
|
|
options.SetStopOnError(true);
|
|
|
|
|
options.SetEchoCommands(false);
|
2014-10-11 00:38:27 +00:00
|
|
|
options.SetPrintResults(true);
|
2019-05-08 01:23:47 +00:00
|
|
|
options.SetPrintErrors(true);
|
2014-04-30 20:29:09 +00:00
|
|
|
options.SetAddToHistory(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-01 18:13:38 +00:00
|
|
|
// Force Async:
|
|
|
|
|
bool old_async = GetDebugger().GetAsyncExecution();
|
|
|
|
|
GetDebugger().SetAsyncExecution(true);
|
2014-04-30 20:29:09 +00:00
|
|
|
GetDebugger().GetCommandInterpreter().HandleCommands(
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
cur_hook_sp->GetCommands(), &exc_ctx_with_reasons[i], options,
|
2016-09-06 20:57:50 +00:00
|
|
|
result);
|
2019-03-01 18:13:38 +00:00
|
|
|
GetDebugger().SetAsyncExecution(old_async);
|
2014-04-30 20:29:09 +00:00
|
|
|
// If the command started the target going again, we should bag out of
|
|
|
|
|
// running the stop hooks.
|
|
|
|
|
if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
|
|
|
|
|
(result.GetStatus() == eReturnStatusSuccessContinuingResult)) {
|
2017-12-05 02:34:05 +00:00
|
|
|
// But only complain if there were more stop hooks to do:
|
|
|
|
|
StopHookCollection::iterator tmp = pos;
|
|
|
|
|
if (++tmp != end)
|
2019-07-19 00:56:26 +00:00
|
|
|
result.AppendMessageWithFormat(
|
|
|
|
|
"\nAborting stop hooks, hook %" PRIu64
|
|
|
|
|
" set the program running.\n"
|
|
|
|
|
" Consider using '-G true' to make "
|
|
|
|
|
"stop hooks auto-continue.\n",
|
|
|
|
|
cur_hook_sp->GetID());
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
keep_going = false;
|
2019-03-01 18:13:38 +00:00
|
|
|
did_restart = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-01 18:13:38 +00:00
|
|
|
// Finally, if auto-continue was requested, do it now:
|
|
|
|
|
if (!did_restart && auto_continue)
|
|
|
|
|
m_process_sp->PrivateResume();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-02 20:41:46 +00:00
|
|
|
result.GetImmediateOutputStream()->Flush();
|
2014-04-30 20:29:09 +00:00
|
|
|
result.GetImmediateErrorStream()->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
const TargetPropertiesSP &Target::GetGlobalProperties() {
|
2014-04-30 20:29:09 +00:00
|
|
|
// NOTE: intentional leak so we don't crash if global destructor chain gets
|
|
|
|
|
// called as other threads still use the result of this function
|
2016-10-19 15:12:45 +00:00
|
|
|
static TargetPropertiesSP *g_settings_sp_ptr =
|
|
|
|
|
new TargetPropertiesSP(new TargetProperties(nullptr));
|
2016-02-26 23:20:08 +00:00
|
|
|
return *g_settings_sp_ptr;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::Install(ProcessLaunchInfo *launch_info) {
|
|
|
|
|
Status error;
|
2014-04-30 20:29:09 +00:00
|
|
|
PlatformSP platform_sp(GetPlatform());
|
2013-11-20 21:07:01 +00:00
|
|
|
if (platform_sp) {
|
2014-04-30 20:29:09 +00:00
|
|
|
if (platform_sp->IsRemote()) {
|
|
|
|
|
if (platform_sp->IsConnected()) {
|
2020-01-21 19:24:57 +00:00
|
|
|
// Install all files that have an install path when connected to a
|
|
|
|
|
// remote platform. If target.auto-install-main-executable is set then
|
|
|
|
|
// also install the main executable even if it does not have an explicit
|
|
|
|
|
// install path specified.
|
2013-11-20 21:07:01 +00:00
|
|
|
const ModuleList &modules = GetImages();
|
|
|
|
|
const size_t num_images = modules.GetSize();
|
|
|
|
|
for (size_t idx = 0; idx < num_images; ++idx) {
|
2014-04-30 20:29:09 +00:00
|
|
|
ModuleSP module_sp(modules.GetModuleAtIndex(idx));
|
2013-11-20 21:07:01 +00:00
|
|
|
if (module_sp) {
|
2016-06-27 23:21:49 +00:00
|
|
|
const bool is_main_executable = module_sp == GetExecutableModule();
|
2014-04-30 20:29:09 +00:00
|
|
|
FileSpec local_file(module_sp->GetFileSpec());
|
2013-11-20 21:07:01 +00:00
|
|
|
if (local_file) {
|
2014-04-30 20:29:09 +00:00
|
|
|
FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
|
2013-11-20 21:07:01 +00:00
|
|
|
if (!remote_file) {
|
2020-01-21 19:24:57 +00:00
|
|
|
if (is_main_executable && GetAutoInstallMainExecutable()) {
|
|
|
|
|
// Automatically install the main executable.
|
2014-04-30 20:29:09 +00:00
|
|
|
remote_file = platform_sp->GetRemoteWorkingDirectory();
|
|
|
|
|
remote_file.AppendPathComponent(
|
|
|
|
|
module_sp->GetFileSpec().GetFilename().GetCString());
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-11-20 21:07:01 +00:00
|
|
|
if (remote_file) {
|
|
|
|
|
error = platform_sp->Install(local_file, remote_file);
|
|
|
|
|
if (error.Success()) {
|
|
|
|
|
module_sp->SetPlatformFileSpec(remote_file);
|
|
|
|
|
if (is_main_executable) {
|
2015-05-29 19:52:29 +00:00
|
|
|
platform_sp->SetFilePermissions(remote_file, 0700);
|
2013-11-20 21:07:01 +00:00
|
|
|
if (launch_info)
|
|
|
|
|
launch_info->SetExecutableFile(remote_file, false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-04-30 20:29:09 +00:00
|
|
|
}
|
2013-12-13 17:20:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-12-13 17:20:18 +00:00
|
|
|
return error;
|
|
|
|
|
}
|
2015-02-10 22:49:57 +00:00
|
|
|
|
|
|
|
|
bool Target::ResolveLoadAddress(addr_t load_addr, Address &so_addr,
|
|
|
|
|
uint32_t stop_id) {
|
|
|
|
|
return m_section_load_history.ResolveLoadAddress(stop_id, load_addr, so_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
bool Target::ResolveFileAddress(lldb::addr_t file_addr,
|
|
|
|
|
Address &resolved_addr) {
|
2011-07-12 17:06:17 +00:00
|
|
|
return m_images.ResolveFileAddress(file_addr, resolved_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
bool Target::SetSectionLoadAddress(const SectionSP §ion_sp,
|
2013-12-06 01:12:00 +00:00
|
|
|
addr_t new_section_load_addr,
|
|
|
|
|
bool warn_multiple) {
|
2015-02-10 22:49:57 +00:00
|
|
|
const addr_t old_section_load_addr =
|
2013-12-06 01:12:00 +00:00
|
|
|
m_section_load_history.GetSectionLoadAddress(
|
2015-02-10 22:49:57 +00:00
|
|
|
SectionLoadHistory::eStopIDNow, section_sp);
|
|
|
|
|
if (old_section_load_addr != new_section_load_addr) {
|
|
|
|
|
uint32_t stop_id = 0;
|
|
|
|
|
ProcessSP process_sp(GetProcessSP());
|
|
|
|
|
if (process_sp)
|
|
|
|
|
stop_id = process_sp->GetStopID();
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2013-12-06 01:12:00 +00:00
|
|
|
stop_id = m_section_load_history.GetLastStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
if (m_section_load_history.SetSectionLoadAddress(
|
2013-12-06 01:12:00 +00:00
|
|
|
stop_id, section_sp, new_section_load_addr, warn_multiple))
|
2015-02-10 22:49:57 +00:00
|
|
|
return true; // Return true if the section load address was changed...
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-02-10 22:49:57 +00:00
|
|
|
return false; // Return false to indicate nothing changed
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
size_t Target::UnloadModuleSections(const ModuleList &module_list) {
|
2014-11-17 19:39:20 +00:00
|
|
|
size_t section_unload_count = 0;
|
|
|
|
|
size_t num_modules = module_list.GetSize();
|
2015-02-10 22:49:57 +00:00
|
|
|
for (size_t i = 0; i < num_modules; ++i) {
|
2014-11-17 19:39:20 +00:00
|
|
|
section_unload_count +=
|
2015-02-10 22:49:57 +00:00
|
|
|
UnloadModuleSections(module_list.GetModuleAtIndex(i));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-11-17 19:39:20 +00:00
|
|
|
return section_unload_count;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
size_t Target::UnloadModuleSections(const lldb::ModuleSP &module_sp) {
|
2013-12-06 01:12:00 +00:00
|
|
|
uint32_t stop_id = 0;
|
|
|
|
|
ProcessSP process_sp(GetProcessSP());
|
2015-02-10 22:49:57 +00:00
|
|
|
if (process_sp)
|
2014-11-17 19:39:20 +00:00
|
|
|
stop_id = process_sp->GetStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
else
|
2013-12-06 01:12:00 +00:00
|
|
|
stop_id = m_section_load_history.GetLastStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
SectionList *sections = module_sp->GetSectionList();
|
2014-11-17 19:39:20 +00:00
|
|
|
size_t section_unload_count = 0;
|
|
|
|
|
if (sections) {
|
|
|
|
|
const uint32_t num_sections = sections->GetNumSections(0);
|
2015-02-10 22:49:57 +00:00
|
|
|
for (uint32_t i = 0; i < num_sections; ++i) {
|
|
|
|
|
section_unload_count += m_section_load_history.SetSectionUnloaded(
|
|
|
|
|
stop_id, sections->GetSectionAtIndex(i));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-11-17 19:39:20 +00:00
|
|
|
return section_unload_count;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
bool Target::SetSectionUnloaded(const lldb::SectionSP §ion_sp) {
|
|
|
|
|
uint32_t stop_id = 0;
|
2013-12-06 01:12:00 +00:00
|
|
|
ProcessSP process_sp(GetProcessSP());
|
2015-02-10 22:49:57 +00:00
|
|
|
if (process_sp)
|
2014-11-17 19:39:20 +00:00
|
|
|
stop_id = process_sp->GetStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
else
|
2013-12-06 01:12:00 +00:00
|
|
|
stop_id = m_section_load_history.GetLastStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
return m_section_load_history.SetSectionUnloaded(stop_id, section_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
bool Target::SetSectionUnloaded(const lldb::SectionSP §ion_sp,
|
2015-02-10 22:49:57 +00:00
|
|
|
addr_t load_addr) {
|
2013-12-06 01:12:00 +00:00
|
|
|
uint32_t stop_id = 0;
|
2015-02-10 22:49:57 +00:00
|
|
|
ProcessSP process_sp(GetProcessSP());
|
|
|
|
|
if (process_sp)
|
2014-11-17 19:39:20 +00:00
|
|
|
stop_id = process_sp->GetStopID();
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2013-12-06 01:12:00 +00:00
|
|
|
stop_id = m_section_load_history.GetLastStopID();
|
2015-02-10 22:49:57 +00:00
|
|
|
return m_section_load_history.SetSectionUnloaded(stop_id, section_sp,
|
2013-12-06 01:12:00 +00:00
|
|
|
load_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-06 01:12:00 +00:00
|
|
|
void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
|
|
|
|
|
Status error;
|
2015-02-10 22:49:57 +00:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s() called for %s", __FUNCTION__,
|
|
|
|
|
launch_info.GetExecutableFile().GetPath().c_str());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
StateType state = eStateInvalid;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
// Scope to temporarily get the process state in case someone has manually
|
|
|
|
|
// remotely connected already to a process and we can skip the platform
|
|
|
|
|
// launching.
|
2016-09-06 20:57:50 +00:00
|
|
|
{
|
2013-12-06 01:12:00 +00:00
|
|
|
ProcessSP process_sp(GetProcessSP());
|
2015-02-10 22:49:57 +00:00
|
|
|
|
|
|
|
|
if (process_sp) {
|
|
|
|
|
state = process_sp->GetState();
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Target::%s the process exists, and its current state is %s",
|
|
|
|
|
__FUNCTION__, StateAsCString(state));
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s the process instance doesn't currently exist.",
|
|
|
|
|
__FUNCTION__);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
launch_info.GetFlags().Set(eLaunchFlagDebug);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
// Get the value of synchronous execution here. If you wait till after you
|
2018-04-30 16:49:04 +00:00
|
|
|
// have started to run, then you could have hit a breakpoint, whose command
|
|
|
|
|
// might switch the value, and then you'll pick up that incorrect value.
|
2013-12-13 17:20:18 +00:00
|
|
|
Debugger &debugger = GetDebugger();
|
2015-02-10 22:49:57 +00:00
|
|
|
const bool synchronous_execution =
|
2014-10-11 00:38:27 +00:00
|
|
|
debugger.GetCommandInterpreter().GetSynchronous();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-11-20 21:07:01 +00:00
|
|
|
PlatformSP platform_sp(GetPlatform());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-01-08 11:55:19 +00:00
|
|
|
FinalizeFileActions(launch_info);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
if (state == eStateConnected) {
|
|
|
|
|
if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
|
|
|
|
|
error.SetErrorString(
|
2015-02-10 22:49:57 +00:00
|
|
|
"can't launch in tty when launching through a remote connection");
|
2013-11-20 21:07:01 +00:00
|
|
|
return error;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
if (!launch_info.GetArchitecture().IsValid())
|
|
|
|
|
launch_info.GetArchitecture() = GetArchitecture();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-12-18 02:06:45 +00:00
|
|
|
// If we're not already connected to the process, and if we have a platform
|
2014-07-22 23:41:36 +00:00
|
|
|
// that can launch a process for debugging, go ahead and do that here.
|
2015-02-10 22:49:57 +00:00
|
|
|
if (state != eStateConnected && platform_sp &&
|
2013-12-13 17:20:18 +00:00
|
|
|
platform_sp->CanDebugProcess()) {
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Target::%s asking the platform to debug the process",
|
|
|
|
|
__FUNCTION__);
|
2015-02-10 22:49:57 +00:00
|
|
|
|
2018-12-18 01:49:02 +00:00
|
|
|
// If there was a previous process, delete it before we make the new one.
|
|
|
|
|
// One subtle point, we delete the process before we release the reference
|
|
|
|
|
// to m_process_sp. That way even if we are the last owner, the process
|
|
|
|
|
// will get Finalized before it gets destroyed.
|
|
|
|
|
DeleteCurrentProcess();
|
2019-07-19 00:56:26 +00:00
|
|
|
|
2015-05-23 03:54:53 +00:00
|
|
|
m_process_sp =
|
2015-02-10 22:49:57 +00:00
|
|
|
GetPlatform()->DebugProcess(launch_info, debugger, this, error);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
} else {
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Target::%s the platform doesn't know how to debug a "
|
|
|
|
|
"process, getting a process plugin to do this for us.",
|
|
|
|
|
__FUNCTION__);
|
2015-02-10 22:49:57 +00:00
|
|
|
|
|
|
|
|
if (state == eStateConnected) {
|
|
|
|
|
assert(m_process_sp);
|
|
|
|
|
} else {
|
|
|
|
|
// Use a Process plugin to construct the process.
|
|
|
|
|
const char *plugin_name = launch_info.GetProcessPluginName();
|
2019-01-07 10:59:57 +00:00
|
|
|
CreateProcess(launch_info.GetListener(), plugin_name, nullptr);
|
2015-02-10 22:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Since we didn't have a platform launch the process, launch it here.
|
2015-12-11 19:52:15 +00:00
|
|
|
if (m_process_sp)
|
2015-10-05 22:58:37 +00:00
|
|
|
error = m_process_sp->Launch(launch_info);
|
|
|
|
|
}
|
2015-02-10 22:49:57 +00:00
|
|
|
|
2020-08-17 12:25:38 -07:00
|
|
|
if (!m_process_sp && error.Success())
|
|
|
|
|
error.SetErrorString("failed to launch or debug process");
|
|
|
|
|
|
|
|
|
|
if (!error.Success())
|
2013-11-20 21:07:01 +00:00
|
|
|
return error;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-08-17 12:25:38 -07:00
|
|
|
if (synchronous_execution ||
|
|
|
|
|
!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
|
|
|
|
|
ListenerSP hijack_listener_sp(launch_info.GetHijackListener());
|
|
|
|
|
if (!hijack_listener_sp) {
|
|
|
|
|
hijack_listener_sp = Listener::MakeListener("lldb.Target.Launch.hijack");
|
|
|
|
|
launch_info.SetHijackListener(hijack_listener_sp);
|
|
|
|
|
m_process_sp->HijackProcessEvents(hijack_listener_sp);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-08-17 12:25:38 -07:00
|
|
|
StateType state = m_process_sp->WaitForProcessToStop(
|
|
|
|
|
llvm::None, nullptr, false, hijack_listener_sp, nullptr);
|
|
|
|
|
|
|
|
|
|
if (state == eStateStopped) {
|
|
|
|
|
if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
|
|
|
|
|
if (synchronous_execution) {
|
|
|
|
|
// Now we have handled the stop-from-attach, and we are just
|
|
|
|
|
// switching to a synchronous resume. So we should switch to the
|
|
|
|
|
// SyncResume hijacker.
|
|
|
|
|
m_process_sp->RestoreProcessEvents();
|
|
|
|
|
m_process_sp->ResumeSynchronous(stream);
|
|
|
|
|
} else {
|
|
|
|
|
m_process_sp->RestoreProcessEvents();
|
|
|
|
|
error = m_process_sp->PrivateResume();
|
|
|
|
|
}
|
|
|
|
|
if (!error.Success()) {
|
|
|
|
|
Status error2;
|
|
|
|
|
error2.SetErrorStringWithFormat(
|
|
|
|
|
"process resume at entry point failed: %s", error.AsCString());
|
|
|
|
|
error = error2;
|
2015-02-10 22:49:57 +00:00
|
|
|
}
|
2020-08-17 12:25:38 -07:00
|
|
|
}
|
|
|
|
|
} else if (state == eStateExited) {
|
|
|
|
|
bool with_shell = !!launch_info.GetShell();
|
|
|
|
|
const int exit_status = m_process_sp->GetExitStatus();
|
|
|
|
|
const char *exit_desc = m_process_sp->GetExitDescription();
|
2014-04-30 20:29:09 +00:00
|
|
|
#define LAUNCH_SHELL_MESSAGE \
|
2015-10-20 00:14:20 +00:00
|
|
|
"\n'r' and 'run' are aliases that default to launching through a " \
|
|
|
|
|
"shell.\nTry launching without going through a shell by using 'process " \
|
2016-09-06 20:57:50 +00:00
|
|
|
"launch'."
|
2014-04-30 20:29:09 +00:00
|
|
|
if (exit_desc && exit_desc[0]) {
|
|
|
|
|
if (with_shell)
|
2015-09-15 21:13:50 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2014-04-30 20:29:09 +00:00
|
|
|
"process exited with status %i (%s)" LAUNCH_SHELL_MESSAGE,
|
|
|
|
|
exit_status, exit_desc);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2015-10-20 00:14:20 +00:00
|
|
|
error.SetErrorStringWithFormat("process exited with status %i (%s)",
|
2014-04-30 20:29:09 +00:00
|
|
|
exit_status, exit_desc);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2014-04-30 20:29:09 +00:00
|
|
|
if (with_shell)
|
2015-09-15 21:13:50 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2014-04-30 20:29:09 +00:00
|
|
|
"process exited with status %i" LAUNCH_SHELL_MESSAGE,
|
|
|
|
|
exit_status);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2014-04-30 20:29:09 +00:00
|
|
|
error.SetErrorStringWithFormat("process exited with status %i",
|
|
|
|
|
exit_status);
|
2015-10-20 00:14:20 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-09-15 21:13:50 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2013-12-13 17:20:18 +00:00
|
|
|
"initial process state wasn't stopped: %s", StateAsCString(state));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-17 12:25:38 -07:00
|
|
|
m_process_sp->RestoreProcessEvents();
|
2013-11-20 21:07:01 +00:00
|
|
|
return error;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
|
2013-12-13 17:20:18 +00:00
|
|
|
auto state = eStateInvalid;
|
2013-12-06 01:12:00 +00:00
|
|
|
auto process_sp = GetProcessSP();
|
|
|
|
|
if (process_sp) {
|
2013-12-18 02:06:45 +00:00
|
|
|
state = process_sp->GetState();
|
2013-12-13 17:20:18 +00:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected) {
|
|
|
|
|
if (state == eStateAttaching)
|
2017-05-12 04:51:55 +00:00
|
|
|
return Status("process attach is in progress");
|
|
|
|
|
return Status("a process is already being debugged");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 23:21:49 +00:00
|
|
|
const ModuleSP old_exec_module_sp = GetExecutableModule();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// If no process info was specified, then use the target executable name as
|
|
|
|
|
// the process to attach to by default
|
2015-02-10 22:49:57 +00:00
|
|
|
if (!attach_info.ProcessInfoSpecified()) {
|
2012-11-29 22:16:27 +00:00
|
|
|
if (old_exec_module_sp)
|
2015-02-10 22:49:57 +00:00
|
|
|
attach_info.GetExecutableFile().GetFilename() =
|
2014-12-19 19:20:44 +00:00
|
|
|
old_exec_module_sp->GetPlatformFileSpec().GetFilename();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-02-10 22:49:57 +00:00
|
|
|
if (!attach_info.ProcessInfoSpecified()) {
|
2017-05-12 04:51:55 +00:00
|
|
|
return Status("no process specified, create a target with a file, or "
|
|
|
|
|
"specify the --pid or --name");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 17:20:18 +00:00
|
|
|
const auto platform_sp =
|
2015-02-10 22:49:57 +00:00
|
|
|
GetDebugger().GetPlatformList().GetSelectedPlatform();
|
2015-10-05 22:58:37 +00:00
|
|
|
ListenerSP hijack_listener_sp;
|
|
|
|
|
const bool async = attach_info.GetAsync();
|
2015-10-20 00:14:20 +00:00
|
|
|
if (!async) {
|
2016-03-07 21:50:25 +00:00
|
|
|
hijack_listener_sp =
|
|
|
|
|
Listener::MakeListener("lldb.Target.Attach.attach.hijack");
|
2015-03-26 20:41:14 +00:00
|
|
|
attach_info.SetHijackListener(hijack_listener_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2015-02-10 22:49:57 +00:00
|
|
|
if (state != eStateConnected && platform_sp != nullptr &&
|
2013-12-13 17:20:18 +00:00
|
|
|
platform_sp->CanDebugProcess()) {
|
2015-02-10 22:49:57 +00:00
|
|
|
SetPlatform(platform_sp);
|
|
|
|
|
process_sp = platform_sp->Attach(attach_info, GetDebugger(), this, error);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2013-12-13 17:20:18 +00:00
|
|
|
if (state != eStateConnected) {
|
|
|
|
|
const char *plugin_name = attach_info.GetProcessPluginName();
|
2015-05-23 03:54:53 +00:00
|
|
|
process_sp =
|
2015-12-11 19:52:15 +00:00
|
|
|
CreateProcess(attach_info.GetListenerForProcess(GetDebugger()),
|
|
|
|
|
plugin_name, nullptr);
|
|
|
|
|
if (process_sp == nullptr) {
|
2015-09-15 21:13:50 +00:00
|
|
|
error.SetErrorStringWithFormat(
|
2015-12-11 19:52:15 +00:00
|
|
|
"failed to create process using plugin %s",
|
2015-02-10 22:49:57 +00:00
|
|
|
(plugin_name) ? plugin_name : "null");
|
2013-11-20 21:07:01 +00:00
|
|
|
return error;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-03-26 20:41:14 +00:00
|
|
|
if (hijack_listener_sp)
|
2016-03-07 21:50:25 +00:00
|
|
|
process_sp->HijackProcessEvents(hijack_listener_sp);
|
2013-12-13 17:20:18 +00:00
|
|
|
error = process_sp->Attach(attach_info);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-20 00:14:20 +00:00
|
|
|
if (error.Success() && process_sp) {
|
|
|
|
|
if (async) {
|
|
|
|
|
process_sp->RestoreProcessEvents();
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2016-07-28 17:32:20 +00:00
|
|
|
state = process_sp->WaitForProcessToStop(
|
2016-11-30 11:56:32 +00:00
|
|
|
llvm::None, nullptr, false, attach_info.GetHijackListener(), stream);
|
2015-10-20 00:14:20 +00:00
|
|
|
process_sp->RestoreProcessEvents();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-20 00:14:20 +00:00
|
|
|
if (state != eStateStopped) {
|
|
|
|
|
const char *exit_desc = process_sp->GetExitDescription();
|
|
|
|
|
if (exit_desc)
|
|
|
|
|
error.SetErrorStringWithFormat("%s", exit_desc);
|
|
|
|
|
else
|
|
|
|
|
error.SetErrorString(
|
|
|
|
|
"process did not stop (no such process or permission problem?)");
|
|
|
|
|
process_sp->Destroy(false);
|
|
|
|
|
}
|
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 error;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-08 11:55:19 +00:00
|
|
|
void Target::FinalizeFileActions(ProcessLaunchInfo &info) {
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
|
|
|
|
|
|
|
|
|
|
// Finalize the file actions, and if none were given, default to opening up a
|
|
|
|
|
// pseudo terminal
|
|
|
|
|
PlatformSP platform_sp = GetPlatform();
|
|
|
|
|
const bool default_to_use_pty =
|
|
|
|
|
m_platform_sp ? m_platform_sp->IsHost() : false;
|
|
|
|
|
LLDB_LOG(
|
|
|
|
|
log,
|
|
|
|
|
"have platform={0}, platform_sp->IsHost()={1}, default_to_use_pty={2}",
|
|
|
|
|
bool(platform_sp),
|
|
|
|
|
platform_sp ? (platform_sp->IsHost() ? "true" : "false") : "n/a",
|
|
|
|
|
default_to_use_pty);
|
|
|
|
|
|
|
|
|
|
// If nothing for stdin or stdout or stderr was specified, then check the
|
|
|
|
|
// process for any default settings that were set with "settings set"
|
|
|
|
|
if (info.GetFileActionForFD(STDIN_FILENO) == nullptr ||
|
|
|
|
|
info.GetFileActionForFD(STDOUT_FILENO) == nullptr ||
|
|
|
|
|
info.GetFileActionForFD(STDERR_FILENO) == nullptr) {
|
|
|
|
|
LLDB_LOG(log, "at least one of stdin/stdout/stderr was not set, evaluating "
|
|
|
|
|
"default handling");
|
|
|
|
|
|
|
|
|
|
if (info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
|
|
|
|
|
// Do nothing, if we are launching in a remote terminal no file actions
|
|
|
|
|
// should be done at all.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.GetFlags().Test(eLaunchFlagDisableSTDIO)) {
|
|
|
|
|
LLDB_LOG(log, "eLaunchFlagDisableSTDIO set, adding suppression action "
|
|
|
|
|
"for stdin, stdout and stderr");
|
|
|
|
|
info.AppendSuppressFileAction(STDIN_FILENO, true, false);
|
|
|
|
|
info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
|
|
|
|
|
info.AppendSuppressFileAction(STDERR_FILENO, false, true);
|
|
|
|
|
} else {
|
|
|
|
|
// Check for any values that might have gotten set with any of: (lldb)
|
|
|
|
|
// settings set target.input-path (lldb) settings set target.output-path
|
|
|
|
|
// (lldb) settings set target.error-path
|
|
|
|
|
FileSpec in_file_spec;
|
|
|
|
|
FileSpec out_file_spec;
|
|
|
|
|
FileSpec err_file_spec;
|
|
|
|
|
// Only override with the target settings if we don't already have an
|
|
|
|
|
// action for in, out or error
|
|
|
|
|
if (info.GetFileActionForFD(STDIN_FILENO) == nullptr)
|
|
|
|
|
in_file_spec = GetStandardInputPath();
|
|
|
|
|
if (info.GetFileActionForFD(STDOUT_FILENO) == nullptr)
|
|
|
|
|
out_file_spec = GetStandardOutputPath();
|
|
|
|
|
if (info.GetFileActionForFD(STDERR_FILENO) == nullptr)
|
|
|
|
|
err_file_spec = GetStandardErrorPath();
|
|
|
|
|
|
|
|
|
|
LLDB_LOG(log, "target stdin='{0}', target stdout='{1}', stderr='{1}'",
|
|
|
|
|
in_file_spec, out_file_spec, err_file_spec);
|
|
|
|
|
|
|
|
|
|
if (in_file_spec) {
|
|
|
|
|
info.AppendOpenFileAction(STDIN_FILENO, in_file_spec, true, false);
|
|
|
|
|
LLDB_LOG(log, "appended stdin open file action for {0}", in_file_spec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_file_spec) {
|
|
|
|
|
info.AppendOpenFileAction(STDOUT_FILENO, out_file_spec, false, true);
|
|
|
|
|
LLDB_LOG(log, "appended stdout open file action for {0}",
|
|
|
|
|
out_file_spec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err_file_spec) {
|
|
|
|
|
info.AppendOpenFileAction(STDERR_FILENO, err_file_spec, false, true);
|
|
|
|
|
LLDB_LOG(log, "appended stderr open file action for {0}",
|
|
|
|
|
err_file_spec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (default_to_use_pty &&
|
|
|
|
|
(!in_file_spec || !out_file_spec || !err_file_spec)) {
|
|
|
|
|
llvm::Error Err = info.SetUpPtyRedirection();
|
|
|
|
|
LLDB_LOG_ERROR(log, std::move(Err), "SetUpPtyRedirection failed: {0}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-20 21:07:01 +00:00
|
|
|
// Target::StopHook
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
Target::StopHook::StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid)
|
|
|
|
|
: UserID(uid), m_target_sp(target_sp), m_commands(), m_specifier_sp(),
|
2019-03-01 18:13:38 +00:00
|
|
|
m_thread_spec_up() {}
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
|
|
|
|
|
Target::StopHook::StopHook(const StopHook &rhs)
|
|
|
|
|
: UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
|
|
|
|
|
m_commands(rhs.m_commands), m_specifier_sp(rhs.m_specifier_sp),
|
2019-03-01 18:13:38 +00:00
|
|
|
m_thread_spec_up(), m_active(rhs.m_active),
|
|
|
|
|
m_auto_continue(rhs.m_auto_continue) {
|
2019-02-13 06:25:41 +00:00
|
|
|
if (rhs.m_thread_spec_up)
|
2020-06-24 17:44:33 -07:00
|
|
|
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
Target::StopHook::~StopHook() = default;
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
|
2015-03-03 19:23:09 +00:00
|
|
|
void Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier) {
|
|
|
|
|
m_specifier_sp.reset(specifier);
|
|
|
|
|
}
|
|
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) {
|
2019-02-13 06:25:41 +00:00
|
|
|
m_thread_spec_up.reset(specifier);
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::StopHook::GetDescription(Stream *s,
|
|
|
|
|
lldb::DescriptionLevel level) const {
|
2019-12-02 12:44:55 +01:00
|
|
|
unsigned indent_level = s->GetIndentLevel();
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
|
|
|
|
|
s->SetIndentLevel(indent_level + 2);
|
|
|
|
|
|
2012-11-29 21:49:15 +00:00
|
|
|
s->Printf("Hook: %" PRIu64 "\n", GetID());
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
if (m_active)
|
|
|
|
|
s->Indent("State: enabled\n");
|
|
|
|
|
else
|
|
|
|
|
s->Indent("State: disabled\n");
|
|
|
|
|
|
2019-03-01 18:13:38 +00:00
|
|
|
if (m_auto_continue)
|
|
|
|
|
s->Indent("AutoContinue on\n");
|
|
|
|
|
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
if (m_specifier_sp) {
|
|
|
|
|
s->Indent();
|
|
|
|
|
s->PutCString("Specifier:\n");
|
|
|
|
|
s->SetIndentLevel(indent_level + 4);
|
|
|
|
|
m_specifier_sp->GetDescription(s, level);
|
|
|
|
|
s->SetIndentLevel(indent_level + 2);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_thread_spec_up) {
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
StreamString tmp;
|
|
|
|
|
s->Indent("Thread:\n");
|
2019-02-13 06:25:41 +00:00
|
|
|
m_thread_spec_up->GetDescription(&tmp, level);
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
s->SetIndentLevel(indent_level + 4);
|
2016-11-16 21:15:24 +00:00
|
|
|
s->Indent(tmp.GetString());
|
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 03:53:59 +00:00
|
|
|
s->PutCString("\n");
|
|
|
|
|
s->SetIndentLevel(indent_level + 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s->Indent("Commands: \n");
|
|
|
|
|
s->SetIndentLevel(indent_level + 4);
|
|
|
|
|
uint32_t num_commands = m_commands.GetSize();
|
|
|
|
|
for (uint32_t i = 0; i < num_commands; i++) {
|
|
|
|
|
s->Indent(m_commands.GetStringAtIndex(i));
|
|
|
|
|
s->PutCString("\n");
|
|
|
|
|
}
|
|
|
|
|
s->SetIndentLevel(indent_level);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
eNoDynamicValues,
|
|
|
|
|
"no-dynamic-values",
|
|
|
|
|
"Don't calculate the dynamic type of values",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eDynamicCanRunTarget,
|
|
|
|
|
"run-target",
|
|
|
|
|
"Calculate the dynamic type of values "
|
|
|
|
|
"even if you have to run the target.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eDynamicDontRunTarget,
|
|
|
|
|
"no-run-target",
|
|
|
|
|
"Calculate the dynamic type of values, but don't run the target.",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
OptionEnumValues lldb_private::GetDynamicValueTypes() {
|
|
|
|
|
return OptionEnumValues(g_dynamic_value_types);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
eInlineBreakpointsNever,
|
|
|
|
|
"never",
|
|
|
|
|
"Never look for inline breakpoint locations (fastest). This setting "
|
|
|
|
|
"should only be used if you know that no inlining occurs in your"
|
|
|
|
|
"programs.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eInlineBreakpointsHeaders,
|
|
|
|
|
"headers",
|
|
|
|
|
"Only check for inline breakpoint locations when setting breakpoints "
|
|
|
|
|
"in header files, but not when setting breakpoint in implementation "
|
|
|
|
|
"source files (default).",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eInlineBreakpointsAlways,
|
|
|
|
|
"always",
|
|
|
|
|
"Always look for inline breakpoint locations when setting file and "
|
|
|
|
|
"line breakpoints (slower but most accurate).",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-05-14 08:55:50 +00:00
|
|
|
enum x86DisassemblyFlavor {
|
2013-03-02 00:26:47 +00:00
|
|
|
eX86DisFlavorDefault,
|
|
|
|
|
eX86DisFlavorIntel,
|
|
|
|
|
eX86DisFlavorATT
|
2019-05-14 08:55:50 +00:00
|
|
|
};
|
2013-03-02 00:26:47 +00:00
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
eX86DisFlavorDefault,
|
|
|
|
|
"default",
|
|
|
|
|
"Disassembler default (currently att).",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eX86DisFlavorIntel,
|
|
|
|
|
"intel",
|
|
|
|
|
"Intel disassembler flavor.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eX86DisFlavorATT,
|
|
|
|
|
"att",
|
|
|
|
|
"AT&T disassembler flavor.",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionEnumValueElement g_hex_immediate_style_values[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
Disassembler::eHexStyleC,
|
|
|
|
|
"c",
|
|
|
|
|
"C-style (0xffff).",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Disassembler::eHexStyleAsm,
|
|
|
|
|
"asm",
|
|
|
|
|
"Asm-style (0ffffh).",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
eLoadScriptFromSymFileTrue,
|
|
|
|
|
"true",
|
|
|
|
|
"Load debug scripts inside symbol files",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eLoadScriptFromSymFileFalse,
|
|
|
|
|
"false",
|
|
|
|
|
"Do not load debug scripts inside symbol files.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eLoadScriptFromSymFileWarn,
|
|
|
|
|
"warn",
|
|
|
|
|
"Warn about debug scripts inside symbol files but do not load them.",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static constexpr OptionEnumValueElement g_load_cwd_lldbinit_values[] = {
|
|
|
|
|
{
|
|
|
|
|
eLoadCWDlldbinitTrue,
|
|
|
|
|
"true",
|
|
|
|
|
"Load .lldbinit files from current directory",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eLoadCWDlldbinitFalse,
|
|
|
|
|
"false",
|
|
|
|
|
"Do not load .lldbinit files from current directory",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eLoadCWDlldbinitWarn,
|
|
|
|
|
"warn",
|
|
|
|
|
"Warn about loading .lldbinit files from current directory",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionEnumValueElement g_memory_module_load_level_values[] = {
|
2019-08-02 00:18:44 +00:00
|
|
|
{
|
|
|
|
|
eMemoryModuleLoadLevelMinimal,
|
|
|
|
|
"minimal",
|
|
|
|
|
"Load minimal information when loading modules from memory. Currently "
|
|
|
|
|
"this setting loads sections only.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eMemoryModuleLoadLevelPartial,
|
|
|
|
|
"partial",
|
|
|
|
|
"Load partial information when loading modules from memory. Currently "
|
|
|
|
|
"this setting loads sections and function bounds.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
eMemoryModuleLoadLevelComplete,
|
|
|
|
|
"complete",
|
|
|
|
|
"Load complete information when loading modules from memory. Currently "
|
|
|
|
|
"this setting loads sections and all symbols.",
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-07-25 21:36:37 +00:00
|
|
|
#define LLDB_PROPERTIES_target
|
2019-07-29 17:22:10 +00:00
|
|
|
#include "TargetProperties.inc"
|
2016-09-06 20:57:50 +00:00
|
|
|
|
|
|
|
|
enum {
|
2019-07-25 21:36:37 +00:00
|
|
|
#define LLDB_PROPERTIES_target
|
2019-07-29 17:22:10 +00:00
|
|
|
#include "TargetPropertiesEnum.inc"
|
2018-11-15 01:18:15 +00:00
|
|
|
ePropertyExperimental,
|
2012-08-22 17:17:09 +00:00
|
|
|
};
|
2011-02-18 01:44:25 +00:00
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
class TargetOptionValueProperties : public OptionValueProperties {
|
|
|
|
|
public:
|
2020-03-19 18:02:05 -07:00
|
|
|
TargetOptionValueProperties(ConstString name) : OptionValueProperties(name) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
// This constructor is used when creating TargetOptionValueProperties when it
|
|
|
|
|
// is part of a new lldb_private::Target instance. It will copy all current
|
|
|
|
|
// global property values as needed
|
2020-03-19 18:02:05 -07:00
|
|
|
TargetOptionValueProperties(const TargetPropertiesSP &target_properties_sp)
|
|
|
|
|
: OptionValueProperties(*target_properties_sp->GetValueProperties()) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
|
|
|
|
|
bool will_modify,
|
2012-08-22 17:17:09 +00:00
|
|
|
uint32_t idx) const override {
|
2014-07-01 21:22:11 +00:00
|
|
|
// When getting the value for a key from the target options, we will always
|
2018-04-30 16:49:04 +00:00
|
|
|
// try and grab the setting from the current target if there is one. Else
|
|
|
|
|
// we just use the one from this instance.
|
2012-08-22 17:17:09 +00:00
|
|
|
if (exe_ctx) {
|
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
|
if (target) {
|
|
|
|
|
TargetOptionValueProperties *target_properties =
|
|
|
|
|
static_cast<TargetOptionValueProperties *>(
|
|
|
|
|
target->GetValueProperties().get());
|
|
|
|
|
if (this != target_properties)
|
|
|
|
|
return target_properties->ProtectedGetPropertyAtIndex(idx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-08-22 17:17:09 +00:00
|
|
|
return ProtectedGetPropertyAtIndex(idx);
|
|
|
|
|
}
|
|
|
|
|
};
|
2011-04-16 00:01:13 +00:00
|
|
|
|
2016-07-07 18:25:48 +00:00
|
|
|
// TargetProperties
|
2020-05-19 11:16:57 -07:00
|
|
|
#define LLDB_PROPERTIES_target_experimental
|
2019-07-29 17:22:10 +00:00
|
|
|
#include "TargetProperties.inc"
|
2019-07-25 21:36:37 +00:00
|
|
|
|
|
|
|
|
enum {
|
2020-05-19 11:16:57 -07:00
|
|
|
#define LLDB_PROPERTIES_target_experimental
|
2019-07-29 17:22:10 +00:00
|
|
|
#include "TargetPropertiesEnum.inc"
|
2019-07-25 21:36:37 +00:00
|
|
|
};
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-07 18:25:48 +00:00
|
|
|
class TargetExperimentalOptionValueProperties : public OptionValueProperties {
|
|
|
|
|
public:
|
|
|
|
|
TargetExperimentalOptionValueProperties()
|
|
|
|
|
: OptionValueProperties(
|
|
|
|
|
ConstString(Properties::GetExperimentalSettingsName())) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TargetExperimentalProperties::TargetExperimentalProperties()
|
|
|
|
|
: Properties(OptionValuePropertiesSP(
|
|
|
|
|
new TargetExperimentalOptionValueProperties())) {
|
2020-05-19 11:16:57 -07:00
|
|
|
m_collection_sp->Initialize(g_target_experimental_properties);
|
2016-07-07 18:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-20 21:07:01 +00:00
|
|
|
// TargetProperties
|
2012-08-22 17:17:09 +00:00
|
|
|
TargetProperties::TargetProperties(Target *target)
|
2020-03-19 18:02:05 -07:00
|
|
|
: Properties(), m_launch_info(), m_target(target) {
|
2012-08-22 17:17:09 +00:00
|
|
|
if (target) {
|
2019-02-11 23:13:08 +00:00
|
|
|
m_collection_sp = std::make_shared<TargetOptionValueProperties>(
|
2020-03-19 18:02:05 -07:00
|
|
|
Target::GetGlobalProperties());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Set callbacks to update launch_info whenever "settins set" updated any
|
|
|
|
|
// of these properties
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyArg0, [this] { Arg0ValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyRunArgs, [this] { RunArgsValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyEnvVars, [this] { EnvVarsValueChangedCallback(); });
|
2020-03-19 18:02:05 -07:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
|
|
|
|
ePropertyUnsetEnvVars, [this] { EnvVarsValueChangedCallback(); });
|
|
|
|
|
m_collection_sp->SetValueChangedCallback(
|
|
|
|
|
ePropertyInheritEnv, [this] { EnvVarsValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyInputPath, [this] { InputPathValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyOutputPath, [this] { OutputPathValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyErrorPath, [this] { ErrorPathValueChangedCallback(); });
|
|
|
|
|
m_collection_sp->SetValueChangedCallback(ePropertyDetachOnError, [this] {
|
|
|
|
|
DetachOnErrorValueChangedCallback();
|
|
|
|
|
});
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
|
2020-08-05 10:02:51 -07:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
|
|
|
|
ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
|
2015-02-13 14:31:06 +00:00
|
|
|
m_collection_sp->SetValueChangedCallback(
|
2020-01-09 14:14:54 +01:00
|
|
|
ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-06-24 17:44:33 -07:00
|
|
|
m_experimental_properties_up =
|
|
|
|
|
std::make_unique<TargetExperimentalProperties>();
|
2016-07-07 18:25:48 +00:00
|
|
|
m_collection_sp->AppendProperty(
|
|
|
|
|
ConstString(Properties::GetExperimentalSettingsName()),
|
|
|
|
|
ConstString("Experimental settings - setting these won't produce "
|
|
|
|
|
"errors if the setting is not present."),
|
|
|
|
|
true, m_experimental_properties_up->GetValueProperties());
|
2012-08-22 17:17:09 +00:00
|
|
|
} else {
|
2019-02-11 23:13:08 +00:00
|
|
|
m_collection_sp =
|
|
|
|
|
std::make_shared<TargetOptionValueProperties>(ConstString("target"));
|
2019-07-29 16:41:30 +00:00
|
|
|
m_collection_sp->Initialize(g_target_properties);
|
2020-06-24 17:44:33 -07:00
|
|
|
m_experimental_properties_up =
|
|
|
|
|
std::make_unique<TargetExperimentalProperties>();
|
2016-07-07 18:25:48 +00:00
|
|
|
m_collection_sp->AppendProperty(
|
|
|
|
|
ConstString(Properties::GetExperimentalSettingsName()),
|
|
|
|
|
ConstString("Experimental settings - setting these won't produce "
|
|
|
|
|
"errors if the setting is not present."),
|
|
|
|
|
true, m_experimental_properties_up->GetValueProperties());
|
2012-08-22 17:17:09 +00:00
|
|
|
m_collection_sp->AppendProperty(
|
2016-07-07 18:25:48 +00:00
|
|
|
ConstString("process"), ConstString("Settings specific to processes."),
|
2012-08-22 17:17:09 +00:00
|
|
|
true, Process::GetGlobalProperties()->GetValueProperties());
|
|
|
|
|
}
|
2012-03-27 02:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
TargetProperties::~TargetProperties() = default;
|
|
|
|
|
|
2020-03-11 10:26:03 -07:00
|
|
|
void TargetProperties::UpdateLaunchInfoFromProperties() {
|
|
|
|
|
Arg0ValueChangedCallback();
|
|
|
|
|
RunArgsValueChangedCallback();
|
|
|
|
|
EnvVarsValueChangedCallback();
|
|
|
|
|
InputPathValueChangedCallback();
|
|
|
|
|
OutputPathValueChangedCallback();
|
|
|
|
|
ErrorPathValueChangedCallback();
|
|
|
|
|
DetachOnErrorValueChangedCallback();
|
|
|
|
|
DisableASLRValueChangedCallback();
|
2020-08-05 10:02:51 -07:00
|
|
|
InheritTCCValueChangedCallback();
|
2020-03-11 10:26:03 -07:00
|
|
|
DisableSTDIOValueChangedCallback();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 18:25:48 +00:00
|
|
|
bool TargetProperties::GetInjectLocalVariables(
|
|
|
|
|
ExecutionContext *exe_ctx) const {
|
|
|
|
|
const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
|
|
|
|
|
exe_ctx, false, ePropertyExperimental);
|
|
|
|
|
OptionValueProperties *exp_values =
|
2015-12-11 19:52:15 +00:00
|
|
|
exp_property->GetValue()->GetAsProperties();
|
2012-08-22 17:17:09 +00:00
|
|
|
if (exp_values)
|
2015-12-11 19:52:15 +00:00
|
|
|
return exp_values->GetPropertyAtIndexAsBoolean(
|
|
|
|
|
exe_ctx, ePropertyInjectLocalVars, true);
|
2015-05-15 18:40:24 +00:00
|
|
|
else
|
2015-12-11 19:52:15 +00:00
|
|
|
return true;
|
2015-05-15 18:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
bool b) {
|
2012-08-22 17:17:09 +00:00
|
|
|
const Property *exp_property =
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndex(exe_ctx, true, ePropertyExperimental);
|
|
|
|
|
OptionValueProperties *exp_values =
|
|
|
|
|
exp_property->GetValue()->GetAsProperties();
|
|
|
|
|
if (exp_values)
|
|
|
|
|
exp_values->SetPropertyAtIndexAsBoolean(exe_ctx, ePropertyInjectLocalVars,
|
2016-09-06 20:57:50 +00:00
|
|
|
true);
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-06 19:20:51 +00:00
|
|
|
}
|
2011-04-22 03:55:06 +00:00
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
ArchSpec TargetProperties::GetDefaultArchitecture() const {
|
2015-12-11 19:52:15 +00:00
|
|
|
OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
|
|
|
|
|
nullptr, ePropertyDefaultArch);
|
|
|
|
|
if (value)
|
2012-08-22 17:17:09 +00:00
|
|
|
return value->GetCurrentValue();
|
|
|
|
|
return ArchSpec();
|
2011-10-28 23:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 02:32:56 +00:00
|
|
|
void TargetProperties::SetDefaultArchitecture(const ArchSpec &arch) {
|
2015-12-11 19:52:15 +00:00
|
|
|
OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
|
|
|
|
|
nullptr, ePropertyDefaultArch);
|
|
|
|
|
if (value)
|
|
|
|
|
return value->SetCurrentValue(arch, true);
|
2014-06-25 02:32:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TargetProperties::GetMoveToNearestCode() const {
|
|
|
|
|
const uint32_t idx = ePropertyMoveToNearestCode;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2014-06-25 02:32:56 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const {
|
|
|
|
|
const uint32_t idx = ePropertyPreferDynamic;
|
2015-12-11 19:52:15 +00:00
|
|
|
return (lldb::DynamicValueType)
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
|
|
|
|
|
const uint32_t idx = ePropertyPreferDynamic;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->SetPropertyAtIndexAsEnumeration(nullptr, idx, d);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2017-04-28 00:51:06 +00:00
|
|
|
bool TargetProperties::GetPreloadSymbols() const {
|
|
|
|
|
const uint32_t idx = ePropertyPreloadSymbols;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2017-04-28 00:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetPreloadSymbols(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyPreloadSymbols;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-02 00:26:47 +00:00
|
|
|
bool TargetProperties::GetDisableASLR() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisableASLR;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2013-03-02 00:26:47 +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
|
|
|
void TargetProperties::SetDisableASLR(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyDisableASLR;
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
<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
|
|
|
}
|
|
|
|
|
|
2020-08-05 10:02:51 -07:00
|
|
|
bool TargetProperties::GetInheritTCC() const {
|
|
|
|
|
const uint32_t idx = ePropertyInheritTCC;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
|
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetInheritTCC(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyInheritTCC;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-17 22:57:12 +00:00
|
|
|
bool TargetProperties::GetDetachOnError() const {
|
|
|
|
|
const uint32_t idx = ePropertyDetachOnError;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2012-10-17 22:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetDetachOnError(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyDetachOnError;
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
2012-10-17 22:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::GetDisableSTDIO() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisableSTDIO;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
void TargetProperties::SetDisableSTDIO(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyDisableSTDIO;
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
const char *TargetProperties::GetDisassemblyFlavor() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisassemblyFlavor;
|
2015-12-11 19:52:15 +00:00
|
|
|
const char *return_value;
|
2011-11-08 02:43:13 +00:00
|
|
|
|
2015-02-13 14:31:06 +00:00
|
|
|
x86DisassemblyFlavor flavor_value =
|
2015-12-11 19:52:15 +00:00
|
|
|
(x86DisassemblyFlavor)m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-03-26 00:15:24 +00:00
|
|
|
return_value = g_x86_dis_flavor_value_types[flavor_value].string_value;
|
2013-03-02 00:26:47 +00:00
|
|
|
return return_value;
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
InlineStrategy TargetProperties::GetInlineStrategy() const {
|
|
|
|
|
const uint32_t idx = ePropertyInlineStrategy;
|
2015-12-11 19:52:15 +00:00
|
|
|
return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 18:08:12 +00:00
|
|
|
llvm::StringRef TargetProperties::GetArg0() const {
|
2012-08-22 17:17:09 +00:00
|
|
|
const uint32_t idx = ePropertyArg0;
|
2019-07-19 00:56:26 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx,
|
|
|
|
|
llvm::StringRef());
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 18:08:12 +00:00
|
|
|
void TargetProperties::SetArg0(llvm::StringRef arg) {
|
2012-08-22 17:17:09 +00:00
|
|
|
const uint32_t idx = ePropertyArg0;
|
2019-07-19 00:56:26 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
|
2012-08-22 17:17:09 +00:00
|
|
|
m_launch_info.SetArg0(arg);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
2011-10-28 23:14:11 +00:00
|
|
|
|
2013-07-01 19:45:50 +00:00
|
|
|
bool TargetProperties::GetRunArguments(Args &args) const {
|
|
|
|
|
const uint32_t idx = ePropertyRunArgs;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
|
2015-04-03 15:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetRunArguments(const Args &args) {
|
|
|
|
|
const uint32_t idx = ePropertyRunArgs;
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
|
2013-07-01 19:45:50 +00:00
|
|
|
m_launch_info.GetArguments() = args;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 18:02:05 -07:00
|
|
|
Environment TargetProperties::ComputeEnvironment() const {
|
|
|
|
|
Environment env;
|
|
|
|
|
|
|
|
|
|
if (m_target &&
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsBoolean(
|
|
|
|
|
nullptr, ePropertyInheritEnv,
|
|
|
|
|
g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
|
|
|
|
|
if (auto platform_sp = m_target->GetPlatform()) {
|
|
|
|
|
Environment platform_env = platform_sp->GetEnvironment();
|
|
|
|
|
for (const auto &KV : platform_env)
|
|
|
|
|
env[KV.first()] = KV.second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Args property_unset_env;
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, ePropertyUnsetEnvVars,
|
|
|
|
|
property_unset_env);
|
|
|
|
|
for (const auto &var : property_unset_env)
|
|
|
|
|
env.erase(var.ref());
|
|
|
|
|
|
|
|
|
|
Args property_env;
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, ePropertyEnvVars,
|
|
|
|
|
property_env);
|
|
|
|
|
for (const auto &KV : Environment(property_env))
|
|
|
|
|
env[KV.first()] = KV.second;
|
|
|
|
|
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
Environment TargetProperties::GetEnvironment() const {
|
2020-03-19 18:02:05 -07:00
|
|
|
return ComputeEnvironment();
|
2016-03-25 01:57:14 +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
|
|
|
void TargetProperties::SetEnvironment(Environment env) {
|
|
|
|
|
// TODO: Get rid of the Args intermediate step
|
2016-03-25 01:57:14 +00:00
|
|
|
const uint32_t idx = ePropertyEnvVars;
|
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
|
|
|
m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, Args(env));
|
2016-03-29 22:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TargetProperties::GetSkipPrologue() const {
|
|
|
|
|
const uint32_t idx = ePropertySkipPrologue;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2015-04-20 16:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
PathMappingList &TargetProperties::GetSourcePathMap() const {
|
|
|
|
|
const uint32_t idx = ePropertySourceMap;
|
2015-12-11 19:52:15 +00:00
|
|
|
OptionValuePathMappings *option_value =
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings(nullptr,
|
|
|
|
|
false, idx);
|
|
|
|
|
assert(option_value);
|
|
|
|
|
return option_value->GetCurrentValue();
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-19 00:56:26 +00:00
|
|
|
void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) {
|
2012-08-22 17:17:09 +00:00
|
|
|
const uint32_t idx = ePropertyExecutableSearchPaths;
|
|
|
|
|
OptionValueFileSpecList *option_value =
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
|
|
|
|
|
false, idx);
|
|
|
|
|
assert(option_value);
|
2019-04-23 20:17:04 +00:00
|
|
|
option_value->AppendCurrentValue(dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileSpecList TargetProperties::GetExecutableSearchPaths() {
|
|
|
|
|
const uint32_t idx = ePropertyExecutableSearchPaths;
|
|
|
|
|
const OptionValueFileSpecList *option_value =
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
|
|
|
|
|
false, idx);
|
|
|
|
|
assert(option_value);
|
2015-12-11 19:52:15 +00:00
|
|
|
return option_value->GetCurrentValue();
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-23 20:17:04 +00:00
|
|
|
FileSpecList TargetProperties::GetDebugFileSearchPaths() {
|
2012-08-22 17:17:09 +00:00
|
|
|
const uint32_t idx = ePropertyDebugFileSearchPaths;
|
2019-04-23 20:17:04 +00:00
|
|
|
const OptionValueFileSpecList *option_value =
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
|
|
|
|
|
false, idx);
|
|
|
|
|
assert(option_value);
|
|
|
|
|
return option_value->GetCurrentValue();
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|
2010-09-20 20:44:43 +00:00
|
|
|
|
2019-04-23 20:17:04 +00:00
|
|
|
FileSpecList TargetProperties::GetClangModuleSearchPaths() {
|
2013-06-04 22:54:16 +00:00
|
|
|
const uint32_t idx = ePropertyClangModuleSearchPaths;
|
2019-04-23 20:17:04 +00:00
|
|
|
const OptionValueFileSpecList *option_value =
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
|
|
|
|
|
false, idx);
|
|
|
|
|
assert(option_value);
|
|
|
|
|
return option_value->GetCurrentValue();
|
2013-06-04 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::GetEnableAutoImportClangModules() const {
|
|
|
|
|
const uint32_t idx = ePropertyAutoImportClangModules;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
Add ability to import std module into expression parser to improve C++ debugging
Summary:
This patch is the MVP version of importing the std module into the expression parser to improve C++ debugging.
What happens in this patch is that we inject a `@import std` into our expression source code. We also
modify our internal Clang instance for parsing this expression to work with modules and debug info
at the same time (which is the main change in terms of LOC). We implicitly build the `std` module on the first use. The
C++ include paths for building are extracted from the debug info, which means that this currently only
works if the program is compiled with `-glldb -fmodules` and uses the std module. The C include paths
are currently specified by LLDB.
I enabled the tests currently only for libc++ and Linux because I could test this locally. I'll enable the tests
for other platforms once this has landed and doesn't break any bots (and I implemented the platform-specific
C include paths for them).
With this patch we can now:
* Build a libc++ as a module and import it into the expression parser.
* Read from the module while also referencing declarations from the debug info. E.g. `std::abs(local_variable)`.
What doesn't work (yet):
* Merging debug info and C++ module declarations. E.g. `std::vector<CustomClass>` doesn't work.
* Pretty much anything that involves the ASTImporter and templated code. As the ASTImporter is used for saving the result declaration, this means that we can't
call yet any function that returns a non-trivial type.
* Use libstdc++ for this, as it requires multiple include paths and Clang only emits one include path per module. Also libstdc++ doesn't support Clang modules without patches.
Reviewers: aprantl, jingham, shafik, friss, davide, serge-sans-paille
Reviewed By: aprantl
Subscribers: labath, mgorny, abidh, jdoerfert, lldb-commits
Tags: #c_modules_in_lldb, #lldb
Differential Revision: https://reviews.llvm.org/D58125
llvm-svn: 355939
2019-03-12 17:09:33 +00:00
|
|
|
bool TargetProperties::GetEnableImportStdModule() const {
|
|
|
|
|
const uint32_t idx = ePropertyImportStdModule;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
Add ability to import std module into expression parser to improve C++ debugging
Summary:
This patch is the MVP version of importing the std module into the expression parser to improve C++ debugging.
What happens in this patch is that we inject a `@import std` into our expression source code. We also
modify our internal Clang instance for parsing this expression to work with modules and debug info
at the same time (which is the main change in terms of LOC). We implicitly build the `std` module on the first use. The
C++ include paths for building are extracted from the debug info, which means that this currently only
works if the program is compiled with `-glldb -fmodules` and uses the std module. The C include paths
are currently specified by LLDB.
I enabled the tests currently only for libc++ and Linux because I could test this locally. I'll enable the tests
for other platforms once this has landed and doesn't break any bots (and I implemented the platform-specific
C include paths for them).
With this patch we can now:
* Build a libc++ as a module and import it into the expression parser.
* Read from the module while also referencing declarations from the debug info. E.g. `std::abs(local_variable)`.
What doesn't work (yet):
* Merging debug info and C++ module declarations. E.g. `std::vector<CustomClass>` doesn't work.
* Pretty much anything that involves the ASTImporter and templated code. As the ASTImporter is used for saving the result declaration, this means that we can't
call yet any function that returns a non-trivial type.
* Use libstdc++ for this, as it requires multiple include paths and Clang only emits one include path per module. Also libstdc++ doesn't support Clang modules without patches.
Reviewers: aprantl, jingham, shafik, friss, davide, serge-sans-paille
Reviewed By: aprantl
Subscribers: labath, mgorny, abidh, jdoerfert, lldb-commits
Tags: #c_modules_in_lldb, #lldb
Differential Revision: https://reviews.llvm.org/D58125
llvm-svn: 355939
2019-03-12 17:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::GetEnableAutoApplyFixIts() const {
|
|
|
|
|
const uint32_t idx = ePropertyAutoApplyFixIts;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|
2011-04-23 02:04:55 +00:00
|
|
|
|
2020-04-06 11:08:12 +02:00
|
|
|
uint64_t TargetProperties::GetNumberOfRetriesWithFixits() const {
|
|
|
|
|
const uint32_t idx = ePropertyRetriesWithFixIts;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsUInt64(
|
|
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::GetEnableNotifyAboutFixIts() const {
|
|
|
|
|
const uint32_t idx = ePropertyNotifyAboutFixIts;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-26 20:18:51 +00:00
|
|
|
bool TargetProperties::GetEnableSaveObjects() const {
|
|
|
|
|
const uint32_t idx = ePropertySaveObjects;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2016-09-26 20:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
bool TargetProperties::GetEnableSyntheticValue() const {
|
|
|
|
|
const uint32_t idx = ePropertyEnableSynthetic;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-04 11:41:23 +00:00
|
|
|
uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
|
|
|
|
|
const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsUInt64(
|
|
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
|
|
|
|
|
const uint32_t idx = ePropertyMaxChildrenCount;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsSInt64(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2010-09-20 20:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-21 22:05:07 +00:00
|
|
|
uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const {
|
2015-12-11 19:52:15 +00:00
|
|
|
const uint32_t idx = ePropertyMaxSummaryLength;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsSInt64(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-07-21 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 18:39:03 +00:00
|
|
|
uint32_t TargetProperties::GetMaximumMemReadSize() const {
|
|
|
|
|
const uint32_t idx = ePropertyMaxMemReadSize;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsSInt64(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2012-08-22 18:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
FileSpec TargetProperties::GetStandardInputPath() const {
|
|
|
|
|
const uint32_t idx = ePropertyInputPath;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-23 22:11:51 +00:00
|
|
|
void TargetProperties::SetStandardInputPath(llvm::StringRef path) {
|
2012-08-22 17:17:09 +00:00
|
|
|
const uint32_t idx = ePropertyInputPath;
|
2016-09-23 22:11:51 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
|
2011-11-08 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-07 21:54:09 +00:00
|
|
|
FileSpec TargetProperties::GetStandardOutputPath() const {
|
|
|
|
|
const uint32_t idx = ePropertyOutputPath;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
|
2013-08-07 21:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-23 22:11:51 +00:00
|
|
|
void TargetProperties::SetStandardOutputPath(llvm::StringRef path) {
|
2013-03-13 17:58:04 +00:00
|
|
|
const uint32_t idx = ePropertyOutputPath;
|
2016-09-23 22:11:51 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
|
2013-03-13 17:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-06 21:59:52 +00:00
|
|
|
FileSpec TargetProperties::GetStandardErrorPath() const {
|
|
|
|
|
const uint32_t idx = ePropertyErrorPath;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
|
2013-12-06 21:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-23 22:11:51 +00:00
|
|
|
void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {
|
|
|
|
|
const uint32_t idx = ePropertyErrorPath;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-13 17:03:52 +00:00
|
|
|
LanguageType TargetProperties::GetLanguage() const {
|
|
|
|
|
OptionValueLanguage *value =
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(
|
|
|
|
|
nullptr, ePropertyLanguage);
|
|
|
|
|
if (value)
|
|
|
|
|
return value->GetCurrentValue();
|
2015-07-21 22:05:07 +00:00
|
|
|
return LanguageType();
|
2013-05-13 17:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 10:54:30 +00:00
|
|
|
llvm::StringRef TargetProperties::GetExpressionPrefixContents() {
|
2016-02-19 00:05:17 +00:00
|
|
|
const uint32_t idx = ePropertyExprPrefix;
|
|
|
|
|
OptionValueFileSpec *file =
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
|
|
|
|
|
idx);
|
|
|
|
|
if (file) {
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 10:54:30 +00:00
|
|
|
DataBufferSP data_sp(file->GetFileContents());
|
2012-08-22 21:21:16 +00:00
|
|
|
if (data_sp)
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 10:54:30 +00:00
|
|
|
return llvm::StringRef(
|
|
|
|
|
reinterpret_cast<const char *>(data_sp->GetBytes()),
|
|
|
|
|
data_sp->GetByteSize());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 10:54:30 +00:00
|
|
|
return "";
|
2016-02-19 00:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-13 01:42:25 +00:00
|
|
|
bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {
|
|
|
|
|
const uint32_t idx = ePropertyBreakpointUseAvoidList;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2013-08-13 01:42:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-14 05:06:49 +00:00
|
|
|
bool TargetProperties::GetUseHexImmediates() const {
|
|
|
|
|
const uint32_t idx = ePropertyUseHexImmediates;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2014-02-14 05:06:49 +00:00
|
|
|
}
|
2013-08-13 01:42:25 +00:00
|
|
|
|
2014-02-14 05:06:49 +00:00
|
|
|
bool TargetProperties::GetUseFastStepping() const {
|
|
|
|
|
const uint32_t idx = ePropertyUseFastStepping;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2014-02-14 05:06:49 +00:00
|
|
|
}
|
2010-09-20 20:44:43 +00:00
|
|
|
|
2015-02-11 02:35:39 +00:00
|
|
|
bool TargetProperties::GetDisplayExpressionsInCrashlogs() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
|
2015-12-11 19:52:15 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2015-02-11 02:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const {
|
|
|
|
|
const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
|
2015-12-11 19:52:15 +00:00
|
|
|
return (LoadScriptFromSymFile)
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-02-11 02:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-13 09:18:18 +00:00
|
|
|
LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const {
|
|
|
|
|
const uint32_t idx = ePropertyLoadCWDlldbinitFile;
|
2015-12-11 19:52:15 +00:00
|
|
|
return (LoadCWDlldbinitFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-05-13 09:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-24 15:14:26 +00:00
|
|
|
Disassembler::HexImmediateStyle TargetProperties::GetHexImmediateStyle() const {
|
|
|
|
|
const uint32_t idx = ePropertyHexImmediateStyle;
|
|
|
|
|
return (Disassembler::HexImmediateStyle)
|
2015-12-11 19:52:15 +00:00
|
|
|
m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-06-24 15:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 17:07:55 +00:00
|
|
|
MemoryModuleLoadLevel TargetProperties::GetMemoryModuleLoadLevel() const {
|
|
|
|
|
const uint32_t idx = ePropertyMemoryModuleLoadLevel;
|
|
|
|
|
return (MemoryModuleLoadLevel)
|
|
|
|
|
m_collection_sp->GetPropertyAtIndexAsEnumeration(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value);
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const {
|
|
|
|
|
const uint32_t idx = ePropertyTrapHandlerNames;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetUserSpecifiedTrapHandlerNames(const Args &args) {
|
|
|
|
|
const uint32_t idx = ePropertyTrapHandlerNames;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TargetProperties::GetDisplayRuntimeSupportValues() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetDisplayRuntimeSupportValues(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 23:38:19 +00:00
|
|
|
bool TargetProperties::GetDisplayRecognizedArguments() const {
|
|
|
|
|
const uint32_t idx = ePropertyDisplayRecognizedArguments;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetDisplayRecognizedArguments(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyDisplayRecognizedArguments;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 14:31:06 +00:00
|
|
|
bool TargetProperties::GetNonStopModeEnabled() const {
|
|
|
|
|
const uint32_t idx = ePropertyNonStopModeEnabled;
|
2015-05-29 19:52:29 +00:00
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetNonStopModeEnabled(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyNonStopModeEnabled;
|
2015-05-29 19:52:29 +00:00
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ProcessLaunchInfo &TargetProperties::GetProcessLaunchInfo() {
|
2015-05-29 19:52:29 +00:00
|
|
|
m_launch_info.SetArg0(GetArg0()); // FIXME: Arg0 callback doesn't work
|
|
|
|
|
return m_launch_info;
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetProcessLaunchInfo(
|
|
|
|
|
const ProcessLaunchInfo &launch_info) {
|
|
|
|
|
m_launch_info = launch_info;
|
|
|
|
|
SetArg0(launch_info.GetArg0());
|
|
|
|
|
SetRunArguments(launch_info.GetArguments());
|
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
|
|
|
SetEnvironment(launch_info.GetEnvironment());
|
2015-02-13 14:31:06 +00:00
|
|
|
const FileAction *input_file_action =
|
|
|
|
|
launch_info.GetFileActionForFD(STDIN_FILENO);
|
|
|
|
|
if (input_file_action) {
|
2016-09-23 22:11:51 +00:00
|
|
|
SetStandardInputPath(input_file_action->GetPath());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-02-13 14:31:06 +00:00
|
|
|
const FileAction *output_file_action =
|
|
|
|
|
launch_info.GetFileActionForFD(STDOUT_FILENO);
|
|
|
|
|
if (output_file_action) {
|
2016-09-23 22:11:51 +00:00
|
|
|
SetStandardOutputPath(output_file_action->GetPath());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-02-13 14:31:06 +00:00
|
|
|
const FileAction *error_file_action =
|
|
|
|
|
launch_info.GetFileActionForFD(STDERR_FILENO);
|
|
|
|
|
if (error_file_action) {
|
2016-09-23 22:11:51 +00:00
|
|
|
SetStandardErrorPath(error_file_action->GetPath());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-02-13 14:31:06 +00:00
|
|
|
SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
|
|
|
|
|
SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
|
2020-08-05 10:02:51 -07:00
|
|
|
SetInheritTCC(
|
|
|
|
|
launch_info.GetFlags().Test(lldb::eLaunchFlagInheritTCCFromParent));
|
2015-02-13 14:31:06 +00:00
|
|
|
SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 01:18:15 +00:00
|
|
|
bool TargetProperties::GetRequireHardwareBreakpoints() const {
|
|
|
|
|
const uint32_t idx = ePropertyRequireHardwareBreakpoints;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
2019-07-29 16:41:30 +00:00
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
2018-11-15 01:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetProperties::SetRequireHardwareBreakpoints(bool b) {
|
|
|
|
|
const uint32_t idx = ePropertyRequireHardwareBreakpoints;
|
|
|
|
|
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 19:24:57 +00:00
|
|
|
bool TargetProperties::GetAutoInstallMainExecutable() const {
|
|
|
|
|
const uint32_t idx = ePropertyAutoInstallMainExecutable;
|
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
|
|
|
|
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::Arg0ValueChangedCallback() {
|
|
|
|
|
m_launch_info.SetArg0(GetArg0());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::RunArgsValueChangedCallback() {
|
2015-02-13 14:31:06 +00:00
|
|
|
Args args;
|
2020-01-09 14:14:54 +01:00
|
|
|
if (GetRunArguments(args))
|
|
|
|
|
m_launch_info.GetArguments() = args;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::EnvVarsValueChangedCallback() {
|
2020-03-19 18:02:05 -07:00
|
|
|
m_launch_info.GetEnvironment() = ComputeEnvironment();
|
2015-02-13 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::InputPathValueChangedCallback() {
|
|
|
|
|
m_launch_info.AppendOpenFileAction(STDIN_FILENO, GetStandardInputPath(), true,
|
|
|
|
|
false);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::OutputPathValueChangedCallback() {
|
|
|
|
|
m_launch_info.AppendOpenFileAction(STDOUT_FILENO, GetStandardOutputPath(),
|
|
|
|
|
false, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::ErrorPathValueChangedCallback() {
|
|
|
|
|
m_launch_info.AppendOpenFileAction(STDERR_FILENO, GetStandardErrorPath(),
|
|
|
|
|
false, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::DetachOnErrorValueChangedCallback() {
|
|
|
|
|
if (GetDetachOnError())
|
|
|
|
|
m_launch_info.GetFlags().Set(lldb::eLaunchFlagDetachOnError);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2020-01-09 14:14:54 +01:00
|
|
|
m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDetachOnError);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::DisableASLRValueChangedCallback() {
|
|
|
|
|
if (GetDisableASLR())
|
|
|
|
|
m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableASLR);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2020-01-09 14:14:54 +01:00
|
|
|
m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-05 10:02:51 -07:00
|
|
|
void TargetProperties::InheritTCCValueChangedCallback() {
|
|
|
|
|
if (GetInheritTCC())
|
|
|
|
|
m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
|
|
|
|
|
else
|
|
|
|
|
m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 14:14:54 +01:00
|
|
|
void TargetProperties::DisableSTDIOValueChangedCallback() {
|
|
|
|
|
if (GetDisableSTDIO())
|
|
|
|
|
m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
|
2015-02-13 14:31:06 +00:00
|
|
|
else
|
2020-01-09 14:14:54 +01:00
|
|
|
m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableSTDIO);
|
2015-02-13 14:31:06 +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
|
|
|
|
|
|
|
|
// Target::TargetEventData
|
|
|
|
|
|
|
|
|
|
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
|
|
|
|
|
: EventData(), m_target_sp(target_sp), m_module_list() {}
|
|
|
|
|
|
|
|
|
|
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp,
|
|
|
|
|
const ModuleList &module_list)
|
|
|
|
|
: EventData(), m_target_sp(target_sp), m_module_list(module_list) {}
|
|
|
|
|
|
2015-10-23 18:39:37 +00:00
|
|
|
Target::TargetEventData::~TargetEventData() = default;
|
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
|
|
|
|
2019-03-06 21:22:25 +00:00
|
|
|
ConstString Target::TargetEventData::GetFlavorString() {
|
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
|
|
|
static ConstString g_flavor("Target::TargetEventData");
|
|
|
|
|
return g_flavor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::TargetEventData::Dump(Stream *s) const {
|
2016-01-19 17:54:47 +00:00
|
|
|
for (size_t i = 0; i < m_module_list.GetSize(); ++i) {
|
|
|
|
|
if (i != 0)
|
|
|
|
|
*s << ", ";
|
|
|
|
|
m_module_list.GetModuleAtIndex(i)->GetDescription(
|
2019-12-04 09:20:42 +01:00
|
|
|
s->AsRawOstream(), lldb::eDescriptionLevelBrief);
|
2016-01-19 17:54:47 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Target::TargetEventData *
|
|
|
|
|
Target::TargetEventData::GetEventDataFromEvent(const Event *event_ptr) {
|
|
|
|
|
if (event_ptr) {
|
|
|
|
|
const EventData *event_data = event_ptr->GetData();
|
|
|
|
|
if (event_data &&
|
|
|
|
|
event_data->GetFlavor() == TargetEventData::GetFlavorString())
|
|
|
|
|
return static_cast<const TargetEventData *>(event_ptr->GetData());
|
|
|
|
|
}
|
2015-12-11 19:52:15 +00:00
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TargetSP Target::TargetEventData::GetTargetFromEvent(const Event *event_ptr) {
|
|
|
|
|
TargetSP target_sp;
|
|
|
|
|
const TargetEventData *event_data = GetEventDataFromEvent(event_ptr);
|
|
|
|
|
if (event_data)
|
|
|
|
|
target_sp = event_data->m_target_sp;
|
|
|
|
|
return target_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModuleList
|
|
|
|
|
Target::TargetEventData::GetModuleListFromEvent(const Event *event_ptr) {
|
|
|
|
|
ModuleList module_list;
|
|
|
|
|
const TargetEventData *event_data = GetEventDataFromEvent(event_ptr);
|
|
|
|
|
if (event_data)
|
|
|
|
|
module_list = event_data->m_module_list;
|
|
|
|
|
return module_list;
|
|
|
|
|
}
|
2019-10-01 00:47:25 +00:00
|
|
|
|
2020-05-19 11:16:57 -07:00
|
|
|
std::recursive_mutex &Target::GetAPIMutex() {
|
2019-10-01 00:47:25 +00:00
|
|
|
if (GetProcessSP() && GetProcessSP()->CurrentThreadIsPrivateStateThread())
|
|
|
|
|
return m_private_mutex;
|
|
|
|
|
else
|
|
|
|
|
return m_mutex;
|
|
|
|
|
}
|