124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===// 224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// 324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// The LLVM Compiler Infrastructure 424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// 524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// This file is distributed under the University of Illinois Open Source 624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// License. See LICENSE.TXT for details. 724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// 824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//===----------------------------------------------------------------------===// 924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 10d891f9b872103235cfd2ed452c6f14a4394d9b3aDaniel Malea#include "lldb/lldb-python.h" 11d891f9b872103235cfd2ed452c6f14a4394d9b3aDaniel Malea 1224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "CommandObjectBreakpoint.h" 1324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "CommandObjectBreakpointCommand.h" 1424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// C Includes 1624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// C++ Includes 1724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// Other libraries and framework includes 1824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// Project includes 1924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Breakpoint/Breakpoint.h" 2024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Breakpoint/BreakpointIDList.h" 2124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Breakpoint/BreakpointLocation.h" 2284cdc15005983e5244d665fa779e33c2b6fac95fJim Ingham#include "lldb/Interpreter/Options.h" 2324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Core/RegularExpression.h" 2424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Core/StreamString.h" 2524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Interpreter/CommandInterpreter.h" 2624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Interpreter/CommandReturnObject.h" 2724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Target/Target.h" 2824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Interpreter/CommandCompletions.h" 2924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Target/StackFrame.h" 303c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham#include "lldb/Target/Thread.h" 313c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham#include "lldb/Target/ThreadSpec.h" 3224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 33a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen#include <vector> 34a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 3524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnerusing namespace lldb; 3624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnerusing namespace lldb_private; 3724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 3824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnerstatic void 392e8cb8a7342a2ea672792067d712a794e215a3a7Jim InghamAddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) 4024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 4124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner s->IndentMore(); 4224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner bp->GetDescription (s, level, true); 4324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner s->IndentLess(); 4424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner s->EOL(); 4524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner} 4624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 4724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 48da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectBreakpointSet 4924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 5024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 51da26bd203cbb104291b39891febf7481794f205fJim Ingham 52da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointSet : public CommandObjectParsed 5324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 54da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 55da26bd203cbb104291b39891febf7481794f205fJim Ingham 56da26bd203cbb104291b39891febf7481794f205fJim Ingham typedef enum BreakpointSetType 57da26bd203cbb104291b39891febf7481794f205fJim Ingham { 58da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeInvalid, 59da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeFileAndLine, 60da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeAddress, 61da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeFunctionName, 62da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeFunctionRegexp, 63da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeSourceRegexp, 64da26bd203cbb104291b39891febf7481794f205fJim Ingham eSetTypeException 65da26bd203cbb104291b39891febf7481794f205fJim Ingham } BreakpointSetType; 66da26bd203cbb104291b39891febf7481794f205fJim Ingham 67da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointSet (CommandInterpreter &interpreter) : 68da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 69da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint set", 70da26bd203cbb104291b39891febf7481794f205fJim Ingham "Sets a breakpoint or set of breakpoints in the executable.", 71da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint set <cmd-options>"), 72da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options (interpreter) 73da26bd203cbb104291b39891febf7481794f205fJim Ingham { 74da26bd203cbb104291b39891febf7481794f205fJim Ingham } 75da26bd203cbb104291b39891febf7481794f205fJim Ingham 76da26bd203cbb104291b39891febf7481794f205fJim Ingham 77da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 78da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointSet () {} 79da26bd203cbb104291b39891febf7481794f205fJim Ingham 80da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Options * 81da26bd203cbb104291b39891febf7481794f205fJim Ingham GetOptions () 82da26bd203cbb104291b39891febf7481794f205fJim Ingham { 83da26bd203cbb104291b39891febf7481794f205fJim Ingham return &m_options; 84da26bd203cbb104291b39891febf7481794f205fJim Ingham } 85da26bd203cbb104291b39891febf7481794f205fJim Ingham 86da26bd203cbb104291b39891febf7481794f205fJim Ingham class CommandOptions : public Options 87da26bd203cbb104291b39891febf7481794f205fJim Ingham { 88da26bd203cbb104291b39891febf7481794f205fJim Ingham public: 89da26bd203cbb104291b39891febf7481794f205fJim Ingham 90da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions (CommandInterpreter &interpreter) : 91da26bd203cbb104291b39891febf7481794f205fJim Ingham Options (interpreter), 92da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition (), 93da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filenames (), 94da26bd203cbb104291b39891febf7481794f205fJim Ingham m_line_num (0), 95da26bd203cbb104291b39891febf7481794f205fJim Ingham m_column (0), 96da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_names (), 97da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_name_type_mask (eFunctionNameTypeNone), 98da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_regexp (), 99da26bd203cbb104291b39891febf7481794f205fJim Ingham m_source_text_regexp(), 100da26bd203cbb104291b39891febf7481794f205fJim Ingham m_modules (), 101da26bd203cbb104291b39891febf7481794f205fJim Ingham m_load_addr(), 102da26bd203cbb104291b39891febf7481794f205fJim Ingham m_ignore_count (0), 103da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id(LLDB_INVALID_THREAD_ID), 104da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index (UINT32_MAX), 105da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name(), 106da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name(), 107da26bd203cbb104291b39891febf7481794f205fJim Ingham m_catch_bp (false), 10849ce8969d3154e1560106cfe530444c09410f217Greg Clayton m_throw_bp (true), 109da26bd203cbb104291b39891febf7481794f205fJim Ingham m_language (eLanguageTypeUnknown), 1102753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_skip_prologue (eLazyBoolCalculate), 1112753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot (false) 112da26bd203cbb104291b39891febf7481794f205fJim Ingham { 113da26bd203cbb104291b39891febf7481794f205fJim Ingham } 114da26bd203cbb104291b39891febf7481794f205fJim Ingham 115da26bd203cbb104291b39891febf7481794f205fJim Ingham 116da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 117da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandOptions () {} 118da26bd203cbb104291b39891febf7481794f205fJim Ingham 119da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Error 120da26bd203cbb104291b39891febf7481794f205fJim Ingham SetOptionValue (uint32_t option_idx, const char *option_arg) 121da26bd203cbb104291b39891febf7481794f205fJim Ingham { 122da26bd203cbb104291b39891febf7481794f205fJim Ingham Error error; 1236475c42148a8ea1ca86e5db465db7eca742d897dGreg Clayton const int short_option = m_getopt_table[option_idx].val; 124da26bd203cbb104291b39891febf7481794f205fJim Ingham 125da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (short_option) 126da26bd203cbb104291b39891febf7481794f205fJim Ingham { 127da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'a': 12849d888d8c3e4de1d2f38d541559f533f1c0bcab3Greg Clayton { 12949d888d8c3e4de1d2f38d541559f533f1c0bcab3Greg Clayton ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); 13049d888d8c3e4de1d2f38d541559f533f1c0bcab3Greg Clayton m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); 13149d888d8c3e4de1d2f38d541559f533f1c0bcab3Greg Clayton } 132da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 133da26bd203cbb104291b39891febf7481794f205fJim Ingham 1342753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'b': 1352753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_names.push_back (option_arg); 1362753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_name_type_mask |= eFunctionNameTypeBase; 1372753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1382753a024a5a314232baa579c0ada87551aa86988Jim Ingham 139da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'C': 140da26bd203cbb104291b39891febf7481794f205fJim Ingham m_column = Args::StringToUInt32 (option_arg, 0); 141da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 142da26bd203cbb104291b39891febf7481794f205fJim Ingham 143da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'c': 144da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition.assign(option_arg); 145da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 146da26bd203cbb104291b39891febf7481794f205fJim Ingham 1472753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'E': 1482753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 1492753a024a5a314232baa579c0ada87551aa86988Jim Ingham LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg); 1502753a024a5a314232baa579c0ada87551aa86988Jim Ingham 1512753a024a5a314232baa579c0ada87551aa86988Jim Ingham switch (language) 1522753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 1532753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeC89: 1542753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeC: 1552753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeC99: 1562753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_language = eLanguageTypeC; 1572753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1582753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeC_plus_plus: 1592753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_language = eLanguageTypeC_plus_plus; 1602753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1612753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeObjC: 1622753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_language = eLanguageTypeObjC; 1632753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1642753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeObjC_plus_plus: 1652753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c"); 1662753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1672753a024a5a314232baa579c0ada87551aa86988Jim Ingham case eLanguageTypeUnknown: 1682753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg); 1692753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1702753a024a5a314232baa579c0ada87551aa86988Jim Ingham default: 1712753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg); 1722753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 1732753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 1742753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 1752753a024a5a314232baa579c0ada87551aa86988Jim Ingham 176da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'f': 177da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filenames.AppendIfUnique (FileSpec(option_arg, false)); 178da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 179da26bd203cbb104291b39891febf7481794f205fJim Ingham 1802753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'F': 1812753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_names.push_back (option_arg); 1822753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_name_type_mask |= eFunctionNameTypeFull; 183da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 184da26bd203cbb104291b39891febf7481794f205fJim Ingham 1852753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'h': 1862753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 1872753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool success; 1882753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_catch_bp = Args::StringToBoolean (option_arg, true, &success); 1892753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (!success) 1902753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg); 1912753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 192b8e005562dd2d6958fd4b85e584b7d6351c96b17Jim Ingham break; 1932753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'i': 1942753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 1952753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); 1962753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (m_ignore_count == UINT32_MAX) 1972753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); 198da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1992753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 200da26bd203cbb104291b39891febf7481794f205fJim Ingham 2012753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'K': 2022753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 2032753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool success; 2042753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool value; 2052753a024a5a314232baa579c0ada87551aa86988Jim Ingham value = Args::StringToBoolean (option_arg, true, &success); 2062753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (value) 2072753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_skip_prologue = eLazyBoolYes; 2082753a024a5a314232baa579c0ada87551aa86988Jim Ingham else 2092753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_skip_prologue = eLazyBoolNo; 2102753a024a5a314232baa579c0ada87551aa86988Jim Ingham 2112753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (!success) 2122753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg); 2132753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 2142753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 2152753a024a5a314232baa579c0ada87551aa86988Jim Ingham 2162753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'l': 2172753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_line_num = Args::StringToUInt32 (option_arg, 0); 218da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 219da26bd203cbb104291b39891febf7481794f205fJim Ingham 2202753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'M': 221da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_names.push_back (option_arg); 2222753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_name_type_mask |= eFunctionNameTypeMethod; 223da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 224da26bd203cbb104291b39891febf7481794f205fJim Ingham 2252753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'n': 226da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_names.push_back (option_arg); 2272753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_name_type_mask |= eFunctionNameTypeAuto; 228da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 229da26bd203cbb104291b39891febf7481794f205fJim Ingham 2302753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'o': 2312753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot = true; 232da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 233da26bd203cbb104291b39891febf7481794f205fJim Ingham 234da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'p': 235da26bd203cbb104291b39891febf7481794f205fJim Ingham m_source_text_regexp.assign (option_arg); 236da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 237da26bd203cbb104291b39891febf7481794f205fJim Ingham 2382753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'q': 2392753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_queue_name.assign (option_arg); 2402753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 2412753a024a5a314232baa579c0ada87551aa86988Jim Ingham 242da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'r': 243da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_regexp.assign (option_arg); 244da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 245da26bd203cbb104291b39891febf7481794f205fJim Ingham 246da26bd203cbb104291b39891febf7481794f205fJim Ingham case 's': 247da26bd203cbb104291b39891febf7481794f205fJim Ingham { 2482753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_modules.AppendIfUnique (FileSpec (option_arg, false)); 2492753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 250da26bd203cbb104291b39891febf7481794f205fJim Ingham } 2512753a024a5a314232baa579c0ada87551aa86988Jim Ingham 2522753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'S': 2532753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_names.push_back (option_arg); 2542753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_func_name_type_mask |= eFunctionNameTypeSelector; 2552753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 2562753a024a5a314232baa579c0ada87551aa86988Jim Ingham 257da26bd203cbb104291b39891febf7481794f205fJim Ingham case 't' : 258da26bd203cbb104291b39891febf7481794f205fJim Ingham { 259da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); 260da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_thread_id == LLDB_INVALID_THREAD_ID) 261da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); 262da26bd203cbb104291b39891febf7481794f205fJim Ingham } 263da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 2642753a024a5a314232baa579c0ada87551aa86988Jim Ingham 265da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'T': 266da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name.assign (option_arg); 267da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 268da26bd203cbb104291b39891febf7481794f205fJim Ingham 269da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'w': 270da26bd203cbb104291b39891febf7481794f205fJim Ingham { 271da26bd203cbb104291b39891febf7481794f205fJim Ingham bool success; 272da26bd203cbb104291b39891febf7481794f205fJim Ingham m_throw_bp = Args::StringToBoolean (option_arg, true, &success); 273da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!success) 274da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg); 275da26bd203cbb104291b39891febf7481794f205fJim Ingham } 276da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 2772753a024a5a314232baa579c0ada87551aa86988Jim Ingham 2782753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'x': 279da26bd203cbb104291b39891febf7481794f205fJim Ingham { 2802753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); 2812753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (m_thread_id == UINT32_MAX) 2822753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); 2832753a024a5a314232baa579c0ada87551aa86988Jim Ingham 284da26bd203cbb104291b39891febf7481794f205fJim Ingham } 285da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 2862753a024a5a314232baa579c0ada87551aa86988Jim Ingham 287da26bd203cbb104291b39891febf7481794f205fJim Ingham default: 288da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 289da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 290da26bd203cbb104291b39891febf7481794f205fJim Ingham } 291da26bd203cbb104291b39891febf7481794f205fJim Ingham 292da26bd203cbb104291b39891febf7481794f205fJim Ingham return error; 293da26bd203cbb104291b39891febf7481794f205fJim Ingham } 294da26bd203cbb104291b39891febf7481794f205fJim Ingham void 295da26bd203cbb104291b39891febf7481794f205fJim Ingham OptionParsingStarting () 296da26bd203cbb104291b39891febf7481794f205fJim Ingham { 297da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition.clear(); 298da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filenames.Clear(); 299da26bd203cbb104291b39891febf7481794f205fJim Ingham m_line_num = 0; 300da26bd203cbb104291b39891febf7481794f205fJim Ingham m_column = 0; 301da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_names.clear(); 30249ce8969d3154e1560106cfe530444c09410f217Greg Clayton m_func_name_type_mask = eFunctionNameTypeNone; 303da26bd203cbb104291b39891febf7481794f205fJim Ingham m_func_regexp.clear(); 30449ce8969d3154e1560106cfe530444c09410f217Greg Clayton m_source_text_regexp.clear(); 305da26bd203cbb104291b39891febf7481794f205fJim Ingham m_modules.Clear(); 30649ce8969d3154e1560106cfe530444c09410f217Greg Clayton m_load_addr = LLDB_INVALID_ADDRESS; 307da26bd203cbb104291b39891febf7481794f205fJim Ingham m_ignore_count = 0; 308da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id = LLDB_INVALID_THREAD_ID; 309da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index = UINT32_MAX; 310da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name.clear(); 311da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name.clear(); 312da26bd203cbb104291b39891febf7481794f205fJim Ingham m_catch_bp = false; 313da26bd203cbb104291b39891febf7481794f205fJim Ingham m_throw_bp = true; 31449ce8969d3154e1560106cfe530444c09410f217Greg Clayton m_language = eLanguageTypeUnknown; 315da26bd203cbb104291b39891febf7481794f205fJim Ingham m_skip_prologue = eLazyBoolCalculate; 3162753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot = false; 317da26bd203cbb104291b39891febf7481794f205fJim Ingham } 318da26bd203cbb104291b39891febf7481794f205fJim Ingham 319da26bd203cbb104291b39891febf7481794f205fJim Ingham const OptionDefinition* 320da26bd203cbb104291b39891febf7481794f205fJim Ingham GetDefinitions () 321da26bd203cbb104291b39891febf7481794f205fJim Ingham { 322da26bd203cbb104291b39891febf7481794f205fJim Ingham return g_option_table; 323da26bd203cbb104291b39891febf7481794f205fJim Ingham } 324da26bd203cbb104291b39891febf7481794f205fJim Ingham 325da26bd203cbb104291b39891febf7481794f205fJim Ingham // Options table: Required for subclasses of Options. 326da26bd203cbb104291b39891febf7481794f205fJim Ingham 327da26bd203cbb104291b39891febf7481794f205fJim Ingham static OptionDefinition g_option_table[]; 328da26bd203cbb104291b39891febf7481794f205fJim Ingham 329da26bd203cbb104291b39891febf7481794f205fJim Ingham // Instance variables to hold the values for command options. 330da26bd203cbb104291b39891febf7481794f205fJim Ingham 331da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_condition; 332da26bd203cbb104291b39891febf7481794f205fJim Ingham FileSpecList m_filenames; 333da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_line_num; 334da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_column; 335da26bd203cbb104291b39891febf7481794f205fJim Ingham std::vector<std::string> m_func_names; 336da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_func_name_type_mask; 337da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_func_regexp; 338da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_source_text_regexp; 339da26bd203cbb104291b39891febf7481794f205fJim Ingham FileSpecList m_modules; 340da26bd203cbb104291b39891febf7481794f205fJim Ingham lldb::addr_t m_load_addr; 341da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_ignore_count; 342da26bd203cbb104291b39891febf7481794f205fJim Ingham lldb::tid_t m_thread_id; 343da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_thread_index; 344da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_thread_name; 345da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_queue_name; 346da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_catch_bp; 347da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_throw_bp; 348da26bd203cbb104291b39891febf7481794f205fJim Ingham lldb::LanguageType m_language; 349da26bd203cbb104291b39891febf7481794f205fJim Ingham LazyBool m_skip_prologue; 3502753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool m_one_shot; 351da26bd203cbb104291b39891febf7481794f205fJim Ingham 352da26bd203cbb104291b39891febf7481794f205fJim Ingham }; 353da26bd203cbb104291b39891febf7481794f205fJim Ingham 354da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 355da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 356da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, 357da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandReturnObject &result) 358da26bd203cbb104291b39891febf7481794f205fJim Ingham { 359da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 360da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 361da26bd203cbb104291b39891febf7481794f205fJim Ingham { 362da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command)."); 363da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 364da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 365da26bd203cbb104291b39891febf7481794f205fJim Ingham } 366da26bd203cbb104291b39891febf7481794f205fJim Ingham 367da26bd203cbb104291b39891febf7481794f205fJim Ingham // The following are the various types of breakpoints that could be set: 368da26bd203cbb104291b39891febf7481794f205fJim Ingham // 1). -f -l -p [-s -g] (setting breakpoint by source location) 369da26bd203cbb104291b39891febf7481794f205fJim Ingham // 2). -a [-s -g] (setting breakpoint by address) 370da26bd203cbb104291b39891febf7481794f205fJim Ingham // 3). -n [-s -g] (setting breakpoint by function name) 371da26bd203cbb104291b39891febf7481794f205fJim Ingham // 4). -r [-s -g] (setting breakpoint by function name regular expression) 372da26bd203cbb104291b39891febf7481794f205fJim Ingham // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text) 373da26bd203cbb104291b39891febf7481794f205fJim Ingham // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.) 374da26bd203cbb104291b39891febf7481794f205fJim Ingham 375da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointSetType break_type = eSetTypeInvalid; 376da26bd203cbb104291b39891febf7481794f205fJim Ingham 377da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_line_num != 0) 378da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeFileAndLine; 379da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) 380da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeAddress; 381da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (!m_options.m_func_names.empty()) 382da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeFunctionName; 383da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (!m_options.m_func_regexp.empty()) 384da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeFunctionRegexp; 385da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (!m_options.m_source_text_regexp.empty()) 386da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeSourceRegexp; 387da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (m_options.m_language != eLanguageTypeUnknown) 388da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eSetTypeException; 389da26bd203cbb104291b39891febf7481794f205fJim Ingham 390da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *bp = NULL; 391da26bd203cbb104291b39891febf7481794f205fJim Ingham FileSpec module_spec; 392da26bd203cbb104291b39891febf7481794f205fJim Ingham const bool internal = false; 393da26bd203cbb104291b39891febf7481794f205fJim Ingham 394da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (break_type) 395da26bd203cbb104291b39891febf7481794f205fJim Ingham { 396da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeFileAndLine: // Breakpoint by source position 397da26bd203cbb104291b39891febf7481794f205fJim Ingham { 398da26bd203cbb104291b39891febf7481794f205fJim Ingham FileSpec file; 39936da2aa6dc5ad9994b638ed09eb81c44cc05540bGreg Clayton const size_t num_files = m_options.m_filenames.GetSize(); 400da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_files == 0) 401da26bd203cbb104291b39891febf7481794f205fJim Ingham { 402da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!GetDefaultFile (target, file, result)) 403da26bd203cbb104291b39891febf7481794f205fJim Ingham { 404da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError("No file supplied and no default file available."); 405da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 406da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 407da26bd203cbb104291b39891febf7481794f205fJim Ingham } 408da26bd203cbb104291b39891febf7481794f205fJim Ingham } 409da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (num_files > 1) 410da26bd203cbb104291b39891febf7481794f205fJim Ingham { 411da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError("Only one file at a time is allowed for file and line breakpoints."); 412da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 413da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 414da26bd203cbb104291b39891febf7481794f205fJim Ingham } 415da26bd203cbb104291b39891febf7481794f205fJim Ingham else 416da26bd203cbb104291b39891febf7481794f205fJim Ingham file = m_options.m_filenames.GetFileSpecAtIndex(0); 41749ce8969d3154e1560106cfe530444c09410f217Greg Clayton 41849ce8969d3154e1560106cfe530444c09410f217Greg Clayton // Only check for inline functions if 41949ce8969d3154e1560106cfe530444c09410f217Greg Clayton LazyBool check_inlines = eLazyBoolCalculate; 42049ce8969d3154e1560106cfe530444c09410f217Greg Clayton 421da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateBreakpoint (&(m_options.m_modules), 422da26bd203cbb104291b39891febf7481794f205fJim Ingham file, 423da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_line_num, 42449ce8969d3154e1560106cfe530444c09410f217Greg Clayton check_inlines, 425da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_skip_prologue, 426da26bd203cbb104291b39891febf7481794f205fJim Ingham internal).get(); 427da26bd203cbb104291b39891febf7481794f205fJim Ingham } 428da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 429da26bd203cbb104291b39891febf7481794f205fJim Ingham 430da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeAddress: // Breakpoint by address 431da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); 432da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 433da26bd203cbb104291b39891febf7481794f205fJim Ingham 434da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeFunctionName: // Breakpoint by function name 435da26bd203cbb104291b39891febf7481794f205fJim Ingham { 436da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t name_type_mask = m_options.m_func_name_type_mask; 437da26bd203cbb104291b39891febf7481794f205fJim Ingham 438da26bd203cbb104291b39891febf7481794f205fJim Ingham if (name_type_mask == 0) 439da26bd203cbb104291b39891febf7481794f205fJim Ingham name_type_mask = eFunctionNameTypeAuto; 440da26bd203cbb104291b39891febf7481794f205fJim Ingham 441da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateBreakpoint (&(m_options.m_modules), 442da26bd203cbb104291b39891febf7481794f205fJim Ingham &(m_options.m_filenames), 443da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_func_names, 444da26bd203cbb104291b39891febf7481794f205fJim Ingham name_type_mask, 445da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_skip_prologue, 446da26bd203cbb104291b39891febf7481794f205fJim Ingham internal).get(); 447da26bd203cbb104291b39891febf7481794f205fJim Ingham } 448da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 449da26bd203cbb104291b39891febf7481794f205fJim Ingham 450da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name 451da26bd203cbb104291b39891febf7481794f205fJim Ingham { 452da26bd203cbb104291b39891febf7481794f205fJim Ingham RegularExpression regexp(m_options.m_func_regexp.c_str()); 453da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!regexp.IsValid()) 454da26bd203cbb104291b39891febf7481794f205fJim Ingham { 455da26bd203cbb104291b39891febf7481794f205fJim Ingham char err_str[1024]; 456da26bd203cbb104291b39891febf7481794f205fJim Ingham regexp.GetErrorAsCString(err_str, sizeof(err_str)); 457da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"", 458da26bd203cbb104291b39891febf7481794f205fJim Ingham err_str); 459da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 460da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 461da26bd203cbb104291b39891febf7481794f205fJim Ingham } 462da26bd203cbb104291b39891febf7481794f205fJim Ingham 463da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), 464da26bd203cbb104291b39891febf7481794f205fJim Ingham &(m_options.m_filenames), 465da26bd203cbb104291b39891febf7481794f205fJim Ingham regexp, 466da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_skip_prologue, 467da26bd203cbb104291b39891febf7481794f205fJim Ingham internal).get(); 468da26bd203cbb104291b39891febf7481794f205fJim Ingham } 469da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 470da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeSourceRegexp: // Breakpoint by regexp on source text. 471da26bd203cbb104291b39891febf7481794f205fJim Ingham { 47236da2aa6dc5ad9994b638ed09eb81c44cc05540bGreg Clayton const size_t num_files = m_options.m_filenames.GetSize(); 473da26bd203cbb104291b39891febf7481794f205fJim Ingham 474da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_files == 0) 475da26bd203cbb104291b39891febf7481794f205fJim Ingham { 476da26bd203cbb104291b39891febf7481794f205fJim Ingham FileSpec file; 477da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!GetDefaultFile (target, file, result)) 478da26bd203cbb104291b39891febf7481794f205fJim Ingham { 479da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("No files provided and could not find default file."); 480da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 481da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 482da26bd203cbb104291b39891febf7481794f205fJim Ingham } 483da26bd203cbb104291b39891febf7481794f205fJim Ingham else 484da26bd203cbb104291b39891febf7481794f205fJim Ingham { 485da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options.m_filenames.Append (file); 486da26bd203cbb104291b39891febf7481794f205fJim Ingham } 487da26bd203cbb104291b39891febf7481794f205fJim Ingham } 488da26bd203cbb104291b39891febf7481794f205fJim Ingham 489da26bd203cbb104291b39891febf7481794f205fJim Ingham RegularExpression regexp(m_options.m_source_text_regexp.c_str()); 490da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!regexp.IsValid()) 491da26bd203cbb104291b39891febf7481794f205fJim Ingham { 492da26bd203cbb104291b39891febf7481794f205fJim Ingham char err_str[1024]; 493da26bd203cbb104291b39891febf7481794f205fJim Ingham regexp.GetErrorAsCString(err_str, sizeof(err_str)); 494da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"", 495da26bd203cbb104291b39891febf7481794f205fJim Ingham err_str); 496da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 497da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 498da26bd203cbb104291b39891febf7481794f205fJim Ingham } 499da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get(); 500da26bd203cbb104291b39891febf7481794f205fJim Ingham } 501da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 502da26bd203cbb104291b39891febf7481794f205fJim Ingham case eSetTypeException: 503da26bd203cbb104291b39891febf7481794f205fJim Ingham { 504da26bd203cbb104291b39891febf7481794f205fJim Ingham bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get(); 505da26bd203cbb104291b39891febf7481794f205fJim Ingham } 506da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 507da26bd203cbb104291b39891febf7481794f205fJim Ingham default: 508da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 509da26bd203cbb104291b39891febf7481794f205fJim Ingham } 510da26bd203cbb104291b39891febf7481794f205fJim Ingham 511da26bd203cbb104291b39891febf7481794f205fJim Ingham // Now set the various options that were passed in: 512da26bd203cbb104291b39891febf7481794f205fJim Ingham if (bp) 513da26bd203cbb104291b39891febf7481794f205fJim Ingham { 514da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) 515da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetThreadID (m_options.m_thread_id); 516da26bd203cbb104291b39891febf7481794f205fJim Ingham 517da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_index != UINT32_MAX) 518da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); 519da26bd203cbb104291b39891febf7481794f205fJim Ingham 520da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!m_options.m_thread_name.empty()) 521da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); 522da26bd203cbb104291b39891febf7481794f205fJim Ingham 523da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!m_options.m_queue_name.empty()) 524da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); 525da26bd203cbb104291b39891febf7481794f205fJim Ingham 526da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_ignore_count != 0) 527da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); 528da26bd203cbb104291b39891febf7481794f205fJim Ingham 529da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!m_options.m_condition.empty()) 530da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetOptions()->SetCondition(m_options.m_condition.c_str()); 5312753a024a5a314232baa579c0ada87551aa86988Jim Ingham 5322753a024a5a314232baa579c0ada87551aa86988Jim Ingham bp->SetOneShot (m_options.m_one_shot); 533da26bd203cbb104291b39891febf7481794f205fJim Ingham } 534da26bd203cbb104291b39891febf7481794f205fJim Ingham 535da26bd203cbb104291b39891febf7481794f205fJim Ingham if (bp) 536da26bd203cbb104291b39891febf7481794f205fJim Ingham { 537da26bd203cbb104291b39891febf7481794f205fJim Ingham Stream &output_stream = result.GetOutputStream(); 5384f61ba926fdcc03d71a1b5db88c18d1e94ed9fd8Jim Ingham const bool show_locations = false; 5394f61ba926fdcc03d71a1b5db88c18d1e94ed9fd8Jim Ingham bp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations); 540da26bd203cbb104291b39891febf7481794f205fJim Ingham // Don't print out this warning for exception breakpoints. They can get set before the target 541da26bd203cbb104291b39891febf7481794f205fJim Ingham // is set, but we won't know how to actually set the breakpoint till we run. 542da26bd203cbb104291b39891febf7481794f205fJim Ingham if (bp->GetNumLocations() == 0 && break_type != eSetTypeException) 543da26bd203cbb104291b39891febf7481794f205fJim Ingham output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n"); 544da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishResult); 545da26bd203cbb104291b39891febf7481794f205fJim Ingham } 546da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (!bp) 547da26bd203cbb104291b39891febf7481794f205fJim Ingham { 548da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Breakpoint creation failed: No breakpoint created."); 549da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 550da26bd203cbb104291b39891febf7481794f205fJim Ingham } 551da26bd203cbb104291b39891febf7481794f205fJim Ingham 552da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 553da26bd203cbb104291b39891febf7481794f205fJim Ingham } 55424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 555da26bd203cbb104291b39891febf7481794f205fJim Inghamprivate: 556da26bd203cbb104291b39891febf7481794f205fJim Ingham bool 557da26bd203cbb104291b39891febf7481794f205fJim Ingham GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result) 558da26bd203cbb104291b39891febf7481794f205fJim Ingham { 559da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t default_line; 560da26bd203cbb104291b39891febf7481794f205fJim Ingham // First use the Source Manager's default file. 561da26bd203cbb104291b39891febf7481794f205fJim Ingham // Then use the current stack frame's file. 562da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) 563da26bd203cbb104291b39891febf7481794f205fJim Ingham { 564ea0bb4d45c14447a2fe9be9f4bd8e79a84513537Greg Clayton StackFrame *cur_frame = m_exe_ctx.GetFramePtr(); 565da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_frame == NULL) 566da26bd203cbb104291b39891febf7481794f205fJim Ingham { 567da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("No selected frame to use to find the default file."); 568da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 569da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 570da26bd203cbb104291b39891febf7481794f205fJim Ingham } 571da26bd203cbb104291b39891febf7481794f205fJim Ingham else if (!cur_frame->HasDebugInformation()) 572da26bd203cbb104291b39891febf7481794f205fJim Ingham { 573da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info."); 574da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 575da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 576da26bd203cbb104291b39891febf7481794f205fJim Ingham } 577da26bd203cbb104291b39891febf7481794f205fJim Ingham else 578da26bd203cbb104291b39891febf7481794f205fJim Ingham { 579da26bd203cbb104291b39891febf7481794f205fJim Ingham const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); 580da26bd203cbb104291b39891febf7481794f205fJim Ingham if (sc.line_entry.file) 581da26bd203cbb104291b39891febf7481794f205fJim Ingham { 582da26bd203cbb104291b39891febf7481794f205fJim Ingham file = sc.line_entry.file; 583da26bd203cbb104291b39891febf7481794f205fJim Ingham } 584da26bd203cbb104291b39891febf7481794f205fJim Ingham else 585da26bd203cbb104291b39891febf7481794f205fJim Ingham { 586da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Can't find the file for the selected frame to use as the default file."); 587da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 588da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 589da26bd203cbb104291b39891febf7481794f205fJim Ingham } 590da26bd203cbb104291b39891febf7481794f205fJim Ingham } 591da26bd203cbb104291b39891febf7481794f205fJim Ingham } 592da26bd203cbb104291b39891febf7481794f205fJim Ingham return true; 593da26bd203cbb104291b39891febf7481794f205fJim Ingham } 594da26bd203cbb104291b39891febf7481794f205fJim Ingham 595da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions m_options; 596da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 5978d03c6f9b1524c5b0701730e8e7252b14c582fe0Johnny Chen// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to 5988d03c6f9b1524c5b0701730e8e7252b14c582fe0Johnny Chen// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately. 5996f4a115d1f0727f80124e2986382df202ffd3d5eJohnny Chen#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 ) 6006f4a115d1f0727f80124e2986382df202ffd3d5eJohnny Chen#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) 6012cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) ) 602d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham 603b344843f75ef893762c93fd0a22d2d45712ce74dGreg ClaytonOptionDefinition 60424943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerCommandObjectBreakpointSet::CommandOptions::g_option_table[] = 60524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 6064722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, 607ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Set the breakpoint only in this shared library. " 608ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Can repeat this option multiple times to specify multiple shared libraries."}, 60934e9a98dcff785b0693594b6d6753f560abf8be2Jim Ingham 6104d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, 6114d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice "Set the number of times this breakpoint is skipped before stopping." }, 6123c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 6132753a024a5a314232baa579c0ada87551aa86988Jim Ingham { LLDB_OPT_SET_ALL, false, "one-shot", 'o', no_argument, NULL, 0, eArgTypeNone, 61407b3a0f9963a3ea6786a659ed90ce2f8b7d027c0Jim Ingham "The breakpoint is deleted the first time it causes a stop." }, 6152753a024a5a314232baa579c0ada87551aa86988Jim Ingham 616e4f3cd7fb037f28484198787a465a5e94d12d2e9Johnny Chen { LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, 617e4f3cd7fb037f28484198787a465a5e94d12d2e9Johnny Chen "The breakpoint stops only if this condition expression evaluates to true."}, 618e4f3cd7fb037f28484198787a465a5e94d12d2e9Johnny Chen 619ff7df6df0e922fe9f6dbd57cc9d44c8c9a2f9e44Bill Wendling { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, 6201b751dc1f143002feeabdbdfbcdf5702388560d9Jim Ingham "The breakpoint stops only for the thread whose indeX matches this argument."}, 6213c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 622ff7df6df0e922fe9f6dbd57cc9d44c8c9a2f9e44Bill Wendling { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, 6233c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham "The breakpoint stops only for the thread whose TID matches this argument."}, 6243c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 625ff7df6df0e922fe9f6dbd57cc9d44c8c9a2f9e44Bill Wendling { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, 6263c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham "The breakpoint stops only for the thread whose thread name matches this argument."}, 6273c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 628ff7df6df0e922fe9f6dbd57cc9d44c8c9a2f9e44Bill Wendling { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, 6293c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham "The breakpoint stops only for threads in the queue whose name is given by this argument."}, 6303c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 631d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, 632708864da6f6f01a69ea213db1e49ce230ff74853Jim Ingham "Specifies the source file in which to set this breakpoint. " 633708864da6f6f01a69ea213db1e49ce230ff74853Jim Ingham "Note, by default lldb only looks for files that are #included if they use the standard include file extensions. " 634c112da81f0dd04c91e905e92c80e51a4e1e8408bJim Ingham "To set breakpoints on .c/.cpp/.m/.mm files that are #included, set target.inline-breakpoint-strategy" 635708864da6f6f01a69ea213db1e49ce230ff74853Jim Ingham " to \"always\"."}, 63624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 6374d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, 638d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham "Specifies the line number on which to set this breakpoint."}, 63924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 64024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner // Comment out this option for the moment, as we don't actually use it, but will in the future. 64124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner // This way users won't see it, but the infrastructure is left in place. 642e4f3cd7fb037f28484198787a465a5e94d12d2e9Johnny Chen // { 0, false, "column", 'C', required_argument, NULL, "<column>", 64324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner // "Set the breakpoint by source location at this particular column."}, 64424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 6454968ad817597891cc02c195d4b3e7c3cde1fc391Enrico Granata { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, 64624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner "Set the breakpoint by address, at the specified address."}, 64724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 6484d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, 64925ba952b10ecf3c99e6865ef1efb091f5eb45980Jim Ingham "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" }, 65024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 6514d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, 652ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and " 653ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "for Objective C this means a full function prototype with class and selector. " 654ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Can be repeated multiple times to make one breakpoint for multiple names." }, 65512bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 6564d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector, 657ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Set the breakpoint by ObjC selector name. Can be repeated multiple times to make one breakpoint for multiple Selectors." }, 65812bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 6594d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod, 660ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Set the breakpoint by C++ method names. Can be repeated multiple times to make one breakpoint for multiple methods." }, 66112bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 6624d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression, 66324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, 66424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 66548fbdf7ffd3c5e28e7b954ed92345c1c45256109Greg Clayton { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, 666ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). " 667ee033f2ed64bf228ff6bdc524ffe607dfe514f9fJim Ingham "Can be repeated multiple times to make one breakpoint for multiple symbols." }, 66848fbdf7ffd3c5e28e7b954ed92345c1c45256109Greg Clayton 66903c8ee5aeafcd6c43f10002a4f8096af01780f86Jim Ingham { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression, 67045546c7f54badb694a0b17db5b9bb6218e525b7eJim Ingham "Set the breakpoint by specifying a regular expression which is matched against the source text in a source file or files " 67145546c7f54badb694a0b17db5b9bb6218e525b7eJim Ingham "specified with the -f option. The -f option can be specified more than once. " 67245546c7f54badb694a0b17db5b9bb6218e525b7eJim Ingham "If no source files are specified, uses the current \"default source file\"" }, 67303c8ee5aeafcd6c43f10002a4f8096af01780f86Jim Ingham 6744722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage, 6754722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" }, 6764722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham 6774722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean, 6784722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham "Set the breakpoint on exception throW." }, 6794722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham 6804722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean, 6814722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham "Set the breakpoint on exception catcH." }, 68203c8ee5aeafcd6c43f10002a4f8096af01780f86Jim Ingham 6832cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', required_argument, NULL, 0, eArgTypeBoolean, 6842cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." }, 6852cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham 6864d6675c8e1cab6360f59865229835ae137d6f68aCaroline Tice { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } 68724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}; 68824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 689da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 690da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectBreakpointModify 691da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 692da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark Modify 69324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 694da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointModify : public CommandObjectParsed 69524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 696da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 697da26bd203cbb104291b39891febf7481794f205fJim Ingham 698da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointModify (CommandInterpreter &interpreter) : 699da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 700da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint modify", 701da26bd203cbb104291b39891febf7481794f205fJim Ingham "Modify the options on a breakpoint or set of breakpoints in the executable. " 702da26bd203cbb104291b39891febf7481794f205fJim Ingham "If no breakpoint is specified, acts on the last created breakpoint. " 703da26bd203cbb104291b39891febf7481794f205fJim Ingham "With the exception of -e, -d and -i, passing an empty argument clears the modification.", 704da26bd203cbb104291b39891febf7481794f205fJim Ingham NULL), 705da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options (interpreter) 706da26bd203cbb104291b39891febf7481794f205fJim Ingham { 707da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentEntry arg; 708da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); 709da26bd203cbb104291b39891febf7481794f205fJim Ingham // Add the entry for the first argument for this command to the object's arguments vector. 710da26bd203cbb104291b39891febf7481794f205fJim Ingham m_arguments.push_back (arg); 711da26bd203cbb104291b39891febf7481794f205fJim Ingham } 712da26bd203cbb104291b39891febf7481794f205fJim Ingham 71324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 714da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 715da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointModify () {} 716da26bd203cbb104291b39891febf7481794f205fJim Ingham 717da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Options * 718da26bd203cbb104291b39891febf7481794f205fJim Ingham GetOptions () 71924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 720da26bd203cbb104291b39891febf7481794f205fJim Ingham return &m_options; 721da26bd203cbb104291b39891febf7481794f205fJim Ingham } 72212bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 723da26bd203cbb104291b39891febf7481794f205fJim Ingham class CommandOptions : public Options 724da26bd203cbb104291b39891febf7481794f205fJim Ingham { 725da26bd203cbb104291b39891febf7481794f205fJim Ingham public: 726da26bd203cbb104291b39891febf7481794f205fJim Ingham 727da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions (CommandInterpreter &interpreter) : 728da26bd203cbb104291b39891febf7481794f205fJim Ingham Options (interpreter), 729da26bd203cbb104291b39891febf7481794f205fJim Ingham m_ignore_count (0), 730da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id(LLDB_INVALID_THREAD_ID), 731da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id_passed(false), 732da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index (UINT32_MAX), 733da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index_passed(false), 734da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name(), 735da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name(), 736da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition (), 7372753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot (false), 738da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_passed (false), 739da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_value (false), 740da26bd203cbb104291b39891febf7481794f205fJim Ingham m_name_passed (false), 741da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_passed (false), 7422753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_condition_passed (false), 7432753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot_passed (false) 7443c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 7453c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 746da26bd203cbb104291b39891febf7481794f205fJim Ingham 747da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 748da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandOptions () {} 749da26bd203cbb104291b39891febf7481794f205fJim Ingham 750da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Error 751da26bd203cbb104291b39891febf7481794f205fJim Ingham SetOptionValue (uint32_t option_idx, const char *option_arg) 7524722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { 753da26bd203cbb104291b39891febf7481794f205fJim Ingham Error error; 7546475c42148a8ea1ca86e5db465db7eca742d897dGreg Clayton const int short_option = m_getopt_table[option_idx].val; 7554722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham 756da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (short_option) 7574722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { 758da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'c': 759da26bd203cbb104291b39891febf7481794f205fJim Ingham if (option_arg != NULL) 760da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition.assign (option_arg); 761da26bd203cbb104291b39891febf7481794f205fJim Ingham else 762da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition.clear(); 763da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition_passed = true; 7644722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham break; 765da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'd': 766da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_passed = true; 767da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_value = false; 7684722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham break; 769da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'e': 770da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_passed = true; 771da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_value = true; 7724722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham break; 773da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'i': 774da26bd203cbb104291b39891febf7481794f205fJim Ingham { 775da26bd203cbb104291b39891febf7481794f205fJim Ingham m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); 776da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_ignore_count == UINT32_MAX) 777da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); 778da26bd203cbb104291b39891febf7481794f205fJim Ingham } 779da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 7802753a024a5a314232baa579c0ada87551aa86988Jim Ingham case 'o': 7812753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 7822753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool value, success; 7832753a024a5a314232baa579c0ada87551aa86988Jim Ingham value = Args::StringToBoolean(option_arg, false, &success); 7842753a024a5a314232baa579c0ada87551aa86988Jim Ingham if (success) 7852753a024a5a314232baa579c0ada87551aa86988Jim Ingham { 7862753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot_passed = true; 7872753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot = value; 7882753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 7892753a024a5a314232baa579c0ada87551aa86988Jim Ingham else 7902753a024a5a314232baa579c0ada87551aa86988Jim Ingham error.SetErrorStringWithFormat("invalid boolean value '%s' passed for -o option", option_arg); 7912753a024a5a314232baa579c0ada87551aa86988Jim Ingham } 7922753a024a5a314232baa579c0ada87551aa86988Jim Ingham break; 793da26bd203cbb104291b39891febf7481794f205fJim Ingham case 't' : 794da26bd203cbb104291b39891febf7481794f205fJim Ingham { 795da26bd203cbb104291b39891febf7481794f205fJim Ingham if (option_arg[0] == '\0') 796da26bd203cbb104291b39891febf7481794f205fJim Ingham { 797da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id = LLDB_INVALID_THREAD_ID; 798da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id_passed = true; 799da26bd203cbb104291b39891febf7481794f205fJim Ingham } 800da26bd203cbb104291b39891febf7481794f205fJim Ingham else 801da26bd203cbb104291b39891febf7481794f205fJim Ingham { 802da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); 803da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_thread_id == LLDB_INVALID_THREAD_ID) 804da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); 805da26bd203cbb104291b39891febf7481794f205fJim Ingham else 806da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id_passed = true; 807da26bd203cbb104291b39891febf7481794f205fJim Ingham } 808da26bd203cbb104291b39891febf7481794f205fJim Ingham } 809da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 810da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'T': 811da26bd203cbb104291b39891febf7481794f205fJim Ingham if (option_arg != NULL) 812da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name.assign (option_arg); 813da26bd203cbb104291b39891febf7481794f205fJim Ingham else 814da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name.clear(); 815da26bd203cbb104291b39891febf7481794f205fJim Ingham m_name_passed = true; 8164722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham break; 817da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'q': 818da26bd203cbb104291b39891febf7481794f205fJim Ingham if (option_arg != NULL) 819da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name.assign (option_arg); 820da26bd203cbb104291b39891febf7481794f205fJim Ingham else 821da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name.clear(); 822da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_passed = true; 8234722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham break; 824da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'x': 825da26bd203cbb104291b39891febf7481794f205fJim Ingham { 826da26bd203cbb104291b39891febf7481794f205fJim Ingham if (option_arg[0] == '\n') 827da26bd203cbb104291b39891febf7481794f205fJim Ingham { 828da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index = UINT32_MAX; 829da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index_passed = true; 830da26bd203cbb104291b39891febf7481794f205fJim Ingham } 831da26bd203cbb104291b39891febf7481794f205fJim Ingham else 832da26bd203cbb104291b39891febf7481794f205fJim Ingham { 833da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0); 834da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_thread_id == UINT32_MAX) 835da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); 836da26bd203cbb104291b39891febf7481794f205fJim Ingham else 837da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index_passed = true; 838da26bd203cbb104291b39891febf7481794f205fJim Ingham } 839da26bd203cbb104291b39891febf7481794f205fJim Ingham } 840da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 8414722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham default: 842da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 843da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 8444722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham } 845da26bd203cbb104291b39891febf7481794f205fJim Ingham 846da26bd203cbb104291b39891febf7481794f205fJim Ingham return error; 8474722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham } 848da26bd203cbb104291b39891febf7481794f205fJim Ingham void 849da26bd203cbb104291b39891febf7481794f205fJim Ingham OptionParsingStarting () 8504722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham { 851da26bd203cbb104291b39891febf7481794f205fJim Ingham m_ignore_count = 0; 852da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id = LLDB_INVALID_THREAD_ID; 853da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_id_passed = false; 854da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index = UINT32_MAX; 855da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_index_passed = false; 856da26bd203cbb104291b39891febf7481794f205fJim Ingham m_thread_name.clear(); 857da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_name.clear(); 858da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition.clear(); 8592753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot = false; 860da26bd203cbb104291b39891febf7481794f205fJim Ingham m_enable_passed = false; 861da26bd203cbb104291b39891febf7481794f205fJim Ingham m_queue_passed = false; 862da26bd203cbb104291b39891febf7481794f205fJim Ingham m_name_passed = false; 863da26bd203cbb104291b39891febf7481794f205fJim Ingham m_condition_passed = false; 8642753a024a5a314232baa579c0ada87551aa86988Jim Ingham m_one_shot_passed = false; 8654722b10307668368bf0f12fa6b8691e4f4cb5488Jim Ingham } 866da26bd203cbb104291b39891febf7481794f205fJim Ingham 867da26bd203cbb104291b39891febf7481794f205fJim Ingham const OptionDefinition* 868da26bd203cbb104291b39891febf7481794f205fJim Ingham GetDefinitions () 8692cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham { 870da26bd203cbb104291b39891febf7481794f205fJim Ingham return g_option_table; 8712cf5ccbbbe3343a6c973d0d65ad5de178a414e30Jim Ingham } 872da26bd203cbb104291b39891febf7481794f205fJim Ingham 87324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 874da26bd203cbb104291b39891febf7481794f205fJim Ingham // Options table: Required for subclasses of Options. 87524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 876da26bd203cbb104291b39891febf7481794f205fJim Ingham static OptionDefinition g_option_table[]; 87724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 878da26bd203cbb104291b39891febf7481794f205fJim Ingham // Instance variables to hold the values for command options. 87924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 880da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_ignore_count; 881da26bd203cbb104291b39891febf7481794f205fJim Ingham lldb::tid_t m_thread_id; 882da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_thread_id_passed; 883da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_thread_index; 884da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_thread_index_passed; 885da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_thread_name; 886da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_queue_name; 887da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_condition; 8882753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool m_one_shot; 889da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_enable_passed; 890da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_enable_value; 891da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_name_passed; 892da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_queue_passed; 893da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_condition_passed; 8942753a024a5a314232baa579c0ada87551aa86988Jim Ingham bool m_one_shot_passed; 89524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 896da26bd203cbb104291b39891febf7481794f205fJim Ingham }; 89724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 898da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 899da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 900da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 90103c8ee5aeafcd6c43f10002a4f8096af01780f86Jim Ingham { 902da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 903da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 904d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham { 905da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No existing target or breakpoints."); 906d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham result.SetStatus (eReturnStatusFailed); 907d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham return false; 908d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham } 90903c8ee5aeafcd6c43f10002a4f8096af01780f86Jim Ingham 910da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 911da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList().GetListMutex(locker); 912da26bd203cbb104291b39891febf7481794f205fJim Ingham 913da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList valid_bp_ids; 914887aa2898314218406275a34cbec30c11cd00acdGreg Clayton 915da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); 91612bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 917da26bd203cbb104291b39891febf7481794f205fJim Ingham if (result.Succeeded()) 918da26bd203cbb104291b39891febf7481794f205fJim Ingham { 919da26bd203cbb104291b39891febf7481794f205fJim Ingham const size_t count = valid_bp_ids.GetSize(); 920da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < count; ++i) 92124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 922da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); 92312bec71b323dc520f0e985a86e09c4712559e115Greg Clayton 924da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) 925d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham { 926da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 927da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) 928d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham { 929da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); 930da26bd203cbb104291b39891febf7481794f205fJim Ingham if (location) 931da26bd203cbb104291b39891febf7481794f205fJim Ingham { 932da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_id_passed) 933da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetThreadID (m_options.m_thread_id); 934da26bd203cbb104291b39891febf7481794f205fJim Ingham 935da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_index_passed) 936da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetThreadIndex(m_options.m_thread_index); 937da26bd203cbb104291b39891febf7481794f205fJim Ingham 938da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_name_passed) 939da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetThreadName(m_options.m_thread_name.c_str()); 940da26bd203cbb104291b39891febf7481794f205fJim Ingham 941da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_queue_passed) 942da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetQueueName(m_options.m_queue_name.c_str()); 943da26bd203cbb104291b39891febf7481794f205fJim Ingham 944da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_ignore_count != 0) 945da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetIgnoreCount(m_options.m_ignore_count); 946da26bd203cbb104291b39891febf7481794f205fJim Ingham 947da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_enable_passed) 948da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetEnabled (m_options.m_enable_value); 949da26bd203cbb104291b39891febf7481794f205fJim Ingham 950da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_condition_passed) 951da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetCondition (m_options.m_condition.c_str()); 952da26bd203cbb104291b39891febf7481794f205fJim Ingham } 953d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham } 954d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham else 955d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham { 956da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_id_passed) 957da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetThreadID (m_options.m_thread_id); 958da26bd203cbb104291b39891febf7481794f205fJim Ingham 959da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_thread_index_passed) 960da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetThreadIndex(m_options.m_thread_index); 961da26bd203cbb104291b39891febf7481794f205fJim Ingham 962da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_name_passed) 963da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetThreadName(m_options.m_thread_name.c_str()); 964da26bd203cbb104291b39891febf7481794f205fJim Ingham 965da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_queue_passed) 966da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetQueueName(m_options.m_queue_name.c_str()); 967da26bd203cbb104291b39891febf7481794f205fJim Ingham 968da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_ignore_count != 0) 969da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetIgnoreCount(m_options.m_ignore_count); 970da26bd203cbb104291b39891febf7481794f205fJim Ingham 971da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_enable_passed) 972da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetEnabled (m_options.m_enable_value); 973da26bd203cbb104291b39891febf7481794f205fJim Ingham 974da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_condition_passed) 975da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->SetCondition (m_options.m_condition.c_str()); 976d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham } 977d6d47976b71187907c1cdeea86fabf7d5534314fJim Ingham } 97824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 97924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 980da26bd203cbb104291b39891febf7481794f205fJim Ingham 981da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 98224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 98324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 984da26bd203cbb104291b39891febf7481794f205fJim Inghamprivate: 985da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions m_options; 98624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}; 98724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 988da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark Modify::CommandOptions 989da26bd203cbb104291b39891febf7481794f205fJim InghamOptionDefinition 990da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectBreakpointModify::CommandOptions::g_option_table[] = 99124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 992da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, 9932753a024a5a314232baa579c0ada87551aa86988Jim Ingham{ LLDB_OPT_SET_ALL, false, "one-shot", 'o', required_argument, NULL, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." }, 994afee498a0bf7ac1242c484c33c35f1f415a4f2ceSean Callanan{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."}, 995da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."}, 996da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."}, 997da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, 998da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."}, 999da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."}, 1000da26bd203cbb104291b39891febf7481794f205fJim Ingham{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."}, 10012753a024a5a314232baa579c0ada87551aa86988Jim Ingham{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } 1002da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 100324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 100424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 100524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// CommandObjectBreakpointEnable 100624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 100710622a27c4e305aa14075f512c1a30efc2c5c1afJim Ingham#pragma mark Enable 100824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1009da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointEnable : public CommandObjectParsed 101024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 1011da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 1012da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : 1013da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 1014da26bd203cbb104291b39891febf7481794f205fJim Ingham "enable", 1015da26bd203cbb104291b39891febf7481794f205fJim Ingham "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", 1016da26bd203cbb104291b39891febf7481794f205fJim Ingham NULL) 1017da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1018da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentEntry arg; 1019da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); 1020da26bd203cbb104291b39891febf7481794f205fJim Ingham // Add the entry for the first argument for this command to the object's arguments vector. 1021da26bd203cbb104291b39891febf7481794f205fJim Ingham m_arguments.push_back (arg); 1022da26bd203cbb104291b39891febf7481794f205fJim Ingham } 102324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 102424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1025da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1026da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointEnable () {} 102724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1028da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 1029da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 1030da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 103124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1032da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 1033da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 1034da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1035da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No existing target or breakpoints."); 1036da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1037da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1038da26bd203cbb104291b39891febf7481794f205fJim Ingham } 10393c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1040da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 1041da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList().GetListMutex(locker); 10423c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1043da26bd203cbb104291b39891febf7481794f205fJim Ingham const BreakpointList &breakpoints = target->GetBreakpointList(); 104424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1045da26bd203cbb104291b39891febf7481794f205fJim Ingham size_t num_breakpoints = breakpoints.GetSize(); 104624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1047da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_breakpoints == 0) 1048da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1049da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("No breakpoints exist to be enabled."); 1050da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1051da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1052da26bd203cbb104291b39891febf7481794f205fJim Ingham } 105324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1054da26bd203cbb104291b39891febf7481794f205fJim Ingham if (command.GetArgumentCount() == 0) 105524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1056da26bd203cbb104291b39891febf7481794f205fJim Ingham // No breakpoint selected; enable all currently set breakpoints. 1057da26bd203cbb104291b39891febf7481794f205fJim Ingham target->EnableAllBreakpoints (); 1058da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints); 1059da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1060da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1061da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1062da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1063da26bd203cbb104291b39891febf7481794f205fJim Ingham // Particular breakpoint selected; enable that breakpoint. 1064da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList valid_bp_ids; 1065da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); 106624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1067da26bd203cbb104291b39891febf7481794f205fJim Ingham if (result.Succeeded()) 1068da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1069da26bd203cbb104291b39891febf7481794f205fJim Ingham int enable_count = 0; 1070da26bd203cbb104291b39891febf7481794f205fJim Ingham int loc_count = 0; 1071da26bd203cbb104291b39891febf7481794f205fJim Ingham const size_t count = valid_bp_ids.GetSize(); 1072da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < count; ++i) 107324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1074da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); 1075da26bd203cbb104291b39891febf7481794f205fJim Ingham 1076da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) 107724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1078da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 1079da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) 108024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1081da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); 1082da26bd203cbb104291b39891febf7481794f205fJim Ingham if (location) 1083da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1084da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetEnabled (true); 1085da26bd203cbb104291b39891febf7481794f205fJim Ingham ++loc_count; 1086da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1087da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1088da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1089da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1090da26bd203cbb104291b39891febf7481794f205fJim Ingham breakpoint->SetEnabled (true); 1091da26bd203cbb104291b39891febf7481794f205fJim Ingham ++enable_count; 109224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 109324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 109424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 1095da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); 1096da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 109724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 109824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 109924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1100da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 1101da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1102da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 110324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 110424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 110524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// CommandObjectBreakpointDisable 110624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 110710622a27c4e305aa14075f512c1a30efc2c5c1afJim Ingham#pragma mark Disable 110824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1109da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointDisable : public CommandObjectParsed 111024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{ 1111da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 1112da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : 1113da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 1114da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint disable", 1115da26bd203cbb104291b39891febf7481794f205fJim Ingham "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", 1116da26bd203cbb104291b39891febf7481794f205fJim Ingham NULL) 111724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1118d256f7929a38606b13567b141966456db25fea81Jim Ingham SetHelpLong( 1119d256f7929a38606b13567b141966456db25fea81Jim Ingham"Disable the specified breakpoint(s) without removing it/them. \n\ 1120d256f7929a38606b13567b141966456db25fea81Jim InghamIf no breakpoints are specified, disable them all.\n\ 1121d256f7929a38606b13567b141966456db25fea81Jim Ingham\n\ 1122d256f7929a38606b13567b141966456db25fea81Jim InghamNote: disabling a breakpoint will cause none of its locations to be hit\n\ 1123d256f7929a38606b13567b141966456db25fea81Jim Inghamregardless of whether they are enabled or disabled. So the sequence: \n\ 1124d256f7929a38606b13567b141966456db25fea81Jim Ingham\n\ 1125d256f7929a38606b13567b141966456db25fea81Jim Ingham (lldb) break disable 1\n\ 1126d256f7929a38606b13567b141966456db25fea81Jim Ingham (lldb) break enable 1.1\n\ 1127d256f7929a38606b13567b141966456db25fea81Jim Ingham\n\ 1128d256f7929a38606b13567b141966456db25fea81Jim Inghamwill NOT cause location 1.1 to get hit. To achieve that, do:\n\ 1129d256f7929a38606b13567b141966456db25fea81Jim Ingham\n\ 1130d256f7929a38606b13567b141966456db25fea81Jim Ingham (lldb) break disable 1.*\n\ 1131d256f7929a38606b13567b141966456db25fea81Jim Ingham (lldb) break enable 1.1\n\ 1132d256f7929a38606b13567b141966456db25fea81Jim Ingham\n\ 1133d256f7929a38606b13567b141966456db25fea81Jim InghamThe first command disables all the locations of breakpoint 1, \n\ 1134d256f7929a38606b13567b141966456db25fea81Jim Inghamthe second re-enables the first location." 1135d256f7929a38606b13567b141966456db25fea81Jim Ingham ); 1136d256f7929a38606b13567b141966456db25fea81Jim Ingham 1137da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentEntry arg; 1138da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); 1139da26bd203cbb104291b39891febf7481794f205fJim Ingham // Add the entry for the first argument for this command to the object's arguments vector. 1140d256f7929a38606b13567b141966456db25fea81Jim Ingham m_arguments.push_back (arg); 1141d256f7929a38606b13567b141966456db25fea81Jim Ingham 114224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 114324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 11443c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1145da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1146da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointDisable () {} 114724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1148da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 1149da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 1150da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 115124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1152da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 1153da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 1154da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1155da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No existing target or breakpoints."); 1156da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1157da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1158da26bd203cbb104291b39891febf7481794f205fJim Ingham } 115924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1160da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 1161da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList().GetListMutex(locker); 116224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1163da26bd203cbb104291b39891febf7481794f205fJim Ingham const BreakpointList &breakpoints = target->GetBreakpointList(); 1164da26bd203cbb104291b39891febf7481794f205fJim Ingham size_t num_breakpoints = breakpoints.GetSize(); 116524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1166da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_breakpoints == 0) 116724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1168da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("No breakpoints exist to be disabled."); 1169da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1170da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1171da26bd203cbb104291b39891febf7481794f205fJim Ingham } 117224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1173da26bd203cbb104291b39891febf7481794f205fJim Ingham if (command.GetArgumentCount() == 0) 1174da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1175da26bd203cbb104291b39891febf7481794f205fJim Ingham // No breakpoint selected; disable all currently set breakpoints. 1176da26bd203cbb104291b39891febf7481794f205fJim Ingham target->DisableAllBreakpoints (); 1177da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints); 1178da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1179da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1180da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1181da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1182da26bd203cbb104291b39891febf7481794f205fJim Ingham // Particular breakpoint selected; disable that breakpoint. 1183da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList valid_bp_ids; 1184da26bd203cbb104291b39891febf7481794f205fJim Ingham 1185da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); 1186da26bd203cbb104291b39891febf7481794f205fJim Ingham 1187da26bd203cbb104291b39891febf7481794f205fJim Ingham if (result.Succeeded()) 1188da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1189da26bd203cbb104291b39891febf7481794f205fJim Ingham int disable_count = 0; 1190da26bd203cbb104291b39891febf7481794f205fJim Ingham int loc_count = 0; 1191da26bd203cbb104291b39891febf7481794f205fJim Ingham const size_t count = valid_bp_ids.GetSize(); 1192da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < count; ++i) 119324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1194da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); 1195da26bd203cbb104291b39891febf7481794f205fJim Ingham 1196da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) 119724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1198da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 1199da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) 120024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1201da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); 1202da26bd203cbb104291b39891febf7481794f205fJim Ingham if (location) 1203da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1204da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetEnabled (false); 1205da26bd203cbb104291b39891febf7481794f205fJim Ingham ++loc_count; 1206da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1207da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1208da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1209da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1210da26bd203cbb104291b39891febf7481794f205fJim Ingham breakpoint->SetEnabled (false); 1211da26bd203cbb104291b39891febf7481794f205fJim Ingham ++disable_count; 121224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 121324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 121424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 1215da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); 1216da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 121724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 121824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 1219da26bd203cbb104291b39891febf7481794f205fJim Ingham 1220da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 122124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 122224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1223da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 122424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 122524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//------------------------------------------------------------------------- 1226da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectBreakpointList 1227a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen//------------------------------------------------------------------------- 1228da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark List 1229a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1230da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointList : public CommandObjectParsed 1231a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen{ 1232da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 1233da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointList (CommandInterpreter &interpreter) : 1234da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 1235da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint list", 1236da26bd203cbb104291b39891febf7481794f205fJim Ingham "List some or all breakpoints at configurable levels of detail.", 1237da26bd203cbb104291b39891febf7481794f205fJim Ingham NULL), 1238da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options (interpreter) 1239da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1240da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentEntry arg; 1241da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentData bp_id_arg; 1242a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1243da26bd203cbb104291b39891febf7481794f205fJim Ingham // Define the first (and only) variant of this arg. 1244da26bd203cbb104291b39891febf7481794f205fJim Ingham bp_id_arg.arg_type = eArgTypeBreakpointID; 1245da26bd203cbb104291b39891febf7481794f205fJim Ingham bp_id_arg.arg_repetition = eArgRepeatOptional; 1246a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1247da26bd203cbb104291b39891febf7481794f205fJim Ingham // There is only one variant this argument could be; put it into the argument entry. 1248da26bd203cbb104291b39891febf7481794f205fJim Ingham arg.push_back (bp_id_arg); 1249a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1250da26bd203cbb104291b39891febf7481794f205fJim Ingham // Push the data for the first argument into the m_arguments vector. 1251da26bd203cbb104291b39891febf7481794f205fJim Ingham m_arguments.push_back (arg); 1252da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1253a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1254a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1255da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1256da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointList () {} 1257a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1258da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Options * 1259da26bd203cbb104291b39891febf7481794f205fJim Ingham GetOptions () 1260a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1261da26bd203cbb104291b39891febf7481794f205fJim Ingham return &m_options; 1262a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1263da26bd203cbb104291b39891febf7481794f205fJim Ingham 1264da26bd203cbb104291b39891febf7481794f205fJim Ingham class CommandOptions : public Options 1265da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1266da26bd203cbb104291b39891febf7481794f205fJim Ingham public: 1267a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1268da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions (CommandInterpreter &interpreter) : 1269da26bd203cbb104291b39891febf7481794f205fJim Ingham Options (interpreter), 1270da26bd203cbb104291b39891febf7481794f205fJim Ingham m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions 1271da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1272da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1273a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1274da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1275da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandOptions () {} 1276a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1277da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Error 1278da26bd203cbb104291b39891febf7481794f205fJim Ingham SetOptionValue (uint32_t option_idx, const char *option_arg) 1279da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1280da26bd203cbb104291b39891febf7481794f205fJim Ingham Error error; 12816475c42148a8ea1ca86e5db465db7eca742d897dGreg Clayton const int short_option = m_getopt_table[option_idx].val; 1282a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1283da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (short_option) 1284da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1285da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'b': 1286da26bd203cbb104291b39891febf7481794f205fJim Ingham m_level = lldb::eDescriptionLevelBrief; 1287da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1288da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'f': 1289da26bd203cbb104291b39891febf7481794f205fJim Ingham m_level = lldb::eDescriptionLevelFull; 1290da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1291da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'v': 1292da26bd203cbb104291b39891febf7481794f205fJim Ingham m_level = lldb::eDescriptionLevelVerbose; 1293da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1294da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'i': 1295da26bd203cbb104291b39891febf7481794f205fJim Ingham m_internal = true; 1296da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1297da26bd203cbb104291b39891febf7481794f205fJim Ingham default: 1298da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 1299da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1300da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1301a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1302da26bd203cbb104291b39891febf7481794f205fJim Ingham return error; 1303da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1304a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1305da26bd203cbb104291b39891febf7481794f205fJim Ingham void 1306da26bd203cbb104291b39891febf7481794f205fJim Ingham OptionParsingStarting () 1307da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1308da26bd203cbb104291b39891febf7481794f205fJim Ingham m_level = lldb::eDescriptionLevelFull; 1309da26bd203cbb104291b39891febf7481794f205fJim Ingham m_internal = false; 1310da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1311a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1312da26bd203cbb104291b39891febf7481794f205fJim Ingham const OptionDefinition * 1313da26bd203cbb104291b39891febf7481794f205fJim Ingham GetDefinitions () 1314da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1315da26bd203cbb104291b39891febf7481794f205fJim Ingham return g_option_table; 1316da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1317a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1318da26bd203cbb104291b39891febf7481794f205fJim Ingham // Options table: Required for subclasses of Options. 1319a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1320da26bd203cbb104291b39891febf7481794f205fJim Ingham static OptionDefinition g_option_table[]; 1321a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1322da26bd203cbb104291b39891febf7481794f205fJim Ingham // Instance variables to hold the values for command options. 1323a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1324da26bd203cbb104291b39891febf7481794f205fJim Ingham lldb::DescriptionLevel m_level; 1325a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1326da26bd203cbb104291b39891febf7481794f205fJim Ingham bool m_internal; 1327da26bd203cbb104291b39891febf7481794f205fJim Ingham }; 1328a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1329da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 1330da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 1331da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 1332a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1333da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 1334da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 1335da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1336da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No current target or breakpoints."); 1337da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1338da26bd203cbb104291b39891febf7481794f205fJim Ingham return true; 1339da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1340a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1341da26bd203cbb104291b39891febf7481794f205fJim Ingham const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); 1342da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 1343da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); 1344a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1345da26bd203cbb104291b39891febf7481794f205fJim Ingham size_t num_breakpoints = breakpoints.GetSize(); 1346a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1347da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_breakpoints == 0) 1348da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1349da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessage ("No breakpoints currently set."); 1350da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1351da26bd203cbb104291b39891febf7481794f205fJim Ingham return true; 1352da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1353da26bd203cbb104291b39891febf7481794f205fJim Ingham 1354da26bd203cbb104291b39891febf7481794f205fJim Ingham Stream &output_stream = result.GetOutputStream(); 1355da26bd203cbb104291b39891febf7481794f205fJim Ingham 1356da26bd203cbb104291b39891febf7481794f205fJim Ingham if (command.GetArgumentCount() == 0) 1357da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1358da26bd203cbb104291b39891febf7481794f205fJim Ingham // No breakpoint selected; show info about all currently set breakpoints. 1359da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessage ("Current breakpoints:"); 1360da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < num_breakpoints; ++i) 1361a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1362da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); 1363da26bd203cbb104291b39891febf7481794f205fJim Ingham AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); 1364da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1365da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1366da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1367da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1368da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1369da26bd203cbb104291b39891febf7481794f205fJim Ingham // Particular breakpoints selected; show info about that breakpoint. 1370da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList valid_bp_ids; 1371da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); 1372a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1373da26bd203cbb104291b39891febf7481794f205fJim Ingham if (result.Succeeded()) 1374da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1375da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) 1376a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1377da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); 1378da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 1379da26bd203cbb104291b39891febf7481794f205fJim Ingham AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); 1380a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1381da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1382da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1383da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1384da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1385da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid breakpoint id."); 1386da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1387a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1388da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1389a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1390da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 1391a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1392a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1393da26bd203cbb104291b39891febf7481794f205fJim Inghamprivate: 1394da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions m_options; 1395da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 1396da26bd203cbb104291b39891febf7481794f205fJim Ingham 1397da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark List::CommandOptions 1398da26bd203cbb104291b39891febf7481794f205fJim InghamOptionDefinition 1399da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectBreakpointList::CommandOptions::g_option_table[] = 1400da26bd203cbb104291b39891febf7481794f205fJim Ingham{ 1401da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, 1402da26bd203cbb104291b39891febf7481794f205fJim Ingham "Show debugger internal breakpoints" }, 1403da26bd203cbb104291b39891febf7481794f205fJim Ingham 1404da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, 1405da26bd203cbb104291b39891febf7481794f205fJim Ingham "Give a brief description of the breakpoint (no location info)."}, 1406da26bd203cbb104291b39891febf7481794f205fJim Ingham 1407da26bd203cbb104291b39891febf7481794f205fJim Ingham // FIXME: We need to add an "internal" command, and then add this sort of thing to it. 1408da26bd203cbb104291b39891febf7481794f205fJim Ingham // But I need to see it for now, and don't want to wait. 1409da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, 1410da26bd203cbb104291b39891febf7481794f205fJim Ingham "Give a full description of the breakpoint and its locations."}, 1411da26bd203cbb104291b39891febf7481794f205fJim Ingham 1412da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, 1413da26bd203cbb104291b39891febf7481794f205fJim Ingham "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, 1414da26bd203cbb104291b39891febf7481794f205fJim Ingham 1415da26bd203cbb104291b39891febf7481794f205fJim Ingham { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } 1416da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 1417da26bd203cbb104291b39891febf7481794f205fJim Ingham 1418da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 1419da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectBreakpointClear 1420da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 1421da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark Clear 1422da26bd203cbb104291b39891febf7481794f205fJim Ingham 1423da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointClear : public CommandObjectParsed 1424da26bd203cbb104291b39891febf7481794f205fJim Ingham{ 1425da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 1426da26bd203cbb104291b39891febf7481794f205fJim Ingham 1427da26bd203cbb104291b39891febf7481794f205fJim Ingham typedef enum BreakpointClearType 1428da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1429da26bd203cbb104291b39891febf7481794f205fJim Ingham eClearTypeInvalid, 1430da26bd203cbb104291b39891febf7481794f205fJim Ingham eClearTypeFileAndLine 1431da26bd203cbb104291b39891febf7481794f205fJim Ingham } BreakpointClearType; 1432da26bd203cbb104291b39891febf7481794f205fJim Ingham 1433da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointClear (CommandInterpreter &interpreter) : 1434da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 1435da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint clear", 1436da26bd203cbb104291b39891febf7481794f205fJim Ingham "Clears a breakpoint or set of breakpoints in the executable.", 1437da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint clear <cmd-options>"), 1438da26bd203cbb104291b39891febf7481794f205fJim Ingham m_options (interpreter) 1439a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1440a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1441da26bd203cbb104291b39891febf7481794f205fJim Ingham 1442da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1443da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointClear () {} 1444da26bd203cbb104291b39891febf7481794f205fJim Ingham 1445da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Options * 1446da26bd203cbb104291b39891febf7481794f205fJim Ingham GetOptions () 1447a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen { 1448da26bd203cbb104291b39891febf7481794f205fJim Ingham return &m_options; 1449a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen } 1450a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1451da26bd203cbb104291b39891febf7481794f205fJim Ingham class CommandOptions : public Options 1452da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1453da26bd203cbb104291b39891febf7481794f205fJim Ingham public: 1454a62ad7c886252a08d614a2b391d0774a151b7196Johnny Chen 1455da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions (CommandInterpreter &interpreter) : 1456da26bd203cbb104291b39891febf7481794f205fJim Ingham Options (interpreter), 1457da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filename (), 1458da26bd203cbb104291b39891febf7481794f205fJim Ingham m_line_num (0) 1459da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1460da26bd203cbb104291b39891febf7481794f205fJim Ingham } 146124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1462da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1463da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandOptions () {} 1464da26bd203cbb104291b39891febf7481794f205fJim Ingham 1465da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual Error 1466da26bd203cbb104291b39891febf7481794f205fJim Ingham SetOptionValue (uint32_t option_idx, const char *option_arg) 1467da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1468da26bd203cbb104291b39891febf7481794f205fJim Ingham Error error; 14696475c42148a8ea1ca86e5db465db7eca742d897dGreg Clayton const int short_option = m_getopt_table[option_idx].val; 1470da26bd203cbb104291b39891febf7481794f205fJim Ingham 1471da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (short_option) 1472da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1473da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'f': 1474da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filename.assign (option_arg); 1475da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1476da26bd203cbb104291b39891febf7481794f205fJim Ingham 1477da26bd203cbb104291b39891febf7481794f205fJim Ingham case 'l': 1478da26bd203cbb104291b39891febf7481794f205fJim Ingham m_line_num = Args::StringToUInt32 (option_arg, 0); 1479da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1480da26bd203cbb104291b39891febf7481794f205fJim Ingham 1481da26bd203cbb104291b39891febf7481794f205fJim Ingham default: 1482da26bd203cbb104291b39891febf7481794f205fJim Ingham error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 1483da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1484da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1485da26bd203cbb104291b39891febf7481794f205fJim Ingham 1486da26bd203cbb104291b39891febf7481794f205fJim Ingham return error; 1487da26bd203cbb104291b39891febf7481794f205fJim Ingham } 148824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1489da26bd203cbb104291b39891febf7481794f205fJim Ingham void 1490da26bd203cbb104291b39891febf7481794f205fJim Ingham OptionParsingStarting () 1491da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1492da26bd203cbb104291b39891febf7481794f205fJim Ingham m_filename.clear(); 1493da26bd203cbb104291b39891febf7481794f205fJim Ingham m_line_num = 0; 1494da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1495da26bd203cbb104291b39891febf7481794f205fJim Ingham 1496da26bd203cbb104291b39891febf7481794f205fJim Ingham const OptionDefinition* 1497da26bd203cbb104291b39891febf7481794f205fJim Ingham GetDefinitions () 1498da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1499da26bd203cbb104291b39891febf7481794f205fJim Ingham return g_option_table; 1500da26bd203cbb104291b39891febf7481794f205fJim Ingham } 150124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1502da26bd203cbb104291b39891febf7481794f205fJim Ingham // Options table: Required for subclasses of Options. 150324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1504da26bd203cbb104291b39891febf7481794f205fJim Ingham static OptionDefinition g_option_table[]; 150524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1506da26bd203cbb104291b39891febf7481794f205fJim Ingham // Instance variables to hold the values for command options. 15073c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1508da26bd203cbb104291b39891febf7481794f205fJim Ingham std::string m_filename; 1509da26bd203cbb104291b39891febf7481794f205fJim Ingham uint32_t m_line_num; 151024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1511da26bd203cbb104291b39891febf7481794f205fJim Ingham }; 151224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1513da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 1514da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 1515da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 151624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1517da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 1518da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 151924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1520da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No existing target or breakpoints."); 1521da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1522da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1523d168690e51f9020b926d3d0d57dc9a2cfb2095a8Jim Ingham } 1524da26bd203cbb104291b39891febf7481794f205fJim Ingham 1525da26bd203cbb104291b39891febf7481794f205fJim Ingham // The following are the various types of breakpoints that could be cleared: 1526da26bd203cbb104291b39891febf7481794f205fJim Ingham // 1). -f -l (clearing breakpoint by source location) 1527da26bd203cbb104291b39891febf7481794f205fJim Ingham 1528da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointClearType break_type = eClearTypeInvalid; 1529da26bd203cbb104291b39891febf7481794f205fJim Ingham 1530da26bd203cbb104291b39891febf7481794f205fJim Ingham if (m_options.m_line_num != 0) 1531da26bd203cbb104291b39891febf7481794f205fJim Ingham break_type = eClearTypeFileAndLine; 1532da26bd203cbb104291b39891febf7481794f205fJim Ingham 1533da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 1534da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList().GetListMutex(locker); 1535da26bd203cbb104291b39891febf7481794f205fJim Ingham 1536da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointList &breakpoints = target->GetBreakpointList(); 1537da26bd203cbb104291b39891febf7481794f205fJim Ingham size_t num_breakpoints = breakpoints.GetSize(); 1538da26bd203cbb104291b39891febf7481794f205fJim Ingham 1539da26bd203cbb104291b39891febf7481794f205fJim Ingham // Early return if there's no breakpoint at all. 1540da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_breakpoints == 0) 1541d168690e51f9020b926d3d0d57dc9a2cfb2095a8Jim Ingham { 1542da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Breakpoint clear: No breakpoint cleared."); 1543da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1544da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 154524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 154624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1547da26bd203cbb104291b39891febf7481794f205fJim Ingham // Find matching breakpoints and delete them. 154824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner 1549da26bd203cbb104291b39891febf7481794f205fJim Ingham // First create a copy of all the IDs. 1550da26bd203cbb104291b39891febf7481794f205fJim Ingham std::vector<break_id_t> BreakIDs; 1551da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < num_breakpoints; ++i) 1552da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID()); 1553da26bd203cbb104291b39891febf7481794f205fJim Ingham 1554da26bd203cbb104291b39891febf7481794f205fJim Ingham int num_cleared = 0; 1555da26bd203cbb104291b39891febf7481794f205fJim Ingham StreamString ss; 1556da26bd203cbb104291b39891febf7481794f205fJim Ingham switch (break_type) 1557da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1558da26bd203cbb104291b39891febf7481794f205fJim Ingham case eClearTypeFileAndLine: // Breakpoint by source position 155924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1560da26bd203cbb104291b39891febf7481794f205fJim Ingham const ConstString filename(m_options.m_filename.c_str()); 1561da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointLocationCollection loc_coll; 1562da26bd203cbb104291b39891febf7481794f205fJim Ingham 1563da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < num_breakpoints; ++i) 156424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1565da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get(); 1566da26bd203cbb104291b39891febf7481794f205fJim Ingham 1567da26bd203cbb104291b39891febf7481794f205fJim Ingham if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) 156824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner { 1569da26bd203cbb104291b39891febf7481794f205fJim Ingham // If the collection size is 0, it's a full match and we can just remove the breakpoint. 1570da26bd203cbb104291b39891febf7481794f205fJim Ingham if (loc_coll.GetSize() == 0) 1571da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1572da26bd203cbb104291b39891febf7481794f205fJim Ingham bp->GetDescription(&ss, lldb::eDescriptionLevelBrief); 1573da26bd203cbb104291b39891febf7481794f205fJim Ingham ss.EOL(); 1574da26bd203cbb104291b39891febf7481794f205fJim Ingham target->RemoveBreakpointByID (bp->GetID()); 1575da26bd203cbb104291b39891febf7481794f205fJim Ingham ++num_cleared; 1576da26bd203cbb104291b39891febf7481794f205fJim Ingham } 157724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 157824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 157924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 1580da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1581da26bd203cbb104291b39891febf7481794f205fJim Ingham 1582da26bd203cbb104291b39891febf7481794f205fJim Ingham default: 1583da26bd203cbb104291b39891febf7481794f205fJim Ingham break; 1584da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1585da26bd203cbb104291b39891febf7481794f205fJim Ingham 1586da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_cleared > 0) 1587da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1588da26bd203cbb104291b39891febf7481794f205fJim Ingham Stream &output_stream = result.GetOutputStream(); 1589da26bd203cbb104291b39891febf7481794f205fJim Ingham output_stream.Printf ("%d breakpoints cleared:\n", num_cleared); 1590da26bd203cbb104291b39891febf7481794f205fJim Ingham output_stream << ss.GetData(); 1591da26bd203cbb104291b39891febf7481794f205fJim Ingham output_stream.EOL(); 159224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner result.SetStatus (eReturnStatusSuccessFinishNoResult); 159324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner } 1594da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1595da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1596da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Breakpoint clear: No breakpoint cleared."); 1597da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1598da26bd203cbb104291b39891febf7481794f205fJim Ingham } 15993c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1600da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 1601da26bd203cbb104291b39891febf7481794f205fJim Ingham } 16023c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1603da26bd203cbb104291b39891febf7481794f205fJim Inghamprivate: 1604da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandOptions m_options; 1605da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 16063c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1607da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark Clear::CommandOptions 16083c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1609b344843f75ef893762c93fd0a22d2d45712ce74dGreg ClaytonOptionDefinition 1610da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectBreakpointClear::CommandOptions::g_option_table[] = 16113c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham{ 1612da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, 1613da26bd203cbb104291b39891febf7481794f205fJim Ingham "Specify the breakpoint by source location in this particular file."}, 1614da26bd203cbb104291b39891febf7481794f205fJim Ingham 1615da26bd203cbb104291b39891febf7481794f205fJim Ingham { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, 1616da26bd203cbb104291b39891febf7481794f205fJim Ingham "Specify the breakpoint by source location at this particular line."}, 1617da26bd203cbb104291b39891febf7481794f205fJim Ingham 1618da26bd203cbb104291b39891febf7481794f205fJim Ingham { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } 16193c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham}; 16203c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1621da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 1622da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectBreakpointDelete 1623da26bd203cbb104291b39891febf7481794f205fJim Ingham//------------------------------------------------------------------------- 1624da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark Delete 16253c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1626da26bd203cbb104291b39891febf7481794f205fJim Inghamclass CommandObjectBreakpointDelete : public CommandObjectParsed 16273c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham{ 1628da26bd203cbb104291b39891febf7481794f205fJim Inghampublic: 1629da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectBreakpointDelete (CommandInterpreter &interpreter) : 1630da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectParsed (interpreter, 1631da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint delete", 1632da26bd203cbb104291b39891febf7481794f205fJim Ingham "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", 1633da26bd203cbb104291b39891febf7481794f205fJim Ingham NULL) 1634da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1635da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandArgumentEntry arg; 1636da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); 1637da26bd203cbb104291b39891febf7481794f205fJim Ingham // Add the entry for the first argument for this command to the object's arguments vector. 1638da26bd203cbb104291b39891febf7481794f205fJim Ingham m_arguments.push_back (arg); 1639da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1640da26bd203cbb104291b39891febf7481794f205fJim Ingham 1641da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual 1642da26bd203cbb104291b39891febf7481794f205fJim Ingham ~CommandObjectBreakpointDelete () {} 16433c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1644da26bd203cbb104291b39891febf7481794f205fJim Inghamprotected: 1645da26bd203cbb104291b39891febf7481794f205fJim Ingham virtual bool 1646da26bd203cbb104291b39891febf7481794f205fJim Ingham DoExecute (Args& command, CommandReturnObject &result) 16473c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1648da26bd203cbb104291b39891febf7481794f205fJim Ingham Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 1649da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target == NULL) 1650da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1651da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("Invalid target. No existing target or breakpoints."); 1652da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1653da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 1654da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1655da26bd203cbb104291b39891febf7481794f205fJim Ingham 1656da26bd203cbb104291b39891febf7481794f205fJim Ingham Mutex::Locker locker; 1657da26bd203cbb104291b39891febf7481794f205fJim Ingham target->GetBreakpointList().GetListMutex(locker); 1658da26bd203cbb104291b39891febf7481794f205fJim Ingham 1659da26bd203cbb104291b39891febf7481794f205fJim Ingham const BreakpointList &breakpoints = target->GetBreakpointList(); 1660da26bd203cbb104291b39891febf7481794f205fJim Ingham 1661da26bd203cbb104291b39891febf7481794f205fJim Ingham size_t num_breakpoints = breakpoints.GetSize(); 1662da26bd203cbb104291b39891febf7481794f205fJim Ingham 1663da26bd203cbb104291b39891febf7481794f205fJim Ingham if (num_breakpoints == 0) 16643c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1665da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError ("No breakpoints exist to be deleted."); 1666da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1667da26bd203cbb104291b39891febf7481794f205fJim Ingham return false; 16683c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 1669da26bd203cbb104291b39891febf7481794f205fJim Ingham 1670da26bd203cbb104291b39891febf7481794f205fJim Ingham if (command.GetArgumentCount() == 0) 16713c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1672da26bd203cbb104291b39891febf7481794f205fJim Ingham if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true)) 16739a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham { 1674da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessage("Operation cancelled..."); 16759a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham } 16769a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham else 16779a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham { 1678da26bd203cbb104291b39891febf7481794f205fJim Ingham target->RemoveAllBreakpoints (); 1679476beee60081230d4e6b4c1994c6d724c9077f8cJim Ingham result.AppendMessageWithFormat ("All breakpoints removed. (%lu %s)\n", num_breakpoints, num_breakpoints > 1 ? "breakpoints" : "breakpoint"); 16809a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham } 1681da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 16823c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 1683da26bd203cbb104291b39891febf7481794f205fJim Ingham else 16843c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1685da26bd203cbb104291b39891febf7481794f205fJim Ingham // Particular breakpoint selected; disable that breakpoint. 1686da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList valid_bp_ids; 1687da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); 1688da26bd203cbb104291b39891febf7481794f205fJim Ingham 1689da26bd203cbb104291b39891febf7481794f205fJim Ingham if (result.Succeeded()) 16909a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham { 1691da26bd203cbb104291b39891febf7481794f205fJim Ingham int delete_count = 0; 1692da26bd203cbb104291b39891febf7481794f205fJim Ingham int disable_count = 0; 1693da26bd203cbb104291b39891febf7481794f205fJim Ingham const size_t count = valid_bp_ids.GetSize(); 1694da26bd203cbb104291b39891febf7481794f205fJim Ingham for (size_t i = 0; i < count; ++i) 1695da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1696da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); 1697da26bd203cbb104291b39891febf7481794f205fJim Ingham 1698da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) 1699da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1700da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) 1701da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1702da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 1703da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); 1704da26bd203cbb104291b39891febf7481794f205fJim Ingham // It makes no sense to try to delete individual locations, so we disable them instead. 1705da26bd203cbb104291b39891febf7481794f205fJim Ingham if (location) 1706da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1707da26bd203cbb104291b39891febf7481794f205fJim Ingham location->SetEnabled (false); 1708da26bd203cbb104291b39891febf7481794f205fJim Ingham ++disable_count; 1709da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1710da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1711da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1712da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1713da26bd203cbb104291b39891febf7481794f205fJim Ingham target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); 1714da26bd203cbb104291b39891febf7481794f205fJim Ingham ++delete_count; 1715da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1716da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1717da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1718da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", 1719da26bd203cbb104291b39891febf7481794f205fJim Ingham delete_count, disable_count); 1720da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 17219a7b291e2a9df2aca6ee47860fbec33b53807c35Jim Ingham } 17223c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 1723da26bd203cbb104291b39891febf7481794f205fJim Ingham return result.Succeeded(); 17243c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 1725da26bd203cbb104291b39891febf7481794f205fJim Ingham}; 17263c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 17273c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham//------------------------------------------------------------------------- 1728da26bd203cbb104291b39891febf7481794f205fJim Ingham// CommandObjectMultiwordBreakpoint 17293c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham//------------------------------------------------------------------------- 1730da26bd203cbb104291b39891febf7481794f205fJim Ingham#pragma mark MultiwordBreakpoint 17313c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1732da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : 1733da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectMultiword (interpreter, 1734da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint", 1735da26bd203cbb104291b39891febf7481794f205fJim Ingham "A set of commands for operating on breakpoints. Also see _regexp-break.", 1736da26bd203cbb104291b39891febf7481794f205fJim Ingham "breakpoint <command> [<command-options>]") 17373c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham{ 1738da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); 1739da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); 1740da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); 1741da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter)); 1742da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); 1743da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); 1744da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); 1745da26bd203cbb104291b39891febf7481794f205fJim Ingham CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); 1746da26bd203cbb104291b39891febf7481794f205fJim Ingham 1747da26bd203cbb104291b39891febf7481794f205fJim Ingham list_command_object->SetCommandName ("breakpoint list"); 1748da26bd203cbb104291b39891febf7481794f205fJim Ingham enable_command_object->SetCommandName("breakpoint enable"); 1749da26bd203cbb104291b39891febf7481794f205fJim Ingham disable_command_object->SetCommandName("breakpoint disable"); 1750da26bd203cbb104291b39891febf7481794f205fJim Ingham clear_command_object->SetCommandName("breakpoint clear"); 1751da26bd203cbb104291b39891febf7481794f205fJim Ingham delete_command_object->SetCommandName("breakpoint delete"); 1752da26bd203cbb104291b39891febf7481794f205fJim Ingham set_command_object->SetCommandName("breakpoint set"); 1753da26bd203cbb104291b39891febf7481794f205fJim Ingham command_command_object->SetCommandName ("breakpoint command"); 1754da26bd203cbb104291b39891febf7481794f205fJim Ingham modify_command_object->SetCommandName ("breakpoint modify"); 1755da26bd203cbb104291b39891febf7481794f205fJim Ingham 17564a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("list", list_command_object); 17574a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("enable", enable_command_object); 17584a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("disable", disable_command_object); 17594a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("clear", clear_command_object); 17604a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("delete", delete_command_object); 17614a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("set", set_command_object); 17624a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("command", command_command_object); 17634a379b1194f3e6b308cd6e80b45d6ca5dd0aafd7Greg Clayton LoadSubCommand ("modify", modify_command_object); 17643c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham} 17653c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1766da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () 17673c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham{ 17683c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham} 17693c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1770da26bd203cbb104291b39891febf7481794f205fJim Inghamvoid 1771da26bd203cbb104291b39891febf7481794f205fJim InghamCommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result, 1772da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList *valid_ids) 17733c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham{ 1774da26bd203cbb104291b39891febf7481794f205fJim Ingham // args can be strings representing 1). integers (for breakpoint ids) 1775da26bd203cbb104291b39891febf7481794f205fJim Ingham // 2). the full breakpoint & location canonical representation 1776da26bd203cbb104291b39891febf7481794f205fJim Ingham // 3). the word "to" or a hyphen, representing a range (in which case there 1777da26bd203cbb104291b39891febf7481794f205fJim Ingham // had *better* be an entry both before & after of one of the first two types. 1778da26bd203cbb104291b39891febf7481794f205fJim Ingham // If args is empty, we will use the last created breakpoint (if there is one.) 1779da26bd203cbb104291b39891febf7481794f205fJim Ingham 1780da26bd203cbb104291b39891febf7481794f205fJim Ingham Args temp_args; 1781da26bd203cbb104291b39891febf7481794f205fJim Ingham 1782da26bd203cbb104291b39891febf7481794f205fJim Ingham if (args.GetArgumentCount() == 0) 17833c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1784da26bd203cbb104291b39891febf7481794f205fJim Ingham if (target->GetLastCreatedBreakpoint()) 1785da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1786da26bd203cbb104291b39891febf7481794f205fJim Ingham valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); 1787da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusSuccessFinishNoResult); 1788da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1789da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1790da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1791da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendError("No breakpoint specified and no last created breakpoint."); 1792da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1793da26bd203cbb104291b39891febf7481794f205fJim Ingham } 1794da26bd203cbb104291b39891febf7481794f205fJim Ingham return; 17953c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 17963c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1797da26bd203cbb104291b39891febf7481794f205fJim Ingham // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to 1798da26bd203cbb104291b39891febf7481794f205fJim Ingham // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for 1799da26bd203cbb104291b39891febf7481794f205fJim Ingham // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. 1800da26bd203cbb104291b39891febf7481794f205fJim Ingham 1801da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); 1802da26bd203cbb104291b39891febf7481794f205fJim Ingham 1803da26bd203cbb104291b39891febf7481794f205fJim Ingham // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: 1804da26bd203cbb104291b39891febf7481794f205fJim Ingham 1805da26bd203cbb104291b39891febf7481794f205fJim Ingham valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); 18063c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 1807da26bd203cbb104291b39891febf7481794f205fJim Ingham // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs 1808da26bd203cbb104291b39891febf7481794f205fJim Ingham // and put into valid_ids. 18093c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham 18103c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham if (result.Succeeded()) 18113c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1812da26bd203cbb104291b39891febf7481794f205fJim Ingham // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list 1813da26bd203cbb104291b39891febf7481794f205fJim Ingham // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. 1814da26bd203cbb104291b39891febf7481794f205fJim Ingham 1815da26bd203cbb104291b39891febf7481794f205fJim Ingham const size_t count = valid_ids->GetSize(); 181654e7afa84d945f9137f9372ecde432f9e1a702fcGreg Clayton for (size_t i = 0; i < count; ++i) 18173c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1818da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); 1819da26bd203cbb104291b39891febf7481794f205fJim Ingham Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); 1820da26bd203cbb104291b39891febf7481794f205fJim Ingham if (breakpoint != NULL) 18213c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 182236da2aa6dc5ad9994b638ed09eb81c44cc05540bGreg Clayton const size_t num_locations = breakpoint->GetNumLocations(); 1823da26bd203cbb104291b39891febf7481794f205fJim Ingham if (cur_bp_id.GetLocationID() > num_locations) 18243c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham { 1825da26bd203cbb104291b39891febf7481794f205fJim Ingham StreamString id_str; 1826da26bd203cbb104291b39891febf7481794f205fJim Ingham BreakpointID::GetCanonicalReference (&id_str, 1827da26bd203cbb104291b39891febf7481794f205fJim Ingham cur_bp_id.GetBreakpointID(), 1828da26bd203cbb104291b39891febf7481794f205fJim Ingham cur_bp_id.GetLocationID()); 1829da26bd203cbb104291b39891febf7481794f205fJim Ingham i = valid_ids->GetSize() + 1; 1830da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", 1831da26bd203cbb104291b39891febf7481794f205fJim Ingham id_str.GetData()); 1832da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 18333c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 18343c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 1835da26bd203cbb104291b39891febf7481794f205fJim Ingham else 1836da26bd203cbb104291b39891febf7481794f205fJim Ingham { 1837da26bd203cbb104291b39891febf7481794f205fJim Ingham i = valid_ids->GetSize() + 1; 1838da26bd203cbb104291b39891febf7481794f205fJim Ingham result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); 1839da26bd203cbb104291b39891febf7481794f205fJim Ingham result.SetStatus (eReturnStatusFailed); 1840da26bd203cbb104291b39891febf7481794f205fJim Ingham } 18413c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 18423c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham } 18433c7b5b9f83cae58ca366db2bba37dc09485f7dccJim Ingham} 1844