aboutsummaryrefslogtreecommitdiffstats
path: root/source/Breakpoint
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Breakpoint
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/Breakpoint')
-rw-r--r--source/Breakpoint/Breakpoint.cpp21
-rw-r--r--source/Breakpoint/BreakpointIDList.cpp10
-rw-r--r--source/Breakpoint/BreakpointLocation.cpp13
-rw-r--r--source/Breakpoint/BreakpointOptions.cpp2
-rw-r--r--source/Breakpoint/BreakpointResolver.cpp23
-rw-r--r--source/Breakpoint/BreakpointResolverAddress.cpp9
-rw-r--r--source/Breakpoint/BreakpointResolverFileLine.cpp6
-rw-r--r--source/Breakpoint/BreakpointResolverFileRegex.cpp15
-rw-r--r--source/Breakpoint/BreakpointResolverName.cpp22
-rw-r--r--source/Breakpoint/BreakpointResolverScripted.cpp52
-rw-r--r--source/Breakpoint/Watchpoint.cpp17
-rw-r--r--source/Breakpoint/WatchpointOptions.cpp5
12 files changed, 87 insertions, 108 deletions
diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp
index 3c3841949b91..a112542803c4 100644
--- a/source/Breakpoint/Breakpoint.cpp
+++ b/source/Breakpoint/Breakpoint.cpp
@@ -496,10 +496,10 @@ void Breakpoint::ClearAllBreakpointSites() {
void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
bool delete_locations) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Breakpoint::ModulesChanged: num_modules: %zu load: %i "
- "delete_locations: %i\n",
- module_list.GetSize(), load, delete_locations);
+ LLDB_LOGF(log,
+ "Breakpoint::ModulesChanged: num_modules: %zu load: %i "
+ "delete_locations: %i\n",
+ module_list.GetSize(), load, delete_locations);
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
if (load) {
@@ -550,10 +550,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
seen = true;
if (!break_loc_sp->ResolveBreakpointSite()) {
- if (log)
- log->Printf("Warning: could not set breakpoint site for "
- "breakpoint location %d of breakpoint %d.\n",
- break_loc_sp->GetID(), GetID());
+ LLDB_LOGF(log,
+ "Warning: could not set breakpoint site for "
+ "breakpoint location %d of breakpoint %d.\n",
+ break_loc_sp->GetID(), GetID());
}
}
}
@@ -659,9 +659,8 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
ModuleSP new_module_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Breakpoint::ModulesReplaced for %s\n",
- old_module_sp->GetSpecificationDescription().c_str());
+ LLDB_LOGF(log, "Breakpoint::ModulesReplaced for %s\n",
+ old_module_sp->GetSpecificationDescription().c_str());
// First find all the locations that are in the old module
BreakpointLocationCollection old_break_locs;
diff --git a/source/Breakpoint/BreakpointIDList.cpp b/source/Breakpoint/BreakpointIDList.cpp
index 1e695fae6995..de68c44ec6a4 100644
--- a/source/Breakpoint/BreakpointIDList.cpp
+++ b/source/Breakpoint/BreakpointIDList.cpp
@@ -122,7 +122,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
for (size_t i = 0; i < old_args.size(); ++i) {
bool is_range = false;
- current_arg = old_args[i].ref;
+ current_arg = old_args[i].ref();
if (!allow_locations && current_arg.contains('.')) {
result.AppendErrorWithFormat(
"Breakpoint locations not allowed, saw location: %s.",
@@ -146,16 +146,16 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
} else
names_found.insert(current_arg);
} else if ((i + 2 < old_args.size()) &&
- BreakpointID::IsRangeIdentifier(old_args[i + 1].ref) &&
+ BreakpointID::IsRangeIdentifier(old_args[i + 1].ref()) &&
BreakpointID::IsValidIDExpression(current_arg) &&
- BreakpointID::IsValidIDExpression(old_args[i + 2].ref)) {
+ BreakpointID::IsValidIDExpression(old_args[i + 2].ref())) {
range_from = current_arg;
- range_to = old_args[i + 2].ref;
+ range_to = old_args[i + 2].ref();
is_range = true;
i = i + 2;
} else {
// See if user has specified id.*
- llvm::StringRef tmp_str = old_args[i].ref;
+ llvm::StringRef tmp_str = old_args[i].ref();
size_t pos = tmp_str.find('.');
if (pos != llvm::StringRef::npos) {
llvm::StringRef bp_id_str = tmp_str.substr(0, pos);
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index b718e2aeea5c..46b8f25c5668 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -257,9 +257,8 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
condition_text, llvm::StringRef(), language, Expression::eResultTypeAny,
EvaluateExpressionOptions(), nullptr, error));
if (error.Fail()) {
- if (log)
- log->Printf("Error getting condition expression: %s.",
- error.AsCString());
+ LLDB_LOGF(log, "Error getting condition expression: %s.",
+ error.AsCString());
m_user_expression_sp.reset();
return true;
}
@@ -312,8 +311,8 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
ret = result_value_sp->IsLogicalTrue(error);
if (log) {
if (error.Success()) {
- log->Printf("Condition successfully evaluated, result is %s.\n",
- ret ? "true" : "false");
+ LLDB_LOGF(log, "Condition successfully evaluated, result is %s.\n",
+ ret ? "true" : "false");
} else {
error.SetErrorString(
"Failed to get an integer result from the expression");
@@ -408,8 +407,8 @@ bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) {
if (log) {
StreamString s;
GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Hit breakpoint location: %s, %s.\n", s.GetData(),
- should_stop ? "stopping" : "continuing");
+ LLDB_LOGF(log, "Hit breakpoint location: %s, %s.\n", s.GetData(),
+ should_stop ? "stopping" : "continuing");
}
return should_stop;
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index f6f279dc382a..0d4c6173c3c5 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -309,7 +309,7 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
}
}
- auto bp_options = llvm::make_unique<BreakpointOptions>(
+ auto bp_options = std::make_unique<BreakpointOptions>(
condition_ref.str().c_str(), enabled,
ignore_count, one_shot, auto_continue);
if (cmd_data_up) {
diff --git a/source/Breakpoint/BreakpointResolver.cpp b/source/Breakpoint/BreakpointResolver.cpp
index b3224aa91753..e0a4e6ac6712 100644
--- a/source/Breakpoint/BreakpointResolver.cpp
+++ b/source/Breakpoint/BreakpointResolver.cpp
@@ -34,7 +34,8 @@ using namespace lldb;
// BreakpointResolver:
const char *BreakpointResolver::g_ty_to_name[] = {"FileAndLine", "Address",
"SymbolName", "SourceRegex",
- "Exception", "Unknown"};
+ "Python", "Exception",
+ "Unknown"};
const char *BreakpointResolver::g_option_names[static_cast<uint32_t>(
BreakpointResolver::OptionNames::LastOptionName)] = {
@@ -294,18 +295,18 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
Address line_start = sc.line_entry.range.GetBaseAddress();
if (!line_start.IsValid()) {
- if (log)
- log->Printf("error: Unable to set breakpoint %s at file address "
- "0x%" PRIx64 "\n",
- log_ident.str().c_str(), line_start.GetFileAddress());
+ LLDB_LOGF(log,
+ "error: Unable to set breakpoint %s at file address "
+ "0x%" PRIx64 "\n",
+ log_ident.str().c_str(), line_start.GetFileAddress());
return;
}
if (!filter.AddressPasses(line_start)) {
- if (log)
- log->Printf("Breakpoint %s at file address 0x%" PRIx64
- " didn't pass the filter.\n",
- log_ident.str().c_str(), line_start.GetFileAddress());
+ LLDB_LOGF(log,
+ "Breakpoint %s at file address 0x%" PRIx64
+ " didn't pass the filter.\n",
+ log_ident.str().c_str(), line_start.GetFileAddress());
}
// If the line number is before the prologue end, move it there...
@@ -329,8 +330,8 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
if (log && bp_loc_sp && !m_breakpoint->IsInternal()) {
StreamString s;
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Added location (skipped prologue: %s): %s \n",
- skipped_prologue ? "yes" : "no", s.GetData());
+ LLDB_LOGF(log, "Added location (skipped prologue: %s): %s \n",
+ skipped_prologue ? "yes" : "no", s.GetData());
}
}
diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp
index 8a6fd6a2692c..b98568098b4b 100644
--- a/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -120,10 +120,8 @@ void BreakpointResolverAddress::ResolveBreakpointInModules(
BreakpointResolver::ResolveBreakpointInModules(filter, modules);
}
-Searcher::CallbackReturn
-BreakpointResolverAddress::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) {
+Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
+ SearchFilter &filter, SymbolContext &context, Address *addr) {
assert(m_breakpoint != nullptr);
if (filter.AddressPasses(m_addr)) {
@@ -149,8 +147,7 @@ BreakpointResolverAddress::SearchCallback(SearchFilter &filter,
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
Log *log(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("Added location: %s\n", s.GetData());
+ LLDB_LOGF(log, "Added location: %s\n", s.GetData());
}
} else {
BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
diff --git a/source/Breakpoint/BreakpointResolverFileLine.cpp b/source/Breakpoint/BreakpointResolverFileLine.cpp
index a6095be31647..2b26f65816bd 100644
--- a/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -198,10 +198,8 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
}
}
-Searcher::CallbackReturn
-BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr, bool containing) {
+Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
+ SearchFilter &filter, SymbolContext &context, Address *addr) {
SymbolContextList sc_list;
assert(m_breakpoint != nullptr);
diff --git a/source/Breakpoint/BreakpointResolverFileRegex.cpp b/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 0b2485245b72..3cb04263c6dc 100644
--- a/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -20,11 +20,11 @@ using namespace lldb_private;
// BreakpointResolverFileRegex:
BreakpointResolverFileRegex::BreakpointResolverFileRegex(
- Breakpoint *bkpt, RegularExpression &regex,
+ Breakpoint *bkpt, RegularExpression regex,
const std::unordered_set<std::string> &func_names, bool exact_match)
: BreakpointResolver(bkpt, BreakpointResolver::FileRegexResolver),
- m_regex(regex), m_exact_match(exact_match), m_function_names(func_names) {
-}
+ m_regex(std::move(regex)), m_exact_match(exact_match),
+ m_function_names(func_names) {}
BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
@@ -69,7 +69,8 @@ BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
}
}
- return new BreakpointResolverFileRegex(bkpt, regex, names_set, exact_match);
+ return new BreakpointResolverFileRegex(bkpt, std::move(regex), names_set,
+ exact_match);
}
StructuredData::ObjectSP
@@ -93,10 +94,8 @@ BreakpointResolverFileRegex::SerializeToStructuredData() {
return WrapOptionsDict(options_dict_sp);
}
-Searcher::CallbackReturn
-BreakpointResolverFileRegex::SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr, bool containing) {
+Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
+ SearchFilter &filter, SymbolContext &context, Address *addr) {
assert(m_breakpoint != nullptr);
if (!context.target_sp)
diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp
index 3ad2e8867f2a..ba9c88c7eae8 100644
--- a/source/Breakpoint/BreakpointResolverName.cpp
+++ b/source/Breakpoint/BreakpointResolverName.cpp
@@ -31,7 +31,8 @@ BreakpointResolverName::BreakpointResolverName(
m_class_name(), m_regex(), m_match_type(type), m_language(language),
m_skip_prologue(skip_prologue) {
if (m_match_type == Breakpoint::Regexp) {
- if (!m_regex.Compile(llvm::StringRef::withNullAsEmpty(name_cstr))) {
+ m_regex = RegularExpression(llvm::StringRef::withNullAsEmpty(name_cstr));
+ if (!m_regex.IsValid()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
@@ -70,12 +71,12 @@ BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
}
BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
- RegularExpression &func_regex,
+ RegularExpression func_regex,
lldb::LanguageType language,
lldb::addr_t offset,
bool skip_prologue)
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
- m_class_name(nullptr), m_regex(func_regex),
+ m_class_name(nullptr), m_regex(std::move(func_regex)),
m_match_type(Breakpoint::Regexp), m_language(language),
m_skip_prologue(skip_prologue) {}
@@ -125,9 +126,8 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::RegexString), regex_text);
if (success) {
- RegularExpression regex(regex_text);
- return new BreakpointResolverName(bkpt, regex, language, offset,
- skip_prologue);
+ return new BreakpointResolverName(bkpt, RegularExpression(regex_text),
+ language, offset, skip_prologue);
} else {
StructuredData::Array *names_array;
success = options_dict.GetValueForKeyAsArray(
@@ -250,8 +250,7 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
Searcher::CallbackReturn
BreakpointResolverName::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) {
+ SymbolContext &context, Address *addr) {
SymbolContextList func_list;
// SymbolContextList sym_list;
@@ -272,7 +271,6 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
bool filter_by_language = (m_language != eLanguageTypeUnknown);
const bool include_symbols = !filter_by_cu;
const bool include_inlines = true;
- const bool append = true;
switch (m_match_type) {
case Breakpoint::Exact:
@@ -281,7 +279,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
const size_t start_func_idx = func_list.GetSize();
context.module_sp->FindFunctions(
lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(),
- include_symbols, include_inlines, append, func_list);
+ include_symbols, include_inlines, func_list);
const size_t end_func_idx = func_list.GetSize();
@@ -295,7 +293,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
context.module_sp->FindFunctions(
m_regex,
!filter_by_cu, // include symbols only if we aren't filtering by CU
- include_inlines, append, func_list);
+ include_inlines, func_list);
}
break;
case Breakpoint::Glob:
@@ -388,7 +386,7 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
if (log) {
StreamString s;
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf("Added location: %s\n", s.GetData());
+ LLDB_LOGF(log, "Added location: %s\n", s.GetData());
}
}
}
diff --git a/source/Breakpoint/BreakpointResolverScripted.cpp b/source/Breakpoint/BreakpointResolverScripted.cpp
index 8363795a4d7f..288fd37c1c79 100644
--- a/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -29,8 +29,7 @@ BreakpointResolverScripted::BreakpointResolverScripted(
Breakpoint *bkpt,
const llvm::StringRef class_name,
lldb::SearchDepth depth,
- StructuredDataImpl *args_data,
- ScriptInterpreter &script_interp)
+ StructuredDataImpl *args_data)
: BreakpointResolver(bkpt, BreakpointResolver::PythonResolver),
m_class_name(class_name), m_depth(depth), m_args_ptr(args_data) {
CreateImplementationIfNeeded();
@@ -68,45 +67,25 @@ BreakpointResolverScripted::CreateFromStructuredData(
llvm::StringRef class_name;
bool success;
- if (!bkpt)
- return nullptr;
-
success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::PythonClassName), class_name);
if (!success) {
error.SetErrorString("BRFL::CFSD: Couldn't find class name entry.");
return nullptr;
}
- lldb::SearchDepth depth;
- int depth_as_int;
- success = options_dict.GetValueForKeyAsInteger(
- GetKey(OptionNames::SearchDepth), depth_as_int);
- if (!success) {
- error.SetErrorString("BRFL::CFSD: Couldn't find class name entry.");
- return nullptr;
- }
- if (depth_as_int >= (int) OptionNames::LastOptionName) {
- error.SetErrorString("BRFL::CFSD: Invalid value for search depth.");
- return nullptr;
- }
- depth = (lldb::SearchDepth) depth_as_int;
+ // The Python function will actually provide the search depth, this is a
+ // placeholder.
+ lldb::SearchDepth depth = lldb::eSearchDepthTarget;
StructuredDataImpl *args_data_impl = new StructuredDataImpl();
- StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+ StructuredData::Dictionary *args_dict = nullptr;
success = options_dict.GetValueForKeyAsDictionary(
GetKey(OptionNames::ScriptArgs), args_dict);
if (success) {
- // FIXME: The resolver needs a copy of the ARGS dict that it can own,
- // so I need to make a copy constructor for the Dictionary so I can pass
- // that to it here. For now the args are empty.
- //StructuredData::Dictionary *dict_copy = new StructuredData::Dictionary(args_dict);
-
+ args_data_impl->SetObjectSP(args_dict->shared_from_this());
}
- ScriptInterpreter *script_interp = bkpt->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
- return new BreakpointResolverScripted(bkpt, class_name, depth, args_data_impl,
- *script_interp);
+ return new BreakpointResolverScripted(bkpt, class_name, depth,
+ args_data_impl);
}
StructuredData::ObjectSP
@@ -116,6 +95,10 @@ BreakpointResolverScripted::SerializeToStructuredData() {
options_dict_sp->AddStringItem(GetKey(OptionNames::PythonClassName),
m_class_name);
+ if (m_args_ptr->IsValid())
+ options_dict_sp->AddItem(GetKey(OptionNames::ScriptArgs),
+ m_args_ptr->GetObjectSP());
+
return WrapOptionsDict(options_dict_sp);
}
@@ -123,10 +106,8 @@ ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
return m_breakpoint->GetTarget().GetDebugger().GetScriptInterpreter();
}
-Searcher::CallbackReturn
-BreakpointResolverScripted::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) {
+Searcher::CallbackReturn BreakpointResolverScripted::SearchCallback(
+ SearchFilter &filter, SymbolContext &context, Address *addr) {
assert(m_breakpoint != nullptr);
bool should_continue = true;
if (!m_implementation_sp)
@@ -173,11 +154,10 @@ void BreakpointResolverScripted::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
BreakpointResolverScripted::CopyForBreakpoint(Breakpoint &breakpoint) {
- ScriptInterpreter *script_interp = GetScriptInterpreter();
// FIXME: Have to make a copy of the arguments from the m_args_ptr and then
// pass that to the new resolver.
lldb::BreakpointResolverSP ret_sp(
- new BreakpointResolverScripted(&breakpoint, m_class_name,
- m_depth, nullptr, *script_interp));
+ new BreakpointResolverScripted(&breakpoint, m_class_name, m_depth,
+ nullptr));
return ret_sp;
}
diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp
index e8a926527d24..17dcda13e9b9 100644
--- a/source/Breakpoint/Watchpoint.cpp
+++ b/source/Breakpoint/Watchpoint.cpp
@@ -13,10 +13,11 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Expression/UserExpression.h"
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
using namespace lldb;
@@ -30,14 +31,22 @@ Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
m_ignore_count(0), m_false_alarms(0), m_decl_str(), m_watch_spec_str(),
m_type(), m_error(), m_options(), m_being_created(true) {
+
if (type && type->IsValid())
m_type = *type;
else {
// If we don't have a known type, then we force it to unsigned int of the
// right size.
- ClangASTContext *ast_context = target.GetScratchClangASTContext();
- m_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint,
- 8 * size);
+ auto type_system_or_err =
+ target.GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(
+ lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS),
+ std::move(err), "Failed to set type.");
+ } else {
+ m_type = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
+ eEncodingUint, 8 * size);
+ }
}
// Set the initial value of the watched variable:
diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp
index 7dd130a3072c..cd5ef930e5dc 100644
--- a/source/Breakpoint/WatchpointOptions.cpp
+++ b/source/Breakpoint/WatchpointOptions.cpp
@@ -170,9 +170,8 @@ void WatchpointOptions::CommandBaton::GetDescription(
s->IndentMore();
if (data && data->user_source.GetSize() > 0) {
- const size_t num_strings = data->user_source.GetSize();
- for (size_t i = 0; i < num_strings; ++i) {
- s->Indent(data->user_source.GetStringAtIndex(i));
+ for (const std::string &line : data->user_source) {
+ s->Indent(line);
s->EOL();
}
} else {