Skip to content

Commit fb2e2df

Browse files
committed
breakpoint add - all subcommands implemented. Testsuite clean but no
new tests.
1 parent 7fca1f8 commit fb2e2df

File tree

8 files changed

+1571
-105
lines changed

8 files changed

+1571
-105
lines changed

lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ static constexpr OptionEnumValueElement g_running_mode[] = {
154154
"Run only this thread while stepping"},
155155
};
156156

157+
static constexpr OptionEnumValueElement g_exception_stage[] = {
158+
{lldb::eExceptionStageThrow, "throw", "Stop when the exception is thrown."},
159+
{lldb::eExceptionStageReThrow, "re-throw", "Stop when the exception is re-thrown."},
160+
{lldb::eExceptionStageCatch, "catch", "Stop when the exception is caught."},
161+
};
162+
163+
static constexpr OptionEnumValueElement g_name_match_style[] = {
164+
{lldb::eNameMatchStyleAuto, "auto", "Match against the leaf nodes of the identifier, or against methods or selectors."},
165+
{lldb::eNameMatchStyleFull, "full", "Match the full identifier name."},
166+
{lldb::eNameMatchStyleBase, "base", "Match against the leaf node of the identifier."},
167+
{lldb::eNameMatchStyleMethod, "method", "Match only against method names."},
168+
{lldb::eNameMatchStyleSelector, "selector", "Match only against selector names."},
169+
{lldb::eNameMatchStyleRegex, "regex", "Match the identifier using a regular expression."},
170+
};
171+
157172
static constexpr OptionEnumValueElement g_completion_type[] = {
158173
{lldb::eNoCompletion, "none", "No completion."},
159174
{lldb::eSourceFileCompletion, "source-file", "Completes to a source file."},
@@ -316,6 +331,8 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
316331
{ lldb::eArgTypeCPUFeatures, "cpu-features", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The CPU feature string." },
317332
{ lldb::eArgTypeManagedPlugin, "managed-plugin", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Plugins managed by the PluginManager" },
318333
{ lldb::eArgTypeProtocol, "protocol", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of the protocol." },
334+
{ lldb::eArgTypeExceptionStage, "exception-stage", lldb::CompletionType::eNoCompletion, g_exception_stage, { nullptr, false }, "Specify at which stage of the exception raise to stop." },
335+
{ lldb::eArgTypeNameMatchStyle, "match-style", lldb::CompletionType::eNoCompletion, g_name_match_style, { nullptr, false }, "Specify the kind of match to use when looking up names." },
319336
// clang-format on
320337
};
321338

lldb/include/lldb/Interpreter/OptionValueFileColonLine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class OptionValueFileColonLine :
4040
m_line_number = LLDB_INVALID_LINE_NUMBER;
4141
m_column_number = LLDB_INVALID_COLUMN_NUMBER;
4242
}
43+
44+
void SetFile(const FileSpec &file_spec) { m_file_spec = file_spec; }
45+
void SetLine(uint32_t line) { m_line_number = line; }
46+
void SetColumn(uint32_t column) { m_column_number = column; }
4347

4448
void AutoComplete(CommandInterpreter &interpreter,
4549
CompletionRequest &request) override;

lldb/include/lldb/lldb-enumerations.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ enum CommandArgumentType {
668668
eArgTypeCPUFeatures,
669669
eArgTypeManagedPlugin,
670670
eArgTypeProtocol,
671+
eArgTypeExceptionStage,
672+
eArgTypeNameMatchStyle,
671673
eArgTypeLastArg // Always keep this entry as the last entry in this
672674
// enumeration!!
673675
};
@@ -1399,6 +1401,22 @@ enum StopDisassemblyType {
13991401
eStopDisassemblyTypeAlways
14001402
};
14011403

1404+
enum ExceptionStage {
1405+
eExceptionStageCreate = (1 << 0),
1406+
eExceptionStageThrow = (1 << 1),
1407+
eExceptionStageReThrow = (1 << 2),
1408+
eExceptionStageCatch = (1 << 3)
1409+
};
1410+
1411+
enum NameMatchStyle {
1412+
eNameMatchStyleAuto = eFunctionNameTypeAuto,
1413+
eNameMatchStyleFull = eFunctionNameTypeFull,
1414+
eNameMatchStyleBase = eFunctionNameTypeBase,
1415+
eNameMatchStyleMethod = eFunctionNameTypeMethod,
1416+
eNameMatchStyleSelector = eFunctionNameTypeSelector,
1417+
eNameMatchStyleRegex = eFunctionNameTypeSelector << 1
1418+
};
1419+
14021420
} // namespace lldb
14031421

14041422
#endif // LLDB_LLDB_ENUMERATIONS_H

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,31 @@ def sort_stopped_threads(
319319
# Utility functions for setting breakpoints
320320
# ==================================================
321321

322+
g_use_break_add = True
323+
def set_use_break_add(use_it):
324+
global g_use_break_add
325+
g_use_break_add = use_it
326+
327+
def get_use_break_add():
328+
global g_use_break_add
329+
return g_use_break_add
322330

323331
def run_break_set_by_script(
324332
test, class_name, extra_options=None, num_expected_locations=1
325333
):
326334
"""Set a scripted breakpoint. Check that it got the right number of locations."""
327335
test.assertTrue(class_name is not None, "Must pass in a class name.")
328-
command = "breakpoint set -P " + class_name
336+
if get_use_break_add():
337+
command = f"breakpoint add scripted -P {class_name}"
338+
else:
339+
command = "breakpoint set -P " + class_name
329340
if extra_options is not None:
330341
command += " " + extra_options
331342

332343
break_results = run_break_set_command(test, command)
333344
check_breakpoint_result(test, break_results, num_locations=num_expected_locations)
334345
return get_bpno_from_match(break_results)
335346

336-
337347
def run_break_set_by_file_and_line(
338348
test,
339349
file_name,
@@ -353,10 +363,16 @@ def run_break_set_by_file_and_line(
353363
If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.
354364
"""
355365

356-
if file_name is None:
357-
command = "breakpoint set -l %d" % (line_number)
366+
if get_use_break_add():
367+
if file_name is None:
368+
command = f"breakpoint add file {line_number} "
369+
else:
370+
command = f"breakpoint add file -f {file_name} -l {line_number} "
358371
else:
359-
command = 'breakpoint set -f "%s" -l %d' % (file_name, line_number)
372+
if file_name is None:
373+
command = "breakpoint set -l %d" % (line_number)
374+
else:
375+
command = 'breakpoint set -f "%s" -l %d' % (file_name, line_number)
360376

361377
if module_name:
362378
command += " --shlib '%s'" % (module_name)
@@ -395,14 +411,20 @@ def run_break_set_by_symbol(
395411
396412
If sym_exact is true, then the output symbol must match the input exactly, otherwise we do a substring match.
397413
"""
398-
command = 'breakpoint set -n "%s"' % (symbol)
414+
if get_use_break_add():
415+
command = f"breakpoint add name"
416+
else:
417+
command = 'breakpoint set -n "%s"' % (symbol)
399418

400419
if module_name:
401420
command += " --shlib '%s'" % (module_name)
402421

403422
if extra_options:
404423
command += " " + extra_options
405424

425+
if get_use_break_add():
426+
command += f" -- '{symbol}'"
427+
406428
break_results = run_break_set_command(test, command)
407429

408430
if num_expected_locations == 1 and sym_exact:
@@ -426,7 +448,10 @@ def run_break_set_by_selector(
426448
):
427449
"""Set a breakpoint by selector. Common options are the same as run_break_set_by_file_and_line."""
428450

429-
command = 'breakpoint set -S "%s"' % (selector)
451+
if get_use_break_add():
452+
command = f"breakpoint add name --match-style selector '{selector}'"
453+
else:
454+
command = 'breakpoint set -S "%s"' % (selector)
430455

431456
if module_name:
432457
command += ' --shlib "%s"' % (module_name)
@@ -458,7 +483,10 @@ def run_break_set_by_regexp(
458483
):
459484
"""Set a breakpoint by regular expression match on symbol name. Common options are the same as run_break_set_by_file_and_line."""
460485

461-
command = 'breakpoint set -r "%s"' % (regexp)
486+
if get_use_break_add():
487+
command = f"breakpoint add name --match-style regex '{regexp}'"
488+
else:
489+
command = 'breakpoint set -r "%s"' % (regexp)
462490
if extra_options:
463491
command += " " + extra_options
464492

@@ -473,10 +501,16 @@ def run_break_set_by_source_regexp(
473501
test, regexp, extra_options=None, num_expected_locations=-1
474502
):
475503
"""Set a breakpoint by source regular expression. Common options are the same as run_break_set_by_file_and_line."""
476-
command = 'breakpoint set -p "%s"' % (regexp)
504+
if get_use_break_add():
505+
command = "breakpoint add pattern"
506+
else:
507+
command = 'breakpoint set -p "%s"' % (regexp)
477508
if extra_options:
478509
command += " " + extra_options
479510

511+
if get_use_break_add():
512+
command += f" -- {regexp}"
513+
480514
break_results = run_break_set_command(test, command)
481515

482516
check_breakpoint_result(test, break_results, num_locations=num_expected_locations)
@@ -493,7 +527,11 @@ def run_break_set_by_file_colon_line(
493527
extra_options=None,
494528
num_expected_locations=-1,
495529
):
496-
command = 'breakpoint set -y "%s"' % (specifier)
530+
if get_use_break_add():
531+
command = f"breakpoint add file '{specifier}'"
532+
else:
533+
command = 'breakpoint set -y "%s"' % (specifier)
534+
497535
if extra_options:
498536
command += " " + extra_options
499537

0 commit comments

Comments
 (0)