2010-06-09 00:52:24 +08:00
//===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
# include "CommandObjectBreakpoint.h"
# include "CommandObjectBreakpointCommand.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
# include "lldb/Breakpoint/Breakpoint.h"
# include "lldb/Breakpoint/BreakpointIDList.h"
# include "lldb/Breakpoint/BreakpointLocation.h"
2010-06-16 03:49:27 +08:00
# include "lldb/Interpreter/Options.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Core/RegularExpression.h"
# include "lldb/Core/StreamString.h"
# include "lldb/Interpreter/CommandInterpreter.h"
# include "lldb/Interpreter/CommandReturnObject.h"
# include "lldb/Target/Target.h"
# include "lldb/Interpreter/CommandCompletions.h"
# include "lldb/Target/StackFrame.h"
2010-06-16 10:00:15 +08:00
# include "lldb/Target/Thread.h"
# include "lldb/Target/ThreadSpec.h"
2010-06-09 00:52:24 +08:00
2010-10-29 01:27:46 +08:00
# include <vector>
2010-06-09 00:52:24 +08:00
using namespace lldb ;
using namespace lldb_private ;
static void
2011-02-19 10:53:09 +08:00
AddBreakpointDescription ( Stream * s , Breakpoint * bp , lldb : : DescriptionLevel level )
2010-06-09 00:52:24 +08:00
{
s - > IndentMore ( ) ;
bp - > GetDescription ( s , level , true ) ;
s - > IndentLess ( ) ;
s - > EOL ( ) ;
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointSet::CommandOptions
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Set::CommandOptions
2010-06-09 00:52:24 +08:00
2011-04-08 06:46:35 +08:00
CommandObjectBreakpointSet : : CommandOptions : : CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter ) ,
2010-06-09 00:52:24 +08:00
m_filename ( ) ,
m_line_num ( 0 ) ,
m_column ( 0 ) ,
2010-11-02 11:02:38 +08:00
m_check_inlines ( true ) ,
2010-06-09 00:52:24 +08:00
m_func_name ( ) ,
2010-06-29 05:30:43 +08:00
m_func_name_type_mask ( 0 ) ,
2010-06-09 00:52:24 +08:00
m_func_regexp ( ) ,
2011-09-21 09:17:13 +08:00
m_source_text_regexp ( ) ,
2010-06-09 00:52:24 +08:00
m_modules ( ) ,
2010-06-16 10:00:15 +08:00
m_load_addr ( ) ,
2010-07-10 04:39:50 +08:00
m_ignore_count ( 0 ) ,
2010-06-16 10:00:15 +08:00
m_thread_id ( LLDB_INVALID_THREAD_ID ) ,
2010-07-10 04:39:50 +08:00
m_thread_index ( UINT32_MAX ) ,
2010-06-16 10:00:15 +08:00
m_thread_name ( ) ,
2010-07-10 04:39:50 +08:00
m_queue_name ( )
2010-06-09 00:52:24 +08:00
{
}
CommandObjectBreakpointSet : : CommandOptions : : ~ CommandOptions ( )
{
}
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-06-09 00:52:24 +08:00
CommandObjectBreakpointSet : : CommandOptions : : g_option_table [ ] =
{
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " shlib " , ' s ' , required_argument , NULL , CommandCompletions : : eModuleCompletion , eArgTypeShlibName ,
2010-06-16 02:47:14 +08:00
" Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs). " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " ignore-count " , ' i ' , required_argument , NULL , 0 , eArgTypeCount ,
" Set the number of times this breakpoint is skipped before stopping. " } ,
2010-06-16 10:00:15 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " thread-index " , ' x ' , required_argument , NULL , NULL , eArgTypeThreadIndex ,
2010-09-18 11:37:20 +08:00
" The breakpoint stops only for the thread whose index matches this argument. " } ,
2010-06-16 10:00:15 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " thread-id " , ' t ' , required_argument , NULL , NULL , eArgTypeThreadID ,
2010-06-16 10:00:15 +08:00
" The breakpoint stops only for the thread whose TID matches this argument. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " thread-name " , ' T ' , required_argument , NULL , NULL , eArgTypeThreadName ,
2010-06-16 10:00:15 +08:00
" The breakpoint stops only for the thread whose thread name matches this argument. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " queue-name " , ' q ' , required_argument , NULL , NULL , eArgTypeQueueName ,
2010-06-16 10:00:15 +08:00
" The breakpoint stops only for threads in the queue whose name is given by this argument. " } ,
2011-09-21 09:17:13 +08:00
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_9 , false , " file " , ' f ' , required_argument , NULL , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename ,
2010-06-09 00:52:24 +08:00
" Set the breakpoint by source location in this particular file. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_1 , true , " line " , ' l ' , required_argument , NULL , 0 , eArgTypeLineNum ,
2010-06-09 00:52:24 +08:00
" Set the breakpoint by source location at this particular line. " } ,
// 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.
// { 0, false, "column", 'c', required_argument, NULL, "<column>",
// "Set the breakpoint by source location at this particular column."},
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_2 , true , " address " , ' a ' , required_argument , NULL , 0 , eArgTypeAddress ,
2010-06-09 00:52:24 +08:00
" Set the breakpoint by address, at the specified address. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_3 , true , " name " , ' n ' , required_argument , NULL , CommandCompletions : : eSymbolCompletion , eArgTypeFunctionName ,
2010-10-12 12:29:14 +08:00
" Set the breakpoint by function name. " } ,
2010-06-09 00:52:24 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_4 , true , " fullname " , ' F ' , required_argument , NULL , CommandCompletions : : eSymbolCompletion , eArgTypeFullName ,
2010-08-27 07:56:11 +08:00
" Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguemnts, and "
" for Objective C this means a full function prototype with class and selector. " } ,
2010-06-29 05:30:43 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_5 , true , " selector " , ' S ' , required_argument , NULL , 0 , eArgTypeSelector ,
2010-08-27 07:56:11 +08:00
" Set the breakpoint by ObjC selector name. " } ,
2010-06-29 05:30:43 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_6 , true , " method " , ' M ' , required_argument , NULL , 0 , eArgTypeMethod ,
2010-08-27 07:56:11 +08:00
" Set the breakpoint by C++ method names. " } ,
2010-06-29 05:30:43 +08:00
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_7 , true , " func-regex " , ' r ' , required_argument , NULL , 0 , eArgTypeRegularExpression ,
2010-06-09 00:52:24 +08:00
" Set the breakpoint by function name, evaluating a regular-expression to find the function name(s). " } ,
2010-10-12 12:29:14 +08:00
{ LLDB_OPT_SET_8 , true , " basename " , ' b ' , required_argument , NULL , CommandCompletions : : eSymbolCompletion , eArgTypeFunctionName ,
" Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). " } ,
2011-09-21 09:17:13 +08:00
{ LLDB_OPT_SET_9 , true , " source-pattern-regexp " , ' p ' , required_argument , NULL , 0 , eArgTypeRegularExpression ,
" Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file. " } ,
2010-10-02 03:59:14 +08:00
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
2010-06-09 00:52:24 +08:00
} ;
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-06-09 00:52:24 +08:00
CommandObjectBreakpointSet : : CommandOptions : : GetDefinitions ( )
{
return g_option_table ;
}
Error
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointSet : : CommandOptions : : SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-06-09 00:52:24 +08:00
{
Error error ;
char short_option = ( char ) m_getopt_table [ option_idx ] . val ;
switch ( short_option )
{
case ' a ' :
2011-03-22 09:53:33 +08:00
m_load_addr = Args : : StringToUInt64 ( option_arg , LLDB_INVALID_ADDRESS , 0 ) ;
2010-06-09 00:52:24 +08:00
if ( m_load_addr = = LLDB_INVALID_ADDRESS )
2011-03-22 09:53:33 +08:00
m_load_addr = Args : : StringToUInt64 ( option_arg , LLDB_INVALID_ADDRESS , 16 ) ;
2010-06-09 00:52:24 +08:00
if ( m_load_addr = = LLDB_INVALID_ADDRESS )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid address string '%s'. \n " , option_arg ) ;
2010-06-09 00:52:24 +08:00
break ;
case ' c ' :
m_column = Args : : StringToUInt32 ( option_arg , 0 ) ;
break ;
2010-06-29 05:30:43 +08:00
2010-06-09 00:52:24 +08:00
case ' f ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_filename . assign ( option_arg ) ;
2010-06-09 00:52:24 +08:00
break ;
2010-06-29 05:30:43 +08:00
2010-06-09 00:52:24 +08:00
case ' l ' :
m_line_num = Args : : StringToUInt32 ( option_arg , 0 ) ;
break ;
2010-06-29 05:30:43 +08:00
2010-10-12 12:29:14 +08:00
case ' b ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_name . assign ( option_arg ) ;
2010-06-29 05:30:43 +08:00
m_func_name_type_mask | = eFunctionNameTypeBase ;
break ;
2010-10-12 12:29:14 +08:00
case ' n ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_name . assign ( option_arg ) ;
2010-10-12 12:29:14 +08:00
m_func_name_type_mask | = eFunctionNameTypeAuto ;
break ;
2010-06-29 05:30:43 +08:00
case ' F ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_name . assign ( option_arg ) ;
2010-06-29 05:30:43 +08:00
m_func_name_type_mask | = eFunctionNameTypeFull ;
break ;
case ' S ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_name . assign ( option_arg ) ;
2010-06-29 05:30:43 +08:00
m_func_name_type_mask | = eFunctionNameTypeSelector ;
break ;
2010-08-27 07:56:11 +08:00
case ' M ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_name . assign ( option_arg ) ;
2010-06-29 05:30:43 +08:00
m_func_name_type_mask | = eFunctionNameTypeMethod ;
break ;
2011-09-21 09:17:13 +08:00
case ' p ' :
m_source_text_regexp . assign ( option_arg ) ;
break ;
2010-06-09 00:52:24 +08:00
case ' r ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_func_regexp . assign ( option_arg ) ;
2010-06-09 00:52:24 +08:00
break ;
2010-06-29 05:30:43 +08:00
2010-06-09 00:52:24 +08:00
case ' s ' :
{
m_modules . push_back ( std : : string ( option_arg ) ) ;
break ;
}
2010-09-18 11:37:20 +08:00
case ' i ' :
2010-06-16 10:00:15 +08:00
{
2011-03-22 09:53:33 +08:00
m_ignore_count = Args : : StringToUInt32 ( option_arg , UINT32_MAX , 0 ) ;
2010-07-10 04:39:50 +08:00
if ( m_ignore_count = = UINT32_MAX )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid ignore count '%s'. \n " , option_arg ) ;
2010-06-16 10:00:15 +08:00
}
2010-06-18 08:58:52 +08:00
break ;
2010-06-16 10:00:15 +08:00
case ' t ' :
{
2011-03-22 09:53:33 +08:00
m_thread_id = Args : : StringToUInt64 ( option_arg , LLDB_INVALID_THREAD_ID , 0 ) ;
2010-06-16 10:00:15 +08:00
if ( m_thread_id = = LLDB_INVALID_THREAD_ID )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid thread id string '%s'. \n " , option_arg ) ;
2010-06-16 10:00:15 +08:00
}
break ;
case ' T ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_thread_name . assign ( option_arg ) ;
2010-06-16 10:00:15 +08:00
break ;
case ' q ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_queue_name . assign ( option_arg ) ;
2010-06-16 10:00:15 +08:00
break ;
case ' x ' :
{
2011-03-22 09:53:33 +08:00
m_thread_index = Args : : StringToUInt32 ( option_arg , UINT32_MAX , 0 ) ;
2010-07-10 04:39:50 +08:00
if ( m_thread_id = = UINT32_MAX )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid thread index string '%s'. \n " , option_arg ) ;
2010-06-16 10:00:15 +08:00
}
break ;
2010-06-09 00:52:24 +08:00
default :
error . SetErrorStringWithFormat ( " Unrecognized option '%c'. \n " , short_option ) ;
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointSet : : CommandOptions : : OptionParsingStarting ( )
2010-06-09 00:52:24 +08:00
{
m_filename . clear ( ) ;
m_line_num = 0 ;
m_column = 0 ;
m_func_name . clear ( ) ;
2010-06-29 05:30:43 +08:00
m_func_name_type_mask = 0 ;
2010-06-09 00:52:24 +08:00
m_func_regexp . clear ( ) ;
m_load_addr = LLDB_INVALID_ADDRESS ;
m_modules . clear ( ) ;
2010-07-10 04:39:50 +08:00
m_ignore_count = 0 ;
2010-06-16 10:00:15 +08:00
m_thread_id = LLDB_INVALID_THREAD_ID ;
2010-07-10 04:39:50 +08:00
m_thread_index = UINT32_MAX ;
2010-06-16 10:00:15 +08:00
m_thread_name . clear ( ) ;
m_queue_name . clear ( ) ;
2010-06-09 00:52:24 +08:00
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointSet
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Set
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointSet : : CommandObjectBreakpointSet ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" breakpoint set " ,
" Sets a breakpoint or set of breakpoints in the executable. " ,
2011-04-08 06:46:35 +08:00
" breakpoint set <cmd-options> " ) ,
m_options ( interpreter )
2010-06-09 00:52:24 +08:00
{
}
CommandObjectBreakpointSet : : ~ CommandObjectBreakpointSet ( )
{
}
Options *
CommandObjectBreakpointSet : : GetOptions ( )
{
return & m_options ;
}
2011-09-21 09:17:13 +08:00
bool
CommandObjectBreakpointSet : : ChooseFile ( Target * target , FileSpec & file , CommandReturnObject & result )
{
if ( m_options . m_filename . empty ( ) )
{
uint32_t default_line ;
// First use the Source Manager's default file.
// Then use the current stack frame's file.
if ( ! target - > GetSourceManager ( ) . GetDefaultFileAndLine ( file , default_line ) )
{
2011-09-22 12:58:26 +08:00
StackFrame * cur_frame = m_interpreter . GetExecutionContext ( ) . GetFramePtr ( ) ;
2011-09-21 09:17:13 +08:00
if ( cur_frame = = NULL )
{
result . AppendError ( " Attempting to set breakpoint by line number alone with no selected frame. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
else if ( ! cur_frame - > HasDebugInformation ( ) )
{
result . AppendError ( " Attempting to set breakpoint by line number alone but selected frame 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 ( " Attempting to set breakpoint by line number alone but can't find the file for the selected frame. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
}
}
else
{
file . SetFile ( m_options . m_filename . c_str ( ) , false ) ;
}
return true ;
}
2010-06-09 00:52:24 +08:00
bool
CommandObjectBreakpointSet : : Execute
(
Args & command ,
CommandReturnObject & result
)
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
if ( target = = NULL )
{
2011-05-04 06:09:39 +08:00
result . AppendError ( " Invalid target. Must set target before setting breakpoints (see 'target create' command). " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
// 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)
2011-09-21 09:17:13 +08:00
// 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
2010-06-09 00:52:24 +08:00
BreakpointSetType break_type = eSetTypeInvalid ;
if ( m_options . m_line_num ! = 0 )
break_type = eSetTypeFileAndLine ;
else if ( m_options . m_load_addr ! = LLDB_INVALID_ADDRESS )
break_type = eSetTypeAddress ;
else if ( ! m_options . m_func_name . empty ( ) )
break_type = eSetTypeFunctionName ;
else if ( ! m_options . m_func_regexp . empty ( ) )
break_type = eSetTypeFunctionRegexp ;
2011-09-21 09:17:13 +08:00
else if ( ! m_options . m_source_text_regexp . empty ( ) )
break_type = eSetTypeSourceRegexp ;
2010-06-09 00:52:24 +08:00
Breakpoint * bp = NULL ;
2010-10-21 04:54:39 +08:00
FileSpec module_spec ;
2010-06-09 00:52:24 +08:00
bool use_module = false ;
int num_modules = m_options . m_modules . size ( ) ;
2011-09-21 09:17:13 +08:00
FileSpecList module_spec_list ;
FileSpecList * module_spec_list_ptr = NULL ;
2010-06-09 00:52:24 +08:00
if ( ( num_modules > 0 ) & & ( break_type ! = eSetTypeAddress ) )
use_module = true ;
2011-09-21 09:17:13 +08:00
if ( use_module )
{
module_spec_list_ptr = & module_spec_list ;
for ( int i = 0 ; i < num_modules ; + + i )
{
module_spec . SetFile ( m_options . m_modules [ i ] . c_str ( ) , false ) ;
module_spec_list . AppendIfUnique ( module_spec ) ;
}
}
2010-06-16 10:00:15 +08:00
2010-06-09 00:52:24 +08:00
switch ( break_type )
{
case eSetTypeFileAndLine : // Breakpoint by source position
{
2010-10-11 09:05:37 +08:00
FileSpec file ;
2011-09-21 09:17:13 +08:00
if ( ! ChooseFile ( target , file , result ) )
break ;
bp = target - > CreateBreakpoint ( module_spec_list_ptr ,
file ,
m_options . m_line_num ,
m_options . m_check_inlines ) . get ( ) ;
2010-06-09 00:52:24 +08:00
}
2010-10-11 09:05:37 +08:00
break ;
2010-06-09 00:52:24 +08:00
case eSetTypeAddress : // Breakpoint by address
bp = target - > CreateBreakpoint ( m_options . m_load_addr , false ) . get ( ) ;
break ;
2010-06-29 05:30:43 +08:00
2010-06-09 00:52:24 +08:00
case eSetTypeFunctionName : // Breakpoint by function name
{
2010-06-29 05:30:43 +08:00
uint32_t name_type_mask = m_options . m_func_name_type_mask ;
if ( name_type_mask = = 0 )
2010-10-12 12:29:14 +08:00
name_type_mask = eFunctionNameTypeAuto ;
2011-09-21 09:17:13 +08:00
bp = target - > CreateBreakpoint ( module_spec_list_ptr ,
m_options . m_func_name . c_str ( ) ,
name_type_mask ,
Breakpoint : : Exact ) . get ( ) ;
2010-06-09 00:52:24 +08:00
}
break ;
2010-06-29 05:30:43 +08:00
2010-06-09 00:52:24 +08:00
case eSetTypeFunctionRegexp : // Breakpoint by regular expression function name
{
RegularExpression regexp ( m_options . m_func_regexp . c_str ( ) ) ;
2011-09-21 09:17:13 +08:00
if ( ! regexp . IsValid ( ) )
2010-06-09 00:52:24 +08:00
{
2011-09-21 09:17:13 +08:00
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 ;
2010-06-09 00:52:24 +08:00
}
2011-09-21 09:17:13 +08:00
bp = target - > CreateBreakpoint ( module_spec_list_ptr , regexp ) . get ( ) ;
2010-06-09 00:52:24 +08:00
}
break ;
2011-09-21 09:17:13 +08:00
case eSetTypeSourceRegexp : // Breakpoint by regexp on source text.
{
FileSpec file ;
if ( ! ChooseFile ( target , file , result ) )
break ;
2010-06-29 05:30:43 +08:00
2011-09-21 09:17:13 +08:00
RegularExpression regexp ( m_options . m_source_text_regexp . c_str ( ) ) ;
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 ;
}
bp = target - > CreateBreakpoint ( module_spec_list_ptr , file , regexp ) . get ( ) ;
}
break ;
2010-06-09 00:52:24 +08:00
default :
break ;
}
2010-06-16 10:00:15 +08:00
// Now set the various options that were passed in:
if ( bp )
{
if ( m_options . m_thread_id ! = LLDB_INVALID_THREAD_ID )
bp - > SetThreadID ( m_options . m_thread_id ) ;
2010-07-10 04:39:50 +08:00
if ( m_options . m_thread_index ! = UINT32_MAX )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetIndex ( m_options . m_thread_index ) ;
if ( ! m_options . m_thread_name . empty ( ) )
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetName ( m_options . m_thread_name . c_str ( ) ) ;
if ( ! m_options . m_queue_name . empty ( ) )
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetQueueName ( m_options . m_queue_name . c_str ( ) ) ;
2010-07-10 04:39:50 +08:00
if ( m_options . m_ignore_count ! = 0 )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > SetIgnoreCount ( m_options . m_ignore_count ) ;
}
2011-09-21 09:17:13 +08:00
if ( bp )
2010-06-09 00:52:24 +08:00
{
2011-02-19 10:53:09 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
2010-06-09 00:52:24 +08:00
output_stream . Printf ( " Breakpoint created: " ) ;
bp - > GetDescription ( & output_stream , lldb : : eDescriptionLevelBrief ) ;
output_stream . EOL ( ) ;
2010-10-29 00:28:56 +08:00
if ( bp - > GetNumLocations ( ) = = 0 )
output_stream . Printf ( " WARNING: Unable to resolve breakpoint to any actual locations. \n " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else if ( ! bp )
{
result . AppendError ( " Breakpoint creation failed: No breakpoint created. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
//-------------------------------------------------------------------------
// CommandObjectMultiwordBreakpoint
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark MultiwordBreakpoint
2010-06-09 00:52:24 +08:00
2010-06-23 09:19:29 +08:00
CommandObjectMultiwordBreakpoint : : CommandObjectMultiwordBreakpoint ( CommandInterpreter & interpreter ) :
2010-09-18 09:14:36 +08:00
CommandObjectMultiword ( interpreter ,
" breakpoint " ,
2011-05-27 04:39:01 +08:00
" A set of commands for operating on breakpoints. Also see _regexp-break. " ,
2010-09-18 09:14:36 +08:00
" breakpoint <command> [<command-options>] " )
2010-06-09 00:52:24 +08:00
{
bool status ;
2010-09-18 09:14:36 +08:00
CommandObjectSP list_command_object ( new CommandObjectBreakpointList ( interpreter ) ) ;
CommandObjectSP enable_command_object ( new CommandObjectBreakpointEnable ( interpreter ) ) ;
CommandObjectSP disable_command_object ( new CommandObjectBreakpointDisable ( interpreter ) ) ;
2010-10-29 01:27:46 +08:00
CommandObjectSP clear_command_object ( new CommandObjectBreakpointClear ( interpreter ) ) ;
CommandObjectSP delete_command_object ( new CommandObjectBreakpointDelete ( interpreter ) ) ;
2010-09-18 09:14:36 +08:00
CommandObjectSP set_command_object ( new CommandObjectBreakpointSet ( interpreter ) ) ;
2010-06-09 00:52:24 +08:00
CommandObjectSP command_command_object ( new CommandObjectBreakpointCommand ( interpreter ) ) ;
2010-09-18 09:14:36 +08:00
CommandObjectSP modify_command_object ( new CommandObjectBreakpointModify ( interpreter ) ) ;
2010-06-09 00:52:24 +08:00
2010-10-29 01:27:46 +08:00
list_command_object - > SetCommandName ( " breakpoint list " ) ;
2010-06-09 00:52:24 +08:00
enable_command_object - > SetCommandName ( " breakpoint enable " ) ;
disable_command_object - > SetCommandName ( " breakpoint disable " ) ;
2010-10-29 01:27:46 +08:00
clear_command_object - > SetCommandName ( " breakpoint clear " ) ;
delete_command_object - > SetCommandName ( " breakpoint delete " ) ;
2010-06-18 08:58:52 +08:00
set_command_object - > SetCommandName ( " breakpoint set " ) ;
2010-10-29 01:27:46 +08:00
command_command_object - > SetCommandName ( " breakpoint command " ) ;
modify_command_object - > SetCommandName ( " breakpoint modify " ) ;
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
status = LoadSubCommand ( " list " , list_command_object ) ;
status = LoadSubCommand ( " enable " , enable_command_object ) ;
status = LoadSubCommand ( " disable " , disable_command_object ) ;
2010-10-29 01:27:46 +08:00
status = LoadSubCommand ( " clear " , clear_command_object ) ;
2010-09-18 09:14:36 +08:00
status = LoadSubCommand ( " delete " , delete_command_object ) ;
status = LoadSubCommand ( " set " , set_command_object ) ;
status = LoadSubCommand ( " command " , command_command_object ) ;
status = LoadSubCommand ( " modify " , modify_command_object ) ;
2010-06-09 00:52:24 +08:00
}
CommandObjectMultiwordBreakpoint : : ~ CommandObjectMultiwordBreakpoint ( )
{
}
void
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( Args & args , Target * target , CommandReturnObject & result ,
BreakpointIDList * valid_ids )
{
// 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.
2010-10-15 07:45:03 +08:00
// If args is empty, we will use the last created breakpoint (if there is one.)
2010-06-09 00:52:24 +08:00
Args temp_args ;
2010-10-15 07:45:03 +08:00
if ( args . GetArgumentCount ( ) = = 0 )
{
2011-09-17 16:33:22 +08:00
if ( target - > GetLastCreatedBreakpoint ( ) )
2010-10-15 07:45:03 +08:00
{
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 ) ;
}
return ;
}
2010-06-09 00:52:24 +08:00
// Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff 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.
BreakpointIDList : : FindAndReplaceIDRanges ( args , target , result , temp_args ) ;
// NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
2010-07-10 04:39:50 +08:00
valid_ids - > InsertStringArray ( temp_args . GetConstArgumentVector ( ) , temp_args . GetArgumentCount ( ) , result ) ;
2010-06-09 00:52:24 +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.
if ( result . Succeeded ( ) )
{
// Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
// of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
2010-07-10 04:39:50 +08:00
const size_t count = valid_ids - > GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
2010-06-09 00:52:24 +08:00
{
BreakpointID cur_bp_id = valid_ids - > GetBreakpointIDAtIndex ( i ) ;
Breakpoint * breakpoint = target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
if ( breakpoint ! = NULL )
{
int num_locations = breakpoint - > GetNumLocations ( ) ;
if ( cur_bp_id . GetLocationID ( ) > num_locations )
{
StreamString id_str ;
2010-07-10 04:39:50 +08:00
BreakpointID : : GetCanonicalReference ( & id_str ,
cur_bp_id . GetBreakpointID ( ) ,
cur_bp_id . GetLocationID ( ) ) ;
i = valid_ids - > GetSize ( ) + 1 ;
2010-06-09 00:52:24 +08:00
result . AppendErrorWithFormat ( " '%s' is not a currently valid breakpoint/location id. \n " ,
id_str . GetData ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
2010-07-10 04:39:50 +08:00
i = valid_ids - > GetSize ( ) + 1 ;
2010-06-09 00:52:24 +08:00
result . AppendErrorWithFormat ( " '%d' is not a currently valid breakpoint id. \n " , cur_bp_id . GetBreakpointID ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
}
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointList::Options
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark List::CommandOptions
2010-06-09 00:52:24 +08:00
2011-04-08 06:46:35 +08:00
CommandObjectBreakpointList : : CommandOptions : : CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter ) ,
2011-02-05 06:59:41 +08:00
m_level ( lldb : : eDescriptionLevelBrief ) // Breakpoint List defaults to brief descriptions
2010-06-09 00:52:24 +08:00
{
}
CommandObjectBreakpointList : : CommandOptions : : ~ CommandOptions ( )
{
}
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-06-09 00:52:24 +08:00
CommandObjectBreakpointList : : CommandOptions : : g_option_table [ ] =
{
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " internal " , ' i ' , no_argument , NULL , 0 , eArgTypeNone ,
2010-06-16 02:47:14 +08:00
" Show debugger internal breakpoints " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_1 , false , " brief " , ' b ' , no_argument , NULL , 0 , eArgTypeNone ,
2010-06-09 00:52:24 +08:00
" Give a brief description of the breakpoint (no location info). " } ,
// 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.
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_2 , false , " full " , ' f ' , no_argument , NULL , 0 , eArgTypeNone ,
2010-06-09 00:52:24 +08:00
" Give a full description of the breakpoint and its locations. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_3 , false , " verbose " , ' v ' , no_argument , NULL , 0 , eArgTypeNone ,
2010-06-09 00:52:24 +08:00
" Explain everything we know about the breakpoint (for debugging debugger bugs). " } ,
2010-10-02 03:59:14 +08:00
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
2010-06-09 00:52:24 +08:00
} ;
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-06-09 00:52:24 +08:00
CommandObjectBreakpointList : : CommandOptions : : GetDefinitions ( )
{
return g_option_table ;
}
Error
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointList : : CommandOptions : : SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-06-09 00:52:24 +08:00
{
Error error ;
char short_option = ( char ) m_getopt_table [ option_idx ] . val ;
switch ( short_option )
{
case ' b ' :
m_level = lldb : : eDescriptionLevelBrief ;
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'. \n " , short_option ) ;
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointList : : CommandOptions : : OptionParsingStarting ( )
2010-06-09 00:52:24 +08:00
{
2011-05-17 09:21:41 +08:00
m_level = lldb : : eDescriptionLevelFull ;
2010-06-09 00:52:24 +08:00
m_internal = false ;
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointList
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark List
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointList : : CommandObjectBreakpointList ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" breakpoint list " ,
" List some or all breakpoints at configurable levels of detail. " ,
2011-04-08 06:46:35 +08:00
NULL ) ,
m_options ( interpreter )
2010-06-09 00:52:24 +08:00
{
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
CommandArgumentEntry arg ;
CommandArgumentData bp_id_arg ;
// Define the first (and only) variant of this arg.
bp_id_arg . arg_type = eArgTypeBreakpointID ;
2010-10-05 06:28:36 +08:00
bp_id_arg . arg_repetition = eArgRepeatOptional ;
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
// 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 ) ;
2010-06-09 00:52:24 +08:00
}
CommandObjectBreakpointList : : ~ CommandObjectBreakpointList ( )
{
}
Options *
CommandObjectBreakpointList : : GetOptions ( )
{
return & m_options ;
}
bool
CommandObjectBreakpointList : : Execute
(
Args & args ,
CommandReturnObject & result
)
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
if ( target = = NULL )
{
2010-09-30 03:42:33 +08:00
result . AppendError ( " Invalid target. No current target or breakpoints. " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
return true ;
}
const BreakpointList & breakpoints = target - > GetBreakpointList ( m_options . m_internal ) ;
2010-06-16 10:00:15 +08:00
Mutex : : Locker locker ;
target - > GetBreakpointList ( m_options . m_internal ) . GetListMutex ( locker ) ;
2010-06-09 00:52:24 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 )
{
result . AppendMessage ( " No breakpoints currently set. " ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
return true ;
}
2011-02-19 10:53:09 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
2010-06-09 00:52:24 +08:00
if ( args . GetArgumentCount ( ) = = 0 )
{
// No breakpoint selected; show info about all currently set breakpoints.
result . AppendMessage ( " Current breakpoints: " ) ;
2010-07-10 04:39:50 +08:00
for ( size_t i = 0 ; i < num_breakpoints ; + + i )
2010-06-09 00:52:24 +08:00
{
2010-07-24 07:33:17 +08:00
Breakpoint * breakpoint = breakpoints . GetBreakpointAtIndex ( i ) . get ( ) ;
2010-06-23 09:19:29 +08:00
AddBreakpointDescription ( & output_stream , breakpoint , m_options . m_level ) ;
2010-06-09 00:52:24 +08:00
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
// Particular breakpoints selected; show info about that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( args , target , result , & valid_bp_ids ) ;
if ( result . Succeeded ( ) )
{
2010-07-10 04:39:50 +08:00
for ( size_t i = 0 ; i < valid_bp_ids . GetSize ( ) ; + + i )
2010-06-09 00:52:24 +08:00
{
BreakpointID cur_bp_id = valid_bp_ids . GetBreakpointIDAtIndex ( i ) ;
Breakpoint * breakpoint = target - > GetBreakpointByID ( cur_bp_id . GetBreakpointID ( ) ) . get ( ) ;
2010-06-23 09:19:29 +08:00
AddBreakpointDescription ( & output_stream , breakpoint , m_options . m_level ) ;
2010-06-09 00:52:24 +08:00
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
result . AppendError ( " Invalid breakpoint id. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
return result . Succeeded ( ) ;
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointEnable
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Enable
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointEnable : : CommandObjectBreakpointEnable ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" enable " ,
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
" Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them. " ,
NULL )
2010-06-09 00:52:24 +08:00
{
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
CommandArgumentEntry arg ;
2011-09-21 09:00:02 +08:00
CommandObject : : AddIDsArgumentData ( arg ) ;
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
// 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
}
CommandObjectBreakpointEnable : : ~ CommandObjectBreakpointEnable ( )
{
}
bool
2010-06-23 09:19:29 +08:00
CommandObjectBreakpointEnable : : Execute
(
Args & args ,
CommandReturnObject & result
)
2010-06-09 00:52:24 +08:00
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
if ( target = = NULL )
{
2010-09-30 03:42:33 +08:00
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-16 10:00:15 +08:00
Mutex : : Locker locker ;
target - > GetBreakpointList ( ) . GetListMutex ( locker ) ;
2010-06-09 00:52:24 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2010-06-16 10:00:15 +08:00
2010-06-09 00:52:24 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 )
{
result . AppendError ( " No breakpoints exist to be enabled. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( args . GetArgumentCount ( ) = = 0 )
{
// No breakpoint selected; enable all currently set breakpoints.
target - > EnableAllBreakpoints ( ) ;
2011-09-21 05:44:10 +08:00
result . AppendMessageWithFormat ( " All breakpoints enabled. (%lu breakpoints) \n " , num_breakpoints ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
// Particular breakpoint selected; enable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( args , target , result , & valid_bp_ids ) ;
if ( result . Succeeded ( ) )
{
int enable_count = 0 ;
int loc_count = 0 ;
2010-07-10 04:39:50 +08:00
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
2010-06-09 00:52:24 +08:00
{
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
{
2010-06-18 08:58:52 +08:00
breakpoint - > SetEnabled ( true ) ;
2010-06-09 00:52:24 +08:00
+ + enable_count ;
}
}
}
result . AppendMessageWithFormat ( " %d breakpoints enabled. \n " , enable_count + loc_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
}
return result . Succeeded ( ) ;
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointDisable
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Disable
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointDisable : : CommandObjectBreakpointDisable ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
" breakpoint disable " ,
2010-09-09 05:06:11 +08:00
" Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all. " ,
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
NULL )
2010-06-09 00:52:24 +08:00
{
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
CommandArgumentEntry arg ;
2011-09-21 09:00:02 +08:00
CommandObject : : AddIDsArgumentData ( arg ) ;
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
// 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
}
CommandObjectBreakpointDisable : : ~ CommandObjectBreakpointDisable ( )
{
}
bool
2010-06-23 09:19:29 +08:00
CommandObjectBreakpointDisable : : Execute
(
Args & args ,
CommandReturnObject & result
)
2010-06-09 00:52:24 +08:00
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
if ( target = = NULL )
{
2010-09-30 03:42:33 +08:00
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-16 10:00:15 +08:00
Mutex : : Locker locker ;
target - > GetBreakpointList ( ) . GetListMutex ( locker ) ;
2010-06-09 00:52:24 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 )
{
result . AppendError ( " No breakpoints exist to be disabled. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( args . GetArgumentCount ( ) = = 0 )
{
// No breakpoint selected; disable all currently set breakpoints.
target - > DisableAllBreakpoints ( ) ;
2011-09-21 05:44:10 +08:00
result . AppendMessageWithFormat ( " All breakpoints disabled. (%lu breakpoints) \n " , num_breakpoints ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( args , target , result , & valid_bp_ids ) ;
if ( result . Succeeded ( ) )
{
int disable_count = 0 ;
int loc_count = 0 ;
2010-07-10 04:39:50 +08:00
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
2010-06-09 00:52:24 +08:00
{
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
{
2010-06-18 08:58:52 +08:00
breakpoint - > SetEnabled ( false ) ;
2010-06-09 00:52:24 +08:00
+ + disable_count ;
}
}
}
result . AppendMessageWithFormat ( " %d breakpoints disabled. \n " , disable_count + loc_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
}
return result . Succeeded ( ) ;
}
2010-10-29 01:27:46 +08:00
//-------------------------------------------------------------------------
// CommandObjectBreakpointClear::CommandOptions
//-------------------------------------------------------------------------
# pragma mark Clear::CommandOptions
2011-04-08 06:46:35 +08:00
CommandObjectBreakpointClear : : CommandOptions : : CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter ) ,
2010-10-29 01:27:46 +08:00
m_filename ( ) ,
m_line_num ( 0 )
{
}
CommandObjectBreakpointClear : : CommandOptions : : ~ CommandOptions ( )
{
}
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-10-29 01:27:46 +08:00
CommandObjectBreakpointClear : : CommandOptions : : g_option_table [ ] =
{
{ LLDB_OPT_SET_1 , false , " file " , ' f ' , required_argument , NULL , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename ,
" Specify the breakpoint by source location in this particular file. " } ,
{ LLDB_OPT_SET_1 , true , " line " , ' l ' , required_argument , NULL , 0 , eArgTypeLineNum ,
" Specify the breakpoint by source location at this particular line. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
} ;
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-10-29 01:27:46 +08:00
CommandObjectBreakpointClear : : CommandOptions : : GetDefinitions ( )
{
return g_option_table ;
}
Error
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointClear : : CommandOptions : : SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-10-29 01:27:46 +08:00
{
Error error ;
char short_option = ( char ) m_getopt_table [ option_idx ] . val ;
switch ( short_option )
{
case ' f ' :
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_filename . assign ( option_arg ) ;
2010-10-29 01:27:46 +08:00
break ;
case ' l ' :
m_line_num = Args : : StringToUInt32 ( option_arg , 0 ) ;
break ;
default :
error . SetErrorStringWithFormat ( " Unrecognized option '%c'. \n " , short_option ) ;
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointClear : : CommandOptions : : OptionParsingStarting ( )
2010-10-29 01:27:46 +08:00
{
m_filename . clear ( ) ;
m_line_num = 0 ;
}
//-------------------------------------------------------------------------
// CommandObjectBreakpointClear
//-------------------------------------------------------------------------
# pragma mark Clear
CommandObjectBreakpointClear : : CommandObjectBreakpointClear ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" breakpoint clear " ,
" Clears a breakpoint or set of breakpoints in the executable. " ,
2011-04-08 06:46:35 +08:00
" breakpoint clear <cmd-options> " ) ,
m_options ( interpreter )
2010-10-29 01:27:46 +08:00
{
}
CommandObjectBreakpointClear : : ~ CommandObjectBreakpointClear ( )
{
}
Options *
CommandObjectBreakpointClear : : GetOptions ( )
{
return & m_options ;
}
bool
CommandObjectBreakpointClear : : Execute
(
Args & command ,
CommandReturnObject & result
)
{
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
if ( target = = NULL )
{
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
// The following are the various types of breakpoints that could be cleared:
// 1). -f -l (clearing breakpoint by source location)
BreakpointClearType break_type = eClearTypeInvalid ;
if ( m_options . m_line_num ! = 0 )
break_type = eClearTypeFileAndLine ;
Mutex : : Locker locker ;
target - > GetBreakpointList ( ) . GetListMutex ( locker ) ;
BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
size_t num_breakpoints = breakpoints . GetSize ( ) ;
// 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 ( ) ;
}
// Find matching breakpoints and delete them.
// 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 ) . get ( ) - > 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 ;
}
if ( num_cleared > 0 )
{
2011-02-19 10:53:09 +08:00
Stream & output_stream = result . GetOutputStream ( ) ;
2010-10-29 01:27:46 +08:00
output_stream . Printf ( " %d breakpoints cleared: \n " , num_cleared ) ;
output_stream < < ss . GetData ( ) ;
output_stream . EOL ( ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
result . AppendError ( " Breakpoint clear: No breakpoint cleared. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
// CommandObjectBreakpointDelete
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Delete
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointDelete : : CommandObjectBreakpointDelete ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" breakpoint delete " ,
2010-09-09 05:06:11 +08:00
" Delete the specified breakpoint(s). If no breakpoints are specified, delete them all. " ,
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
NULL )
2010-06-09 00:52:24 +08:00
{
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
CommandArgumentEntry arg ;
2011-09-21 09:00:02 +08:00
CommandObject : : AddIDsArgumentData ( arg ) ;
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
// 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
}
CommandObjectBreakpointDelete : : ~ CommandObjectBreakpointDelete ( )
{
}
bool
2010-06-23 09:19:29 +08:00
CommandObjectBreakpointDelete : : Execute
(
Args & args ,
CommandReturnObject & result
)
2010-06-09 00:52:24 +08:00
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
if ( target = = NULL )
{
2010-09-30 03:42:33 +08:00
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
2010-06-09 00:52:24 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-06-16 10:00:15 +08:00
Mutex : : Locker locker ;
target - > GetBreakpointList ( ) . GetListMutex ( locker ) ;
2010-06-09 00:52:24 +08:00
const BreakpointList & breakpoints = target - > GetBreakpointList ( ) ;
2010-06-16 10:00:15 +08:00
2010-06-09 00:52:24 +08:00
size_t num_breakpoints = breakpoints . GetSize ( ) ;
if ( num_breakpoints = = 0 )
{
result . AppendError ( " No breakpoints exist to be deleted. " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( args . GetArgumentCount ( ) = = 0 )
{
2010-10-15 07:45:03 +08:00
if ( ! m_interpreter . Confirm ( " About to delete all breakpoints, do you want to do that? " , true ) )
2010-06-09 00:52:24 +08:00
{
2010-10-15 07:45:03 +08:00
result . AppendMessage ( " Operation cancelled... " ) ;
}
else
{
target - > RemoveAllBreakpoints ( ) ;
2011-09-21 05:44:10 +08:00
result . AppendMessageWithFormat ( " All breakpoints removed. (%lu breakpoints) \n " , num_breakpoints ) ;
2010-06-09 00:52:24 +08:00
}
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( args , target , result , & valid_bp_ids ) ;
if ( result . Succeeded ( ) )
{
int delete_count = 0 ;
int disable_count = 0 ;
2010-07-10 04:39:50 +08:00
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
2010-06-09 00:52:24 +08:00
{
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 ;
}
}
}
result . AppendMessageWithFormat ( " %d breakpoints deleted; %d breakpoint locations disabled. \n " ,
delete_count , disable_count ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
}
return result . Succeeded ( ) ;
}
2010-06-16 10:00:15 +08:00
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
// CommandObjectBreakpointModify::CommandOptions
2010-06-16 10:00:15 +08:00
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Modify::CommandOptions
2010-06-16 10:00:15 +08:00
2011-04-08 06:46:35 +08:00
CommandObjectBreakpointModify : : CommandOptions : : CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter ) ,
2010-07-10 04:39:50 +08:00
m_ignore_count ( 0 ) ,
2010-06-16 10:00:15 +08:00
m_thread_id ( LLDB_INVALID_THREAD_ID ) ,
2010-12-04 07:04:19 +08:00
m_thread_id_passed ( false ) ,
2010-07-10 04:39:50 +08:00
m_thread_index ( UINT32_MAX ) ,
2010-12-04 07:04:19 +08:00
m_thread_index_passed ( false ) ,
2010-06-16 10:00:15 +08:00
m_thread_name ( ) ,
m_queue_name ( ) ,
2010-10-15 07:45:03 +08:00
m_condition ( ) ,
2010-07-10 04:39:50 +08:00
m_enable_passed ( false ) ,
m_enable_value ( false ) ,
m_name_passed ( false ) ,
2010-10-15 07:45:03 +08:00
m_queue_passed ( false ) ,
m_condition_passed ( false )
2010-06-16 10:00:15 +08:00
{
}
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : CommandOptions : : ~ CommandOptions ( )
2010-06-16 10:00:15 +08:00
{
}
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : CommandOptions : : g_option_table [ ] =
2010-06-16 10:00:15 +08:00
{
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " ignore-count " , ' i ' , required_argument , NULL , NULL , eArgTypeCount , " Set the number of times this breakpoint is skipped before stopping. " } ,
{ LLDB_OPT_SET_ALL , false , " thread-index " , ' x ' , required_argument , NULL , NULL , eArgTypeThreadIndex , " The breakpoint stops only for the thread whose indeX matches this argument. " } ,
{ LLDB_OPT_SET_ALL , false , " thread-id " , ' t ' , required_argument , NULL , NULL , eArgTypeThreadID , " The breakpoint stops only for the thread whose TID matches this argument. " } ,
{ LLDB_OPT_SET_ALL , false , " thread-name " , ' T ' , required_argument , NULL , NULL , eArgTypeThreadName , " The breakpoint stops only for the thread whose thread name matches this argument. " } ,
{ LLDB_OPT_SET_ALL , false , " queue-name " , ' q ' , required_argument , NULL , NULL , eArgTypeQueueName , " The breakpoint stops only for threads in the queue whose name is given by this argument. " } ,
2010-10-15 07:45:03 +08:00
{ LLDB_OPT_SET_ALL , false , " condition " , ' c ' , required_argument , NULL , NULL , eArgTypeExpression , " The breakpoint stops only if this condition expression evaluates to true. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_1 , false , " enable " , ' e ' , no_argument , NULL , NULL , eArgTypeNone , " Enable the breakpoint. " } ,
{ LLDB_OPT_SET_2 , false , " disable " , ' d ' , no_argument , NULL , NULL , eArgTypeNone , " Disable the breakpoint. " } ,
2010-10-15 07:45:03 +08:00
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
2010-06-16 10:00:15 +08:00
} ;
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : CommandOptions : : GetDefinitions ( )
2010-06-16 10:00:15 +08:00
{
return g_option_table ;
}
Error
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointModify : : CommandOptions : : SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-06-16 10:00:15 +08:00
{
Error error ;
char short_option = ( char ) m_getopt_table [ option_idx ] . val ;
switch ( short_option )
{
2010-10-15 07:45:03 +08:00
case ' c ' :
if ( option_arg ! = NULL )
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_condition . assign ( option_arg ) ;
2010-10-15 07:45:03 +08:00
else
m_condition . clear ( ) ;
m_condition_passed = true ;
break ;
2010-06-18 08:58:52 +08:00
case ' d ' :
m_enable_passed = true ;
m_enable_value = false ;
break ;
case ' e ' :
m_enable_passed = true ;
m_enable_value = true ;
break ;
2010-09-18 11:37:20 +08:00
case ' i ' :
2010-06-16 10:00:15 +08:00
{
2011-03-22 09:53:33 +08:00
m_ignore_count = Args : : StringToUInt32 ( option_arg , UINT32_MAX , 0 ) ;
2010-07-10 04:39:50 +08:00
if ( m_ignore_count = = UINT32_MAX )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid ignore count '%s'. \n " , option_arg ) ;
2010-06-16 10:00:15 +08:00
}
2010-06-18 08:58:52 +08:00
break ;
2010-06-16 10:00:15 +08:00
case ' t ' :
{
2011-03-22 09:53:33 +08:00
if ( option_arg [ 0 ] = = ' \0 ' )
2010-12-04 07:04:19 +08:00
{
m_thread_id = LLDB_INVALID_THREAD_ID ;
m_thread_id_passed = true ;
}
else
{
2011-03-22 09:53:33 +08:00
m_thread_id = Args : : StringToUInt64 ( option_arg , LLDB_INVALID_THREAD_ID , 0 ) ;
2010-12-04 07:04:19 +08:00
if ( m_thread_id = = LLDB_INVALID_THREAD_ID )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid thread id string '%s'. \n " , option_arg ) ;
2010-12-04 07:04:19 +08:00
else
m_thread_id_passed = true ;
}
2010-06-16 10:00:15 +08:00
}
break ;
case ' T ' :
2010-06-19 12:35:20 +08:00
if ( option_arg ! = NULL )
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_thread_name . assign ( option_arg ) ;
2010-06-19 12:35:20 +08:00
else
m_thread_name . clear ( ) ;
m_name_passed = true ;
2010-06-16 10:00:15 +08:00
break ;
case ' q ' :
2010-06-19 12:35:20 +08:00
if ( option_arg ! = NULL )
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
m_queue_name . assign ( option_arg ) ;
2010-06-19 12:35:20 +08:00
else
m_queue_name . clear ( ) ;
m_queue_passed = true ;
2010-06-16 10:00:15 +08:00
break ;
case ' x ' :
{
2011-03-22 09:53:33 +08:00
if ( option_arg [ 0 ] = = ' \n ' )
2010-12-04 07:04:19 +08:00
{
m_thread_index = UINT32_MAX ;
m_thread_index_passed = true ;
}
else
{
2011-03-22 09:53:33 +08:00
m_thread_index = Args : : StringToUInt32 ( option_arg , UINT32_MAX , 0 ) ;
2010-12-04 07:04:19 +08:00
if ( m_thread_id = = UINT32_MAX )
2011-03-22 09:53:33 +08:00
error . SetErrorStringWithFormat ( " Invalid thread index string '%s'. \n " , option_arg ) ;
2010-12-04 07:04:19 +08:00
else
m_thread_index_passed = true ;
}
2010-06-16 10:00:15 +08:00
}
break ;
default :
error . SetErrorStringWithFormat ( " Unrecognized option '%c'. \n " , short_option ) ;
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
CommandObjectBreakpointModify : : CommandOptions : : OptionParsingStarting ( )
2010-06-16 10:00:15 +08:00
{
2010-07-10 04:39:50 +08:00
m_ignore_count = 0 ;
2010-06-16 10:00:15 +08:00
m_thread_id = LLDB_INVALID_THREAD_ID ;
2010-12-04 07:04:19 +08:00
m_thread_id_passed = false ;
2010-07-10 04:39:50 +08:00
m_thread_index = UINT32_MAX ;
2010-12-04 07:04:19 +08:00
m_thread_index_passed = false ;
2010-06-16 10:00:15 +08:00
m_thread_name . clear ( ) ;
m_queue_name . clear ( ) ;
2010-10-15 07:45:03 +08:00
m_condition . clear ( ) ;
2010-06-18 08:58:52 +08:00
m_enable_passed = false ;
2010-06-19 12:35:20 +08:00
m_queue_passed = false ;
m_name_passed = false ;
2010-10-15 07:45:03 +08:00
m_condition_passed = false ;
2010-06-16 10:00:15 +08:00
}
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
// CommandObjectBreakpointModify
2010-06-16 10:00:15 +08:00
//-------------------------------------------------------------------------
2010-06-18 08:58:52 +08:00
# pragma mark Modify
2010-06-16 10:00:15 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectBreakpointModify : : CommandObjectBreakpointModify ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" breakpoint modify " ,
2010-12-04 06:37:19 +08:00
" Modify the options on a breakpoint or set of breakpoints in the executable. "
2010-12-04 07:04:19 +08:00
" 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. " ,
2011-04-08 06:46:35 +08:00
NULL ) ,
m_options ( interpreter )
2010-06-16 10:00:15 +08:00
{
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
CommandArgumentEntry arg ;
2011-09-21 09:00:02 +08:00
CommandObject : : AddIDsArgumentData ( arg ) ;
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
llvm-svn: 115318
2010-10-02 01:46:38 +08:00
// Add the entry for the first argument for this command to the object's arguments vector.
m_arguments . push_back ( arg ) ;
2010-06-16 10:00:15 +08:00
}
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : ~ CommandObjectBreakpointModify ( )
2010-06-16 10:00:15 +08:00
{
}
Options *
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : GetOptions ( )
2010-06-16 10:00:15 +08:00
{
return & m_options ;
}
bool
2010-06-18 08:58:52 +08:00
CommandObjectBreakpointModify : : Execute
2010-06-16 10:00:15 +08:00
(
Args & command ,
CommandReturnObject & result
)
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2010-06-16 10:00:15 +08:00
if ( target = = NULL )
{
2010-09-30 03:42:33 +08:00
result . AppendError ( " Invalid target. No existing target or breakpoints. " ) ;
2010-06-16 10:00:15 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
Mutex : : Locker locker ;
target - > GetBreakpointList ( ) . GetListMutex ( locker ) ;
BreakpointIDList valid_bp_ids ;
CommandObjectMultiwordBreakpoint : : VerifyBreakpointIDs ( command , target , result , & valid_bp_ids ) ;
if ( result . Succeeded ( ) )
{
2010-07-10 04:39:50 +08:00
const size_t count = valid_bp_ids . GetSize ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
2010-06-16 10:00:15 +08:00
{
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 ( ) ;
if ( location )
{
2010-12-04 07:04:19 +08:00
if ( m_options . m_thread_id_passed )
2010-06-16 10:00:15 +08:00
location - > SetThreadID ( m_options . m_thread_id ) ;
2010-12-04 07:04:19 +08:00
if ( m_options . m_thread_index_passed )
2010-06-16 10:00:15 +08:00
location - > GetLocationOptions ( ) - > GetThreadSpec ( ) - > SetIndex ( m_options . m_thread_index ) ;
2010-06-19 12:35:20 +08:00
if ( m_options . m_name_passed )
2010-06-16 10:00:15 +08:00
location - > GetLocationOptions ( ) - > GetThreadSpec ( ) - > SetName ( m_options . m_thread_name . c_str ( ) ) ;
2010-06-19 12:35:20 +08:00
if ( m_options . m_queue_passed )
2010-06-16 10:00:15 +08:00
location - > GetLocationOptions ( ) - > GetThreadSpec ( ) - > SetQueueName ( m_options . m_queue_name . c_str ( ) ) ;
2010-07-10 04:39:50 +08:00
if ( m_options . m_ignore_count ! = 0 )
2010-06-16 10:00:15 +08:00
location - > GetLocationOptions ( ) - > SetIgnoreCount ( m_options . m_ignore_count ) ;
2010-06-18 08:58:52 +08:00
if ( m_options . m_enable_passed )
location - > SetEnabled ( m_options . m_enable_value ) ;
2010-10-15 07:45:03 +08:00
if ( m_options . m_condition_passed )
location - > SetCondition ( m_options . m_condition . c_str ( ) ) ;
2010-06-16 10:00:15 +08:00
}
}
else
{
2010-12-04 07:04:19 +08:00
if ( m_options . m_thread_id_passed )
2010-06-16 10:00:15 +08:00
bp - > SetThreadID ( m_options . m_thread_id ) ;
2010-12-04 07:04:19 +08:00
if ( m_options . m_thread_index_passed )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetIndex ( m_options . m_thread_index ) ;
2010-06-19 12:35:20 +08:00
if ( m_options . m_name_passed )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetName ( m_options . m_thread_name . c_str ( ) ) ;
2010-06-19 12:35:20 +08:00
if ( m_options . m_queue_passed )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > GetThreadSpec ( ) - > SetQueueName ( m_options . m_queue_name . c_str ( ) ) ;
2010-07-10 04:39:50 +08:00
if ( m_options . m_ignore_count ! = 0 )
2010-06-16 10:00:15 +08:00
bp - > GetOptions ( ) - > SetIgnoreCount ( m_options . m_ignore_count ) ;
2010-06-18 08:58:52 +08:00
if ( m_options . m_enable_passed )
bp - > SetEnabled ( m_options . m_enable_value ) ;
2010-10-15 07:45:03 +08:00
if ( m_options . m_condition_passed )
bp - > SetCondition ( m_options . m_condition . c_str ( ) ) ;
2010-06-16 10:00:15 +08:00
}
}
}
}
return result . Succeeded ( ) ;
}