Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,27 @@ static constexpr OptionEnumValueElement g_running_mode[] = {
"Run only this thread while stepping"},
};

static constexpr OptionEnumValueElement g_exception_stage[] = {
{lldb::eExceptionStageThrow, "throw", "Stop when the exception is thrown."},
{lldb::eExceptionStageReThrow, "re-throw",
"Stop when the exception is re-thrown."},
{lldb::eExceptionStageCatch, "catch", "Stop when the exception is caught."},
};

static constexpr OptionEnumValueElement g_name_match_style[] = {
{lldb::eNameMatchStyleAuto, "auto",
"Match against the leaf nodes of the identifier, or against methods or "
"selectors."},
{lldb::eNameMatchStyleFull, "full", "Match the full identifier name."},
{lldb::eNameMatchStyleBase, "base",
"Match against the leaf node of the identifier."},
{lldb::eNameMatchStyleMethod, "method", "Match only against method names."},
{lldb::eNameMatchStyleSelector, "selector",
"Match only against selector names."},
{lldb::eNameMatchStyleRegex, "regex",
"Match the identifier using a regular expression."},
};

static constexpr OptionEnumValueElement g_completion_type[] = {
{lldb::eNoCompletion, "none", "No completion."},
{lldb::eSourceFileCompletion, "source-file", "Completes to a source file."},
Expand Down Expand Up @@ -316,6 +337,8 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
{ lldb::eArgTypeCPUFeatures, "cpu-features", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The CPU feature string." },
{ lldb::eArgTypeManagedPlugin, "managed-plugin", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "Plugins managed by the PluginManager" },
{ lldb::eArgTypeProtocol, "protocol", lldb::CompletionType::eNoCompletion, {}, { nullptr, false }, "The name of the protocol." },
{ lldb::eArgTypeExceptionStage, "exception-stage", lldb::CompletionType::eNoCompletion, g_exception_stage, { nullptr, false }, "Specify at which stage of the exception raise to stop." },
{ lldb::eArgTypeNameMatchStyle, "match-style", lldb::CompletionType::eNoCompletion, g_name_match_style, { nullptr, false }, "Specify the kind of match to use when looking up names." },
// clang-format on
};

Expand Down
4 changes: 4 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class OptionValueFileColonLine :
m_column_number = LLDB_INVALID_COLUMN_NUMBER;
}

void SetFile(const FileSpec &file_spec) { m_file_spec = file_spec; }
void SetLine(uint32_t line) { m_line_number = line; }
void SetColumn(uint32_t column) { m_column_number = column; }

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

Expand Down
18 changes: 18 additions & 0 deletions lldb/include/lldb/lldb-enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ enum CommandArgumentType {
eArgTypeCPUFeatures,
eArgTypeManagedPlugin,
eArgTypeProtocol,
eArgTypeExceptionStage,
eArgTypeNameMatchStyle,
eArgTypeLastArg // Always keep this entry as the last entry in this
// enumeration!!
};
Expand Down Expand Up @@ -1401,6 +1403,22 @@ enum StopDisassemblyType {
eStopDisassemblyTypeAlways
};

enum ExceptionStage {
eExceptionStageCreate = (1 << 0),
eExceptionStageThrow = (1 << 1),
eExceptionStageReThrow = (1 << 2),
eExceptionStageCatch = (1 << 3)
};

enum NameMatchStyle {
eNameMatchStyleAuto = eFunctionNameTypeAuto,
eNameMatchStyleFull = eFunctionNameTypeFull,
eNameMatchStyleBase = eFunctionNameTypeBase,
eNameMatchStyleMethod = eFunctionNameTypeMethod,
eNameMatchStyleSelector = eFunctionNameTypeSelector,
eNameMatchStyleRegex = eFunctionNameTypeSelector << 1
};

} // namespace lldb

#endif // LLDB_LLDB_ENUMERATIONS_H
61 changes: 51 additions & 10 deletions lldb/packages/Python/lldbsuite/test/lldbutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,34 @@ def sort_stopped_threads(
# Utility functions for setting breakpoints
# ==================================================

g_use_break_add = True


def set_use_break_add(use_it):
global g_use_break_add
g_use_break_add = use_it


def get_use_break_add():
global g_use_break_add
return g_use_break_add

def run_break_set_by_script(
test, class_name, extra_options=None, num_expected_locations=1
):
"""Set a scripted breakpoint. Check that it got the right number of locations."""
test.assertTrue(class_name is not None, "Must pass in a class name.")
command = "breakpoint set -P " + class_name
if get_use_break_add():
command = f"breakpoint add scripted -P {class_name}"
else:
command = "breakpoint set -P " + class_name
if extra_options is not None:
command += " " + extra_options

break_results = run_break_set_command(test, command)
check_breakpoint_result(test, break_results, num_locations=num_expected_locations)
return get_bpno_from_match(break_results)


def run_break_set_by_file_and_line(
test,
file_name,
Expand All @@ -353,10 +366,16 @@ def run_break_set_by_file_and_line(
If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.
"""

if file_name is None:
command = "breakpoint set -l %d" % (line_number)
if get_use_break_add():
if file_name is None:
command = f"breakpoint add file {line_number} "
else:
command = f"breakpoint add file -f {file_name} -l {line_number} "
else:
command = 'breakpoint set -f "%s" -l %d' % (file_name, line_number)
if file_name is None:
command = "breakpoint set -l %d" % (line_number)
else:
command = 'breakpoint set -f "%s" -l %d' % (file_name, line_number)

if module_name:
command += " --shlib '%s'" % (module_name)
Expand Down Expand Up @@ -395,14 +414,20 @@ def run_break_set_by_symbol(

If sym_exact is true, then the output symbol must match the input exactly, otherwise we do a substring match.
"""
command = 'breakpoint set -n "%s"' % (symbol)
if get_use_break_add():
command = f"breakpoint add name"
else:
command = 'breakpoint set -n "%s"' % (symbol)

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

if extra_options:
command += " " + extra_options

if get_use_break_add():
command += f" -- '{symbol}'"

break_results = run_break_set_command(test, command)

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

command = 'breakpoint set -S "%s"' % (selector)
if get_use_break_add():
command = f"breakpoint add name --match-style selector '{selector}'"
else:
command = 'breakpoint set -S "%s"' % (selector)

if module_name:
command += ' --shlib "%s"' % (module_name)
Expand Down Expand Up @@ -458,7 +486,10 @@ def run_break_set_by_regexp(
):
"""Set a breakpoint by regular expression match on symbol name. Common options are the same as run_break_set_by_file_and_line."""

command = 'breakpoint set -r "%s"' % (regexp)
if get_use_break_add():
command = f"breakpoint add name --match-style regex '{regexp}'"
else:
command = 'breakpoint set -r "%s"' % (regexp)
if extra_options:
command += " " + extra_options

Expand All @@ -473,10 +504,16 @@ def run_break_set_by_source_regexp(
test, regexp, extra_options=None, num_expected_locations=-1
):
"""Set a breakpoint by source regular expression. Common options are the same as run_break_set_by_file_and_line."""
command = 'breakpoint set -p "%s"' % (regexp)
if get_use_break_add():
command = "breakpoint add pattern"
else:
command = 'breakpoint set -p "%s"' % (regexp)
if extra_options:
command += " " + extra_options

if get_use_break_add():
command += f" -- {regexp}"

break_results = run_break_set_command(test, command)

check_breakpoint_result(test, break_results, num_locations=num_expected_locations)
Expand All @@ -493,7 +530,11 @@ def run_break_set_by_file_colon_line(
extra_options=None,
num_expected_locations=-1,
):
command = 'breakpoint set -y "%s"' % (specifier)
if get_use_break_add():
command = f"breakpoint add file '{specifier}'"
else:
command = 'breakpoint set -y "%s"' % (specifier)

if extra_options:
command += " " + extra_options

Expand Down
Loading
Loading