2010-06-09 00:52:24 +08:00
//===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===//
//
2019-01-19 16:50:56 +08: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-09 00:52:24 +08:00
//
//===----------------------------------------------------------------------===//
2016-02-19 06:39:14 +08:00
# include "CommandObjectBreakpoint.h"
# include "CommandObjectBreakpointCommand.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Breakpoint/Breakpoint.h"
# include "lldb/Breakpoint/BreakpointIDList.h"
# include "lldb/Breakpoint/BreakpointLocation.h"
2017-03-23 07:33:16 +08:00
# include "lldb/Host/OptionParser.h"
2016-09-07 04:57:50 +08:00
# include "lldb/Interpreter/CommandCompletions.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Interpreter/CommandInterpreter.h"
# include "lldb/Interpreter/CommandReturnObject.h"
2018-04-10 17:03:59 +08:00
# include "lldb/Interpreter/OptionArgParser.h"
2016-09-07 04:57:50 +08:00
# include "lldb/Interpreter/OptionValueBoolean.h"
# include "lldb/Interpreter/OptionValueString.h"
# include "lldb/Interpreter/OptionValueUInt64.h"
# include "lldb/Interpreter/Options.h"
2015-09-02 09:06:46 +08:00
# include "lldb/Target/Language.h"
2013-11-04 17:33:30 +08:00
# include "lldb/Target/StackFrame.h"
2016-09-07 04:57:50 +08:00
# include "lldb/Target/Target.h"
2010-06-16 10:00:15 +08:00
# include "lldb/Target/Thread.h"
# include "lldb/Target/ThreadSpec.h"
2017-02-03 05:39:50 +08:00
# include "lldb/Utility/RegularExpression.h"
# include "lldb/Utility/StreamString.h"
2010-06-09 00:52:24 +08:00
2019-02-12 07:13:08 +08:00
# include <memory>
# include <vector>
2010-06-09 00:52:24 +08:00
using namespace lldb ;
using namespace lldb_private ;
2016-09-07 04:57:50 +08:00
static void AddBreakpointDescription ( Stream * s , Breakpoint * bp ,
lldb : : DescriptionLevel level ) {
s - > IndentMore ( ) ;
bp - > GetDescription ( s , level , true ) ;
s - > IndentLess ( ) ;
s - > EOL ( ) ;
2010-06-09 00:52:24 +08:00
}
2017-09-15 04:22:49 +08:00
// Modifiable Breakpoint Options
# pragma mark Modify::CommandOptions
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_modify_options [ ] = {
2017-09-15 04:22:49 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " ignore-count " , ' i ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeCount , " Set the number of times this breakpoint is skipped before stopping. " } ,
{ LLDB_OPT_SET_1 , false , " one-shot " , ' o ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " The breakpoint is deleted the first time it stop causes a stop. " } ,
{ LLDB_OPT_SET_1 , false , " thread-index " , ' x ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeThreadIndex , " The breakpoint stops only for the thread whose index matches this argument. " } ,
{ LLDB_OPT_SET_1 , false , " thread-id " , ' t ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeThreadID , " The breakpoint stops only for the thread whose TID matches this argument. " } ,
{ LLDB_OPT_SET_1 , false , " thread-name " , ' T ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeThreadName , " The breakpoint stops only for the thread whose thread name matches this argument. " } ,
{ LLDB_OPT_SET_1 , false , " queue-name " , ' q ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeQueueName , " The breakpoint stops only for threads in the queue whose name is given by this argument. " } ,
{ LLDB_OPT_SET_1 , false , " condition " , ' c ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeExpression , " The breakpoint stops only if this condition expression evaluates to true. " } ,
{ LLDB_OPT_SET_1 , false , " auto-continue " , ' G ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " The breakpoint will auto-continue after running its commands. " } ,
{ LLDB_OPT_SET_2 , false , " enable " , ' e ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Enable the breakpoint. " } ,
{ LLDB_OPT_SET_3 , false , " disable " , ' d ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Disable the breakpoint. " } ,
{ LLDB_OPT_SET_4 , false , " command " , ' C ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeCommand , " A command to run when the breakpoint is hit, can be provided more than once, the commands will get run in order left to right. " } ,
2017-09-15 04:22:49 +08:00
// clang-format on
} ;
class lldb_private : : BreakpointOptionGroup : public OptionGroup
{
public :
BreakpointOptionGroup ( ) :
OptionGroup ( ) ,
m_bp_opts ( false ) { }
~ BreakpointOptionGroup ( ) override = default ;
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
return llvm : : makeArrayRef ( g_breakpoint_modify_options ) ;
}
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
const int short_option = g_breakpoint_modify_options [ option_idx ] . short_option ;
switch ( short_option ) {
case ' c ' :
2018-05-01 00:49:04 +08:00
// Normally an empty breakpoint condition marks is as unset. But we need
// to say it was passed in.
2017-09-15 04:22:49 +08:00
m_bp_opts . SetCondition ( option_arg . str ( ) . c_str ( ) ) ;
m_bp_opts . m_set_flags . Set ( BreakpointOptions : : eCondition ) ;
break ;
case ' C ' :
m_commands . push_back ( option_arg ) ;
break ;
case ' d ' :
m_bp_opts . SetEnabled ( false ) ;
break ;
case ' e ' :
m_bp_opts . SetEnabled ( true ) ;
break ;
case ' G ' : {
bool value , success ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , false , & success ) ;
2017-09-15 04:22:49 +08:00
if ( success ) {
m_bp_opts . SetAutoContinue ( value ) ;
} else
error . SetErrorStringWithFormat (
" invalid boolean value '%s' passed for -G option " ,
option_arg . str ( ) . c_str ( ) ) ;
}
break ;
case ' i ' :
{
uint32_t ignore_count ;
if ( option_arg . getAsInteger ( 0 , ignore_count ) )
error . SetErrorStringWithFormat ( " invalid ignore count '%s' " ,
option_arg . str ( ) . c_str ( ) ) ;
else
m_bp_opts . SetIgnoreCount ( ignore_count ) ;
}
break ;
case ' o ' : {
bool value , success ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , false , & success ) ;
2017-09-15 04:22:49 +08:00
if ( success ) {
m_bp_opts . SetOneShot ( value ) ;
} else
error . SetErrorStringWithFormat (
" invalid boolean value '%s' passed for -o option " ,
option_arg . str ( ) . c_str ( ) ) ;
} break ;
case ' t ' :
{
lldb : : tid_t thread_id = LLDB_INVALID_THREAD_ID ;
if ( option_arg [ 0 ] ! = ' \0 ' ) {
if ( option_arg . getAsInteger ( 0 , thread_id ) )
error . SetErrorStringWithFormat ( " invalid thread id string '%s' " ,
option_arg . str ( ) . c_str ( ) ) ;
}
m_bp_opts . SetThreadID ( thread_id ) ;
}
break ;
case ' T ' :
m_bp_opts . GetThreadSpec ( ) - > SetName ( option_arg . str ( ) . c_str ( ) ) ;
break ;
case ' q ' :
m_bp_opts . GetThreadSpec ( ) - > SetQueueName ( option_arg . str ( ) . c_str ( ) ) ;
break ;
case ' x ' :
{
uint32_t thread_index = UINT32_MAX ;
if ( option_arg [ 0 ] ! = ' \n ' ) {
if ( option_arg . getAsInteger ( 0 , thread_index ) )
error . SetErrorStringWithFormat ( " invalid thread index string '%s' " ,
option_arg . str ( ) . c_str ( ) ) ;
}
m_bp_opts . GetThreadSpec ( ) - > SetIndex ( thread_index ) ;
}
break ;
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_bp_opts . Clear ( ) ;
m_commands . clear ( ) ;
}
Status OptionParsingFinished ( ExecutionContext * execution_context ) override {
if ( ! m_commands . empty ( ) )
{
if ( ! m_commands . empty ( ) )
{
auto cmd_data = llvm : : make_unique < BreakpointOptions : : CommandData > ( ) ;
for ( std : : string & str : m_commands )
cmd_data - > user_source . AppendString ( str ) ;
cmd_data - > stop_on_error = true ;
m_bp_opts . SetCommandDataCallback ( cmd_data ) ;
}
}
return Status ( ) ;
}
const BreakpointOptions & GetBreakpointOptions ( )
{
return m_bp_opts ;
}
std : : vector < std : : string > m_commands ;
BreakpointOptions m_bp_opts ;
} ;
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_dummy_options [ ] = {
2017-09-15 04:22:49 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " dummy-breakpoints " , ' D ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Act on Dummy breakpoints - i.e. breakpoints set before a file is provided, "
2017-09-15 04:22:49 +08:00
" which prime new targets. " } ,
// clang-format on
} ;
class BreakpointDummyOptionGroup : public OptionGroup
{
public :
BreakpointDummyOptionGroup ( ) :
OptionGroup ( ) { }
~ BreakpointDummyOptionGroup ( ) override = default ;
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
return llvm : : makeArrayRef ( g_breakpoint_dummy_options ) ;
}
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
const int short_option = g_breakpoint_modify_options [ option_idx ] . short_option ;
switch ( short_option ) {
case ' D ' :
m_use_dummy = true ;
break ;
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_use_dummy = false ;
}
bool m_use_dummy ;
} ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
2018-09-14 05:35:32 +08:00
# define LLDB_OPT_NOT_10 (LLDB_OPT_SET_FROM_TO(1, 11) & ~LLDB_OPT_SET_10)
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
# define LLDB_OPT_SKIP_PROLOGUE (LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3, 8))
2018-09-14 05:35:32 +08:00
# define LLDB_OPT_FILE (LLDB_OPT_SET_FROM_TO(1, 11) & ~LLDB_OPT_SET_2 & ~LLDB_OPT_SET_10)
# define LLDB_OPT_OFFSET_APPLIES (LLDB_OPT_SET_FROM_TO(1, 8) & ~LLDB_OPT_SET_2)
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
# define LLDB_OPT_MOVE_TO_NEAREST_CODE (LLDB_OPT_SET_1 | LLDB_OPT_SET_9)
# define LLDB_OPT_EXPR_LANGUAGE (LLDB_OPT_SET_FROM_TO(3, 8))
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_set_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_NOT_10 , false , " shlib " , ' s ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eModuleCompletion , eArgTypeShlibName , " Set the breakpoint only in this shared library. Can repeat this option "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" multiple times to specify multiple shared libraries. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_ALL , false , " hardware " , ' H ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Require the breakpoint to use hardware breakpoints. " } ,
{ LLDB_OPT_FILE , false , " file " , ' f ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename , " Specifies the source file in which to set this breakpoint. Note, by default "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" lldb only looks for files that are #included if they use the standard include "
" file extensions. To set breakpoints on .c/.cpp/.m/.mm files that are "
" #included, set target.inline-breakpoint-strategy to \" always \" . " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , true , " line " , ' l ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeLineNum , " Specifies the line number on which to set this breakpoint. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
2018-05-01 00:49:04 +08:00
// Comment out this option for the moment, as we don't actually use it, but
// will in the future. This way users won't see it, but the infrastructure is
// left in place.
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// { 0, false, "column", 'C', OptionParser::eRequiredArgument, nullptr, "<column>",
// "Set the breakpoint by source location at this particular column."},
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_2 , true , " address " , ' a ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeAddressOrExpression , " Set the breakpoint at the specified address. If the address maps uniquely to "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" a particular binary, then the address will be converted to a \" file \" "
" address, so that the breakpoint will track that binary+offset no matter where "
" the binary eventually loads. Alternately, if you also specify the module - "
" with the -s option - then the address will be treated as a file address in "
" that module, and resolved accordingly. Again, this will allow lldb to track "
" that offset on subsequent reloads. The module need not have been loaded at "
" the time you specify this breakpoint, and will get resolved when the module "
" is loaded. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_3 , true , " name " , ' n ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSymbolCompletion , eArgTypeFunctionName , " Set the breakpoint by function name. Can be repeated multiple times to make "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" one breakpoint for multiple names " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_9 , false , " source-regexp-function " , ' X ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSymbolCompletion , eArgTypeFunctionName , " When used with '-p' limits the source regex to source contained in the named "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" functions. Can be repeated multiple times. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_4 , true , " fullname " , ' F ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSymbolCompletion , eArgTypeFullName , " Set the breakpoint by fully qualified function names. For C++ this means "
2018-06-14 00:21:24 +08:00
" namespaces and all arguments, and for Objective-C this means a full function "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" prototype with class and selector. Can be repeated multiple times to make "
" one breakpoint for multiple names. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_5 , true , " selector " , ' S ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeSelector , " Set the breakpoint by ObjC selector name. Can be repeated multiple times to "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" make one breakpoint for multiple Selectors. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_6 , true , " method " , ' M ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeMethod , " Set the breakpoint by C++ method names. Can be repeated multiple times to "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" make one breakpoint for multiple methods. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_7 , true , " func-regex " , ' r ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeRegularExpression , " Set the breakpoint by function name, evaluating a regular-expression to find "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" the function name(s). " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_8 , true , " basename " , ' b ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSymbolCompletion , eArgTypeFunctionName , " Set the breakpoint by function basename (C++ namespaces and arguments will be "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" ignored). Can be repeated multiple times to make one breakpoint for multiple "
" symbols. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_9 , true , " source-pattern-regexp " , ' p ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeRegularExpression , " Set the breakpoint by specifying a regular expression which is matched "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" against the source text in a source file or files specified with the -f "
" option. The -f option can be specified more than once. If no source files "
" are specified, uses the current \" default source file \" . If you want to "
" match against all source files, pass the \" --all-files \" option. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_9 , false , " all-files " , ' A ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " All files are searched for source pattern matches. " } ,
{ LLDB_OPT_SET_11 , true , " python-class " , ' P ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypePythonClass , " The name of the class that implement a scripted breakpoint. " } ,
{ LLDB_OPT_SET_11 , false , " python-class-key " , ' k ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeNone , " The key for a key/value pair passed to the class that implements a scripted breakpoint. Can be specified more than once. " } ,
{ LLDB_OPT_SET_11 , false , " python-class-value " , ' v ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeNone , " The value for the previous key in the pair passed to the class that implements a scripted breakpoint. Can be specified more than once. " } ,
{ LLDB_OPT_SET_10 , true , " language-exception " , ' E ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeLanguage , " Set the breakpoint on exceptions thrown by the specified language (without "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" options, on throw but not catch.) " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_10 , false , " on-throw " , ' w ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Set the breakpoint on exception throW. " } ,
{ LLDB_OPT_SET_10 , false , " on-catch " , ' h ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Set the breakpoint on exception catcH. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// Don't add this option till it actually does something useful...
// { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeTypeName,
// "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" },
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_EXPR_LANGUAGE , false , " language " , ' L ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeLanguage , " Specifies the Language to use when interpreting the breakpoint's expression "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" (note: currently only implemented for setting breakpoints on identifiers). "
" If not set the target.language setting is used. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SKIP_PROLOGUE , false , " skip-prologue " , ' K ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " sKip the prologue if the breakpoint is at the beginning of a function. "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" If not set the target.skip-prologue setting is used. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_ALL , false , " breakpoint-name " , ' N ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBreakpointName , " Adds this to the list of names for this breakpoint. " } ,
{ LLDB_OPT_OFFSET_APPLIES , false , " address-slide " , ' R ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeAddress , " Add the specified offset to whatever address(es) the breakpoint resolves to. "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" At present this applies the offset directly as given, and doesn't try to align it to instruction boundaries. " } ,
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_MOVE_TO_NEAREST_CODE , false , " move-to-nearest-code " , ' m ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Move breakpoints to nearest code. If not set the target.move-to-nearest-code "
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
" setting is used. " } ,
// clang-format on
} ;
2012-06-09 05:56:10 +08:00
// CommandObjectBreakpointSet
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointSet : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2019-05-14 16:55:50 +08:00
enum BreakpointSetType {
2016-09-07 04:57:50 +08:00
eSetTypeInvalid ,
eSetTypeFileAndLine ,
eSetTypeAddress ,
eSetTypeFunctionName ,
eSetTypeFunctionRegexp ,
eSetTypeSourceRegexp ,
2018-09-14 05:35:32 +08:00
eSetTypeException ,
eSetTypeScripted ,
2019-05-14 16:55:50 +08:00
} ;
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointSet ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " breakpoint set " ,
" Sets a breakpoint or set of breakpoints in the executable. " ,
" breakpoint set <cmd-options> " ) ,
2017-09-15 04:22:49 +08:00
m_bp_opts ( ) , m_options ( ) {
// We're picking up all the normal options, commands and disable.
m_all_options . Append ( & m_bp_opts ,
LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4 ,
LLDB_OPT_SET_ALL ) ;
m_all_options . Append ( & m_dummy_options , LLDB_OPT_SET_1 , LLDB_OPT_SET_ALL ) ;
m_all_options . Append ( & m_options ) ;
m_all_options . Finalize ( ) ;
}
2016-09-07 04:57:50 +08:00
~ CommandObjectBreakpointSet ( ) override = default ;
2017-09-15 04:22:49 +08:00
Options * GetOptions ( ) override { return & m_all_options ; }
2016-09-07 04:57:50 +08:00
2017-09-15 04:22:49 +08:00
class CommandOptions : public OptionGroup {
2016-09-07 04:57:50 +08:00
public :
CommandOptions ( )
2017-09-15 04:22:49 +08:00
: OptionGroup ( ) , m_condition ( ) , m_filenames ( ) , m_line_num ( 0 ) , m_column ( 0 ) ,
2016-09-07 04:57:50 +08:00
m_func_names ( ) , m_func_name_type_mask ( eFunctionNameTypeNone ) ,
m_func_regexp ( ) , m_source_text_regexp ( ) , m_modules ( ) , m_load_addr ( ) ,
m_catch_bp ( false ) , m_throw_bp ( true ) , m_hardware ( false ) ,
m_exception_language ( eLanguageTypeUnknown ) ,
m_language ( lldb : : eLanguageTypeUnknown ) ,
2017-09-15 04:22:49 +08:00
m_skip_prologue ( eLazyBoolCalculate ) ,
2016-09-07 04:57:50 +08:00
m_all_files ( false ) , m_move_to_nearest_code ( eLazyBoolCalculate ) { }
~ CommandOptions ( ) override = default ;
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2017-09-15 04:22:49 +08:00
const int short_option = g_breakpoint_set_options [ option_idx ] . short_option ;
2016-09-07 04:57:50 +08:00
switch ( short_option ) {
case ' a ' : {
2018-04-10 17:03:59 +08:00
m_load_addr = OptionArgParser : : ToAddress ( execution_context , option_arg ,
LLDB_INVALID_ADDRESS , & error ) ;
2016-09-07 04:57:50 +08:00
} break ;
case ' A ' :
m_all_files = true ;
break ;
case ' b ' :
m_func_names . push_back ( option_arg ) ;
m_func_name_type_mask | = eFunctionNameTypeBase ;
break ;
2016-11-13 00:56:47 +08:00
case ' C ' :
if ( option_arg . getAsInteger ( 0 , m_column ) )
2016-09-07 04:57:50 +08:00
error . SetErrorStringWithFormat ( " invalid column number: %s " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' E ' : {
2016-11-13 00:56:47 +08:00
LanguageType language = Language : : GetLanguageTypeFromString ( option_arg ) ;
2016-09-07 04:57:50 +08:00
switch ( language ) {
case eLanguageTypeC89 :
case eLanguageTypeC :
case eLanguageTypeC99 :
case eLanguageTypeC11 :
m_exception_language = eLanguageTypeC ;
break ;
case eLanguageTypeC_plus_plus :
case eLanguageTypeC_plus_plus_03 :
case eLanguageTypeC_plus_plus_11 :
case eLanguageTypeC_plus_plus_14 :
m_exception_language = eLanguageTypeC_plus_plus ;
break ;
case eLanguageTypeObjC :
m_exception_language = eLanguageTypeObjC ;
break ;
case eLanguageTypeObjC_plus_plus :
error . SetErrorStringWithFormat (
" Set exception breakpoints separately for c++ and objective-c " ) ;
break ;
case eLanguageTypeUnknown :
error . SetErrorStringWithFormat (
" Unknown language type: '%s' for exception breakpoint " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
default :
error . SetErrorStringWithFormat (
" Unsupported language type: '%s' for exception breakpoint " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
}
} break ;
case ' f ' :
2018-11-02 05:05:36 +08:00
m_filenames . AppendIfUnique ( FileSpec ( option_arg ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' F ' :
m_func_names . push_back ( option_arg ) ;
m_func_name_type_mask | = eFunctionNameTypeFull ;
break ;
2017-08-04 02:13:24 +08:00
2016-09-07 04:57:50 +08:00
case ' h ' : {
bool success ;
2018-04-10 17:03:59 +08:00
m_catch_bp = OptionArgParser : : ToBoolean ( option_arg , true , & success ) ;
2016-09-07 04:57:50 +08:00
if ( ! success )
error . SetErrorStringWithFormat (
2016-11-13 00:56:47 +08:00
" Invalid boolean value for on-catch option: '%s' " ,
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
} break ;
case ' H ' :
m_hardware = true ;
break ;
2018-09-14 05:35:32 +08:00
case ' k ' : {
if ( m_current_key . empty ( ) )
m_current_key . assign ( option_arg ) ;
else
error . SetErrorStringWithFormat ( " Key: %s missing value. " ,
m_current_key . c_str ( ) ) ;
} break ;
2016-09-07 04:57:50 +08:00
case ' K ' : {
bool success ;
bool value ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , true , & success ) ;
2016-09-07 04:57:50 +08:00
if ( value )
m_skip_prologue = eLazyBoolYes ;
else
m_skip_prologue = eLazyBoolNo ;
if ( ! success )
error . SetErrorStringWithFormat (
" Invalid boolean value for skip prologue option: '%s' " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
} break ;
2016-11-13 00:56:47 +08:00
case ' l ' :
if ( option_arg . getAsInteger ( 0 , m_line_num ) )
2016-09-07 04:57:50 +08:00
error . SetErrorStringWithFormat ( " invalid line number: %s. " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' L ' :
2016-11-13 00:56:47 +08:00
m_language = Language : : GetLanguageTypeFromString ( option_arg ) ;
2016-09-07 04:57:50 +08:00
if ( m_language = = eLanguageTypeUnknown )
error . SetErrorStringWithFormat (
2016-11-13 00:56:47 +08:00
" Unknown language type: '%s' for breakpoint " ,
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' m ' : {
bool success ;
bool value ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , true , & success ) ;
2016-09-07 04:57:50 +08:00
if ( value )
m_move_to_nearest_code = eLazyBoolYes ;
else
m_move_to_nearest_code = eLazyBoolNo ;
if ( ! success )
error . SetErrorStringWithFormat (
" Invalid boolean value for move-to-nearest-code option: '%s' " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
}
case ' M ' :
m_func_names . push_back ( option_arg ) ;
m_func_name_type_mask | = eFunctionNameTypeMethod ;
break ;
case ' n ' :
m_func_names . push_back ( option_arg ) ;
m_func_name_type_mask | = eFunctionNameTypeAuto ;
break ;
2016-09-17 10:00:02 +08:00
case ' N ' : {
2016-11-13 00:56:47 +08:00
if ( BreakpointID : : StringIsBreakpointName ( option_arg , error ) )
2016-09-07 04:57:50 +08:00
m_breakpoint_names . push_back ( option_arg ) ;
2016-09-21 09:21:19 +08:00
else
error . SetErrorStringWithFormat ( " Invalid breakpoint name: %s " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
2016-09-17 10:00:02 +08:00
}
2016-09-07 04:57:50 +08:00
case ' R ' : {
lldb : : addr_t tmp_offset_addr ;
2018-04-10 17:03:59 +08:00
tmp_offset_addr = OptionArgParser : : ToAddress ( execution_context ,
option_arg , 0 , & error ) ;
2016-09-07 04:57:50 +08:00
if ( error . Success ( ) )
m_offset_addr = tmp_offset_addr ;
} break ;
case ' O ' :
2016-11-13 00:56:47 +08:00
m_exception_extra_args . AppendArgument ( " -O " ) ;
m_exception_extra_args . AppendArgument ( option_arg ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' p ' :
m_source_text_regexp . assign ( option_arg ) ;
break ;
2018-09-14 05:35:32 +08:00
case ' P ' :
m_python_class . assign ( option_arg ) ;
break ;
2016-09-07 04:57:50 +08:00
case ' r ' :
m_func_regexp . assign ( option_arg ) ;
break ;
case ' s ' :
2018-11-02 05:05:36 +08:00
m_modules . AppendIfUnique ( FileSpec ( option_arg ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' S ' :
m_func_names . push_back ( option_arg ) ;
m_func_name_type_mask | = eFunctionNameTypeSelector ;
break ;
2018-09-14 05:35:32 +08:00
case ' v ' : {
if ( ! m_current_key . empty ( ) ) {
m_extra_args_sp - > AddStringItem ( m_current_key , option_arg ) ;
m_current_key . clear ( ) ;
}
else
error . SetErrorStringWithFormat ( " Value \" %s \" missing matching key. " ,
option_arg . str ( ) . c_str ( ) ) ;
} break ;
2016-09-07 04:57:50 +08:00
case ' w ' : {
bool success ;
2018-04-10 17:03:59 +08:00
m_throw_bp = OptionArgParser : : ToBoolean ( option_arg , true , & success ) ;
2016-09-07 04:57:50 +08:00
if ( ! success )
error . SetErrorStringWithFormat (
2016-11-13 00:56:47 +08:00
" Invalid boolean value for on-throw option: '%s' " ,
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
} break ;
case ' X ' :
m_source_regex_func_names . insert ( option_arg ) ;
break ;
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
2012-06-09 05:56:10 +08:00
}
2016-09-07 04:57:50 +08:00
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_filenames . Clear ( ) ;
m_line_num = 0 ;
m_column = 0 ;
m_func_names . clear ( ) ;
m_func_name_type_mask = eFunctionNameTypeNone ;
m_func_regexp . clear ( ) ;
m_source_text_regexp . clear ( ) ;
m_modules . Clear ( ) ;
m_load_addr = LLDB_INVALID_ADDRESS ;
m_offset_addr = 0 ;
m_catch_bp = false ;
m_throw_bp = true ;
m_hardware = false ;
m_exception_language = eLanguageTypeUnknown ;
m_language = lldb : : eLanguageTypeUnknown ;
m_skip_prologue = eLazyBoolCalculate ;
m_breakpoint_names . clear ( ) ;
m_all_files = false ;
m_exception_extra_args . Clear ( ) ;
m_move_to_nearest_code = eLazyBoolCalculate ;
m_source_regex_func_names . clear ( ) ;
2018-09-14 05:35:32 +08:00
m_python_class . clear ( ) ;
2019-02-12 07:13:08 +08:00
m_extra_args_sp = std : : make_shared < StructuredData : : Dictionary > ( ) ;
2018-09-14 05:35:32 +08:00
m_current_key . clear ( ) ;
2016-09-07 04:57:50 +08:00
}
2012-06-09 05:56:10 +08:00
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_set_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2016-09-07 04:57:50 +08:00
// Instance variables to hold the values for command options.
std : : string m_condition ;
FileSpecList m_filenames ;
uint32_t m_line_num ;
uint32_t m_column ;
std : : vector < std : : string > m_func_names ;
std : : vector < std : : string > m_breakpoint_names ;
2018-10-26 04:45:40 +08:00
lldb : : FunctionNameType m_func_name_type_mask ;
2016-09-07 04:57:50 +08:00
std : : string m_func_regexp ;
std : : string m_source_text_regexp ;
FileSpecList m_modules ;
lldb : : addr_t m_load_addr ;
lldb : : addr_t m_offset_addr ;
bool m_catch_bp ;
bool m_throw_bp ;
bool m_hardware ; // Request to use hardware breakpoints
lldb : : LanguageType m_exception_language ;
lldb : : LanguageType m_language ;
LazyBool m_skip_prologue ;
bool m_all_files ;
Args m_exception_extra_args ;
LazyBool m_move_to_nearest_code ;
std : : unordered_set < std : : string > m_source_regex_func_names ;
2018-09-14 05:35:32 +08:00
std : : string m_python_class ;
StructuredData : : DictionarySP m_extra_args_sp ;
std : : string m_current_key ;
2016-09-07 04:57:50 +08:00
} ;
protected :
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
2017-09-15 04:22:49 +08:00
Target * target = GetSelectedOrDummyTarget ( m_dummy_options . m_use_dummy ) ;
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. Must set target before setting "
" breakpoints (see 'target create' command). " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
2012-06-09 05:56:10 +08:00
}
2016-09-07 04:57:50 +08:00
// The following are the various types of breakpoints that could be set:
// 1). -f -l -p [-s -g] (setting breakpoint by source location)
// 2). -a [-s -g] (setting breakpoint by address)
// 3). -n [-s -g] (setting breakpoint by function name)
// 4). -r [-s -g] (setting breakpoint by function name regular
// expression)
// 5). -p -f (setting a breakpoint by comparing a reg-exp
// to source text)
// 6). -E [-w -h] (setting a breakpoint for exceptions for a
// given language.)
BreakpointSetType break_type = eSetTypeInvalid ;
2018-09-14 05:35:32 +08:00
if ( ! m_options . m_python_class . empty ( ) )
break_type = eSetTypeScripted ;
else if ( m_options . m_line_num ! = 0 )
2016-09-07 04:57:50 +08:00
break_type = eSetTypeFileAndLine ;
else if ( m_options . m_load_addr ! = LLDB_INVALID_ADDRESS )
break_type = eSetTypeAddress ;
else if ( ! m_options . m_func_names . empty ( ) )
break_type = eSetTypeFunctionName ;
else if ( ! m_options . m_func_regexp . empty ( ) )
break_type = eSetTypeFunctionRegexp ;
else if ( ! m_options . m_source_text_regexp . empty ( ) )
break_type = eSetTypeSourceRegexp ;
else if ( m_options . m_exception_language ! = eLanguageTypeUnknown )
break_type = eSetTypeException ;
2017-09-15 04:22:49 +08:00
BreakpointSP bp_sp = nullptr ;
2016-09-07 04:57:50 +08:00
FileSpec module_spec ;
const bool internal = false ;
// If the user didn't specify skip-prologue, having an offset should turn
// that off.
if ( m_options . m_offset_addr ! = 0 & &
m_options . m_skip_prologue = = eLazyBoolCalculate )
m_options . m_skip_prologue = eLazyBoolNo ;
switch ( break_type ) {
case eSetTypeFileAndLine : // Breakpoint by source position
2012-06-09 05:56:10 +08:00
{
2016-09-07 04:57:50 +08:00
FileSpec file ;
const size_t num_files = m_options . m_filenames . GetSize ( ) ;
if ( num_files = = 0 ) {
if ( ! GetDefaultFile ( target , file , result ) ) {
result . AppendError ( " No file supplied and no default file available. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
} else if ( num_files > 1 ) {
result . AppendError ( " Only one file at a time is allowed for file and "
" line breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
} else
file = m_options . m_filenames . GetFileSpecAtIndex ( 0 ) ;
// Only check for inline functions if
LazyBool check_inlines = eLazyBoolCalculate ;
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateBreakpoint ( & ( m_options . m_modules ) ,
file ,
2018-08-30 23:11:00 +08:00
m_options . m_line_num ,
m_options . m_column ,
2017-09-15 04:22:49 +08:00
m_options . m_offset_addr ,
check_inlines ,
m_options . m_skip_prologue ,
internal ,
m_options . m_hardware ,
m_options . m_move_to_nearest_code ) ;
2016-09-07 04:57:50 +08:00
} break ;
case eSetTypeAddress : // Breakpoint by address
{
// If a shared library has been specified, make an lldb_private::Address
2017-09-15 04:22:49 +08:00
// with the library, and use that. That way the address breakpoint
// will track the load location of the library.
2016-09-07 04:57:50 +08:00
size_t num_modules_specified = m_options . m_modules . GetSize ( ) ;
if ( num_modules_specified = = 1 ) {
const FileSpec * file_spec =
m_options . m_modules . GetFileSpecPointerAtIndex ( 0 ) ;
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateAddressInModuleBreakpoint ( m_options . m_load_addr ,
internal , file_spec ,
m_options . m_hardware ) ;
2016-09-07 04:57:50 +08:00
} else if ( num_modules_specified = = 0 ) {
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateBreakpoint ( m_options . m_load_addr , internal ,
m_options . m_hardware ) ;
2016-09-07 04:57:50 +08:00
} else {
result . AppendError ( " Only one shared library can be specified for "
" address breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
break ;
}
case eSetTypeFunctionName : // Breakpoint by function name
{
2018-10-26 04:45:40 +08:00
FunctionNameType name_type_mask = m_options . m_func_name_type_mask ;
2016-09-07 04:57:50 +08:00
if ( name_type_mask = = 0 )
name_type_mask = eFunctionNameTypeAuto ;
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateBreakpoint ( & ( m_options . m_modules ) ,
& ( m_options . m_filenames ) ,
m_options . m_func_names ,
name_type_mask ,
m_options . m_language ,
m_options . m_offset_addr ,
m_options . m_skip_prologue ,
internal ,
m_options . m_hardware ) ;
2016-09-07 04:57:50 +08:00
} break ;
case eSetTypeFunctionRegexp : // Breakpoint by regular expression function
// name
2016-09-13 07:10:56 +08:00
{
2016-09-22 00:01:28 +08:00
RegularExpression regexp ( m_options . m_func_regexp ) ;
2016-09-13 07:10:56 +08:00
if ( ! regexp . IsValid ( ) ) {
char err_str [ 1024 ] ;
regexp . GetErrorAsCString ( err_str , sizeof ( err_str ) ) ;
result . AppendErrorWithFormat (
" Function name regular expression could not be compiled: \" %s \" " ,
err_str ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2016-09-07 04:57:50 +08:00
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateFuncRegexBreakpoint ( & ( m_options . m_modules ) ,
& ( m_options . m_filenames ) ,
regexp ,
m_options . m_language ,
m_options . m_skip_prologue ,
internal ,
m_options . m_hardware ) ;
2016-09-13 07:10:56 +08:00
}
break ;
2016-09-07 04:57:50 +08:00
case eSetTypeSourceRegexp : // Breakpoint by regexp on source text.
{
const size_t num_files = m_options . m_filenames . GetSize ( ) ;
if ( num_files = = 0 & & ! m_options . m_all_files ) {
FileSpec file ;
if ( ! GetDefaultFile ( target , file , result ) ) {
result . AppendError (
" No files provided and could not find default file. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
} else {
m_options . m_filenames . Append ( file ) ;
}
}
2016-09-22 00:01:28 +08:00
RegularExpression regexp ( m_options . m_source_text_regexp ) ;
2016-09-07 04:57:50 +08:00
if ( ! regexp . IsValid ( ) ) {
char err_str [ 1024 ] ;
regexp . GetErrorAsCString ( err_str , sizeof ( err_str ) ) ;
result . AppendErrorWithFormat (
" Source text regular expression could not be compiled: \" %s \" " ,
err_str ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2017-09-15 04:22:49 +08:00
bp_sp =
target - > CreateSourceRegexBreakpoint ( & ( m_options . m_modules ) ,
& ( m_options . m_filenames ) ,
m_options
. m_source_regex_func_names ,
regexp ,
internal ,
m_options . m_hardware ,
m_options . m_move_to_nearest_code ) ;
2016-09-07 04:57:50 +08:00
} break ;
case eSetTypeException : {
2017-05-12 12:51:55 +08:00
Status precond_error ;
2017-09-15 04:22:49 +08:00
bp_sp = target - > CreateExceptionBreakpoint ( m_options . m_exception_language ,
m_options . m_catch_bp ,
m_options . m_throw_bp ,
internal ,
& m_options
. m_exception_extra_args ,
& precond_error ) ;
2016-09-07 04:57:50 +08:00
if ( precond_error . Fail ( ) ) {
result . AppendErrorWithFormat (
" Error setting extra exception arguments: %s " ,
precond_error . AsCString ( ) ) ;
2017-09-15 04:22:49 +08:00
target - > RemoveBreakpointByID ( bp_sp - > GetID ( ) ) ;
2016-09-07 04:57:50 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
} break ;
2018-09-14 05:35:32 +08:00
case eSetTypeScripted : {
Status error ;
bp_sp = target - > CreateScriptedBreakpoint ( m_options . m_python_class ,
& ( m_options . m_modules ) ,
& ( m_options . m_filenames ) ,
false ,
m_options . m_hardware ,
m_options . m_extra_args_sp ,
& error ) ;
if ( error . Fail ( ) ) {
result . AppendErrorWithFormat (
" Error setting extra exception arguments: %s " ,
error . AsCString ( ) ) ;
target - > RemoveBreakpointByID ( bp_sp - > GetID ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
} break ;
2016-09-07 04:57:50 +08:00
default :
break ;
}
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
// Now set the various options that were passed in:
2017-09-15 04:22:49 +08:00
if ( bp_sp ) {
bp_sp - > GetOptions ( ) - > CopyOverSetOptions ( m_bp_opts . GetBreakpointOptions ( ) ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
if ( ! m_options . m_breakpoint_names . empty ( ) ) {
2017-05-12 12:51:55 +08:00
Status name_error ;
2016-09-21 09:21:19 +08:00
for ( auto name : m_options . m_breakpoint_names ) {
2017-09-15 04:22:49 +08:00
target - > AddNameToBreakpoint ( bp_sp , name . c_str ( ) , name_error ) ;
2016-09-21 09:21:19 +08:00
if ( name_error . Fail ( ) ) {
result . AppendErrorWithFormat ( " Invalid breakpoint name: %s " ,
name . c_str ( ) ) ;
2017-09-15 04:22:49 +08:00
target - > RemoveBreakpointByID ( bp_sp - > GetID ( ) ) ;
2016-09-21 09:21:19 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
2016-09-07 04:57:50 +08:00
}
}
2017-09-15 04:22:49 +08:00
if ( bp_sp ) {
2016-09-07 04:57:50 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
const bool show_locations = false ;
2017-09-15 04:22:49 +08:00
bp_sp - > GetDescription ( & output_stream , lldb : : eDescriptionLevelInitial ,
2016-09-07 04:57:50 +08:00
show_locations ) ;
2019-04-27 14:19:42 +08:00
if ( target = = GetDebugger ( ) . GetDummyTarget ( ) )
2016-09-07 04:57:50 +08:00
output_stream . Printf ( " Breakpoint set in dummy target, will get copied "
" into future targets. \n " ) ;
else {
2018-05-01 00:49:04 +08:00
// Don't print out this warning for exception breakpoints. They can
// get set before the target is set, but we won't know how to actually
// set the breakpoint till we run.
2017-09-15 04:22:49 +08:00
if ( bp_sp - > GetNumLocations ( ) = = 0 & & break_type ! = eSetTypeException ) {
2016-09-07 04:57:50 +08:00
output_stream . Printf ( " WARNING: Unable to resolve breakpoint to any "
" actual locations. \n " ) ;
}
}
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
2017-09-15 04:22:49 +08:00
} else if ( ! bp_sp ) {
2016-09-07 04:57:50 +08:00
result . AppendError ( " Breakpoint creation failed: No breakpoint created. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2012-06-09 05:56:10 +08:00
}
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
private :
2016-09-07 04:57:50 +08:00
bool GetDefaultFile ( Target * target , FileSpec & file ,
CommandReturnObject & result ) {
uint32_t default_line ;
2018-05-01 00:49:04 +08:00
// First use the Source Manager's default file. Then use the current stack
// frame's file.
2016-09-07 04:57:50 +08:00
if ( ! target - > GetSourceManager ( ) . GetDefaultFileAndLine ( file , default_line ) ) {
StackFrame * cur_frame = m_exe_ctx . GetFramePtr ( ) ;
if ( cur_frame = = nullptr ) {
result . AppendError (
" No selected frame to use to find the default file. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
} else if ( ! cur_frame - > HasDebugInformation ( ) ) {
result . AppendError ( " Cannot use the selected frame to find the default "
" file, it has no debug info. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
} else {
const SymbolContext & sc =
cur_frame - > GetSymbolContext ( eSymbolContextLineEntry ) ;
if ( sc . line_entry . file ) {
file = sc . line_entry . file ;
} else {
result . AppendError ( " Can't find the file for the selected frame to "
" use as the default file. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
2012-06-09 05:56:10 +08:00
}
2016-09-07 04:57:50 +08:00
return true ;
}
2017-09-15 04:22:49 +08:00
BreakpointOptionGroup m_bp_opts ;
BreakpointDummyOptionGroup m_dummy_options ;
2016-09-07 04:57:50 +08:00
CommandOptions m_options ;
2017-09-15 04:22:49 +08:00
OptionGroupOptions m_all_options ;
2012-06-09 05:56:10 +08:00
} ;
2016-02-19 06:39:14 +08:00
2012-06-09 05:56:10 +08:00
// CommandObjectBreakpointModify
# pragma mark Modify
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointModify : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointModify ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " breakpoint modify " ,
" Modify the options on a breakpoint or set of "
" breakpoints in the executable. "
" If no breakpoint is specified, acts on the last "
" created breakpoint. "
" With the exception of -e, -d and -i, passing an "
" empty argument clears the modification. " ,
2016-02-19 06:39:14 +08:00
nullptr ) ,
2016-09-07 04:57:50 +08:00
m_options ( ) {
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
2017-09-15 04:22:49 +08:00
m_options . Append ( & m_bp_opts ,
LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3 ,
LLDB_OPT_SET_ALL ) ;
m_options . Append ( & m_dummy_opts , LLDB_OPT_SET_1 , LLDB_OPT_SET_ALL ) ;
m_options . Finalize ( ) ;
2016-09-07 04:57:50 +08:00
}
~ CommandObjectBreakpointModify ( ) override = default ;
Options * GetOptions ( ) override { return & m_options ; }
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
2017-09-15 04:22:49 +08:00
Target * target = GetSelectedOrDummyTarget ( m_dummy_opts . m_use_dummy ) ;
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointOrLocationIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : disablePerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i ) {
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
if ( cur_bp_id . GetBreakpointID ( ) ! = LLDB_INVALID_BREAK_ID ) {
Breakpoint * bp =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
if ( cur_bp_id . GetLocationID ( ) ! = LLDB_INVALID_BREAK_ID ) {
BreakpointLocation * location =
bp - > FindLocationByID ( cur_bp_id . GetLocationID ( ) ) . get ( ) ;
2017-09-15 04:22:49 +08:00
if ( location )
location - > GetLocationOptions ( )
- > CopyOverSetOptions ( m_bp_opts . GetBreakpointOptions ( ) ) ;
2016-09-07 04:57:50 +08:00
} else {
2017-09-15 04:22:49 +08:00
bp - > GetOptions ( )
- > CopyOverSetOptions ( m_bp_opts . GetBreakpointOptions ( ) ) ;
2016-09-07 04:57:50 +08:00
}
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
}
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
private :
2017-09-15 04:22:49 +08:00
BreakpointOptionGroup m_bp_opts ;
BreakpointDummyOptionGroup m_dummy_opts ;
OptionGroupOptions m_options ;
2010-06-09 00:52:24 +08:00
} ;
// CommandObjectBreakpointEnable
2010-06-18 08:58:52 +08:00
# pragma mark Enable
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointEnable : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointEnable ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " enable " ,
" Enable the specified disabled breakpoint(s). If "
" no breakpoints are specified, enable all of them. " ,
nullptr ) {
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
}
~ CommandObjectBreakpointEnable ( ) override = default ;
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
if ( num_breakpoints = = 0 ) {
result . AppendError ( " No breakpoints exist to be enabled. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-09 00:52:24 +08:00
2016-10-06 04:03:37 +08:00
if ( command . empty ( ) ) {
2016-09-07 04:57:50 +08:00
// No breakpoint selected; enable all currently set breakpoints.
2017-09-15 04:22:49 +08:00
target - > EnableAllowedBreakpoints ( ) ;
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat ( " All breakpoints enabled. (% " PRIu64
" breakpoints) \n " ,
( uint64_t ) num_breakpoints ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
// Particular breakpoint selected; enable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointOrLocationIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : disablePerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
int enable_count = 0 ;
int loc_count = 0 ;
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i ) {
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
if ( cur_bp_id . GetBreakpointID ( ) ! = LLDB_INVALID_BREAK_ID ) {
Breakpoint * breakpoint =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
if ( cur_bp_id . GetLocationID ( ) ! = LLDB_INVALID_BREAK_ID ) {
BreakpointLocation * location =
breakpoint - > FindLocationByID ( cur_bp_id . GetLocationID ( ) ) . get ( ) ;
if ( location ) {
location - > SetEnabled ( true ) ;
+ + loc_count ;
}
} else {
breakpoint - > SetEnabled ( true ) ;
+ + enable_count ;
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
}
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat ( " %d breakpoints enabled. \n " ,
enable_count + loc_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
2012-06-09 05:56:10 +08:00
}
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
} ;
2010-06-09 00:52:24 +08:00
// CommandObjectBreakpointDisable
2010-06-18 08:58:52 +08:00
# pragma mark Disable
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointDisable : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointDisable ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " breakpoint disable " ,
" Disable the specified breakpoint(s) without deleting "
" them. If none are specified, disable all "
" breakpoints. " ,
nullptr ) {
SetHelpLong (
" Disable the specified breakpoint(s) without deleting them. \
2016-07-15 06:03:10 +08:00
If none are specified , disable all breakpoints . "
2016-09-07 04:57:50 +08:00
R " (
2015-07-14 13:48:36 +08:00
2016-07-15 06:03:10 +08:00
) "
2016-09-07 04:57:50 +08:00
" Note: disabling a breakpoint will cause none of its locations to be hit \
2016-07-15 06:03:10 +08:00
regardless of whether individual locations are enabled or disabled . After the sequence : "
2016-09-07 04:57:50 +08:00
R " (
2015-07-14 13:48:36 +08:00
( lldb ) break disable 1
( lldb ) break enable 1.1
execution will NOT stop at location 1.1 . To achieve that , type :
( lldb ) break disable 1. *
( lldb ) break enable 1.1
2016-07-15 06:03:10 +08:00
) "
2016-09-07 04:57:50 +08:00
" The first command disables all locations for breakpoint 1, \
2016-07-15 06:03:10 +08:00
the second re - enables the first location . " );
2016-09-07 04:57:50 +08:00
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
}
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
~ CommandObjectBreakpointDisable ( ) override = default ;
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
size_t num_breakpoints = breakpoints . GetSize ( ) ;
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
if ( num_breakpoints = = 0 ) {
result . AppendError ( " No breakpoints exist to be disabled. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-09 00:52:24 +08:00
2016-10-06 04:03:37 +08:00
if ( command . empty ( ) ) {
2016-09-07 04:57:50 +08:00
// No breakpoint selected; disable all currently set breakpoints.
2017-09-15 04:22:49 +08:00
target - > DisableAllowedBreakpoints ( ) ;
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat ( " All breakpoints disabled. (% " PRIu64
" breakpoints) \n " ,
( uint64_t ) num_breakpoints ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointOrLocationIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : disablePerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
int disable_count = 0 ;
int loc_count = 0 ;
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i ) {
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
if ( cur_bp_id . GetBreakpointID ( ) ! = LLDB_INVALID_BREAK_ID ) {
Breakpoint * breakpoint =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
if ( cur_bp_id . GetLocationID ( ) ! = LLDB_INVALID_BREAK_ID ) {
BreakpointLocation * location =
breakpoint - > FindLocationByID ( cur_bp_id . GetLocationID ( ) ) . get ( ) ;
if ( location ) {
location - > SetEnabled ( false ) ;
+ + loc_count ;
}
} else {
breakpoint - > SetEnabled ( false ) ;
+ + disable_count ;
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
}
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat ( " %d breakpoints disabled. \n " ,
disable_count + loc_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
2010-06-09 00:52:24 +08:00
}
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
} ;
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
// CommandObjectBreakpointList
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
# pragma mark List::CommandOptions
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_list_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_ALL , false , " internal " , ' i ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Show debugger internal breakpoints " } ,
{ LLDB_OPT_SET_1 , false , " brief " , ' b ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Give a brief description of the breakpoint (no location info). " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// FIXME: We need to add an "internal" command, and then add this sort of thing to it.
// But I need to see it for now, and don't want to wait.
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_2 , false , " full " , ' f ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Give a full description of the breakpoint and its locations. " } ,
{ LLDB_OPT_SET_3 , false , " verbose " , ' v ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Explain everything we know about the breakpoint (for debugging debugger bugs). " } ,
{ LLDB_OPT_SET_ALL , false , " dummy-breakpoints " , ' D ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format on
} ;
2012-06-09 05:56:10 +08:00
# pragma mark List
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointList : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointList ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " breakpoint list " ,
" List some or all breakpoints at configurable levels of detail. " ,
nullptr ) ,
m_options ( ) {
CommandArgumentEntry arg ;
CommandArgumentData bp_id_arg ;
// Define the first (and only) variant of this arg.
bp_id_arg . arg_type = eArgTypeBreakpointID ;
bp_id_arg . arg_repetition = eArgRepeatOptional ;
// There is only one variant this argument could be; put it into the
// argument entry.
arg . push_back ( bp_id_arg ) ;
// Push the data for the first argument into the m_arguments vector.
m_arguments . push_back ( arg ) ;
}
~ CommandObjectBreakpointList ( ) override = default ;
Options * GetOptions ( ) override { return & m_options ; }
class CommandOptions : public Options {
public :
CommandOptions ( )
: Options ( ) , m_level ( lldb : : eDescriptionLevelBrief ) , m_use_dummy ( false ) {
2012-06-09 05:56:10 +08:00
}
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
~ CommandOptions ( ) override = default ;
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-07 04:57:50 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
switch ( short_option ) {
case ' b ' :
m_level = lldb : : eDescriptionLevelBrief ;
break ;
case ' D ' :
m_use_dummy = true ;
break ;
case ' f ' :
m_level = lldb : : eDescriptionLevelFull ;
break ;
case ' v ' :
m_level = lldb : : eDescriptionLevelVerbose ;
break ;
case ' i ' :
m_internal = true ;
break ;
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
2010-10-29 01:27:46 +08:00
}
2016-09-07 04:57:50 +08:00
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_level = lldb : : eDescriptionLevelFull ;
m_internal = false ;
m_use_dummy = false ;
}
2010-10-29 01:27:46 +08:00
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_list_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
// Instance variables to hold the values for command options.
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
lldb : : DescriptionLevel m_level ;
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
bool m_internal ;
bool m_use_dummy ;
} ;
2010-10-29 01:27:46 +08:00
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( m_options . m_use_dummy ) ;
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No current target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
return true ;
}
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints =
target - > GetBreakpointList ( m_options . m_internal ) ;
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( m_options . m_internal ) . GetListMutex ( lock ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
if ( num_breakpoints = = 0 ) {
result . AppendMessage ( " No breakpoints currently set. " ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
return true ;
}
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
2016-10-06 04:03:37 +08:00
if ( command . empty ( ) ) {
2016-09-07 04:57:50 +08:00
// No breakpoint selected; show info about all currently set breakpoints.
result . AppendMessage ( " Current breakpoints: " ) ;
for ( size_t i = 0 ; i < num_breakpoints ; + + i ) {
Breakpoint * breakpoint = breakpoints . GetBreakpointAtIndex ( i ) . get ( ) ;
2017-09-15 04:22:49 +08:00
if ( breakpoint - > AllowList ( ) )
AddBreakpointDescription ( & output_stream , breakpoint ,
m_options . m_level ) ;
2016-09-07 04:57:50 +08:00
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
// Particular breakpoints selected; show info about that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointOrLocationIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : listPerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
for ( size_t i = 0 ; i < valid_bp_ids . GetSize ( ) ; + + i ) {
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
Breakpoint * breakpoint =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
AddBreakpointDescription ( & output_stream , breakpoint ,
m_options . m_level ) ;
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
result . AppendError ( " Invalid breakpoint ID. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
2010-10-29 01:27:46 +08:00
}
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
private :
2016-09-07 04:57:50 +08:00
CommandOptions m_options ;
2012-06-09 05:56:10 +08:00
} ;
// CommandObjectBreakpointClear
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
# pragma mark Clear::CommandOptions
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_clear_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " file " , ' f ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename , " Specify the breakpoint by source location in this particular file. " } ,
{ LLDB_OPT_SET_1 , true , " line " , ' l ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeLineNum , " Specify the breakpoint by source location at this particular line. " }
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format on
} ;
2012-06-09 05:56:10 +08:00
# pragma mark Clear
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointClear : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2019-05-14 16:55:50 +08:00
enum BreakpointClearType { eClearTypeInvalid , eClearTypeFileAndLine } ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointClear ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " breakpoint clear " ,
" Delete or disable breakpoints matching the "
" specified source file and line. " ,
" breakpoint clear <cmd-options> " ) ,
m_options ( ) { }
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
~ CommandObjectBreakpointClear ( ) override = default ;
2010-10-29 01:27:46 +08:00
2016-09-07 04:57:50 +08:00
Options * GetOptions ( ) override { return & m_options ; }
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
class CommandOptions : public Options {
public :
CommandOptions ( ) : Options ( ) , m_filename ( ) , m_line_num ( 0 ) { }
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
~ CommandOptions ( ) override = default ;
2012-06-09 05:56:10 +08:00
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-07 04:57:50 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
switch ( short_option ) {
case ' f ' :
m_filename . assign ( option_arg ) ;
break ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
case ' l ' :
2016-11-13 00:56:47 +08:00
option_arg . getAsInteger ( 0 , m_line_num ) ;
2016-09-07 04:57:50 +08:00
break ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
return error ;
}
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_filename . clear ( ) ;
m_line_num = 0 ;
}
2010-06-09 00:52:24 +08:00
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_clear_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
// Instance variables to hold the values for command options.
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
std : : string m_filename ;
uint32_t m_line_num ;
} ;
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2012-06-09 05:56:10 +08:00
2018-05-01 00:49:04 +08:00
// The following are the various types of breakpoints that could be
// cleared:
2016-09-07 04:57:50 +08:00
// 1). -f -l (clearing breakpoint by source location)
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
BreakpointClearType break_type = eClearTypeInvalid ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
if ( m_options . m_line_num ! = 0 )
break_type = eClearTypeFileAndLine ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
size_t num_breakpoints = breakpoints . GetSize ( ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
// Early return if there's no breakpoint at all.
if ( num_breakpoints = = 0 ) {
result . AppendError ( " Breakpoint clear: No breakpoint cleared. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return result . Succeeded ( ) ;
}
2010-06-09 00:52:24 +08:00
2016-09-07 04:57:50 +08:00
// Find matching breakpoints and delete them.
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
// First create a copy of all the IDs.
std : : vector < break_id_t > BreakIDs ;
for ( size_t i = 0 ; i < num_breakpoints ; + + i )
BreakIDs . push_back ( breakpoints . GetBreakpointAtIndex ( i ) - > GetID ( ) ) ;
int num_cleared = 0 ;
StreamString ss ;
switch ( break_type ) {
case eClearTypeFileAndLine : // Breakpoint by source position
{
const ConstString filename ( m_options . m_filename . c_str ( ) ) ;
BreakpointLocationCollection loc_coll ;
for ( size_t i = 0 ; i < num_breakpoints ; + + i ) {
Breakpoint * bp = breakpoints . FindBreakpointByID ( BreakIDs [ i ] ) . get ( ) ;
if ( bp - > GetMatchingFileLine ( filename , m_options . m_line_num , loc_coll ) ) {
// If the collection size is 0, it's a full match and we can just
// remove the breakpoint.
if ( loc_coll . GetSize ( ) = = 0 ) {
bp - > GetDescription ( & ss , lldb : : eDescriptionLevelBrief ) ;
ss . EOL ( ) ;
target - > RemoveBreakpointByID ( bp - > GetID ( ) ) ;
+ + num_cleared ;
}
}
}
} break ;
default :
break ;
}
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
if ( num_cleared > 0 ) {
Stream & output_stream = result . GetOutputStream ( ) ;
output_stream . Printf ( " %d breakpoints cleared: \n " , num_cleared ) ;
2016-11-17 05:15:24 +08:00
output_stream < < ss . GetString ( ) ;
2016-09-07 04:57:50 +08:00
output_stream . EOL ( ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
result . AppendError ( " Breakpoint clear: No breakpoint cleared. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2012-06-09 05:56:10 +08:00
}
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2012-06-09 05:56:10 +08:00
private :
2016-09-07 04:57:50 +08:00
CommandOptions m_options ;
2012-06-09 05:56:10 +08:00
} ;
2010-06-16 10:00:15 +08:00
2012-06-09 05:56:10 +08:00
// CommandObjectBreakpointDelete
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_delete_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " force " , ' f ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Delete all breakpoints without querying for confirmation. " } ,
{ LLDB_OPT_SET_1 , false , " dummy-breakpoints " , ' D ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Delete Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format on
} ;
2012-06-09 05:56:10 +08:00
# pragma mark Delete
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointDelete : public CommandObjectParsed {
2012-06-09 05:56:10 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointDelete ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " breakpoint delete " ,
" Delete the specified breakpoint(s). If no "
" breakpoints are specified, delete them all. " ,
2016-02-19 06:39:14 +08:00
nullptr ) ,
2016-09-07 04:57:50 +08:00
m_options ( ) {
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
}
~ CommandObjectBreakpointDelete ( ) override = default ;
Options * GetOptions ( ) override { return & m_options ; }
class CommandOptions : public Options {
public :
CommandOptions ( ) : Options ( ) , m_use_dummy ( false ) , m_force ( false ) { }
~ CommandOptions ( ) override = default ;
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-07 04:57:50 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
switch ( short_option ) {
case ' f ' :
m_force = true ;
break ;
case ' D ' :
m_use_dummy = true ;
break ;
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
2012-06-09 05:56:10 +08:00
}
2016-09-07 04:57:50 +08:00
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_use_dummy = false ;
m_force = false ;
2014-12-06 09:28:03 +08:00
}
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_delete_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2014-12-06 09:28:03 +08:00
2016-09-07 04:57:50 +08:00
// Instance variables to hold the values for command options.
bool m_use_dummy ;
bool m_force ;
} ;
2014-12-06 09:28:03 +08:00
2012-06-09 05:56:10 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( m_options . m_use_dummy ) ;
2014-12-06 09:28:03 +08:00
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2016-05-19 13:13:57 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
2012-06-09 05:56:10 +08:00
2016-09-07 04:57:50 +08:00
if ( num_breakpoints = = 0 ) {
result . AppendError ( " No breakpoints exist to be deleted. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2012-06-09 05:56:10 +08:00
2016-10-06 04:03:37 +08:00
if ( command . empty ( ) ) {
2016-09-07 04:57:50 +08:00
if ( ! m_options . m_force & &
! m_interpreter . Confirm (
" About to delete all breakpoints, do you want to do that? " ,
true ) ) {
result . AppendMessage ( " Operation cancelled... " ) ;
} else {
2017-09-15 04:22:49 +08:00
target - > RemoveAllowedBreakpoints ( ) ;
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat (
" All breakpoints removed. (% " PRIu64 " breakpoint%s) \n " ,
( uint64_t ) num_breakpoints , num_breakpoints > 1 ? " s " : " " ) ;
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointOrLocationIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : deletePerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
int delete_count = 0 ;
int disable_count = 0 ;
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i ) {
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
if ( cur_bp_id . GetBreakpointID ( ) ! = LLDB_INVALID_BREAK_ID ) {
if ( cur_bp_id . GetLocationID ( ) ! = LLDB_INVALID_BREAK_ID ) {
Breakpoint * breakpoint =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
BreakpointLocation * location =
breakpoint - > FindLocationByID ( cur_bp_id . GetLocationID ( ) ) . get ( ) ;
// It makes no sense to try to delete individual locations, so we
// disable them instead.
if ( location ) {
location - > SetEnabled ( false ) ;
+ + disable_count ;
}
} else {
target - > RemoveBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) ;
+ + delete_count ;
2010-12-04 07:04:19 +08:00
}
2016-09-07 04:57:50 +08:00
}
2010-06-16 10:00:15 +08:00
}
2016-09-07 04:57:50 +08:00
result . AppendMessageWithFormat (
" %d breakpoints deleted; %d breakpoint locations disabled. \n " ,
delete_count , disable_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
2010-06-16 10:00:15 +08:00
}
2016-09-07 04:57:50 +08:00
return result . Succeeded ( ) ;
}
2016-02-19 06:39:14 +08:00
2014-12-06 09:28:03 +08:00
private :
2016-09-07 04:57:50 +08:00
CommandOptions m_options ;
2014-12-06 09:28:03 +08:00
} ;
2014-12-17 07:40:14 +08:00
// CommandObjectBreakpointName
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_name_options [ ] = {
2016-09-07 04:57:50 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " name " , ' N ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBreakpointName , " Specifies a breakpoint name to use. " } ,
{ LLDB_OPT_SET_2 , false , " breakpoint-id " , ' B ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBreakpointID , " Specify a breakpoint ID to use. " } ,
{ LLDB_OPT_SET_3 , false , " dummy-breakpoints " , ' D ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Operate on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets. " } ,
{ LLDB_OPT_SET_4 , false , " help-string " , ' H ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeNone , " A help string describing the purpose of this name. " } ,
2016-09-07 04:57:50 +08:00
// clang-format on
2014-12-17 07:40:14 +08:00
} ;
2016-09-07 04:57:50 +08:00
class BreakpointNameOptionGroup : public OptionGroup {
2014-12-17 07:40:14 +08:00
public :
2016-09-07 04:57:50 +08:00
BreakpointNameOptionGroup ( )
: OptionGroup ( ) , m_breakpoint ( LLDB_INVALID_BREAK_ID ) , m_use_dummy ( false ) {
}
~ BreakpointNameOptionGroup ( ) override = default ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_name_options ) ;
2016-09-07 04:57:50 +08:00
}
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-07 04:57:50 +08:00
const int short_option = g_breakpoint_name_options [ option_idx ] . short_option ;
switch ( short_option ) {
case ' N ' :
2016-11-13 00:56:47 +08:00
if ( BreakpointID : : StringIsBreakpointName ( option_arg , error ) & &
2016-09-07 04:57:50 +08:00
error . Success ( ) )
2016-11-13 00:56:47 +08:00
m_name . SetValueFromString ( option_arg ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' B ' :
2016-11-13 00:56:47 +08:00
if ( m_breakpoint . SetValueFromString ( option_arg ) . Fail ( ) )
2016-09-07 04:57:50 +08:00
error . SetErrorStringWithFormat (
2016-09-24 01:48:13 +08:00
" unrecognized value \" %s \" for breakpoint " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
case ' D ' :
2016-11-13 00:56:47 +08:00
if ( m_use_dummy . SetValueFromString ( option_arg ) . Fail ( ) )
2016-09-07 04:57:50 +08:00
error . SetErrorStringWithFormat (
2016-09-24 01:48:13 +08:00
" unrecognized value \" %s \" for use-dummy " ,
2016-11-13 00:56:47 +08:00
option_arg . str ( ) . c_str ( ) ) ;
2016-09-07 04:57:50 +08:00
break ;
2017-09-15 08:52:35 +08:00
case ' H ' :
m_help_string . SetValueFromString ( option_arg ) ;
break ;
2016-09-07 04:57:50 +08:00
default :
error . SetErrorStringWithFormat ( " unrecognized short option '%c' " ,
short_option ) ;
break ;
2014-12-17 07:40:14 +08:00
}
2016-09-07 04:57:50 +08:00
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_name . Clear ( ) ;
m_breakpoint . Clear ( ) ;
m_use_dummy . Clear ( ) ;
m_use_dummy . SetDefaultValue ( false ) ;
2017-09-15 08:52:35 +08:00
m_help_string . Clear ( ) ;
2016-09-07 04:57:50 +08:00
}
OptionValueString m_name ;
OptionValueUInt64 m_breakpoint ;
OptionValueBoolean m_use_dummy ;
2017-09-15 08:52:35 +08:00
OptionValueString m_help_string ;
2014-12-17 07:40:14 +08:00
} ;
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_access_options [ ] = {
2017-09-15 04:22:49 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_1 , false , " allow-list " , ' L ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Determines whether the breakpoint will show up in break list if not referred to explicitly. " } ,
{ LLDB_OPT_SET_2 , false , " allow-disable " , ' A ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Determines whether the breakpoint can be disabled by name or when all breakpoints are disabled. " } ,
{ LLDB_OPT_SET_3 , false , " allow-delete " , ' D ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBoolean , " Determines whether the breakpoint can be deleted by name or when all breakpoints are deleted. " } ,
2017-09-15 04:22:49 +08:00
// clang-format on
} ;
2018-09-27 02:50:19 +08:00
class BreakpointAccessOptionGroup : public OptionGroup {
2017-09-15 04:22:49 +08:00
public :
2018-09-27 02:50:19 +08:00
BreakpointAccessOptionGroup ( ) : OptionGroup ( ) { }
2017-09-15 04:22:49 +08:00
~ BreakpointAccessOptionGroup ( ) override = default ;
2018-09-27 02:50:19 +08:00
2017-09-15 04:22:49 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
return llvm : : makeArrayRef ( g_breakpoint_access_options ) ;
}
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
const int short_option
= g_breakpoint_access_options [ option_idx ] . short_option ;
switch ( short_option ) {
case ' L ' : {
bool value , success ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , false , & success ) ;
2017-09-15 04:22:49 +08:00
if ( success ) {
m_permissions . SetAllowList ( value ) ;
} else
error . SetErrorStringWithFormat (
" invalid boolean value '%s' passed for -L option " ,
option_arg . str ( ) . c_str ( ) ) ;
} break ;
case ' A ' : {
bool value , success ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , false , & success ) ;
2017-09-15 04:22:49 +08:00
if ( success ) {
m_permissions . SetAllowDisable ( value ) ;
} else
error . SetErrorStringWithFormat (
" invalid boolean value '%s' passed for -L option " ,
option_arg . str ( ) . c_str ( ) ) ;
} break ;
case ' D ' : {
bool value , success ;
2018-04-10 17:03:59 +08:00
value = OptionArgParser : : ToBoolean ( option_arg , false , & success ) ;
2017-09-15 04:22:49 +08:00
if ( success ) {
m_permissions . SetAllowDelete ( value ) ;
} else
error . SetErrorStringWithFormat (
" invalid boolean value '%s' passed for -L option " ,
option_arg . str ( ) . c_str ( ) ) ;
} break ;
}
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
}
const BreakpointName : : Permissions & GetPermissions ( ) const
{
return m_permissions ;
}
BreakpointName : : Permissions m_permissions ;
} ;
class CommandObjectBreakpointNameConfigure : public CommandObjectParsed {
public :
CommandObjectBreakpointNameConfigure ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " configure " , " Configure the options for the breakpoint "
" name provided. "
" If you provide a breakpoint id, the options will be copied from "
" the breakpoint, otherwise only the options specified will be set "
" on the name. " ,
" breakpoint name configure <command-options> "
" <breakpoint-name-list> " ) ,
m_bp_opts ( ) , m_option_group ( ) {
// Create the first variant for the first (and only) argument for this
// command.
CommandArgumentEntry arg1 ;
CommandArgumentData id_arg ;
id_arg . arg_type = eArgTypeBreakpointName ;
id_arg . arg_repetition = eArgRepeatOptional ;
arg1 . push_back ( id_arg ) ;
m_arguments . push_back ( arg1 ) ;
m_option_group . Append ( & m_bp_opts ,
LLDB_OPT_SET_ALL ,
LLDB_OPT_SET_1 ) ;
m_option_group . Append ( & m_access_options ,
LLDB_OPT_SET_ALL ,
LLDB_OPT_SET_ALL ) ;
2017-09-15 08:52:35 +08:00
m_option_group . Append ( & m_bp_id ,
LLDB_OPT_SET_2 | LLDB_OPT_SET_4 ,
LLDB_OPT_SET_ALL ) ;
2017-09-15 04:22:49 +08:00
m_option_group . Finalize ( ) ;
}
~ CommandObjectBreakpointNameConfigure ( ) override = default ;
Options * GetOptions ( ) override { return & m_option_group ; }
protected :
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
const size_t argc = command . GetArgumentCount ( ) ;
if ( argc = = 0 ) {
result . AppendError ( " No names provided. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
Target * target =
GetSelectedOrDummyTarget ( false ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
// Make a pass through first to see that all the names are legal.
for ( auto & entry : command . entries ( ) ) {
Status error ;
if ( ! BreakpointID : : StringIsBreakpointName ( entry . ref , error ) )
{
result . AppendErrorWithFormat ( " Invalid breakpoint name: %s - %s " ,
entry . c_str ( ) , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
2018-05-01 00:49:04 +08:00
// Now configure them, we already pre-checked the names so we don't need to
// check the error:
2017-09-15 04:22:49 +08:00
BreakpointSP bp_sp ;
if ( m_bp_id . m_breakpoint . OptionWasSet ( ) )
{
lldb : : break_id_t bp_id = m_bp_id . m_breakpoint . GetUInt64Value ( ) ;
bp_sp = target - > GetBreakpointByID ( bp_id ) ;
if ( ! bp_sp )
{
result . AppendErrorWithFormatv ( " Could not find specified breakpoint {0} " ,
bp_id ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
Status error ;
for ( auto & entry : command . entries ( ) ) {
ConstString name ( entry . c_str ( ) ) ;
BreakpointName * bp_name = target - > FindBreakpointName ( name , true , error ) ;
if ( ! bp_name )
continue ;
2017-09-15 08:52:35 +08:00
if ( m_bp_id . m_help_string . OptionWasSet ( ) )
bp_name - > SetHelp ( m_bp_id . m_help_string . GetStringValue ( ) . str ( ) . c_str ( ) ) ;
2017-09-15 04:22:49 +08:00
if ( bp_sp )
target - > ConfigureBreakpointName ( * bp_name ,
* bp_sp - > GetOptions ( ) ,
m_access_options . GetPermissions ( ) ) ;
else
target - > ConfigureBreakpointName ( * bp_name ,
m_bp_opts . GetBreakpointOptions ( ) ,
m_access_options . GetPermissions ( ) ) ;
}
return true ;
}
private :
BreakpointNameOptionGroup m_bp_id ; // Only using the id part of this.
BreakpointOptionGroup m_bp_opts ;
BreakpointAccessOptionGroup m_access_options ;
OptionGroupOptions m_option_group ;
} ;
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
2014-12-17 07:40:14 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointNameAdd ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " add " , " Add a name to the breakpoints provided. " ,
" breakpoint name add <command-options> <breakpoint-id-list> " ) ,
m_name_options ( ) , m_option_group ( ) {
// Create the first variant for the first (and only) argument for this
// command.
CommandArgumentEntry arg1 ;
CommandArgumentData id_arg ;
id_arg . arg_type = eArgTypeBreakpointID ;
id_arg . arg_repetition = eArgRepeatOptional ;
arg1 . push_back ( id_arg ) ;
m_arguments . push_back ( arg1 ) ;
m_option_group . Append ( & m_name_options , LLDB_OPT_SET_1 , LLDB_OPT_SET_ALL ) ;
m_option_group . Finalize ( ) ;
}
~ CommandObjectBreakpointNameAdd ( ) override = default ;
Options * GetOptions ( ) override { return & m_option_group ; }
2014-12-17 07:40:14 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
if ( ! m_name_options . m_name . OptionWasSet ( ) ) {
result . SetError ( " No name option provided. " ) ;
return false ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
Target * target =
GetSelectedOrDummyTarget ( m_name_options . m_use_dummy . GetCurrentValue ( ) ) ;
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2016-05-19 13:13:57 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 ) {
result . SetError ( " No breakpoints, cannot add names. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : listPerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
if ( valid_bp_ids . GetSize ( ) = = 0 ) {
result . SetError ( " No breakpoints specified, cannot add names. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
size_t num_valid_ids = valid_bp_ids . GetSize ( ) ;
2017-09-15 04:22:49 +08:00
const char * bp_name = m_name_options . m_name . GetCurrentValue ( ) ;
Status error ; // This error reports illegal names, but we've already
// checked that, so we don't need to check it again here.
2016-09-07 04:57:50 +08:00
for ( size_t index = 0 ; index < num_valid_ids ; index + + ) {
lldb : : break_id_t bp_id =
valid_bp_ids . GetBreakpointIDAtIndex ( index ) . GetBreakpointID ( ) ;
BreakpointSP bp_sp = breakpoints . FindBreakpointByID ( bp_id ) ;
2017-09-15 04:22:49 +08:00
target - > AddNameToBreakpoint ( bp_sp , bp_name , error ) ;
2016-09-07 04:57:50 +08:00
}
2014-12-17 07:40:14 +08:00
}
2016-09-07 04:57:50 +08:00
return true ;
}
2014-12-17 07:40:14 +08:00
private :
2016-09-07 04:57:50 +08:00
BreakpointNameOptionGroup m_name_options ;
OptionGroupOptions m_option_group ;
2014-12-17 07:40:14 +08:00
} ;
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
2014-12-17 07:40:14 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointNameDelete ( CommandInterpreter & interpreter )
: CommandObjectParsed (
interpreter , " delete " ,
" Delete a name from the breakpoints provided. " ,
" breakpoint name delete <command-options> <breakpoint-id-list> " ) ,
m_name_options ( ) , m_option_group ( ) {
// Create the first variant for the first (and only) argument for this
// command.
CommandArgumentEntry arg1 ;
CommandArgumentData id_arg ;
id_arg . arg_type = eArgTypeBreakpointID ;
id_arg . arg_repetition = eArgRepeatOptional ;
arg1 . push_back ( id_arg ) ;
m_arguments . push_back ( arg1 ) ;
m_option_group . Append ( & m_name_options , LLDB_OPT_SET_1 , LLDB_OPT_SET_ALL ) ;
m_option_group . Finalize ( ) ;
}
~ CommandObjectBreakpointNameDelete ( ) override = default ;
Options * GetOptions ( ) override { return & m_option_group ; }
2014-12-17 07:40:14 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
if ( ! m_name_options . m_name . OptionWasSet ( ) ) {
result . SetError ( " No name option provided. " ) ;
return false ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
Target * target =
GetSelectedOrDummyTarget ( m_name_options . m_use_dummy . GetCurrentValue ( ) ) ;
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2016-05-19 13:13:57 +08:00
2016-09-07 04:57:50 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 ) {
result . SetError ( " No breakpoints, cannot delete names. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : deletePerm ) ;
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
if ( valid_bp_ids . GetSize ( ) = = 0 ) {
result . SetError ( " No breakpoints specified, cannot delete names. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2017-09-15 04:22:49 +08:00
ConstString bp_name ( m_name_options . m_name . GetCurrentValue ( ) ) ;
2016-09-07 04:57:50 +08:00
size_t num_valid_ids = valid_bp_ids . GetSize ( ) ;
for ( size_t index = 0 ; index < num_valid_ids ; index + + ) {
lldb : : break_id_t bp_id =
valid_bp_ids . GetBreakpointIDAtIndex ( index ) . GetBreakpointID ( ) ;
BreakpointSP bp_sp = breakpoints . FindBreakpointByID ( bp_id ) ;
2017-09-15 04:22:49 +08:00
target - > RemoveNameFromBreakpoint ( bp_sp , bp_name ) ;
2016-09-07 04:57:50 +08:00
}
2014-12-17 07:40:14 +08:00
}
2016-09-07 04:57:50 +08:00
return true ;
}
2014-12-17 07:40:14 +08:00
private :
2016-09-07 04:57:50 +08:00
BreakpointNameOptionGroup m_name_options ;
OptionGroupOptions m_option_group ;
2014-12-17 07:40:14 +08:00
} ;
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointNameList : public CommandObjectParsed {
2014-12-17 07:40:14 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointNameList ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " list " ,
2017-09-15 04:22:49 +08:00
" List either the names for a breakpoint or info "
" about a given name. With no arguments, lists all "
" names " ,
2016-09-07 04:57:50 +08:00
" breakpoint name list <command-options> " ) ,
m_name_options ( ) , m_option_group ( ) {
2017-09-15 04:22:49 +08:00
m_option_group . Append ( & m_name_options , LLDB_OPT_SET_3 , LLDB_OPT_SET_ALL ) ;
2016-09-07 04:57:50 +08:00
m_option_group . Finalize ( ) ;
}
2014-12-17 07:40:14 +08:00
2016-09-07 04:57:50 +08:00
~ CommandObjectBreakpointNameList ( ) override = default ;
2016-02-19 06:39:14 +08:00
2016-09-07 04:57:50 +08:00
Options * GetOptions ( ) override { return & m_option_group ; }
2014-12-17 07:40:14 +08:00
protected :
2016-09-07 04:57:50 +08:00
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target =
GetSelectedOrDummyTarget ( m_name_options . m_use_dummy . GetCurrentValue ( ) ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2017-09-15 04:22:49 +08:00
std : : vector < std : : string > name_list ;
if ( command . empty ( ) ) {
target - > GetBreakpointNames ( name_list ) ;
} else {
for ( const Args : : ArgEntry & arg : command )
{
name_list . push_back ( arg . c_str ( ) ) ;
}
}
if ( name_list . empty ( ) ) {
result . AppendMessage ( " No breakpoint names found. " ) ;
} else {
for ( const std : : string & name_str : name_list ) {
const char * name = name_str . c_str ( ) ;
// First print out the options for the name:
Status error ;
BreakpointName * bp_name = target - > FindBreakpointName ( ConstString ( name ) ,
false ,
error ) ;
if ( bp_name )
{
2016-09-07 04:57:50 +08:00
StreamString s ;
2017-09-15 04:22:49 +08:00
result . AppendMessageWithFormat ( " Name: %s \n " , name ) ;
if ( bp_name - > GetDescription ( & s , eDescriptionLevelFull ) )
{
result . AppendMessage ( s . GetString ( ) ) ;
}
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
bool any_set = false ;
for ( BreakpointSP bp_sp : breakpoints . Breakpoints ( ) ) {
if ( bp_sp - > MatchesName ( name ) ) {
StreamString s ;
any_set = true ;
bp_sp - > GetDescription ( & s , eDescriptionLevelBrief ) ;
s . EOL ( ) ;
result . AppendMessage ( s . GetString ( ) ) ;
}
}
if ( ! any_set )
result . AppendMessage ( " No breakpoints using this name. " ) ;
} else {
result . AppendMessageWithFormat ( " Name: %s not found. \n " , name ) ;
2016-09-07 04:57:50 +08:00
}
}
2014-12-17 07:40:14 +08:00
}
2016-09-07 04:57:50 +08:00
return true ;
}
2014-12-17 07:40:14 +08:00
private :
2016-09-07 04:57:50 +08:00
BreakpointNameOptionGroup m_name_options ;
OptionGroupOptions m_option_group ;
2014-12-17 07:40:14 +08:00
} ;
2016-09-13 07:10:56 +08:00
// CommandObjectBreakpointName
2016-09-07 04:57:50 +08:00
class CommandObjectBreakpointName : public CommandObjectMultiword {
2014-12-17 07:40:14 +08:00
public :
2016-09-07 04:57:50 +08:00
CommandObjectBreakpointName ( CommandInterpreter & interpreter )
: CommandObjectMultiword (
interpreter , " name " , " Commands to manage name tags for breakpoints " ,
" breakpoint name <subcommand> [<command-options>] " ) {
CommandObjectSP add_command_object (
new CommandObjectBreakpointNameAdd ( interpreter ) ) ;
CommandObjectSP delete_command_object (
new CommandObjectBreakpointNameDelete ( interpreter ) ) ;
CommandObjectSP list_command_object (
new CommandObjectBreakpointNameList ( interpreter ) ) ;
2017-09-15 04:22:49 +08:00
CommandObjectSP configure_command_object (
new CommandObjectBreakpointNameConfigure ( interpreter ) ) ;
2016-09-07 04:57:50 +08:00
LoadSubCommand ( " add " , add_command_object ) ;
LoadSubCommand ( " delete " , delete_command_object ) ;
LoadSubCommand ( " list " , list_command_object ) ;
2017-09-15 04:22:49 +08:00
LoadSubCommand ( " configure " , configure_command_object ) ;
2016-09-07 04:57:50 +08:00
}
~ CommandObjectBreakpointName ( ) override = default ;
2014-12-17 07:40:14 +08:00
} ;
2016-09-13 07:10:56 +08:00
// CommandObjectBreakpointRead
2016-09-23 06:20:28 +08:00
# pragma mark Read::CommandOptions
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_read_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_ALL , true , " file " , ' f ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eDiskFileCompletion , eArgTypeFilename , " The file from which to read the breakpoints. " } ,
{ LLDB_OPT_SET_ALL , false , " breakpoint-name " , ' N ' , OptionParser : : eRequiredArgument , nullptr , { } , 0 , eArgTypeBreakpointName , " Only read in breakpoints with this name. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format on
} ;
# pragma mark Read
2016-09-13 07:10:56 +08:00
class CommandObjectBreakpointRead : public CommandObjectParsed {
public :
CommandObjectBreakpointRead ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " breakpoint read " ,
" Read and set the breakpoints previously saved to "
" a file with \" breakpoint write \" . " ,
nullptr ) ,
m_options ( ) {
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
}
~ CommandObjectBreakpointRead ( ) override = default ;
Options * GetOptions ( ) override { return & m_options ; }
class CommandOptions : public Options {
public :
CommandOptions ( ) : Options ( ) { }
~ CommandOptions ( ) override = default ;
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-13 07:10:56 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
switch ( short_option ) {
case ' f ' :
m_filename . assign ( option_arg ) ;
break ;
2016-09-23 06:20:28 +08:00
case ' N ' : {
2017-05-12 12:51:55 +08:00
Status name_error ;
2016-09-23 06:20:28 +08:00
if ( ! BreakpointID : : StringIsBreakpointName ( llvm : : StringRef ( option_arg ) ,
name_error ) ) {
error . SetErrorStringWithFormat ( " Invalid breakpoint name: %s " ,
name_error . AsCString ( ) ) ;
}
m_names . push_back ( option_arg ) ;
break ;
}
2016-09-13 07:10:56 +08:00
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_filename . clear ( ) ;
2016-09-23 06:20:28 +08:00
m_names . clear ( ) ;
2016-09-13 07:10:56 +08:00
}
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_read_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2016-09-13 07:10:56 +08:00
// Instance variables to hold the values for command options.
std : : string m_filename ;
2016-09-23 06:20:28 +08:00
std : : vector < std : : string > m_names ;
2016-09-13 07:10:56 +08:00
} ;
protected :
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2016-09-23 06:20:28 +08:00
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2018-11-02 05:05:36 +08:00
FileSpec input_spec ( m_options . m_filename ) ;
FileSystem : : Instance ( ) . Resolve ( input_spec ) ;
2016-09-15 03:07:35 +08:00
BreakpointIDList new_bps ;
2017-05-12 12:51:55 +08:00
Status error = target - > CreateBreakpointsFromFile (
input_spec , m_options . m_names , new_bps ) ;
2016-09-13 07:10:56 +08:00
2016-09-15 03:07:35 +08:00
if ( ! error . Success ( ) ) {
result . AppendError ( error . AsCString ( ) ) ;
2016-09-13 07:10:56 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2016-09-23 06:20:28 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
size_t num_breakpoints = new_bps . GetSize ( ) ;
if ( num_breakpoints = = 0 ) {
result . AppendMessage ( " No breakpoints added. " ) ;
} else {
// No breakpoint selected; show info about all currently set breakpoints.
result . AppendMessage ( " New breakpoints: " ) ;
for ( size_t i = 0 ; i < num_breakpoints ; + + i ) {
BreakpointID bp_id = new_bps . GetBreakpointIDAtIndex ( i ) ;
Breakpoint * bp = target - > GetBreakpointList ( )
. FindBreakpointByID ( bp_id . GetBreakpointID ( ) )
. get ( ) ;
if ( bp )
bp - > GetDescription ( & output_stream , lldb : : eDescriptionLevelInitial ,
false ) ;
}
}
2016-09-13 07:10:56 +08:00
return result . Succeeded ( ) ;
}
private :
CommandOptions m_options ;
} ;
// CommandObjectBreakpointWrite
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
# pragma mark Write::CommandOptions
2018-09-27 02:50:19 +08:00
static constexpr OptionDefinition g_breakpoint_write_options [ ] = {
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format off
2018-09-27 02:50:19 +08:00
{ LLDB_OPT_SET_ALL , true , " file " , ' f ' , OptionParser : : eRequiredArgument , nullptr , { } , CommandCompletions : : eDiskFileCompletion , eArgTypeFilename , " The file into which to write the breakpoints. " } ,
{ LLDB_OPT_SET_ALL , false , " append " , ' a ' , OptionParser : : eNoArgument , nullptr , { } , 0 , eArgTypeNone , " Append to saved breakpoints file if it exists. " } ,
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
// clang-format on
} ;
# pragma mark Write
2016-09-13 07:10:56 +08:00
class CommandObjectBreakpointWrite : public CommandObjectParsed {
public :
CommandObjectBreakpointWrite ( CommandInterpreter & interpreter )
: CommandObjectParsed ( interpreter , " breakpoint write " ,
" Write the breakpoints listed to a file that can "
" be read in with \" breakpoint read \" . "
" If given no arguments, writes all breakpoints. " ,
nullptr ) ,
m_options ( ) {
CommandArgumentEntry arg ;
CommandObject : : AddIDsArgumentData ( arg , eArgTypeBreakpointID ,
eArgTypeBreakpointIDRange ) ;
// Add the entry for the first argument for this command to the object's
// arguments vector.
m_arguments . push_back ( arg ) ;
}
~ CommandObjectBreakpointWrite ( ) override = default ;
Options * GetOptions ( ) override { return & m_options ; }
class CommandOptions : public Options {
public :
CommandOptions ( ) : Options ( ) { }
~ CommandOptions ( ) override = default ;
2017-05-12 12:51:55 +08:00
Status SetOptionValue ( uint32_t option_idx , llvm : : StringRef option_arg ,
ExecutionContext * execution_context ) override {
Status error ;
2016-09-13 07:10:56 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
switch ( short_option ) {
case ' f ' :
m_filename . assign ( option_arg ) ;
break ;
2016-09-23 07:42:42 +08:00
case ' a ' :
m_append = true ;
break ;
2016-09-13 07:10:56 +08:00
default :
error . SetErrorStringWithFormat ( " unrecognized option '%c' " ,
short_option ) ;
break ;
}
return error ;
}
void OptionParsingStarting ( ExecutionContext * execution_context ) override {
m_filename . clear ( ) ;
2016-09-23 07:42:42 +08:00
m_append = false ;
2016-09-13 07:10:56 +08:00
}
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
llvm : : ArrayRef < OptionDefinition > GetDefinitions ( ) override {
2016-09-23 05:06:13 +08:00
return llvm : : makeArrayRef ( g_breakpoint_write_options ) ;
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-23 04:22:55 +08:00
}
2016-09-13 07:10:56 +08:00
// Instance variables to hold the values for command options.
std : : string m_filename ;
2016-09-23 07:42:42 +08:00
bool m_append = false ;
2016-09-13 07:10:56 +08:00
} ;
protected :
bool DoExecute ( Args & command , CommandReturnObject & result ) override {
Target * target = GetSelectedOrDummyTarget ( ) ;
if ( target = = nullptr ) {
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
std : : unique_lock < std : : recursive_mutex > lock ;
target - > GetBreakpointList ( ) . GetListMutex ( lock ) ;
2016-09-15 03:07:35 +08:00
BreakpointIDList valid_bp_ids ;
2016-10-06 04:03:37 +08:00
if ( ! command . empty ( ) ) {
2016-09-13 07:10:56 +08:00
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs (
2017-09-15 04:22:49 +08:00
command , target , result , & valid_bp_ids ,
BreakpointName : : Permissions : : PermissionKinds : : listPerm ) ;
2016-09-13 07:10:56 +08:00
2016-09-15 03:07:35 +08:00
if ( ! result . Succeeded ( ) ) {
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
2016-09-13 07:10:56 +08:00
}
}
2018-11-02 05:05:36 +08:00
FileSpec file_spec ( m_options . m_filename ) ;
FileSystem : : Instance ( ) . Resolve ( file_spec ) ;
Status error = target - > SerializeBreakpointsToFile ( file_spec , valid_bp_ids ,
m_options . m_append ) ;
2016-09-15 03:07:35 +08:00
if ( ! error . Success ( ) ) {
result . AppendErrorWithFormat ( " error serializing breakpoints: %s. " ,
error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
2016-09-13 07:10:56 +08:00
return result . Succeeded ( ) ;
}
private :
CommandOptions m_options ;
} ;
2012-06-09 05:56:10 +08:00
// CommandObjectMultiwordBreakpoint
# pragma mark MultiwordBreakpoint
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
CommandObjectMultiwordBreakpoint : : CommandObjectMultiwordBreakpoint (
CommandInterpreter & interpreter )
: CommandObjectMultiword (
interpreter , " breakpoint " ,
" Commands for operating on breakpoints (see 'help b' for shorthand.) " ,
" breakpoint <subcommand> [<command-options>] " ) {
CommandObjectSP list_command_object (
new CommandObjectBreakpointList ( interpreter ) ) ;
CommandObjectSP enable_command_object (
new CommandObjectBreakpointEnable ( interpreter ) ) ;
CommandObjectSP disable_command_object (
new CommandObjectBreakpointDisable ( interpreter ) ) ;
CommandObjectSP clear_command_object (
new CommandObjectBreakpointClear ( interpreter ) ) ;
CommandObjectSP delete_command_object (
new CommandObjectBreakpointDelete ( interpreter ) ) ;
CommandObjectSP set_command_object (
new CommandObjectBreakpointSet ( interpreter ) ) ;
CommandObjectSP command_command_object (
new CommandObjectBreakpointCommand ( interpreter ) ) ;
CommandObjectSP modify_command_object (
new CommandObjectBreakpointModify ( interpreter ) ) ;
CommandObjectSP name_command_object (
new CommandObjectBreakpointName ( interpreter ) ) ;
2016-09-13 07:10:56 +08:00
CommandObjectSP write_command_object (
new CommandObjectBreakpointWrite ( interpreter ) ) ;
CommandObjectSP read_command_object (
new CommandObjectBreakpointRead ( interpreter ) ) ;
2016-09-07 04:57:50 +08:00
list_command_object - > SetCommandName ( " breakpoint list " ) ;
enable_command_object - > SetCommandName ( " breakpoint enable " ) ;
disable_command_object - > SetCommandName ( " breakpoint disable " ) ;
clear_command_object - > SetCommandName ( " breakpoint clear " ) ;
delete_command_object - > SetCommandName ( " breakpoint delete " ) ;
set_command_object - > SetCommandName ( " breakpoint set " ) ;
command_command_object - > SetCommandName ( " breakpoint command " ) ;
modify_command_object - > SetCommandName ( " breakpoint modify " ) ;
name_command_object - > SetCommandName ( " breakpoint name " ) ;
2016-09-13 07:10:56 +08:00
write_command_object - > SetCommandName ( " breakpoint write " ) ;
read_command_object - > SetCommandName ( " breakpoint read " ) ;
2016-09-07 04:57:50 +08:00
LoadSubCommand ( " list " , list_command_object ) ;
LoadSubCommand ( " enable " , enable_command_object ) ;
LoadSubCommand ( " disable " , disable_command_object ) ;
LoadSubCommand ( " clear " , clear_command_object ) ;
LoadSubCommand ( " delete " , delete_command_object ) ;
LoadSubCommand ( " set " , set_command_object ) ;
LoadSubCommand ( " command " , command_command_object ) ;
LoadSubCommand ( " modify " , modify_command_object ) ;
LoadSubCommand ( " name " , name_command_object ) ;
2016-09-13 07:10:56 +08:00
LoadSubCommand ( " write " , write_command_object ) ;
LoadSubCommand ( " read " , read_command_object ) ;
2010-06-16 10:00:15 +08:00
}
2016-02-19 06:39:14 +08:00
CommandObjectMultiwordBreakpoint : : ~ CommandObjectMultiwordBreakpoint ( ) = default ;
2010-06-16 10:00:15 +08:00
2016-09-07 04:57:50 +08:00
void CommandObjectMultiwordBreakpoint : : VerifyIDs ( Args & args , Target * target ,
bool allow_locations ,
CommandReturnObject & result ,
2017-09-15 04:22:49 +08:00
BreakpointIDList * valid_ids ,
BreakpointName : : Permissions
: : PermissionKinds
purpose ) {
2016-09-07 04:57:50 +08:00
// args can be strings representing 1). integers (for breakpoint ids)
// 2). the full breakpoint & location
// canonical representation
// 3). the word "to" or a hyphen,
// representing a range (in which case there
// had *better* be an entry both before &
// after of one of the first two types.
// 4). A breakpoint name
// If args is empty, we will use the last created breakpoint (if there is
// one.)
Args temp_args ;
2016-10-06 04:03:37 +08:00
if ( args . empty ( ) ) {
2016-09-07 04:57:50 +08:00
if ( target - > GetLastCreatedBreakpoint ( ) ) {
valid_ids - > AddBreakpointID ( BreakpointID (
target - > GetLastCreatedBreakpoint ( ) - > GetID ( ) , LLDB_INVALID_BREAK_ID ) ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
} else {
result . AppendError (
" No breakpoint specified and no last created breakpoint. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2010-06-16 10:00:15 +08:00
}
2016-09-07 04:57:50 +08:00
return ;
}
// Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff
2018-05-01 00:49:04 +08:00
// directly from the old ARGS to the new TEMP_ARGS. Do not copy breakpoint
// id range strings over; instead generate a list of strings for all the
// breakpoint ids in the range, and shove all of those breakpoint id strings
// into TEMP_ARGS.
2016-09-07 04:57:50 +08:00
2017-09-15 04:22:49 +08:00
BreakpointIDList : : FindAndReplaceIDRanges ( args , target , allow_locations ,
purpose , result , temp_args ) ;
2016-09-07 04:57:50 +08:00
// NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual
// BreakpointIDList:
2018-06-20 16:12:50 +08:00
valid_ids - > InsertStringArray ( temp_args . GetArgumentArrayRef ( ) , result ) ;
2016-09-07 04:57:50 +08:00
2018-05-01 00:49:04 +08:00
// At this point, all of the breakpoint ids that the user passed in have
// been converted to breakpoint IDs and put into valid_ids.
2016-09-07 04:57:50 +08:00
if ( result . Succeeded ( ) ) {
// Now that we've converted everything from args into a list of breakpoint
2018-05-01 00:49:04 +08:00
// ids, go through our tentative list of breakpoint id's and verify that
// they correspond to valid/currently set breakpoints.
2016-09-07 04:57:50 +08:00
const size_t count = valid_ids - > GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i ) {
BreakpointID cur_bp_id = valid_ids - > GetBreakpointIDAtIndex ( i ) ;
Breakpoint * breakpoint =
target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
if ( breakpoint ! = nullptr ) {
const size_t num_locations = breakpoint - > GetNumLocations ( ) ;
if ( static_cast < size_t > ( cur_bp_id . GetLocationID ( ) ) > num_locations ) {
StreamString id_str ;
BreakpointID : : GetCanonicalReference (
& id_str , cur_bp_id . GetBreakpointID ( ) , cur_bp_id . GetLocationID ( ) ) ;
i = valid_ids - > GetSize ( ) + 1 ;
result . AppendErrorWithFormat (
" '%s' is not a currently valid breakpoint/location id. \n " ,
id_str . GetData ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
} else {
i = valid_ids - > GetSize ( ) + 1 ;
result . AppendErrorWithFormat (
" '%d' is not a currently valid breakpoint ID. \n " ,
cur_bp_id . GetBreakpointID ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
2010-06-16 10:00:15 +08:00
}
2016-09-07 04:57:50 +08:00
}
2010-06-16 10:00:15 +08:00
}