Skip to content
Merged
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
3 changes: 3 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class OptionValue {
eTypeChar,
eTypeDictionary,
eTypeEnum,
eTypeFileLineColumn,
eTypeFileSpec,
eTypeFileSpecList,
eTypeFormat,
Expand Down Expand Up @@ -135,6 +136,8 @@ class OptionValue {
return eTypeDictionary;
case 1u << eTypeEnum:
return eTypeEnum;
case 1u << eTypeFileLineColumn:
return eTypeFileLineColumn;
case 1u << eTypeFileSpec:
return eTypeFileSpec;
case 1u << eTypeFileSpecList:
Expand Down
64 changes: 64 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===-- OptionValueFileColonLine.h -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_INTERPRETER_OPTIONVALUEFILECOLONLINE_H
#define LLDB_INTERPRETER_OPTIONVALUEFILECOLONLINE_H

#include "lldb/Interpreter/OptionValue.h"

#include "lldb/Utility/FileSpec.h"
#include "llvm/Support/Chrono.h"

namespace lldb_private {

class OptionValueFileColonLine : public OptionValue {
public:
OptionValueFileColonLine();
OptionValueFileColonLine(const llvm::StringRef input);

~OptionValueFileColonLine() override {}

OptionValue::Type GetType() const override { return eTypeFileLineColumn; }

void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

Status
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
Status
SetValueFromString(const char *,
VarSetOperationType = eVarSetOperationAssign) = delete;

bool Clear() override {
m_file_spec.Clear();
m_line_number = LLDB_INVALID_LINE_NUMBER;
m_column_number = 0;
}

lldb::OptionValueSP DeepCopy() const override;

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

FileSpec &GetFileSpec() { return m_file_spec; }
uint32_t GetLineNumber() { return m_line_number; }
uint32_t GetColumnNumber() { return m_column_number; }

void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }

protected:
FileSpec m_file_spec;
uint32_t m_line_number;
uint32_t m_column_number;
uint32_t m_completion_mask;
};

} // namespace lldb_private

#endif // LLDB_INTERPRETER_OPTIONVALUEFILECOLONLINE_H
1 change: 1 addition & 0 deletions lldb/include/lldb/Interpreter/OptionValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "lldb/Interpreter/OptionValueChar.h"
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Interpreter/OptionValueEnumeration.h"
#include "lldb/Interpreter/OptionValueFileColonLine.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueFormat.h"
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
#define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX
#define LLDB_INVALID_OFFSET UINT64_MAX // Must match max of lldb::offset_t
#define LLDB_INVALID_LINE_NUMBER UINT32_MAX
#define LLDB_INVALID_COLUMN_NUMBER 0
#define LLDB_INVALID_QUEUE_ID 0

/// CPU Type definitions
Expand All @@ -119,6 +120,7 @@
#define LLDB_OPT_SET_9 (1U << 8)
#define LLDB_OPT_SET_10 (1U << 9)
#define LLDB_OPT_SET_11 (1U << 10)
#define LLDB_OPT_SET_12 (1U << 11)
#define LLDB_OPT_SET_FROM_TO(A, B) \
(((1U << (B)) - 1) ^ (((1U << (A)) - 1) >> 1))

Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/lldb-enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ enum CommandArgumentType {
eArgTypeExpression,
eArgTypeExpressionPath,
eArgTypeExprFormat,
eArgTypeFileLineColumn,
eArgTypeFilename,
eArgTypeFormat,
eArgTypeFrameIndex,
Expand Down
36 changes: 36 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lldbutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,29 @@ def run_break_set_by_source_regexp(

return get_bpno_from_match(break_results)

def run_break_set_by_file_colon_line(
test,
specifier,
path,
line_number,
column_number = 0,
extra_options=None,
num_expected_locations=-1):
command = 'breakpoint set -y "%s"'%(specifier)
if extra_options:
command += " " + extra_options

print("About to run: '%s'", command)
break_results = run_break_set_command(test, command)
check_breakpoint_result(
test,
break_results,
num_locations = num_expected_locations,
file_name = path,
line_number = line_number,
column_number = column_number)

return get_bpno_from_match(break_results)

def run_break_set_command(test, command):
"""Run the command passed in - it must be some break set variant - and analyze the result.
Expand All @@ -552,6 +575,7 @@ def run_break_set_command(test, command):
If there is only one location, the dictionary MAY contain:
file - source file name
line_no - source line number
column - source column number
symbol - symbol name
inline_symbol - inlined symbol name
offset - offset from the original symbol
Expand Down Expand Up @@ -603,6 +627,7 @@ def check_breakpoint_result(
break_results,
file_name=None,
line_number=-1,
column_number=0,
symbol_name=None,
symbol_match_exact=True,
module_name=None,
Expand Down Expand Up @@ -642,6 +667,17 @@ def check_breakpoint_result(
(line_number,
out_line_number))

if column_number != 0:
out_column_number = 0
if 'column' in break_results:
out_column_number = break_results['column']

test.assertTrue(
column_number == out_column_number,
"Breakpoint column number %s doesn't match resultant column %s." %
(column_number,
out_column_number))

if symbol_name:
out_symbol_name = ""
# Look first for the inlined symbol name, otherwise use the symbol
Expand Down
18 changes: 17 additions & 1 deletion lldb/source/Commands/CommandObjectBreakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/OptionValueFileColonLine.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
Expand Down Expand Up @@ -443,7 +444,22 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
case 'X':
m_source_regex_func_names.insert(std::string(option_arg));
break;


case 'y':
{
OptionValueFileColonLine value;
Status fcl_err = value.SetValueFromString(option_arg);
if (!fcl_err.Success()) {
error.SetErrorStringWithFormat(
"Invalid value for file:line specifier: %s",
fcl_err.AsCString());
} else {
m_filenames.AppendIfUnique(value.GetFileSpec());
m_line_num = value.GetLineNumber();
m_column = value.GetColumnNumber();
}
} break;

default:
llvm_unreachable("Unimplemented option");
}
Expand Down
17 changes: 17 additions & 0 deletions lldb/source/Commands/CommandObjectSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueFileColonLine.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
Expand Down Expand Up @@ -667,6 +668,22 @@ class CommandObjectSourceList : public CommandObjectParsed {
case 'r':
reverse = true;
break;
case 'y':
{
OptionValueFileColonLine value;
Status fcl_err = value.SetValueFromString(option_arg);
if (!fcl_err.Success()) {
error.SetErrorStringWithFormat(
"Invalid value for file:line specifier: %s",
fcl_err.AsCString());
} else {
file_name = value.GetFileSpec().GetPath();
start_line = value.GetLineNumber();
// I don't see anything useful to do with a column number, but I don't
// want to complain since someone may well have cut and pasted a
// listing from somewhere that included a column.
}
} break;
default:
llvm_unreachable("Unimplemented option");
}
Expand Down
17 changes: 12 additions & 5 deletions lldb/source/Commands/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let Command = "breakpoint dummy" in {

let Command = "breakpoint set" in {
def breakpoint_set_shlib : Option<"shlib", "s">, Arg<"ShlibName">,
Completion<"Module">, Groups<[1,2,3,4,5,6,7,8,9,11]>, // *not* in group 10
Completion<"Module">, Groups<[1,2,3,4,5,6,7,8,9,11,12]>, // *not* in group 10
Desc<"Set the breakpoint only in this shared library. Can repeat this "
"option multiple times to specify multiple shared libraries.">;
def breakpoint_set_hardware : Option<"hardware", "H">,
Expand Down Expand Up @@ -186,21 +186,24 @@ let Command = "breakpoint set" in {
"expression (note: currently only implemented for setting breakpoints on "
"identifiers). If not set the target.language setting is used.">;
def breakpoint_set_skip_prologue : Option<"skip-prologue", "K">,
Arg<"Boolean">, Groups<[1,3,4,5,6,7,8]>,
Arg<"Boolean">, Groups<[1,3,4,5,6,7,8,12]>,
Desc<"sKip the prologue if the breakpoint is at the beginning of a "
"function. If not set the target.skip-prologue setting is used.">;
def breakpoint_set_breakpoint_name : Option<"breakpoint-name", "N">,
Arg<"BreakpointName">,
Desc<"Adds this to the list of names for this breakpoint.">;
def breakpoint_set_address_slide : Option<"address-slide", "R">,
Arg<"Address">, Groups<[1,3,4,5,6,7,8]>,
Arg<"Address">, Groups<[1,3,4,5,6,7,8,12]>,
Desc<"Add the specified offset to whatever address(es) the breakpoint "
"resolves to. At present this applies the offset directly as given, and "
"doesn't try to align it to instruction boundaries.">;
def breakpoint_set_move_to_nearest_code : Option<"move-to-nearest-code", "m">,
Groups<[1, 9]>, Arg<"Boolean">,
Groups<[1,9,12]>, Arg<"Boolean">,
Desc<"Move breakpoints to nearest code. If not set the "
"target.move-to-nearest-codesetting is used.">;
def breakpoint_set_file_colon_line : Option<"joint-specifier", "y">, Group<12>, Arg<"FileLineColumn">,
Required, Completion<"SourceFile">,
Desc<"A specifier in the form filename:line[:column] for setting file & line breakpoints.">;
/* Don't add this option till it actually does something useful...
def breakpoint_set_exception_typename : Option<"exception-typename", "O">,
Arg<"TypeName">, Desc<"The breakpoint will only stop if an "
Expand Down Expand Up @@ -737,7 +740,7 @@ let Command = "source info" in {
let Command = "source list" in {
def source_list_count : Option<"count", "c">, Arg<"Count">,
Desc<"The number of source lines to display.">;
def source_list_shlib : Option<"shlib", "s">, Groups<[1,2]>, Arg<"ShlibName">,
def source_list_shlib : Option<"shlib", "s">, Groups<[1,2,5]>, Arg<"ShlibName">,
Completion<"Module">,
Desc<"Look up the source file in the given shared library.">;
def source_list_show_breakpoints : Option<"show-breakpoints", "b">,
Expand All @@ -755,6 +758,10 @@ let Command = "source list" in {
" information for the corresponding file and line.">;
def source_list_reverse : Option<"reverse", "r">, Group<4>, Desc<"Reverse the"
" listing to look backwards from the last displayed block of source.">;
def source_list_file_colon_line : Option<"joint-specifier", "y">, Group<5>,
Arg<"FileLineColumn">, Completion<"SourceFile">,
Desc<"A specifier in the form filename:line[:column] from which to display"
" source.">;
}

let Command = "target dependents" in {
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ add_lldb_library(lldbInterpreter
OptionValueChar.cpp
OptionValueDictionary.cpp
OptionValueEnumeration.cpp
OptionValueFileColonLine.cpp
OptionValueFileSpec.cpp
OptionValueFileSpecList.cpp
OptionValueFormat.cpp
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Interpreter/CommandObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." },
{ eArgTypeLanguage, "source-language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
{ eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." },
{ eArgTypeFileLineColumn, "linespec", CommandCompletions::eNoCompletion, { nullptr, false }, "A source specifier in the form file:line[:column]" },
{ eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
{ eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
{ eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." },
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Interpreter/OptionValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ const char *OptionValue::GetBuiltinTypeAsCString(Type t) {
return "dictionary";
case eTypeEnum:
return "enum";
case eTypeFileLineColumn:
return "file:line:column specifier";
case eTypeFileSpec:
return "file";
case eTypeFileSpecList:
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Interpreter/OptionValueArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void OptionValueArray::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
case eTypeChar:
case eTypeEnum:
case eTypeFileSpec:
case eTypeFileLineColumn:
case eTypeFormat:
case eTypeSInt64:
case eTypeString:
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Interpreter/OptionValueDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void OptionValueDictionary::DumpValue(const ExecutionContext *exe_ctx,
case eTypeBoolean:
case eTypeChar:
case eTypeEnum:
case eTypeFileLineColumn:
case eTypeFileSpec:
case eTypeFormat:
case eTypeSInt64:
Expand Down
Loading