diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Breakpoint/BreakpointOptions.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/Breakpoint/BreakpointOptions.cpp')
-rw-r--r-- | source/Breakpoint/BreakpointOptions.cpp | 99 |
1 files changed, 40 insertions, 59 deletions
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp index ff497c5633b0..f6f279dc382a 100644 --- a/source/Breakpoint/BreakpointOptions.cpp +++ b/source/Breakpoint/BreakpointOptions.cpp @@ -1,9 +1,8 @@ //===-- BreakpointOptions.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -120,18 +119,16 @@ bool BreakpointOptions::NullCallback(void *baton, return true; } -//---------------------------------------------------------------------- // BreakpointOptions constructor -//---------------------------------------------------------------------- BreakpointOptions::BreakpointOptions(bool all_flags_set) : m_callback(BreakpointOptions::NullCallback), m_callback_baton_sp(), m_baton_is_command_baton(false), m_callback_is_synchronous(false), - m_enabled(true), m_one_shot(false), m_ignore_count(0), m_thread_spec_ap(), + m_enabled(true), m_one_shot(false), m_ignore_count(0), m_thread_spec_up(), m_condition_text(), m_condition_text_hash(0), m_auto_continue(false), m_set_flags(0) { - if (all_flags_set) - m_set_flags.Set(~((Flags::ValueType) 0)); - } + if (all_flags_set) + m_set_flags.Set(~((Flags::ValueType)0)); +} BreakpointOptions::BreakpointOptions(const char *condition, bool enabled, int32_t ignore, bool one_shot, @@ -148,26 +145,21 @@ BreakpointOptions::BreakpointOptions(const char *condition, bool enabled, } } -//---------------------------------------------------------------------- // BreakpointOptions copy constructor -//---------------------------------------------------------------------- BreakpointOptions::BreakpointOptions(const BreakpointOptions &rhs) : m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp), m_baton_is_command_baton(rhs.m_baton_is_command_baton), m_callback_is_synchronous(rhs.m_callback_is_synchronous), m_enabled(rhs.m_enabled), m_one_shot(rhs.m_one_shot), - m_ignore_count(rhs.m_ignore_count), m_thread_spec_ap(), - m_auto_continue(rhs.m_auto_continue), - m_set_flags(rhs.m_set_flags) { - if (rhs.m_thread_spec_ap.get() != nullptr) - m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); + m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(), + m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) { + if (rhs.m_thread_spec_up != nullptr) + m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up)); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; } -//---------------------------------------------------------------------- // BreakpointOptions assignment operator -//---------------------------------------------------------------------- const BreakpointOptions &BreakpointOptions:: operator=(const BreakpointOptions &rhs) { m_callback = rhs.m_callback; @@ -177,8 +169,8 @@ operator=(const BreakpointOptions &rhs) { m_enabled = rhs.m_enabled; m_one_shot = rhs.m_one_shot; m_ignore_count = rhs.m_ignore_count; - if (rhs.m_thread_spec_ap.get() != nullptr) - m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); + if (rhs.m_thread_spec_up != nullptr) + m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up)); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; m_auto_continue = rhs.m_auto_continue; @@ -229,19 +221,16 @@ void BreakpointOptions::CopyOverSetOptions(const BreakpointOptions &incoming) m_auto_continue = incoming.m_auto_continue; m_set_flags.Set(eAutoContinue); } - if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_ap) - { - if (!m_thread_spec_ap) - m_thread_spec_ap.reset(new ThreadSpec(*incoming.m_thread_spec_ap.get())); + if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_up) { + if (!m_thread_spec_up) + m_thread_spec_up.reset(new ThreadSpec(*incoming.m_thread_spec_up)); else - *m_thread_spec_ap.get() = *incoming.m_thread_spec_ap.get(); + *m_thread_spec_up = *incoming.m_thread_spec_up; m_set_flags.Set(eThreadSpec); } } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- BreakpointOptions::~BreakpointOptions() = default; std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData( @@ -256,55 +245,50 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData( const char *key = GetKey(OptionNames::EnabledState); bool success; - if (key) { + if (key && options_dict.HasKey(key)) { success = options_dict.GetValueForKeyAsBoolean(key, enabled); if (!success) { - error.SetErrorStringWithFormat("%s key is not a boolean.", - GetKey(OptionNames::EnabledState)); + error.SetErrorStringWithFormat("%s key is not a boolean.", key); return nullptr; } set_options.Set(eEnabled); } key = GetKey(OptionNames::OneShotState); - if (key) { + if (key && options_dict.HasKey(key)) { success = options_dict.GetValueForKeyAsBoolean(key, one_shot); if (!success) { - error.SetErrorStringWithFormat("%s key is not a boolean.", - GetKey(OptionNames::OneShotState)); + error.SetErrorStringWithFormat("%s key is not a boolean.", key); return nullptr; } set_options.Set(eOneShot); } key = GetKey(OptionNames::AutoContinue); - if (key) { + if (key && options_dict.HasKey(key)) { success = options_dict.GetValueForKeyAsBoolean(key, auto_continue); if (!success) { - error.SetErrorStringWithFormat("%s key is not a boolean.", - GetKey(OptionNames::AutoContinue)); + error.SetErrorStringWithFormat("%s key is not a boolean.", key); return nullptr; } set_options.Set(eAutoContinue); } key = GetKey(OptionNames::IgnoreCount); - if (key) { + if (key && options_dict.HasKey(key)) { success = options_dict.GetValueForKeyAsInteger(key, ignore_count); if (!success) { - error.SetErrorStringWithFormat("%s key is not an integer.", - GetKey(OptionNames::IgnoreCount)); + error.SetErrorStringWithFormat("%s key is not an integer.", key); return nullptr; } set_options.Set(eIgnoreCount); } key = GetKey(OptionNames::ConditionText); - if (key) { + if (key && options_dict.HasKey(key)) { success = options_dict.GetValueForKeyAsString(key, condition_ref); if (!success) { - error.SetErrorStringWithFormat("%s key is not an string.", - GetKey(OptionNames::ConditionText)); + error.SetErrorStringWithFormat("%s key is not an string.", key); return nullptr; } set_options.Set(eCondition); @@ -328,12 +312,11 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData( auto bp_options = llvm::make_unique<BreakpointOptions>( condition_ref.str().c_str(), enabled, ignore_count, one_shot, auto_continue); - if (cmd_data_up.get()) { + if (cmd_data_up) { if (cmd_data_up->interpreter == eScriptLanguageNone) bp_options->SetCommandDataCallback(cmd_data_up); else { - ScriptInterpreter *interp = - target.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + ScriptInterpreter *interp = target.GetDebugger().GetScriptInterpreter(); if (!interp) { error.SetErrorStringWithFormat( "Can't set script commands - no script interpreter"); @@ -405,18 +388,16 @@ StructuredData::ObjectSP BreakpointOptions::SerializeToStructuredData() { BreakpointOptions::CommandData::GetSerializationKey(), commands_sp); } } - if (m_set_flags.Test(eThreadSpec) && m_thread_spec_ap) { + if (m_set_flags.Test(eThreadSpec) && m_thread_spec_up) { StructuredData::ObjectSP thread_spec_sp = - m_thread_spec_ap->SerializeToStructuredData(); + m_thread_spec_up->SerializeToStructuredData(); options_dict_sp->AddItem(ThreadSpec::GetSerializationKey(), thread_spec_sp); } return options_dict_sp; } -//------------------------------------------------------------------ // Callbacks -//------------------------------------------------------------------ void BreakpointOptions::SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &callback_baton_sp, bool callback_is_synchronous) { @@ -522,17 +503,16 @@ const char *BreakpointOptions::GetConditionText(size_t *hash) const { } const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const { - return m_thread_spec_ap.get(); + return m_thread_spec_up.get(); } ThreadSpec *BreakpointOptions::GetThreadSpec() { - if (m_thread_spec_ap.get() == nullptr) - { + if (m_thread_spec_up == nullptr) { m_set_flags.Set(eThreadSpec); - m_thread_spec_ap.reset(new ThreadSpec()); + m_thread_spec_up.reset(new ThreadSpec()); } - return m_thread_spec_ap.get(); + return m_thread_spec_up.get(); } void BreakpointOptions::SetThreadID(lldb::tid_t thread_id) { @@ -542,7 +522,7 @@ void BreakpointOptions::SetThreadID(lldb::tid_t thread_id) { void BreakpointOptions::SetThreadSpec( std::unique_ptr<ThreadSpec> &thread_spec_up) { - m_thread_spec_ap = std::move(thread_spec_up); + m_thread_spec_up = std::move(thread_spec_up); m_set_flags.Set(eThreadSpec); } @@ -574,8 +554,8 @@ void BreakpointOptions::GetDescription(Stream *s, if (m_auto_continue) s->Printf("auto-continue "); - if (m_thread_spec_ap.get()) - m_thread_spec_ap->GetDescription(s, level); + if (m_thread_spec_up) + m_thread_spec_up->GetDescription(s, level); if (level == lldb::eDescriptionLevelFull) { s->IndentLess(); @@ -666,6 +646,7 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction( options.SetStopOnError(data->stop_on_error); options.SetEchoCommands(true); options.SetPrintResults(true); + options.SetPrintErrors(true); options.SetAddToHistory(false); debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx, @@ -680,7 +661,7 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction( void BreakpointOptions::Clear() { m_set_flags.Clear(); - m_thread_spec_ap.release(); + m_thread_spec_up.release(); m_one_shot = false; m_ignore_count = 0; m_auto_continue = false; |