[Lldb-commits] [PATCH] D101361: [LLDB] Support AArch64/Linux watchpoint on tagged addresses
DavidSpickett added a reviewer: mgorny. DavidSpickett added a subscriber: mgorny. DavidSpickett added a comment. @mgorny Does FreeBSD do anything with the top byte ignore feature? Comment at: lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp:476 + return hit_addr & ((1ULL << 56) - 1); +} I think it was fine where it was, my point was just to check whether FreeBSD enables TBI at all. Seems like it should be an OS level query. 99% of the time we'd be fine assuming it's enabled but I don't like the idea of pretending that it is and giving a false impression. Unless assuming TBI is safe just because the hardware registers don't hold those bits anyway. In which case the comment should justify that. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101361/new/ https://reviews.llvm.org/D101361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D99944: [LLDB] AArch64 Linux and elf-core PAC stack unwinder support
DavidSpickett added a comment. The code LGTM but others should decide if this fits with their efforts. Comment at: lldb/test/API/functionalities/unwind/aarch64_unwind_pac/Makefile:3 + +CFLAGS := -g -Os -march=armv8.5-a -mbranch-protection=pac-ret+leaf + Nit: `armv8.3-a` would also be fine here CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99944/new/ https://reviews.llvm.org/D99944 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D101361: [LLDB] Support AArch64/Linux watchpoint on tagged addresses
omjavaid added inline comments. Comment at: lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp:476 + return hit_addr & ((1ULL << 56) - 1); +} DavidSpickett wrote: > I think it was fine where it was, my point was just to check whether FreeBSD > enables TBI at all. > > Seems like it should be an OS level query. 99% of the time we'd be fine > assuming it's enabled but I don't like the idea of pretending that it is and > giving a false impression. > > Unless assuming TBI is safe just because the hardware registers don't hold > those bits anyway. In which case the comment should justify that. My first choice was to ignore FreeBSD implementation unless someone from FreeBSD does it after testing. The test-case in this patch is also enabled only for Linux/AArch 64. But as an after thought, to make things uniform across LLDB, I made this change given that we are ignoring top-byte of watchpoint install address from all platforms with ABISysV on host side. Also watchpoint address in DBGWVR is 48 bits in normal VA mode and 52 bits in LVA mode so thought ignoring top byte across all platforms seemed safe. But lets wait for what @mgorny has to say on this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101361/new/ https://reviews.llvm.org/D101361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D101128: [lldb-vscode] only report long running progress events
wallace updated this revision to Diff 342754. wallace added a comment. nits Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101128/new/ https://reviews.llvm.org/D101128 Files: lldb/tools/lldb-vscode/ProgressEvent.cpp lldb/tools/lldb-vscode/ProgressEvent.h lldb/tools/lldb-vscode/VSCode.cpp lldb/tools/lldb-vscode/VSCode.h lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -376,8 +376,7 @@ const char *message = lldb::SBDebugger::GetProgressFromEvent( event, progress_id, completed, total, is_debugger_specific); if (message) - g_vsc.SendProgressEvent( - ProgressEvent(progress_id, message, completed, total)); + g_vsc.SendProgressEvent(progress_id, message, completed, total); } } } Index: lldb/tools/lldb-vscode/VSCode.h === --- lldb/tools/lldb-vscode/VSCode.h +++ lldb/tools/lldb-vscode/VSCode.h @@ -114,7 +114,7 @@ uint32_t reverse_request_seq; std::map request_handlers; bool waiting_for_run_in_terminal; - ProgressEventFilterQueue progress_event_queue; + ProgressEventReporter progress_event_reporter; // Keep track of the last stop thread index IDs as threads won't go away // unless we send a "thread" event to indicate the thread exited. llvm::DenseSet thread_ids; @@ -125,10 +125,6 @@ int64_t GetLineForPC(int64_t sourceReference, lldb::addr_t pc) const; ExceptionBreakpoint *GetExceptionBreakpoint(const std::string &filter); ExceptionBreakpoint *GetExceptionBreakpoint(const lldb::break_id_t bp_id); - // Send the JSON in "json_str" to the "out" stream. Correctly send the - // "Content-Length:" field followed by the length, followed by the raw - // JSON bytes. - void SendJSON(const std::string &json_str); // Serialize the JSON value into a string and send the JSON packet to // the "out" stream. @@ -138,7 +134,8 @@ void SendOutput(OutputType o, const llvm::StringRef output); - void SendProgressEvent(const ProgressEvent &event); + void SendProgressEvent(uint64_t progress_id, const char *message, + uint64_t completed, uint64_t total); void __attribute__((format(printf, 3, 4))) SendFormattedOutput(OutputType o, const char *format, ...); @@ -208,6 +205,12 @@ /// The callback to execute when the given request is triggered by the /// IDE. void RegisterRequestCallback(std::string request, RequestCallback callback); + +private: + // Send the JSON in "json_str" to the "out" stream. Correctly send the + // "Content-Length:" field followed by the length, followed by the raw + // JSON bytes. + void SendJSON(const std::string &json_str); }; extern VSCode g_vsc; Index: lldb/tools/lldb-vscode/VSCode.cpp === --- lldb/tools/lldb-vscode/VSCode.cpp +++ lldb/tools/lldb-vscode/VSCode.cpp @@ -42,7 +42,7 @@ focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false), stop_at_entry(false), is_attach(false), reverse_request_seq(0), waiting_for_run_in_terminal(false), - progress_event_queue( + progress_event_reporter( [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }) { const char *log_file_path = getenv("LLDBVSCODE_LOG"); #if defined(_WIN32) @@ -322,8 +322,9 @@ // }; // } -void VSCode::SendProgressEvent(const ProgressEvent &event) { - progress_event_queue.Push(event); +void VSCode::SendProgressEvent(uint64_t progress_id, const char *message, + uint64_t completed, uint64_t total) { + progress_event_reporter.Push(progress_id, message, completed, total); } void __attribute__((format(printf, 3, 4))) Index: lldb/tools/lldb-vscode/ProgressEvent.h === --- lldb/tools/lldb-vscode/ProgressEvent.h +++ lldb/tools/lldb-vscode/ProgressEvent.h @@ -6,6 +6,10 @@ // //===--===// +#include +#include +#include + #include "VSCodeForward.h" #include "llvm/Support/JSON.h" @@ -13,50 +17,127 @@ namespace lldb_vscode { enum ProgressEventType { - progressInvalid, progressStart, progressUpdate, progressEnd }; +class ProgressEvent; +using ProgressEventReportCallback = std::function; + class ProgressEvent { public: - ProgressEvent() {} + /// Constructor for an start event + ProgressEvent(uint64_t progress_id, llvm::StringRef message, +llvm::Optional percentage); - ProgressEvent(uint64_t progress_id, const char *message, uint64_t completed, -uint64_t total); + /// Constructor for an update or end event + ProgressEvent(ui
[Lldb-commits] [PATCH] D100740: [trace] Dedup different source lines when dumping instructions + refactor
wallace marked 6 inline comments as done. wallace added inline comments. Comment at: lldb/source/Target/Trace.cpp:173 + // instruction's disassembler when possible. + auto calculate_disass = [&](const Address &address, const SymbolContext &sc) { +if (prev_insn.disassembler) { clayborg wrote: > Can or should we get the disassembler in calculate_symbol_context above after > calling address.CalculateSymbolContext(...)? i think it's fine as it is, as we don't always need a disassembly. I want to use this TraverseInstructionsWithSymbolInfo method for creating the call graph, and I don't need the disassembly for that Comment at: lldb/source/Target/Trace.cpp:203 + thread, position, direction, + [&](size_t index, Expected load_address) -> bool { +if (!load_address) clayborg wrote: > Can this function really be called without a valid load address? yes, whenever there are gaps in the trace Comment at: lldb/source/Target/Trace.cpp:310 size_t end_position, bool raw) { - if (!IsTraced(thread)) { + Optional instructions_count = GetInstructionCount(thread); + if (!instructions_count) { clayborg wrote: > Should this return a Expected? In case there is an error we want to > show? Like maybe the trace buffer was truncated, or missing when it was > expected? Can we have a process that is traced, but by the time we fetch the > instructions, the circular buffer was filled with other data and even though > the thread was traced there is no data? Any kind of errors are represented as failed instructions, which means that if the entire operation failed, there's one single instruction with an error message. If the thread is not traced at all, then this method return None. There can be errors while getting the data or errors while decoding individual instructions. That was a suggestion by Labath and I think this makes the code simpler, as there is only one way to handle errors. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100740/new/ https://reviews.llvm.org/D100740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D100740: [trace] Dedup different source lines when dumping instructions + refactor
wallace updated this revision to Diff 342770. wallace marked an inline comment as done. wallace added a comment. address comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100740/new/ https://reviews.llvm.org/D100740 Files: lldb/include/lldb/Core/AddressRange.h lldb/include/lldb/Target/Trace.h lldb/source/Core/AddressRange.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h lldb/source/Target/Trace.cpp lldb/test/API/commands/trace/TestTraceStartStop.py Index: lldb/test/API/commands/trace/TestTraceStartStop.py === --- lldb/test/API/commands/trace/TestTraceStartStop.py +++ lldb/test/API/commands/trace/TestTraceStartStop.py @@ -100,7 +100,6 @@ a.out`main \+ 11 at main.cpp:4 \[1\] {ADDRESS_REGEX}movl .* \[2\] {ADDRESS_REGEX}jmp .* ; <\+28> at main.cpp:4 - a.out`main \+ 28 at main.cpp:4 \[3\] {ADDRESS_REGEX}cmpl .* \[4\] {ADDRESS_REGEX}jle .* ; <\+20> at main.cpp:5''']) Index: lldb/source/Target/Trace.cpp === --- lldb/source/Target/Trace.cpp +++ lldb/source/Target/Trace.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Symbol/Function.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Thread.h" @@ -101,189 +102,256 @@ return num == 0 ? 1 : static_cast(log10(num)) + 1; } -/// Dump the symbol context of the given instruction address if it's different -/// from the symbol context of the previous instruction in the trace. -/// -/// \param[in] prev_sc -/// The symbol context of the previous instruction in the trace. -/// -/// \param[in] address -/// The address whose symbol information will be dumped. -/// /// \return -/// The symbol context of the current address, which might differ from the -/// previous one. -static SymbolContext DumpSymbolContext(Stream &s, const SymbolContext &prev_sc, - Target &target, const Address &address) { - AddressRange range; - if (prev_sc.GetAddressRange(eSymbolContextEverything, 0, - /*inline_block_range*/ false, range) && - range.ContainsFileAddress(address)) -return prev_sc; +/// \b true if the provided line entries match line, column and source file. +/// This function assumes that the line entries are valid. +static bool FileLineAndColumnMatches(const LineEntry &a, const LineEntry &b) { + if (a.line != b.line) +return false; + if (a.column != b.column) +return false; + + return FileSpec::Compare(a.file, b.file, true) == 0; +} + +// This custom LineEntry validator is neded because some line_entries have +// 0 as line, which is meaningless. Notice that LineEntry::IsValid only +// checks that line is not LLDB_INVALID_LINE_NUMBER, i.e. UINT32_MAX. +static bool IsLineEntryValid(const LineEntry &line_entry) { + return line_entry.IsValid() && line_entry.line > 0; +} +/// Helper structure for \a TraverseInstructionsWithSymbolInfo. +struct InstructionSymbolInfo { SymbolContext sc; - address.CalculateSymbolContext(&sc, eSymbolContextEverything); + Address address; + lldb::addr_t load_address; + lldb::DisassemblerSP disassembler; + lldb::InstructionSP instruction; + lldb_private::ExecutionContext exe_ctx; +}; - if (!prev_sc.module_sp && !sc.module_sp) -return sc; - if (prev_sc.module_sp == sc.module_sp && !sc.function && !sc.symbol && - !prev_sc.function && !prev_sc.symbol) +/// InstructionSymbolInfo object with symbol information for the given +/// instruction, calculated efficiently. +/// +/// \param[in] symbol_scope +/// If not \b 0, then the \a InstructionSymbolInfo will have its +/// SymbolContext calculated up to that level. +/// +/// \param[in] include_disassembler +/// If \b true, then the \a InstructionSymbolInfo will have the +/// \a disassembler and \a instruction objects calculated. +static void TraverseInstructionsWithSymbolInfo( +Trace &trace, Thread &thread, size_t position, +Trace::TraceDirection direction, SymbolContextItem symbol_scope, +bool include_disassembler, +std::function insn)> +callback) { + InstructionSymbolInfo prev_insn; + + Target &target = thread.GetProcess()->GetTarget(); + ExecutionContext exe_ctx; + target.CalculateExecutionContext(exe_ctx); + const ArchSpec &arch = target.GetArchitecture(); + + // Find the symbol context for the given address reusing the previous + // instruction's symbol context when possible. + auto calculate_symbol_context = [&](const Address &address) { +AddressRange range; +if (prev_insn.sc.GetAddressRange(symbol_scope, 0, + /*inline_block_range*/ false, range) &
[Lldb-commits] [lldb] 0c3f762 - [lldb/Utility] Update path in FileSpec documentation (NFC)
Author: Med Ismail Bennani Date: 2021-05-04T16:34:44Z New Revision: 0c3f762c8fd142464f9f3146091045a9b63db2c1 URL: https://github.com/llvm/llvm-project/commit/0c3f762c8fd142464f9f3146091045a9b63db2c1 DIFF: https://github.com/llvm/llvm-project/commit/0c3f762c8fd142464f9f3146091045a9b63db2c1.diff LOG: [lldb/Utility] Update path in FileSpec documentation (NFC) Update FileSpec doxygen path to reflect its actual location in the source-tree. Signed-off-by: Med Ismail Bennani Added: Modified: lldb/include/lldb/Utility/FileSpec.h Removed: diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index f7cbeb247100d..ef768089c3037 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -38,7 +38,7 @@ template class SmallVectorImpl; namespace lldb_private { -/// \class FileSpec FileSpec.h "lldb/Host/FileSpec.h" +/// \class FileSpec FileSpec.h "lldb/Utility/FileSpec.h" /// A file utility class. /// /// A file specification class that divides paths up into a directory ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1435f6b - [lldb] Move and clean-up the Declaration class (NFC)
Author: Med Ismail Bennani Date: 2021-05-04T16:34:44Z New Revision: 1435f6b00be79f1042818da8714ad4de2aef7848 URL: https://github.com/llvm/llvm-project/commit/1435f6b00be79f1042818da8714ad4de2aef7848 DIFF: https://github.com/llvm/llvm-project/commit/1435f6b00be79f1042818da8714ad4de2aef7848.diff LOG: [lldb] Move and clean-up the Declaration class (NFC) This patch moves the Declaration class from the Symbol library to the Core library. This will allow to use it in a more generic fashion and aims to lower the dependency cycles when it comes to the linking. The patch also does some cleaning up by making column information permanent and removing the LLDB_ENABLE_DECLARATION_COLUMNS directives. Differential revision: https://reviews.llvm.org/D101556 Signed-off-by: Med Ismail Bennani Added: lldb/include/lldb/Core/Declaration.h lldb/source/Core/Declaration.cpp Modified: lldb/include/lldb/Symbol/Function.h lldb/include/lldb/Symbol/Type.h lldb/include/lldb/Symbol/Variable.h lldb/source/API/SBDeclaration.cpp lldb/source/API/SBValue.cpp lldb/source/Core/Address.cpp lldb/source/Core/CMakeLists.txt lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectVariable.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/CMakeLists.txt lldb/unittests/Symbol/TestClangASTImporter.cpp lldb/unittests/Symbol/TestTypeSystemClang.cpp Removed: lldb/include/lldb/Symbol/Declaration.h lldb/source/Symbol/Declaration.cpp diff --git a/lldb/include/lldb/Symbol/Declaration.h b/lldb/include/lldb/Core/Declaration.h similarity index 77% rename from lldb/include/lldb/Symbol/Declaration.h rename to lldb/include/lldb/Core/Declaration.h index 7f19f45411a02..5df8034ae3c4b 100644 --- a/lldb/include/lldb/Symbol/Declaration.h +++ b/lldb/include/lldb/Core/Declaration.h @@ -14,7 +14,7 @@ namespace lldb_private { -/// \class Declaration Declaration.h "lldb/Symbol/Declaration.h" +/// \class Declaration Declaration.h "lldb/Core/Declaration.h" /// A class that describes the declaration location of a ///lldb object. /// @@ -24,14 +24,7 @@ namespace lldb_private { class Declaration { public: /// Default constructor. - Declaration() - : m_file(), m_line(0) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS -, -m_column(0) -#endif - { - } + Declaration() : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) {} /// Construct with file specification, and optional line and column. /// @@ -46,23 +39,13 @@ class Declaration { /// \param[in] column /// The column number that describes where this was declared. /// Set to zero if there is no column number information. - Declaration(const FileSpec &file_spec, uint32_t line = 0, uint32_t column = 0) - : m_file(file_spec), m_line(line) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS -, -m_column(column) -#endif - { - } + Declaration(const FileSpec &file_spec, uint32_t line = 0, + uint16_t column = LLDB_INVALID_COLUMN_NUMBER) + : m_file(file_spec), m_line(line), m_column(column) {} /// Construct with a pointer to another Declaration object. Declaration(const Declaration *decl_ptr) - : m_file(), m_line(0) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS -, -m_column(0) -#endif - { + : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { if (decl_ptr) *this = *decl_ptr; } @@ -74,9 +57,7 @@ class Declaration { void Clear() { m_file.Clear(); m_line = 0; -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS m_column = 0; -#endif } /// Compare two declaration objects. @@ -118,18 +99,6 @@ class Declaration { void Dump(Stream *s, bool show_fullpaths) const; bool DumpStopContext(Stream *s, bool show_fullpaths) const; - /// Get accessor for the declaration column number. - /// - /// \return - /// Non-zero indicates a valid column number, zero indicates no - /// column information is available. - uint32_t GetColumn() const { -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS -return m_column; -#else -return 0; -#endif - } /// Get accessor for file specification. /// @@ -150,7 +119,32 @@ class Declaration { /// line information is available. uint32_t GetLine() const { return m_line; } - bool IsValid() const { return m_file && m_line != 0; } + /// Get accessor for the declaration column number. + /// + /// \return + /// Non-zero indicates a valid column number, zero indicates no + /// column information is available. + uint16_t GetColumn() const { return m_column; } + + /// Convert to boolean operator. + /// + /// This allows code to check a Declaration object to see if it + /// contains anything valid usin
[Lldb-commits] [lldb] adfffeb - [lldb/Core] Add SourceLocationSpec class (NFC)
Author: Med Ismail Bennani Date: 2021-05-04T16:34:45Z New Revision: adfffebec6d6910304e4b1ccdbef78e226a8fd32 URL: https://github.com/llvm/llvm-project/commit/adfffebec6d6910304e4b1ccdbef78e226a8fd32 DIFF: https://github.com/llvm/llvm-project/commit/adfffebec6d6910304e4b1ccdbef78e226a8fd32.diff LOG: [lldb/Core] Add SourceLocationSpec class (NFC) A source location specifier class that holds a Declaration object containing a FileSpec with line and column information. The column line is optional. It also holds search flags that can be fetched by resolvers to look inlined declarations and/or exact matches. It describes a specific location in a source file and allows the user to perform checks and comparaisons between multiple instances of that class. Differential Revision: https://reviews.llvm.org/D100962 Signed-off-by: Med Ismail Bennani Added: lldb/include/lldb/Core/SourceLocationSpec.h lldb/source/Core/SourceLocationSpec.cpp lldb/unittests/Core/SourceLocationSpecTest.cpp Modified: lldb/source/Core/CMakeLists.txt lldb/unittests/Core/CMakeLists.txt Removed: diff --git a/lldb/include/lldb/Core/SourceLocationSpec.h b/lldb/include/lldb/Core/SourceLocationSpec.h new file mode 100644 index 0..808931186dba5 --- /dev/null +++ b/lldb/include/lldb/Core/SourceLocationSpec.h @@ -0,0 +1,188 @@ +//===-- SourceLocationSpec.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_UTILITY_SOURCELOCATIONSPEC_H +#define LLDB_UTILITY_SOURCELOCATIONSPEC_H + +#include "lldb/Core/Declaration.h" +#include "lldb/lldb-defines.h" +#include "llvm/ADT/Optional.h" + +#include + +namespace lldb_private { + +/// \class SourceLocationSpec SourceLocationSpec.h +/// "lldb/Core/SourceLocationSpec.h" A source location specifier class. +/// +/// A source location specifier class that holds a Declaration object containing +/// a FileSpec with line and column information. The column line is optional. +/// It also holds search flags that can be fetched by resolvers to look inlined +/// declarations and/or exact matches. +class SourceLocationSpec { +public: + /// Constructor. + /// + /// Takes a \a file_spec with a \a line number and a \a column number. If + /// \a column is null or not provided, it is set to llvm::None. + /// + /// \param[in] file_spec + /// The full or partial path to a file. + /// + /// \param[in] line + /// The line number in the source file. + /// + /// \param[in] column + /// The column number in the line of the source file. + /// + /// \param[in] check_inlines + /// Whether to look for a match in inlined declaration. + /// + /// \param[in] exact_match + /// Whether to look for an exact match. + /// + explicit SourceLocationSpec(FileSpec file_spec, uint32_t line, + llvm::Optional column = llvm::None, + bool check_inlines = false, + bool exact_match = false); + + SourceLocationSpec() = delete; + + /// Convert to boolean operator. + /// + /// This allows code to check a SourceLocationSpec object to see if it + /// contains anything valid using code such as: + /// + /// \code + /// SourceLocationSpec location_spec(...); + /// if (location_spec) + /// { ... + /// \endcode + /// + /// \return + /// A pointer to this object if both the file_spec and the line are valid, + /// nullptr otherwise. + explicit operator bool() const; + + /// Logical NOT operator. + /// + /// This allows code to check a SourceLocationSpec object to see if it is + /// invalid using code such as: + /// + /// \code + /// SourceLocationSpec location_spec(...); + /// if (!location_spec) + /// { ... + /// \endcode + /// + /// \return + /// Returns \b true if the object has an invalid file_spec or line number, + /// \b false otherwise. + bool operator!() const; + + /// Equal to operator + /// + /// Tests if this object is equal to \a rhs. + /// + /// \param[in] rhs + /// A const SourceLocationSpec object reference to compare this object + /// to. + /// + /// \return + /// \b true if this object is equal to \a rhs, \b false + /// otherwise. + bool operator==(const SourceLocationSpec &rhs) const; + + /// Not equal to operator + /// + /// Tests if this object is not equal to \a rhs. + /// + /// \param[in] rhs + /// A const SourceLocationSpec object reference to compare this object + /// to. + /// + /// \return + /// \b true if this object is equal to \a rhs, \b false + /// otherwise. + bool opera
[Lldb-commits] [PATCH] D101556: [lldb] Move and clean-up the Declaration class (NFC)
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1435f6b00be7: [lldb] Move and clean-up the Declaration class (NFC) (authored by mib). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101556/new/ https://reviews.llvm.org/D101556 Files: lldb/include/lldb/Core/Declaration.h lldb/include/lldb/Symbol/Declaration.h lldb/include/lldb/Symbol/Function.h lldb/include/lldb/Symbol/Type.h lldb/include/lldb/Symbol/Variable.h lldb/source/API/SBDeclaration.cpp lldb/source/API/SBValue.cpp lldb/source/Core/Address.cpp lldb/source/Core/CMakeLists.txt lldb/source/Core/Declaration.cpp lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectVariable.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/CMakeLists.txt lldb/source/Symbol/Declaration.cpp lldb/unittests/Symbol/TestClangASTImporter.cpp lldb/unittests/Symbol/TestTypeSystemClang.cpp Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp === --- lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -10,9 +10,9 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "TestingSupport/SubsystemRAII.h" #include "TestingSupport/Symbol/ClangTestUtils.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Symbol/Declaration.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/ExprCXX.h" Index: lldb/unittests/Symbol/TestClangASTImporter.cpp === --- lldb/unittests/Symbol/TestClangASTImporter.cpp +++ lldb/unittests/Symbol/TestClangASTImporter.cpp @@ -14,9 +14,9 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "TestingSupport/SubsystemRAII.h" #include "TestingSupport/Symbol/ClangTestUtils.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Symbol/Declaration.h" #include "clang/AST/DeclCXX.h" using namespace clang; Index: lldb/source/Symbol/CMakeLists.txt === --- lldb/source/Symbol/CMakeLists.txt +++ lldb/source/Symbol/CMakeLists.txt @@ -14,7 +14,6 @@ CompilerType.cpp DWARFCallFrameInfo.cpp DebugMacros.cpp - Declaration.cpp DeclVendor.cpp FuncUnwinders.cpp Function.cpp Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp === --- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -17,8 +17,8 @@ #include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h" #include "Plugins/ExpressionParser/Clang/ClangUtil.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/TypeSystem.h" Index: lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h === --- lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h +++ lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h @@ -14,7 +14,7 @@ #include "llvm/ADT/DenseMap.h" #include "DWARFDIE.h" -#include "lldb/Symbol/Declaration.h" +#include "lldb/Core/Declaration.h" class UniqueDWARFASTType { public: Index: lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -8,7 +8,7 @@ #include "UniqueDWARFASTType.h" -#include "lldb/Symbol/Declaration.h" +#include "lldb/Core/Declaration.h" bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, const lldb_private::Declaration &decl, Index: lldb/source/Core/ValueObjectVariable.cpp === --- lldb/source/Core/ValueObjectVariable.cpp +++ lldb/source/Core/ValueObjectVariable.cpp @@ -10,10 +10,10 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" Index: lldb/source/Core/ValueObject.cpp ===
[Lldb-commits] [PATCH] D100962: [lldb/Core] Add SourceLocationSpec class (NFC)
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGadfffebec6d6: [lldb/Core] Add SourceLocationSpec class (NFC) (authored by mib). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100962/new/ https://reviews.llvm.org/D100962 Files: lldb/include/lldb/Core/SourceLocationSpec.h lldb/source/Core/CMakeLists.txt lldb/source/Core/SourceLocationSpec.cpp lldb/unittests/Core/CMakeLists.txt lldb/unittests/Core/SourceLocationSpecTest.cpp Index: lldb/unittests/Core/SourceLocationSpecTest.cpp === --- /dev/null +++ lldb/unittests/Core/SourceLocationSpecTest.cpp @@ -0,0 +1,183 @@ +//===-- SourceLocationSpecTest.cpp ===// +// +// 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 +// +//===--===// + +#include "gtest/gtest.h" + +#include "lldb/Core/SourceLocationSpec.h" +#include "lldb/Utility/LLDBAssert.h" + +#include "llvm/Testing/Support/Error.h" + +using namespace lldb_private; + +TEST(SourceLocationSpecTest, OperatorBool) { + SourceLocationSpec invalid(FileSpec(), 0); + EXPECT_FALSE(invalid); + + SourceLocationSpec invalid_filespec(FileSpec(), 4); + EXPECT_FALSE(invalid_filespec); + + SourceLocationSpec invalid_line(FileSpec("/foo/bar"), 0); + EXPECT_FALSE(invalid_line); + + SourceLocationSpec valid_fs_line_no_column(FileSpec("/foo/bar"), 4); + EXPECT_TRUE(valid_fs_line_no_column); + + SourceLocationSpec invalid_fs_column(FileSpec(), 4, 0); + EXPECT_FALSE(invalid_fs_column); + + SourceLocationSpec invalid_line_column(FileSpec("/foo/bar"), 0, 19); + EXPECT_FALSE(invalid_line_column); + + SourceLocationSpec valid_fs_line_zero_column(FileSpec("/foo/bar"), 4, 0); + EXPECT_TRUE(valid_fs_line_zero_column); + + SourceLocationSpec valid_fs_line_column(FileSpec("/foo/bar"), 4, 19); + EXPECT_TRUE(valid_fs_line_column); +} + +TEST(SourceLocationSpecTest, FileLineColumnComponents) { + FileSpec fs("/foo/bar", FileSpec::Style::posix); + const uint32_t line = 19; + const uint16_t column = 4; + + SourceLocationSpec without_column(fs, line, LLDB_INVALID_COLUMN_NUMBER, false, +true); + EXPECT_TRUE(without_column); + EXPECT_EQ(fs, without_column.GetFileSpec()); + EXPECT_EQ(line, without_column.GetLine().getValueOr(0)); + EXPECT_EQ(llvm::None, without_column.GetColumn()); + EXPECT_FALSE(without_column.GetCheckInlines()); + EXPECT_TRUE(without_column.GetExactMatch()); + EXPECT_STREQ("check inlines = false, exact match = true, decl = /foo/bar:19", + without_column.GetString().c_str()); + + SourceLocationSpec with_column(fs, line, column, true, false); + EXPECT_TRUE(with_column); + EXPECT_EQ(column, *with_column.GetColumn()); + EXPECT_TRUE(with_column.GetCheckInlines()); + EXPECT_FALSE(with_column.GetExactMatch()); + EXPECT_STREQ( + "check inlines = true, exact match = false, decl = /foo/bar:19:4", + with_column.GetString().c_str()); +} + +static SourceLocationSpec Create(bool check_inlines, bool exact_match, + FileSpec fs, uint32_t line, + uint16_t column = LLDB_INVALID_COLUMN_NUMBER) { + return SourceLocationSpec(fs, line, column, check_inlines, exact_match); +} + +TEST(SourceLocationSpecTest, Equal) { + auto Equal = [](SourceLocationSpec lhs, SourceLocationSpec rhs, bool full) { +return SourceLocationSpec::Equal(lhs, rhs, full); + }; + + const FileSpec fs("/foo/bar", FileSpec::Style::posix); + const FileSpec other_fs("/foo/baz", FileSpec::Style::posix); + + // mutating FileSpec + const Inlined, ExactMatch, Line + EXPECT_TRUE( + Equal(Create(false, false, fs, 4), Create(false, false, fs, 4), true)); + EXPECT_TRUE( + Equal(Create(true, true, fs, 4), Create(true, true, fs, 4), false)); + EXPECT_FALSE(Equal(Create(false, false, fs, 4), + Create(false, false, other_fs, 4), true)); + EXPECT_FALSE( + Equal(Create(true, true, fs, 4), Create(true, true, other_fs, 4), false)); + + // Mutating FileSpec + const Inlined, ExactMatch, Line, Column + EXPECT_TRUE(Equal(Create(false, false, fs, 4, 19), +Create(false, false, fs, 4, 19), true)); + EXPECT_TRUE(Equal(Create(true, true, fs, 4, 19), +Create(true, true, fs, 4, 19), false)); + EXPECT_FALSE(Equal(Create(false, false, fs, 4, 19), + Create(false, false, other_fs, 4, 19), true)); + EXPECT_FALSE(Equal(Create(true, true, fs, 4, 19), + Create(true, true, other_fs, 4, 19), false)); + + // Asymetric match + EXPECT_FALSE( + Equal(Create(true, tru
[Lldb-commits] [PATCH] D101128: [lldb-vscode] only report long running progress events
clayborg requested changes to this revision. clayborg added inline comments. This revision now requires changes to proceed. Comment at: lldb/tools/lldb-vscode/ProgressEvent.cpp:143-148 + // The event finished before we were able to report it. + if (!m_start_event.Reported() && Finished()) +return true; + + if (!m_start_event.Report(m_report_callback)) +return false; Comment at: lldb/tools/lldb-vscode/ProgressEvent.cpp:171 + +bool ProgressEventManager::Finished() const { return m_finished; } + put in header file Comment at: lldb/tools/lldb-vscode/ProgressEvent.cpp:176 +: m_report_callback(report_callback) { + m_thread_should_exit = false; + m_thread = std::thread([&] { init before { with "m_thread_should_exit(false)" Comment at: lldb/tools/lldb-vscode/ProgressEvent.cpp:197-201 +else if (event_manager->ReportIfNeeded()) + m_unreported_start_events + .pop(); // we remove it from the queue as it started reporting + // already, the Push method will be able to continue its + // reports. Comment at: lldb/tools/lldb-vscode/ProgressEvent.cpp:214-215 + if (it == m_event_managers.end()) { +if (Optional event = +CreateStartProgressEvent(progress_id, message, completed, total)) { + ProgressEventManagerSP event_manager = Why is this returning an optional event? We know we need a start event here and it must be made. The Optional seems like it isn't needed? Comment at: lldb/tools/lldb-vscode/ProgressEvent.h:31-40 + ProgressEvent(uint64_t progress_id, llvm::StringRef message, +llvm::Optional percentage); - ProgressEvent(uint64_t progress_id, const char *message, uint64_t completed, -uint64_t total); + /// Constructor for an update or end event + ProgressEvent(uint64_t progress_id, const ProgressEvent &prev_event); + + /// Constructor for an update or end event, which happens when percentage is Seems like all these constructors are a bit much. We should probably have one that just takes all the needed parameters including the ProgressEventType. It is unclear from each constructor what each one does unless you look very carefully at the header documentation. It will be very clear if we just have: ``` ProgressEvent(uint64_t progress_id, StringRef message, ProgressEventType event_type, llvm::Optional percentage = llvm::None); ``` Comment at: lldb/tools/lldb-vscode/ProgressEvent.h:32 + ProgressEvent(uint64_t progress_id, llvm::StringRef message, +llvm::Optional percentage); Why is there an optional percentage for a start event? Comment at: lldb/tools/lldb-vscode/ProgressEvent.h:35 + /// Constructor for an update or end event + ProgressEvent(uint64_t progress_id, const ProgressEvent &prev_event); + Why do we need this constructor? At the very least we don't need the progress_id since the prev_event will have one Comment at: lldb/tools/lldb-vscode/ProgressEvent.h:39-40 + /// 100. + ProgressEvent(uint64_t progress_id, uint32_t percentage, +const ProgressEvent &prev_event); Don't need progress_id if we have a prev_event. We probably don't need the previous constructor if we have this one. Might be better as: ``` ProgressEvent(const ProgressEvent &prev_event, uint32_t percentage); ``` If the percentage is 100, then this is an end event? Otherwise it is an update event? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101128/new/ https://reviews.llvm.org/D101128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D100740: [trace] Dedup different source lines when dumping instructions + refactor
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Just fix the one issue where we use the FileSpec operator== and this is good to go! Comment at: lldb/source/Core/AddressRange.cpp:59 + // the file addresses in this case only. + return ContainsFileAddress(addr); +} It might be worth scanning the code to see if anyone is using AddressRange::ContainsFileAddress() incorrectly. It is fine to use this within a module to check if an address is in the range, but not ok if the address can come from a different module. Comment at: lldb/source/Target/Trace.cpp:114 + + return FileSpec::Compare(a.file, b.file, true) == 0; +} No need to compare, just use == operator Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100740/new/ https://reviews.llvm.org/D100740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3e2ed74 - [lldb] Refactor argument group by SourceLocationSpec (NFCI)
Author: Med Ismail Bennani Date: 2021-05-04T23:04:31Z New Revision: 3e2ed7440569d59e073d4799b310255547bd2dd2 URL: https://github.com/llvm/llvm-project/commit/3e2ed7440569d59e073d4799b310255547bd2dd2 DIFF: https://github.com/llvm/llvm-project/commit/3e2ed7440569d59e073d4799b310255547bd2dd2.diff LOG: [lldb] Refactor argument group by SourceLocationSpec (NFCI) This patch refactors a good part of the code base turning the usual FileSpec, Line, Column, CheckInlines, ExactMatch arguments into a SourceLocationSpec object. This change is required for a following patch that will add handling of the column line information when doing symbol resolution. Differential Revision: https://reviews.llvm.org/D100965 Signed-off-by: Med Ismail Bennani Added: Modified: lldb/include/lldb/Breakpoint/BreakpointResolver.h lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Core/AddressResolverFileLine.h lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/LineTable.h lldb/include/lldb/Symbol/SymbolFile.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/Breakpoint.cpp lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/Module.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/LineTable.cpp lldb/source/Symbol/SymbolFile.cpp lldb/source/Target/Target.cpp lldb/unittests/Symbol/TestLineEntry.cpp Removed: diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolver.h b/lldb/include/lldb/Breakpoint/BreakpointResolver.h index d067b1eea6fff..7aa43b9f45df5 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolver.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolver.h @@ -204,7 +204,8 @@ class BreakpointResolver : public Searcher { /// filter the results to find the first breakpoint >= (line, column). void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, - uint32_t line = 0, uint32_t column = 0); + uint32_t line = 0, + llvm::Optional column = llvm::None); void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool, const char *) = delete; diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 222fc6fcd45d9..bd8d0394d4d2d 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -10,6 +10,7 @@ #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H #include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Core/SourceLocationSpec.h" namespace lldb_private { @@ -21,10 +22,8 @@ namespace lldb_private { class BreakpointResolverFileLine : public BreakpointResolver { public: BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt, - const FileSpec &resolver, - uint32_t line_no, uint32_t column, - lldb::addr_t m_offset, bool check_inlines, - bool skip_prologue, bool exact_match); + lldb::addr_t offset, bool skip_prologue, + const SourceLocationSpec &location_spec); static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, @@ -60,13 +59,8 @@ class BreakpointResolverFileLine : public BreakpointResolver { void FilterContexts(SymbolContextList &sc_list, bool is_relative); friend class Breakpoint; - FileSpec m_file_spec; ///< This is the file spec we are looking for. - uint32_t m_line_number; ///< This is the line number that we are looking for. - uint32_t m_column; ///< This is the column that we are looking for. - bool m_inlines; ///< This determines whether the resolver looks for inlined - ///< functions or not. + SourceLocationSpec m_location_spec; bool m_skip_prologue; - bool m_exact_match; private:
[Lldb-commits] [PATCH] D100965: [lldb] Refactor argument group by SourceLocationSpec (NFCI)
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG3e2ed7440569: [lldb] Refactor argument group by SourceLocationSpec (NFCI) (authored by mib). Changed prior to commit: https://reviews.llvm.org/D100965?vs=342079&id=342895#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100965/new/ https://reviews.llvm.org/D100965 Files: lldb/include/lldb/Breakpoint/BreakpointResolver.h lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Core/AddressResolverFileLine.h lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/LineTable.h lldb/include/lldb/Symbol/SymbolFile.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/Breakpoint.cpp lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/Module.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/LineTable.cpp lldb/source/Symbol/SymbolFile.cpp lldb/source/Target/Target.cpp lldb/unittests/Symbol/TestLineEntry.cpp Index: lldb/unittests/Symbol/TestLineEntry.cpp === --- lldb/unittests/Symbol/TestLineEntry.cpp +++ lldb/unittests/Symbol/TestLineEntry.cpp @@ -53,20 +53,23 @@ } llvm::Expected LineEntryTest::GetLineEntryForLine(uint32_t line) { - bool check_inlines = true; - bool exact = true; + // TODO: Handle SourceLocationSpec column information SymbolContextList sc_comp_units; SymbolContextList sc_line_entries; FileSpec file_spec("inlined-functions.cpp"); - m_module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, -lldb::eSymbolContextCompUnit, -sc_comp_units); + m_module_sp->ResolveSymbolContextsForFileSpec( + file_spec, line, /*check_inlines=*/true, lldb::eSymbolContextCompUnit, + sc_comp_units); if (sc_comp_units.GetSize() == 0) return llvm::createStringError(llvm::inconvertibleErrorCode(), "No comp unit found on the test object."); + + SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None, + /*check_inlines=*/true, + /*exact_match=*/true); + sc_comp_units[0].comp_unit->ResolveSymbolContext( - file_spec, line, check_inlines, exact, eSymbolContextLineEntry, - sc_line_entries); + location_spec, eSymbolContextLineEntry, sc_line_entries); if (sc_line_entries.GetSize() == 0) return llvm::createStringError(llvm::inconvertibleErrorCode(), "No line entry found on the test object."); Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -371,9 +371,14 @@ if (move_to_nearest_code == eLazyBoolCalculate) move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo; + SourceLocationSpec location_spec(remapped_file, line_no, column, + check_inlines, + !static_cast(move_to_nearest_code)); + if (!location_spec) +return nullptr; + BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine( - nullptr, remapped_file, line_no, column, offset, check_inlines, - skip_prologue, !static_cast(move_to_nearest_code))); + nullptr, offset, skip_prologue, location_spec)); return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true); } Index: lldb/source/Symbol/SymbolFile.cpp === --- lldb/source/Symbol/SymbolFile.cpp +++ lldb/source/Symbol/SymbolFile.cpp @@ -97,10 +97,10 @@ return type_system_or_err; } -uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec, - uint32_t line, bool check_inlines, - lldb::SymbolContextItem resolve_scope, - SymbolContextList &sc_list)
[Lldb-commits] [lldb] 30fcdf0 - [lldb/Symbol] Update SymbolFilePDB unitest with SourceLocationSpec
Author: Med Ismail Bennani Date: 2021-05-05T00:34:44Z New Revision: 30fcdf0b19661ca77767bd41ceba03f5dd33 URL: https://github.com/llvm/llvm-project/commit/30fcdf0b19661ca77767bd41ceba03f5dd33 DIFF: https://github.com/llvm/llvm-project/commit/30fcdf0b19661ca77767bd41ceba03f5dd33.diff LOG: [lldb/Symbol] Update SymbolFilePDB unitest with SourceLocationSpec This patch should fix the windows test failure following `3e2ed7440569`. It makes use of a `SourceLocationSpec` object when resolving a symbol context from `SymbolFilePDB` file. Signed-off-by: Med Ismail Bennani Added: Modified: lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Removed: diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 63bb6b7c40436..f9df3ced747d4 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -171,8 +171,9 @@ TEST_F(SymbolFilePDBTests, TestResolveSymbolContextBasename) { FileSpec header_spec("test-pdb.cpp"); SymbolContextList sc_list; + SourceLocationSpec location_spec(header_spec, /*line=*/0); uint32_t result_count = symfile->ResolveSymbolContext( - header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list); + location_spec, lldb::eSymbolContextCompUnit, sc_list); EXPECT_EQ(1u, result_count); EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec)); } @@ -190,8 +191,9 @@ TEST_F(SymbolFilePDBTests, TestResolveSymbolContextFullPath) { FileSpec header_spec( R"spec(D:\src\llvm\tools\lldb\unittests\SymbolFile\PDB\Inputs\test-pdb.cpp)spec"); SymbolContextList sc_list; + SourceLocationSpec location_spec(header_spec, /*line=*/0); uint32_t result_count = symfile->ResolveSymbolContext( - header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list); + location_spec, lldb::eSymbolContextCompUnit, sc_list); EXPECT_GE(1u, result_count); EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec)); } @@ -214,8 +216,10 @@ TEST_F(SymbolFilePDBTests, TestLookupOfHeaderFileWithInlines) { FileSpec alt_cpp_spec("test-pdb-alt.cpp"); for (const auto &hspec : header_specs) { SymbolContextList sc_list; +SourceLocationSpec location_spec(hspec, /*line=*/0, /*column=*/llvm::None, + /*check_inlines=*/true); uint32_t result_count = symfile->ResolveSymbolContext( -hspec, 0, true, lldb::eSymbolContextCompUnit, sc_list); +location_spec, lldb::eSymbolContextCompUnit, sc_list); EXPECT_EQ(2u, result_count); EXPECT_TRUE(ContainsCompileUnit(sc_list, main_cpp_spec)); EXPECT_TRUE(ContainsCompileUnit(sc_list, alt_cpp_spec)); @@ -238,8 +242,9 @@ TEST_F(SymbolFilePDBTests, TestLookupOfHeaderFileWithNoInlines) { FileSpec("test-pdb-nested.h")}; for (const auto &hspec : header_specs) { SymbolContextList sc_list; +SourceLocationSpec location_spec(hspec, /*line=*/0); uint32_t result_count = symfile->ResolveSymbolContext( -hspec, 0, false, lldb::eSymbolContextCompUnit, sc_list); +location_spec, lldb::eSymbolContextCompUnit, sc_list); EXPECT_EQ(0u, result_count); } } @@ -264,8 +269,9 @@ TEST_F(SymbolFilePDBTests, TestLineTablesMatchAll) { lldb::SymbolContextItem scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry; - uint32_t count = - symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list); + SourceLocationSpec location_spec( + source_file, /*line=*/0, /*column=*/llvm::None, /*check_inlines=*/true); + uint32_t count = symfile->ResolveSymbolContext(location_spec, scope, sc_list); EXPECT_EQ(1u, count); SymbolContext sc; EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc)); @@ -314,8 +320,9 @@ TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) { lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry; // First test with line 7, and verify that only line 7 entries are added. - uint32_t count = - symfile->ResolveSymbolContext(source_file, 7, true, scope, sc_list); + SourceLocationSpec location_spec( + source_file, /*line=*/7, /*column=*/llvm::None, /*check_inlines=*/true); + uint32_t count = symfile->ResolveSymbolContext(location_spec, scope, sc_list); EXPECT_EQ(1u, count); SymbolContext sc; EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc)); @@ -331,6 +338,8 @@ TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) { sc_list.Clear(); // Then test with line 9, and verify that only line 9 entries are added. + location_spec = SourceLocationSpec( + source_file, /*line=*/9, /*column=*/llvm::None, /*check_inlines=*/true); count = symfile->ResolveSymbolContext(source_file, 9, true, scope, sc_list); EXPECT_EQ(1u, count); EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc)); __
[Lldb-commits] [lldb] d5069da - [lldb/Symbol] Fix typo in SymbolFilePDBTests (NFC)
Author: Med Ismail Bennani Date: 2021-05-05T00:38:41Z New Revision: d5069dace7c254a6c2c878bde465344eb6c0cf56 URL: https://github.com/llvm/llvm-project/commit/d5069dace7c254a6c2c878bde465344eb6c0cf56 DIFF: https://github.com/llvm/llvm-project/commit/d5069dace7c254a6c2c878bde465344eb6c0cf56.diff LOG: [lldb/Symbol] Fix typo in SymbolFilePDBTests (NFC) Signed-off-by: Med Ismail Bennani Added: Modified: lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Removed: diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index f9df3ced747d..7c7d1902eefb 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -340,7 +340,7 @@ TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) { // Then test with line 9, and verify that only line 9 entries are added. location_spec = SourceLocationSpec( source_file, /*line=*/9, /*column=*/llvm::None, /*check_inlines=*/true); - count = symfile->ResolveSymbolContext(source_file, 9, true, scope, sc_list); + count = symfile->ResolveSymbolContext(location_spec, scope, sc_list); EXPECT_EQ(1u, count); EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ade59d5 - [trace] Dedup different source lines when dumping instructions + refactor
Author: Walter Erquinigo Date: 2021-05-04T19:40:52-07:00 New Revision: ade59d530964e28498051ab20e44cbf6594be595 URL: https://github.com/llvm/llvm-project/commit/ade59d530964e28498051ab20e44cbf6594be595 DIFF: https://github.com/llvm/llvm-project/commit/ade59d530964e28498051ab20e44cbf6594be595.diff LOG: [trace] Dedup different source lines when dumping instructions + refactor When dumping the traced instructions in a for loop, like this one 4: for (int a = 0; a < n; a++) 5:do something; there might be multiple LineEntry objects for line 4, but with different address ranges. This was causing the dump command to dump something like this: ``` a.out`main + 11 at main.cpp:4 [1] 0x00400518movl $0x0, -0x8(%rbp) [2] 0x0040051fjmp0x400529 ; <+28> at main.cpp:4 a.out`main + 28 at main.cpp:4 [3] 0x00400529cmpl $0x3, -0x8(%rbp) [4] 0x0040052djle0x400521 ; <+20> at main.cpp:5 ``` which is confusing, as main.cpp:4 appears twice consecutively. This diff fixes that issue by making the line entry comparison strictly about the line, column and file name. Before it was also comparing the address ranges, which we don't need because our output is strictly about what the user sees in the source. Besides, I've noticed that the logic that traverses instructions and calculates symbols and disassemblies had too much coupling, and made my changes harder to implement, so I decided to decouple it. Now there are two methods for iterating over the instruction of a trace. The existing one does it on raw load addresses, but the one provides a SymbolContext and an InstructionSP, and does the calculations efficiently (not as efficient as possible for now though), so the caller doesn't need to care about these details. I think I'll be using that iterator to reconstruct the call stacks. I was able to fix a test with this change. Differential Revision: https://reviews.llvm.org/D100740 Added: Modified: lldb/include/lldb/Core/AddressRange.h lldb/include/lldb/Target/Trace.h lldb/source/Core/AddressRange.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h lldb/source/Target/Trace.cpp lldb/test/API/commands/trace/TestTraceStartStop.py Removed: diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h index 8ccf96a436a1..d7017840197d 100644 --- a/lldb/include/lldb/Core/AddressRange.h +++ b/lldb/include/lldb/Core/AddressRange.h @@ -94,8 +94,7 @@ class AddressRange { /// \return /// Returns \b true if \a so_addr is contained in this range, /// \b false otherwise. - //bool - //Contains (const Address &so_addr) const; + bool Contains(const Address &so_addr) const; /// Check if a section offset address is contained in this range. /// diff --git a/lldb/include/lldb/Target/Trace.h b/lldb/include/lldb/Target/Trace.h index 403b1f868a59..81585fa7be40 100644 --- a/lldb/include/lldb/Target/Trace.h +++ b/lldb/include/lldb/Target/Trace.h @@ -210,8 +210,9 @@ class Trace : public PluginInterface, /// The thread whose trace will be inspected. /// /// \return - /// The total number of instructions in the trace. - virtual size_t GetInstructionCount(Thread &thread) = 0; + /// The total number of instructions in the trace, or \a llvm::None if the + /// thread is not being traced. + virtual llvm::Optional GetInstructionCount(Thread &thread) = 0; /// Check if a thread is currently traced by this object. /// diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp index 0868ac5e0888..aeb99f857a78 100644 --- a/lldb/source/Core/AddressRange.cpp +++ b/lldb/source/Core/AddressRange.cpp @@ -8,6 +8,7 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" @@ -42,14 +43,22 @@ AddressRange::AddressRange(const Address &so_addr, addr_t byte_size) AddressRange::~AddressRange() {} -// bool -// AddressRange::Contains (const Address &addr) const -//{ -//const addr_t byte_size = GetByteSize(); -//if (byte_size) -//return addr.GetSection() == m_base_addr.GetSection() && -//(addr.GetOffset() - m_base_addr.GetOffset()) < byte_size; -//} +bool AddressRange::Contains(const Address &addr) const { + SectionSP range_sect_sp = GetBaseAddress().GetSection(); + SectionSP addr_sect_sp = addr.GetSection(); + if (range_sect_sp) { +if (!addr_sect_sp || +range_sect_sp->GetModule() != addr_sect_sp->GetModule()) + return false; // Modules do not match. + } else if (addr_sect_sp) { +return false; // Range has no module but "addr" does b
[Lldb-commits] [PATCH] D100740: [trace] Dedup different source lines when dumping instructions + refactor
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGade59d530964: [trace] Dedup different source lines when dumping instructions + refactor (authored by wallace, committed by Walter Erquinigo). Changed prior to commit: https://reviews.llvm.org/D100740?vs=342770&id=342931#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100740/new/ https://reviews.llvm.org/D100740 Files: lldb/include/lldb/Core/AddressRange.h lldb/include/lldb/Target/Trace.h lldb/source/Core/AddressRange.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h lldb/source/Target/Trace.cpp lldb/test/API/commands/trace/TestTraceStartStop.py Index: lldb/test/API/commands/trace/TestTraceStartStop.py === --- lldb/test/API/commands/trace/TestTraceStartStop.py +++ lldb/test/API/commands/trace/TestTraceStartStop.py @@ -100,7 +100,6 @@ a.out`main \+ 11 at main.cpp:4 \[1\] {ADDRESS_REGEX}movl .* \[2\] {ADDRESS_REGEX}jmp .* ; <\+28> at main.cpp:4 - a.out`main \+ 28 at main.cpp:4 \[3\] {ADDRESS_REGEX}cmpl .* \[4\] {ADDRESS_REGEX}jle .* ; <\+20> at main.cpp:5''']) Index: lldb/source/Target/Trace.cpp === --- lldb/source/Target/Trace.cpp +++ lldb/source/Target/Trace.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Symbol/Function.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Thread.h" @@ -101,189 +102,255 @@ return num == 0 ? 1 : static_cast(log10(num)) + 1; } -/// Dump the symbol context of the given instruction address if it's different -/// from the symbol context of the previous instruction in the trace. -/// -/// \param[in] prev_sc -/// The symbol context of the previous instruction in the trace. -/// -/// \param[in] address -/// The address whose symbol information will be dumped. -/// /// \return -/// The symbol context of the current address, which might differ from the -/// previous one. -static SymbolContext DumpSymbolContext(Stream &s, const SymbolContext &prev_sc, - Target &target, const Address &address) { - AddressRange range; - if (prev_sc.GetAddressRange(eSymbolContextEverything, 0, - /*inline_block_range*/ false, range) && - range.ContainsFileAddress(address)) -return prev_sc; +/// \b true if the provided line entries match line, column and source file. +/// This function assumes that the line entries are valid. +static bool FileLineAndColumnMatches(const LineEntry &a, const LineEntry &b) { + if (a.line != b.line) +return false; + if (a.column != b.column) +return false; + return a.file == b.file; +} + +// This custom LineEntry validator is neded because some line_entries have +// 0 as line, which is meaningless. Notice that LineEntry::IsValid only +// checks that line is not LLDB_INVALID_LINE_NUMBER, i.e. UINT32_MAX. +static bool IsLineEntryValid(const LineEntry &line_entry) { + return line_entry.IsValid() && line_entry.line > 0; +} +/// Helper structure for \a TraverseInstructionsWithSymbolInfo. +struct InstructionSymbolInfo { SymbolContext sc; - address.CalculateSymbolContext(&sc, eSymbolContextEverything); + Address address; + lldb::addr_t load_address; + lldb::DisassemblerSP disassembler; + lldb::InstructionSP instruction; + lldb_private::ExecutionContext exe_ctx; +}; - if (!prev_sc.module_sp && !sc.module_sp) -return sc; - if (prev_sc.module_sp == sc.module_sp && !sc.function && !sc.symbol && - !prev_sc.function && !prev_sc.symbol) +/// InstructionSymbolInfo object with symbol information for the given +/// instruction, calculated efficiently. +/// +/// \param[in] symbol_scope +/// If not \b 0, then the \a InstructionSymbolInfo will have its +/// SymbolContext calculated up to that level. +/// +/// \param[in] include_disassembler +/// If \b true, then the \a InstructionSymbolInfo will have the +/// \a disassembler and \a instruction objects calculated. +static void TraverseInstructionsWithSymbolInfo( +Trace &trace, Thread &thread, size_t position, +Trace::TraceDirection direction, SymbolContextItem symbol_scope, +bool include_disassembler, +std::function insn)> +callback) { + InstructionSymbolInfo prev_insn; + + Target &target = thread.GetProcess()->GetTarget(); + ExecutionContext exe_ctx; + target.CalculateExecutionContext(exe_ctx); + const ArchSpec &arch = target.GetArchitecture(); + + // Find the symbol context for the given address reusing the previous + // instruction's symbol context whe
[Lldb-commits] [PATCH] D101221: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
mib marked 2 inline comments as done. mib added inline comments. Comment at: lldb/include/lldb/Symbol/LineTable.h:344 + template + uint32_t FindLineEntryIndexByFileIndexImpl( + uint32_t start_idx, T file_idx, JDevlieghere wrote: > It seems like this method is only using `m_entries`, so I would turn this > into a static (non-member) function in the cpp file and pass `m_entries` as > an argument. Besides m_entries, the function also calls `LineTable::ConvertEntryAtIndexToLineEntry` which is declared `protected`. Making the function "static" makes it more convoluted, IMO. I'd rather leave it in the header file. Comment at: lldb/include/lldb/Symbol/LineTable.h:377 + continue; +} else if (m_entries[idx].line == line) { + ConvertEntryAtIndexToLineEntry(idx, *line_entry_ptr); JDevlieghere wrote: > I know you're just moving the code but maybe a good opportunity to simplify > the else-after-continue and else-after-return below. As discussed, I'll simplify these in a follow-up patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101221/new/ https://reviews.llvm.org/D101221 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D101221: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
mib updated this revision to Diff 342940. mib edited the summary of this revision. mib added a comment. Address @JDevlieghere comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101221/new/ https://reviews.llvm.org/D101221 Files: lldb/include/lldb/Symbol/LineTable.h lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Symbol/LineTable.cpp lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/Makefile lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp @@ -0,0 +1,35 @@ +static int this_is_a_very_long_function_with_a_bunch_of_arguments( +int first, int second, int third, int fourth, int fifth) { + int result = first + second + third + fourth + fifth; + return result; +} + +int square(int x) { return x * x; } + +int main(int argc, char const *argv[]) { + // This is a random comment. + int did_call = 0; + + int first = 1; + int second = 2; + int third = 3; + int fourth = 4; + int fifth = 5; + + //v In the middle of a function name (col:42) + int result = this_is_a_very_long_function_with_a_bunch_of_arguments( + first, second, third, fourth, fifth); + + // v In the middle of the lambda declaration argument (col:23) + auto lambda = [&](int n) { + // v Inside the lambda (col:26) +return first + third * n; + }; + + result = lambda(3); + + // v At the beginning of a function name (col:50) + if(square(argc+1) != 0) { did_call = 1; return square(argc); } + + return square(0); +} Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c === --- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c +++ /dev/null @@ -1,14 +0,0 @@ -int square(int x) -{ - return x * x; -} - -int main (int argc, char const *argv[]) -{ - int did_call = 0; - - // Line 20.v Column 50. - if(square(argc+1) != 0) { did_call = 1; return square(argc); } - // ^ - return square(0); -} Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py @@ -2,8 +2,7 @@ Test setting a breakpoint by line and column. """ - - +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -18,14 +17,16 @@ @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLineAndColumn(self): self.build() -main_c = lldb.SBFileSpec("main.c") +src_file = lldb.SBFileSpec("main.cpp") +line = line_number("main.cpp", + "At the beginning of a function name (col:50)") + 1 # Next line after comment _, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, - main_c, 11, 50) + src_file, line, 50) self.expect("fr v did_call", substrs=['1']) in_then = False for i in range(breakpoint.GetNumLocations()): b_loc = breakpoint.GetLocationAtIndex(i).GetAddress().GetLineEntry() -self.assertEqual(b_loc.GetLine(), 11) +self.assertEqual(b_loc.GetLine(), line) in_then |= b_loc.GetColumn() == 50 self.assertTrue(in_then) @@ -33,13 +34,16 @@ @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLine(self): self.build() -main_c = lldb.SBFileSpec("main.c") -_, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, main_c, 11) +src_file = lldb.SBFileSpec("main.cpp") +line = line_number("main.cpp", + "At the beginning of a function name (col:50)") + 1 # Next line after comment +_, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, src_file, + line) self.expect("fr v did_call", substrs=['0']) in_condition = False for i in range(breakpoint.G
[Lldb-commits] [lldb] 3a62d4f - Fix typo, arvm7 -> armv7
Author: Brad Smith Date: 2021-05-05T00:56:44-04:00 New Revision: 3a62d4fde88544125ce9ceff990db108ee91148a URL: https://github.com/llvm/llvm-project/commit/3a62d4fde88544125ce9ceff990db108ee91148a DIFF: https://github.com/llvm/llvm-project/commit/3a62d4fde88544125ce9ceff990db108ee91148a.diff LOG: Fix typo, arvm7 -> armv7 Added: Modified: lldb/docs/man/lldb.rst lldb/tools/driver/Driver.cpp Removed: diff --git a/lldb/docs/man/lldb.rst b/lldb/docs/man/lldb.rst index 6dca15fa35dc..b75288db380d 100644 --- a/lldb/docs/man/lldb.rst +++ b/lldb/docs/man/lldb.rst @@ -256,11 +256,11 @@ executable. To disambiguate between arguments passed to lldb and arguments passed to the debugged executable, arguments starting with a - must be passed after --. - lldb --arch x86_64 /path/to/program program argument -- --arch arvm7 + lldb --arch x86_64 /path/to/program program argument -- --arch armv7 For convenience, passing the executable after -- is also supported. - lldb --arch x86_64 -- /path/to/program program argument --arch arvm7 + lldb --arch x86_64 -- /path/to/program program argument --arch armv7 Passing one of the attach options causes :program:`lldb` to immediately attach to the given process. diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index c5121538741f..b91e930f3d84 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -751,11 +751,11 @@ static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) { arguments passed to the debugged executable, arguments starting with a - must be passed after --. -lldb --arch x86_64 /path/to/program program argument -- --arch arvm7 +lldb --arch x86_64 /path/to/program program argument -- --arch armv7 For convenience, passing the executable after -- is also supported. -lldb --arch x86_64 -- /path/to/program program argument --arch arvm7 +lldb --arch x86_64 -- /path/to/program program argument --arch armv7 Passing one of the attach options causes lldb to immediately attach to the given process. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D101221: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101221/new/ https://reviews.llvm.org/D101221 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 35ecfda - [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
Author: Med Ismail Bennani Date: 2021-05-05T05:07:50Z New Revision: 35ecfda01ccd19e1222c065056f68bbd2575e4ac URL: https://github.com/llvm/llvm-project/commit/35ecfda01ccd19e1222c065056f68bbd2575e4ac DIFF: https://github.com/llvm/llvm-project/commit/35ecfda01ccd19e1222c065056f68bbd2575e4ac.diff LOG: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match This patch fixes the column symbol resolution when creating a breakpoint with the `move_to_nearest_code` flag set. In order to achieve this, the patch adds column information handling in the `LineTable`'s `LineEntry` finder. After experimenting a little, it turns out the most natural approach in case of an inaccurate column match, is to move backward and match the previous `LineEntry` rather than going forward like we do with simple line breakpoints. The patch also reflows the function to reduce code duplication. Finally, it updates the `BreakpointResolver` heuristic to align it with the `LineTable` method. rdar://73218201 Differential Revision: https://reviews.llvm.org/D101221 Signed-off-by: Med Ismail Bennani Added: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp Modified: lldb/include/lldb/Symbol/LineTable.h lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Symbol/LineTable.cpp lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/Makefile lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py Removed: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h index 301e04cf104f..68b540640987 100644 --- a/lldb/include/lldb/Symbol/LineTable.h +++ b/lldb/include/lldb/Symbol/LineTable.h @@ -158,7 +158,7 @@ class LineTable { LineEntry *line_entry_ptr); uint32_t FindLineEntryIndexByFileIndex( - uint32_t start_idx, const std::vector &file_indexes, + uint32_t start_idx, const std::vector &file_idx, const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr); size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append, @@ -339,6 +339,75 @@ class LineTable { private: LineTable(const LineTable &) = delete; const LineTable &operator=(const LineTable &) = delete; + + template + uint32_t FindLineEntryIndexByFileIndexImpl( + uint32_t start_idx, T file_idx, + const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr, + std::function file_idx_matcher) { +const size_t count = m_entries.size(); +size_t best_match = UINT32_MAX; + +if (!line_entry_ptr) + return best_match; + +const uint32_t line = src_location_spec.GetLine().getValueOr(0); +const uint16_t column = +src_location_spec.GetColumn().getValueOr(LLDB_INVALID_COLUMN_NUMBER); +const bool exact_match = src_location_spec.GetExactMatch(); + +for (size_t idx = start_idx; idx < count; ++idx) { + // Skip line table rows that terminate the previous row (is_terminal_entry + // is non-zero) + if (m_entries[idx].is_terminal_entry) +continue; + + if (!file_idx_matcher(file_idx, m_entries[idx].file_idx)) +continue; + + // Exact match always wins. Otherwise try to find the closest line > the + // desired line. + // FIXME: Maybe want to find the line closest before and the line closest + // after and if they're not in the same function, don't return a match. + + if (column == LLDB_INVALID_COLUMN_NUMBER) { +if (m_entries[idx].line < line) { + continue; +} else if (m_entries[idx].line == line) { + ConvertEntryAtIndexToLineEntry(idx, *line_entry_ptr); + return idx; +} else if (!exact_match) { + if (best_match == UINT32_MAX || + m_entries[idx].line < m_entries[best_match].line) +best_match = idx; +} + } else { +if (m_entries[idx].line < line) { + continue; +} else if (m_entries[idx].line == line && + m_entries[idx].column == column) { + ConvertEntryAtIndexToLineEntry(idx, *line_entry_ptr); + return idx; +} else if (!exact_match) { + if (best_match == UINT32_MAX) +best_match = idx; + else if (m_entries[idx].line < m_entries[best_match].line) +best_match = idx; + else if (m_entries[idx].line == m_entries[best_match].line) +if (m_entries[idx].column && +m_entries[idx].column < m_entries[best_match].column) + best_match = idx; +} + } +} + +if (best_match != UINT32_MAX) { + if (line_entry_ptr) +ConvertEntryAtIndexToLineEntry(best_match, *line_entry_ptr); + return best_match; +
[Lldb-commits] [PATCH] D101221: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG35ecfda01ccd: [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match (authored by mib). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101221/new/ https://reviews.llvm.org/D101221 Files: lldb/include/lldb/Symbol/LineTable.h lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Symbol/LineTable.cpp lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/Makefile lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.cpp @@ -0,0 +1,35 @@ +static int this_is_a_very_long_function_with_a_bunch_of_arguments( +int first, int second, int third, int fourth, int fifth) { + int result = first + second + third + fourth + fifth; + return result; +} + +int square(int x) { return x * x; } + +int main(int argc, char const *argv[]) { + // This is a random comment. + int did_call = 0; + + int first = 1; + int second = 2; + int third = 3; + int fourth = 4; + int fifth = 5; + + //v In the middle of a function name (col:42) + int result = this_is_a_very_long_function_with_a_bunch_of_arguments( + first, second, third, fourth, fifth); + + // v In the middle of the lambda declaration argument (col:23) + auto lambda = [&](int n) { + // v Inside the lambda (col:26) +return first + third * n; + }; + + result = lambda(3); + + // v At the beginning of a function name (col:50) + if(square(argc+1) != 0) { did_call = 1; return square(argc); } + + return square(0); +} Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c === --- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/main.c +++ /dev/null @@ -1,14 +0,0 @@ -int square(int x) -{ - return x * x; -} - -int main (int argc, char const *argv[]) -{ - int did_call = 0; - - // Line 20.v Column 50. - if(square(argc+1) != 0) { did_call = 1; return square(argc); } - // ^ - return square(0); -} Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py @@ -2,8 +2,7 @@ Test setting a breakpoint by line and column. """ - - +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -18,14 +17,16 @@ @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLineAndColumn(self): self.build() -main_c = lldb.SBFileSpec("main.c") +src_file = lldb.SBFileSpec("main.cpp") +line = line_number("main.cpp", + "At the beginning of a function name (col:50)") + 1 # Next line after comment _, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, - main_c, 11, 50) + src_file, line, 50) self.expect("fr v did_call", substrs=['1']) in_then = False for i in range(breakpoint.GetNumLocations()): b_loc = breakpoint.GetLocationAtIndex(i).GetAddress().GetLineEntry() -self.assertEqual(b_loc.GetLine(), 11) +self.assertEqual(b_loc.GetLine(), line) in_then |= b_loc.GetColumn() == 50 self.assertTrue(in_then) @@ -33,13 +34,16 @@ @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLine(self): self.build() -main_c = lldb.SBFileSpec("main.c") -_, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, main_c, 11) +src_file = lldb.SBFileSpec("main.cpp") +line = line_number("main.cpp", + "At the beginning of a function name (col:50)") + 1 # Next line after comment +_, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, src_file, + line)
[Lldb-commits] [lldb] 9775582 - [lldb/Test] Disable testBreakpointByLineAndColumnNearestCode on Windows
Author: Med Ismail Bennani Date: 2021-05-05T06:04:08Z New Revision: 9775582e347c08f79f84748d143eb8c2e4258afb URL: https://github.com/llvm/llvm-project/commit/9775582e347c08f79f84748d143eb8c2e4258afb DIFF: https://github.com/llvm/llvm-project/commit/9775582e347c08f79f84748d143eb8c2e4258afb.diff LOG: [lldb/Test] Disable testBreakpointByLineAndColumnNearestCode on Windows Signed-off-by: Med Ismail Bennani Added: Modified: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py Removed: diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py index 6b63da012f0a..b9238480d5ae 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py @@ -47,6 +47,7 @@ def testBreakpointByLine(self): in_condition |= b_loc.GetColumn() < 30 self.assertTrue(in_condition) +@skipIfWindows ## Skip gcc version less 7.1 since it doesn't support -gcolumn-info @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLineAndColumnNearestCode(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits