summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBDebugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API/SBDebugger.cpp')
-rw-r--r--lldb/source/API/SBDebugger.cpp97
1 files changed, 63 insertions, 34 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index b7ac8047f8e5d..5f62987f37dad 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1,4 +1,4 @@
-//===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBDebugger.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
@@ -312,7 +313,7 @@ SBError SBDebugger::SetInputFile(SBFile file) {
repro::DataRecorder *recorder = nullptr;
if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
- recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder();
+ recorder = g->GetOrCreate<repro::CommandProvider>().GetNewRecorder();
FileSP file_sp = file.m_opaque_sp;
@@ -596,8 +597,9 @@ SBSourceManager SBDebugger::GetSourceManager() {
}
bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
- LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
- (char *, size_t), "", arch_name_len);
+ LLDB_RECORD_CHAR_PTR_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
+ (char *, size_t), arch_name, "",
+ arch_name_len);
if (arch_name && arch_name_len) {
ArchSpec default_arch = Target::GetDefaultArchitecture();
@@ -1165,9 +1167,9 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
if (m_opaque_sp) {
CommandInterpreterRunOptions options;
-
- m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(
- auto_handle_events, spawn_thread, options);
+ options.SetAutoHandleEvents(auto_handle_events);
+ options.SetSpawnThread(spawn_thread);
+ m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
}
}
@@ -1185,15 +1187,35 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
quit_requested, stopped_for_crash);
if (m_opaque_sp) {
+ options.SetAutoHandleEvents(auto_handle_events);
+ options.SetSpawnThread(spawn_thread);
CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
- interp.RunCommandInterpreter(auto_handle_events, spawn_thread,
- options.ref());
- num_errors = interp.GetNumErrors();
- quit_requested = interp.GetQuitRequested();
- stopped_for_crash = interp.GetStoppedForCrash();
+ CommandInterpreterRunResult result =
+ interp.RunCommandInterpreter(options.ref());
+ num_errors = result.GetNumErrors();
+ quit_requested =
+ result.IsResult(lldb::eCommandInterpreterResultQuitRequested);
+ stopped_for_crash =
+ result.IsResult(lldb::eCommandInterpreterResultInferiorCrash);
}
}
+SBCommandInterpreterRunResult SBDebugger::RunCommandInterpreter(
+ const SBCommandInterpreterRunOptions &options) {
+ LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
+ RunCommandInterpreter,
+ (const lldb::SBCommandInterpreterRunOptions &), options);
+
+ if (!m_opaque_sp)
+ return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult());
+
+ CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
+ CommandInterpreterRunResult result =
+ interp.RunCommandInterpreter(options.ref());
+
+ return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult(result));
+}
+
SBError SBDebugger::RunREPL(lldb::LanguageType language,
const char *repl_options) {
LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL,
@@ -1282,7 +1304,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name,
if (value_sp) {
StreamString value_strm;
value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
- const std::string &value_str = value_strm.GetString();
+ const std::string &value_str = std::string(value_strm.GetString());
if (!value_str.empty()) {
StringList string_list;
string_list.SplitIntoLines(value_str);
@@ -1374,6 +1396,18 @@ bool SBDebugger::GetUseColor() const {
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
}
+bool SBDebugger::SetUseSourceCache(bool value) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value);
+
+ return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
+}
+
+bool SBDebugger::GetUseSourceCache() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache);
+
+ return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
+}
+
bool SBDebugger::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
description);
@@ -1627,46 +1661,38 @@ static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
-static bool GetDefaultArchitectureRedirect(char *arch_name,
- size_t arch_name_len) {
- // The function is writing to its argument. Without the redirect it would
- // write into the replay buffer.
- char buffer[1024];
- return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len);
-}
-
template <> void RegisterMethods<SBDebugger>(Registry &R) {
// Custom implementation.
- R.Register(&invoke<void (SBDebugger::*)(
- FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit,
+ R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
+ &SBDebugger::SetErrorFileHandle>::record,
&SetFileHandleRedirect);
- R.Register(&invoke<void (SBDebugger::*)(
- FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit,
+ R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
+ &SBDebugger::SetOutputFileHandle>::record,
&SetFileHandleRedirect);
- R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>(
- &SBDebugger::GetDefaultArchitecture),
- &GetDefaultArchitectureRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetInputFile>::doit,
+ SBFile)>::method<&SBDebugger::SetInputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetOutputFile>::doit,
+ SBFile)>::method<&SBDebugger::SetOutputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetErrorFile>::doit,
+ SBFile)>::method<&SBDebugger::SetErrorFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetInputFile>::doit,
+ FileSP)>::method<&SBDebugger::SetInputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetOutputFile>::doit,
+ FileSP)>::method<&SBDebugger::SetOutputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetErrorFile>::doit,
+ FileSP)>::method<&SBDebugger::SetErrorFile>::record,
&SetFileRedirect);
+ LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(bool, SBDebugger,
+ GetDefaultArchitecture);
+
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
@@ -1816,6 +1842,9 @@ template <> void RegisterMethods<SBDebugger>(Registry &R) {
(lldb::SBTypeNameSpecifier));
LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog,
(const char *, const char **));
+ LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
+ RunCommandInterpreter,
+ (const lldb::SBCommandInterpreterRunOptions &));
}
} // namespace repro