[Lldb-commits] [PATCH] D82064: [ARM64] Add QEMU testing environment setup guide for SVE testing
omjavaid added inline comments. Comment at: lldb/docs/resources/test.rst:427 +actual hardware. QEMU helper scripts and README.txt document can be found under +llvm-project/lldb/scripts/lldb-test-qemu which can help setup a virtual testing +environment for LLDB using QEMU. These scripts currently work with Arm or JDevlieghere wrote: > What's the reason you chose to refer to the README in the source tree instead > of converting it to an RST page and linking to that page from here? I think > it's good to have an entry here rather than the whole document, but I still > think this should be a hyperlink to its own page. Well honestly this was more of me going lazy I ll make it a separate rst page if that sounds more appropriate. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82064/new/ https://reviews.llvm.org/D82064 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87441: Speedup collecting DWARF attribute values
dmantipov updated this revision to Diff 291519. dmantipov added a comment. Drop prefixes and tweak the style to match clang-format requirements. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87441/new/ https://reviews.llvm.org/D87441 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -52,8 +52,10 @@ DWARFAttributes(); ~DWARFAttributes(); - void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form); + void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, + dw_form_t form) { +m_infos.emplace_back(cu, attr_die_offset, attr, form); + } const DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; } @@ -77,6 +79,11 @@ // case we have DW_FORM_ref_addr values dw_offset_t die_offset; DWARFAttribute attr; + +AttributeValue(const DWARFUnit *cu, dw_offset_t die_offset, dw_attr_t attr, + dw_form_t form) + : cu(cu), die_offset(die_offset), +attr(attr, form, DWARFFormValue::ValueType()) {} }; typedef llvm::SmallVector collection; collection m_infos; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -25,13 +25,6 @@ return UINT32_MAX; } -void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form) { - AttributeValue attr_value = { - cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}}; - m_infos.push_back(attr_value); -} - bool DWARFAttributes::ExtractFormValueAtIndex( uint32_t i, DWARFFormValue &form_value) const { const DWARFUnit *cu = CompileUnitAtIndex(i); Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -52,8 +52,10 @@ DWARFAttributes(); ~DWARFAttributes(); - void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form); + void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, + dw_form_t form) { +m_infos.emplace_back(cu, attr_die_offset, attr, form); + } const DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; } @@ -77,6 +79,11 @@ // case we have DW_FORM_ref_addr values dw_offset_t die_offset; DWARFAttribute attr; + +AttributeValue(const DWARFUnit *cu, dw_offset_t die_offset, dw_attr_t attr, + dw_form_t form) + : cu(cu), die_offset(die_offset), +attr(attr, form, DWARFFormValue::ValueType()) {} }; typedef llvm::SmallVector collection; collection m_infos; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -25,13 +25,6 @@ return UINT32_MAX; } -void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form) { - AttributeValue attr_value = { - cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}}; - m_infos.push_back(attr_value); -} - bool DWARFAttributes::ExtractFormValueAtIndex( uint32_t i, DWARFFormValue &form_value) const { const DWARFUnit *cu = CompileUnitAtIndex(i); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 132e57b - Retry of D84974
Author: Walter Erquinigo Date: 2020-09-14T10:44:13-07:00 New Revision: 132e57bc597bd3f50174b7d286c43f76b47f11c1 URL: https://github.com/llvm/llvm-project/commit/132e57bc597bd3f50174b7d286c43f76b47f11c1 DIFF: https://github.com/llvm/llvm-project/commit/132e57bc597bd3f50174b7d286c43f76b47f11c1.diff LOG: Retry of D84974 - Fix a small issue caused by a conflicting name (GetObject) on Windows. The fix was to rename the internal GetObject function to GetNextFunction. Added: lldb/test/API/tools/lldb-vscode/runInTerminal/Makefile lldb/test/API/tools/lldb-vscode/runInTerminal/TestVSCode_runInTerminal.py lldb/test/API/tools/lldb-vscode/runInTerminal/main.c Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/tools/lldb-vscode/JSONUtils.cpp lldb/tools/lldb-vscode/JSONUtils.h lldb/tools/lldb-vscode/VSCode.cpp lldb/tools/lldb-vscode/VSCode.h lldb/tools/lldb-vscode/lldb-vscode.cpp lldb/tools/lldb-vscode/package.json Removed: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py index fa5a9c0db1eb..5710751ec34b 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py @@ -282,7 +282,7 @@ def launch(self, program=None, args=None, cwd=None, env=None, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, terminateCommands=None, sourcePath=None, debuggerRoot=None, launchCommands=None, - sourceMap=None, disconnectAutomatically=True): + sourceMap=None, disconnectAutomatically=True, runInTerminal=False): '''Sending launch request to vscode ''' @@ -316,10 +316,16 @@ def cleanup(): sourcePath=sourcePath, debuggerRoot=debuggerRoot, launchCommands=launchCommands, -sourceMap=sourceMap) +sourceMap=sourceMap, +runInTerminal=runInTerminal) if not (response and response['success']): self.assertTrue(response['success'], 'launch failed (%s)' % (response['message'])) +# We need to trigger a request_configurationDone after we've successfully +# attached a runInTerminal process to finish initialization. +if runInTerminal: +self.vscode.request_configurationDone() + def build_and_launch(self, program, args=None, cwd=None, env=None, stopOnEntry=False, disableASLR=True, @@ -327,7 +333,7 @@ def build_and_launch(self, program, args=None, cwd=None, env=None, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, terminateCommands=None, sourcePath=None, - debuggerRoot=None): + debuggerRoot=None, runInTerminal=False): '''Build the default Makefile target, create the VSCode debug adaptor, and launch the process. ''' @@ -337,4 +343,4 @@ def build_and_launch(self, program, args=None, cwd=None, env=None, self.launch(program, args, cwd, env, stopOnEntry, disableASLR, disableSTDIO, shellExpandArguments, trace, initCommands, preRunCommands, stopCommands, exitCommands, -terminateCommands, sourcePath, debuggerRoot) +terminateCommands, sourcePath, debuggerRoot, runInTerminal=runInTerminal) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py index 6b1c1c961b54..834e33ef5c3d 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -300,12 +300,29 @@ def send_recv(self, command): self.send_packet(command) done = False while not done: -response = self.recv_packet(filter_type='response') -if response is None: +response_or_request = self.recv_packet(filter_type=['response', 'request']) +if response_or_request is None: desc = 'no response for "%s"' % (command['command']) raise ValueError(desc) -self.validate_response(command, response) -return response +if response_or_request['type'] == 'response': +self.validate_response(command, response_or_request) +return response_or_request +else: +if response_o
[Lldb-commits] [lldb] a3bc040 - Fix 132e57bc597bd3f50174b7d286c43f76b47f11c1
Author: Walter Erquinigo Date: 2020-09-14T10:54:17-07:00 New Revision: a3bc0401d436d8c7d2dd5b54e13b81333d53bdff URL: https://github.com/llvm/llvm-project/commit/a3bc0401d436d8c7d2dd5b54e13b81333d53bdff DIFF: https://github.com/llvm/llvm-project/commit/a3bc0401d436d8c7d2dd5b54e13b81333d53bdff.diff LOG: Fix 132e57bc597bd3f50174b7d286c43f76b47f11c1 Compile error found in http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/17403/steps/build/logs/stdio Simple fix Added: Modified: lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp index 08973ec0f171..3b0817c71e62 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -2995,7 +2995,7 @@ int main(int argc, char *argv[]) { uint32_t packet_idx = 0; while (!g_vsc.sent_terminated_event) { llvm::json::Object object; -lldb_vscode::PacketStatus status = g_vsc.GetObject(object); +lldb_vscode::PacketStatus status = g_vsc.GetNextObject(object); if (status == lldb_vscode::PacketStatus::EndOfFile) break; if (status != lldb_vscode::PacketStatus::Success) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87626: Fix .debug_aranges parsing.
clayborg created this revision. clayborg added reviewers: labath, aprantl, JDevlieghere. Herald added a project: LLDB. clayborg requested review of this revision. Code was added that used llvm error checking to parse .debug_aranges, but the error check after parsing the DWARFDebugArangesSet was reversed and was causing no error to be returned with no valid address ranges being actually used. This meant we always would fall back onto creating out own address ranges by parsing the compile unit's ranges. This was causing problems for cases where the DW_TAG_compile_unit had a single address range by using a DW_AT_low_pc and DW_AT_high_pc attribute pair (not using a DW_AT_ranges attribute), but the .debug_aranges had correct split ranges. In this case we would end up using the single range for the compile unit that encompassed all of the ranges from the .debug_aranges section and would cause address resolving issues in LLDB where address lookups would fail for certain addresses. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D87626 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp === --- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp +++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp @@ -19,6 +19,7 @@ #include "Plugins/SymbolFile/DWARF/DWARFDataExtractor.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h" +#include "Plugins/SymbolFile/DWARF/DWARFDebugAranges.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" @@ -70,7 +71,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) { // Test that if we have a .debug_abbrev that contains ordered abbreviation // codes that start at 1, that we get O(1) access. - + const auto byte_order = eByteOrderLittle; const uint8_t addr_size = 4; StreamString encoder(Stream::eBinary, addr_size, byte_order); @@ -81,7 +82,7 @@ encoder.PutULEB128(DW_FORM_strp); encoder.PutULEB128(0); encoder.PutULEB128(0); - + encoder.PutULEB128(2); // Abbrev code 2 encoder.PutULEB128(DW_TAG_subprogram); encoder.PutHex8(DW_CHILDREN_no); @@ -89,9 +90,9 @@ encoder.PutULEB128(DW_FORM_strp); encoder.PutULEB128(0); encoder.PutULEB128(0); - + encoder.PutULEB128(0); // Abbrev code 0 (termination) - + DWARFDataExtractor data; data.SetData(encoder.GetData(), encoder.GetSize(), byte_order); DWARFAbbreviationDeclarationSet abbrev_set; @@ -101,7 +102,7 @@ // Make sure we have O(1) access to each abbreviation by making sure the // index offset is 1 and not UINT32_MAX EXPECT_EQ(abbrev_set.GetIndexOffset(), 1u); - + auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(1); EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit); EXPECT_TRUE(abbrev1->HasChildren()); @@ -115,7 +116,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) { // Test that if we have a .debug_abbrev that contains ordered abbreviation // codes that start at 5, that we get O(1) access. - + const auto byte_order = eByteOrderLittle; const uint8_t addr_size = 4; StreamString encoder(Stream::eBinary, addr_size, byte_order); @@ -126,7 +127,7 @@ encoder.PutULEB128(DW_FORM_strp); encoder.PutULEB128(0); encoder.PutULEB128(0); - + encoder.PutULEB128(6); // Abbrev code 6 encoder.PutULEB128(DW_TAG_subprogram); encoder.PutHex8(DW_CHILDREN_no); @@ -134,9 +135,9 @@ encoder.PutULEB128(DW_FORM_strp); encoder.PutULEB128(0); encoder.PutULEB128(0); - + encoder.PutULEB128(0); // Abbrev code 0 (termination) - + DWARFDataExtractor data; data.SetData(encoder.GetData(), encoder.GetSize(), byte_order); DWARFAbbreviationDeclarationSet abbrev_set; @@ -146,7 +147,7 @@ // Make sure we have O(1) access to each abbreviation by making sure the // index offset is 5 and not UINT32_MAX EXPECT_EQ(abbrev_set.GetIndexOffset(), 5u); - + auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(5); EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit); EXPECT_TRUE(abbrev1->HasChildren()); @@ -160,7 +161,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOutOfOrder) { // Test that if we have a .debug_abbrev that contains unordered abbreviation // codes, that we can access the information correctly. - + const auto byte_order = eByteOrderLittle; const uint8_t addr_size = 4; StreamString encoder(Stream::eBinary, addr_size, byte_order); @@ -171,7 +172,7 @@ encoder.PutULEB128(DW_FORM_strp); encoder.PutULEB128(0); encoder.PutULEB128(0); - + encoder.PutULEB128(1); // Abbrev code 1 encoder.PutULEB128(DW_TAG_subprogram); encoder.PutHex8(DW_CHILDREN_no); @@ -179,9 +180,9 @@ encoder.Put
[Lldb-commits] [PATCH] D87633: [lldb] Reword CompilerType docstring to not say "generic type"
kastiglione created this revision. kastiglione added reviewers: aprantl, teemperor. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. kastiglione requested review of this revision. Herald added a subscriber: JDevlieghere. Since "generic type" has a precise meaning in some languages, reword the docstring of `CompilerType` to avoid ambiguity. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D87633 Files: lldb/include/lldb/Symbol/CompilerType.h Index: lldb/include/lldb/Symbol/CompilerType.h === --- lldb/include/lldb/Symbol/CompilerType.h +++ lldb/include/lldb/Symbol/CompilerType.h @@ -20,7 +20,7 @@ class DataExtractor; -/// Represents a generic type in a programming language. +/// Generic representation of a type in a programming language. /// /// This class serves as an abstraction for a type inside one of the TypeSystems /// implemented by the language plugins. It does not have any actual logic in it Index: lldb/include/lldb/Symbol/CompilerType.h === --- lldb/include/lldb/Symbol/CompilerType.h +++ lldb/include/lldb/Symbol/CompilerType.h @@ -20,7 +20,7 @@ class DataExtractor; -/// Represents a generic type in a programming language. +/// Generic representation of a type in a programming language. /// /// This class serves as an abstraction for a type inside one of the TypeSystems /// implemented by the language plugins. It does not have any actual logic in it ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest
rupprecht created this revision. rupprecht added a reviewer: JDevlieghere. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. rupprecht requested review of this revision. Register the `faulthandler` module so we can see what lldb tests are doing when they misbehave (e.g. run under a test runner that sets a timeout). This will print a stack trace for the following signals: - `SIGSEGV`, `SIGFPE`, `SIGABRT`, `SIGBUS`, and `SIGILL` (via `faulthandler.enable()`) - `SIGTERM` (via `faulthandler.register(SIGTERM)`) [This is what our test runners sends when it times out]. The only signal we currently handle is `SIGINT` (via `unittest2.signals.installHandler()`) so there should be no overlap added by this patch. Because this import is not available until python3, and the `register()` method is not available on Windows, this is enabled defensively. This should have absolutely no effect when tests are passing (or even normally failing), but can be observed by running this while ninja is running: kill -s SIGTERM $(ps aux | grep dotest.py | head -1 | awk '{print $2}') Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D87637 Files: lldb/packages/Python/lldbsuite/test/dotest.py Index: lldb/packages/Python/lldbsuite/test/dotest.py === --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -449,6 +449,18 @@ lldbtest_config.codesign_identity = args.codesign_identity +def registerFaulthandler(): +try: +import faulthandler +except ImportError: +# faulthandler is not available until python3 +return + +faulthandler.enable() +# faulthandler.register is not available on Windows. +if getattr(faulthandler, 'register', None): +faulthandler.register(signal.SIGTERM, chain=True) + def setupSysPath(): """ Add LLDB.framework/Resources/Python to the search paths for modules. @@ -875,6 +887,9 @@ # parseOptionsAndInitTestdirs() +# Print a stack trace if the test hangs or is passed SIGTERM. +registerFaulthandler() + setupSysPath() import lldbconfig Index: lldb/packages/Python/lldbsuite/test/dotest.py === --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -449,6 +449,18 @@ lldbtest_config.codesign_identity = args.codesign_identity +def registerFaulthandler(): +try: +import faulthandler +except ImportError: +# faulthandler is not available until python3 +return + +faulthandler.enable() +# faulthandler.register is not available on Windows. +if getattr(faulthandler, 'register', None): +faulthandler.register(signal.SIGTERM, chain=True) + def setupSysPath(): """ Add LLDB.framework/Resources/Python to the search paths for modules. @@ -875,6 +887,9 @@ # parseOptionsAndInitTestdirs() +# Print a stack trace if the test hangs or is passed SIGTERM. +registerFaulthandler() + setupSysPath() import lldbconfig ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87640: Add '<' meta command to read in code from external file
pcbeard created this revision. pcbeard added reviewers: jingham, teemperor. pcbeard created this object with visibility "All Users". pcbeard added a project: LLDB. Herald added a subscriber: JDevlieghere. pcbeard requested review of this revision. Perform all error handling in ReadCode() Add :help text describing “< path”, add extra line before Commands Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D87640 Files: lldb/source/Expression/REPL.cpp Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -123,10 +123,11 @@ "Valid statements, expressions, and declarations are immediately " "compiled and executed.\n\n" "The complete set of LLDB debugging commands are also available as " - "described below. Commands " + "described below.\n\nCommands " "must be prefixed with a colon at the REPL prompt (:quit for " "example.) Typing just a colon " - "followed by return will switch to the LLDB prompt.\n\n"; + "followed by return will switch to the LLDB prompt.\n\n" + "Type “< path” to read in code from a text file “path”.\n\n"; } bool REPL::IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { @@ -179,6 +180,36 @@ return (int)desired_indent - actual_indent; } +static bool ReadCode(const std::string &path, std::string &code, + lldb::StreamFileSP &error_sp) { + auto &fs = FileSystem::Instance(); + llvm::Twine pathTwine(path); + if (!fs.Exists(pathTwine)) { +error_sp->Printf("no such file at path '%s'\n", path.c_str()); +return false; + } + if (!fs.Readable(pathTwine)) { +error_sp->Printf("could not read file at path '%s'\n", path.c_str()); +return false; + } + const size_t file_size = fs.GetByteSize(pathTwine); + const size_t max_size = code.max_size(); + if (file_size > max_size) { +error_sp->Printf("file at path '%s' too large: " + "file_size = %llu, max_size = %llu\n", + path.c_str(), file_size, max_size); +return false; + } + auto data_sp = fs.CreateDataBuffer(pathTwine); + if (data_sp == nullptr) { +error_sp->Printf("could not create buffer for " + "file at path '%s'\n", path.c_str()); +return false; + } + code.assign((const char *)data_sp->GetBytes(), data_sp->GetByteSize()); + return true; +} + void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { lldb::StreamFileSP output_sp(io_handler.GetOutputStreamFileSP()); lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFileSP()); @@ -257,6 +288,14 @@ } } } else { + if (code[0] == '<') { +// user wants to read code from a file. interpret rest of line as a literal path +auto path = llvm::StringRef(code.substr(1)).trim().str(); +if (!ReadCode(path, code, error_sp)) { + return; +} + } + // Unwind any expression we might have been running in case our REPL // expression crashed and the user was looking around if (m_dedicated_repl_mode) { Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -123,10 +123,11 @@ "Valid statements, expressions, and declarations are immediately " "compiled and executed.\n\n" "The complete set of LLDB debugging commands are also available as " - "described below. Commands " + "described below.\n\nCommands " "must be prefixed with a colon at the REPL prompt (:quit for " "example.) Typing just a colon " - "followed by return will switch to the LLDB prompt.\n\n"; + "followed by return will switch to the LLDB prompt.\n\n" + "Type â< pathâ to read in code from a text file âpathâ.\n\n"; } bool REPL::IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { @@ -179,6 +180,36 @@ return (int)desired_indent - actual_indent; } +static bool ReadCode(const std::string &path, std::string &code, + lldb::StreamFileSP &error_sp) { + auto &fs = FileSystem::Instance(); + llvm::Twine pathTwine(path); + if (!fs.Exists(pathTwine)) { +error_sp->Printf("no such file at path '%s'\n", path.c_str()); +return false; + } + if (!fs.Readable(pathTwine)) { +error_sp->Printf("could not read file at path '%s'\n", path.c_str()); +return false; + } + const size_t file_size = fs.GetByteSize(pathTwine); + const size_t max_size = code.max_size(); + if (file_size > max_size) { +error_sp->Printf("file at path '%s' too large: " + "file_size = %llu, max_size = %llu\n", + path.c_str(), file_size, max_size); +return false; + } + auto data_
[Lldb-commits] [PATCH] D87640: Add '<' meta command to read in code from external file
jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. LGTM. This will get tests on the swift side till we have a REPL for C++ we can use to test this out. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87640/new/ https://reviews.llvm.org/D87640 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87640: Add '<' meta command to read in code from external file
pcbeard updated this revision to Diff 291742. pcbeard added a comment. Reformatted whitespace. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87640/new/ https://reviews.llvm.org/D87640 Files: lldb/source/Expression/REPL.cpp Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -123,10 +123,11 @@ "Valid statements, expressions, and declarations are immediately " "compiled and executed.\n\n" "The complete set of LLDB debugging commands are also available as " - "described below. Commands " + "described below.\n\nCommands " "must be prefixed with a colon at the REPL prompt (:quit for " "example.) Typing just a colon " - "followed by return will switch to the LLDB prompt.\n\n"; + "followed by return will switch to the LLDB prompt.\n\n" + "Type “< path” to read in code from a text file “path”.\n\n"; } bool REPL::IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { @@ -179,6 +180,36 @@ return (int)desired_indent - actual_indent; } +static bool ReadCode(const std::string &path, std::string &code, + lldb::StreamFileSP &error_sp) { + auto &fs = FileSystem::Instance(); + llvm::Twine pathTwine(path); + if (!fs.Exists(pathTwine)) { +error_sp->Printf("no such file at path '%s'\n", path.c_str()); +return false; + } + if (!fs.Readable(pathTwine)) { +error_sp->Printf("could not read file at path '%s'\n", path.c_str()); +return false; + } + const size_t file_size = fs.GetByteSize(pathTwine); + const size_t max_size = code.max_size(); + if (file_size > max_size) { +error_sp->Printf("file at path '%s' too large: " + "file_size = %llu, max_size = %llu\n", + path.c_str(), file_size, max_size); +return false; + } + auto data_sp = fs.CreateDataBuffer(pathTwine); + if (data_sp == nullptr) { +error_sp->Printf("could not create buffer for file at path '%s'\n", + path.c_str()); +return false; + } + code.assign((const char *)data_sp->GetBytes(), data_sp->GetByteSize()); + return true; +} + void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { lldb::StreamFileSP output_sp(io_handler.GetOutputStreamFileSP()); lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFileSP()); @@ -257,6 +288,15 @@ } } } else { + if (code[0] == '<') { +// User wants to read code from a file. +// Interpret rest of line as a literal path. +auto path = llvm::StringRef(code.substr(1)).trim().str(); +if (!ReadCode(path, code, error_sp)) { + return; +} + } + // Unwind any expression we might have been running in case our REPL // expression crashed and the user was looking around if (m_dedicated_repl_mode) { Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -123,10 +123,11 @@ "Valid statements, expressions, and declarations are immediately " "compiled and executed.\n\n" "The complete set of LLDB debugging commands are also available as " - "described below. Commands " + "described below.\n\nCommands " "must be prefixed with a colon at the REPL prompt (:quit for " "example.) Typing just a colon " - "followed by return will switch to the LLDB prompt.\n\n"; + "followed by return will switch to the LLDB prompt.\n\n" + "Type â< pathâ to read in code from a text file âpathâ.\n\n"; } bool REPL::IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { @@ -179,6 +180,36 @@ return (int)desired_indent - actual_indent; } +static bool ReadCode(const std::string &path, std::string &code, + lldb::StreamFileSP &error_sp) { + auto &fs = FileSystem::Instance(); + llvm::Twine pathTwine(path); + if (!fs.Exists(pathTwine)) { +error_sp->Printf("no such file at path '%s'\n", path.c_str()); +return false; + } + if (!fs.Readable(pathTwine)) { +error_sp->Printf("could not read file at path '%s'\n", path.c_str()); +return false; + } + const size_t file_size = fs.GetByteSize(pathTwine); + const size_t max_size = code.max_size(); + if (file_size > max_size) { +error_sp->Printf("file at path '%s' too large: " + "file_size = %llu, max_size = %llu\n", + path.c_str(), file_size, max_size); +return false; + } + auto data_sp = fs.CreateDataBuffer(pathTwine); + if (data_sp == nullptr) { +error_sp->Printf("could not create buffer for file at path '%s'\n", + path.c_str()); +return
[Lldb-commits] [PATCH] D87626: Fix .debug_aranges parsing.
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. Nice catch! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87626/new/ https://reviews.llvm.org/D87626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D87442: [lldb] Show flags for memory regions
omjavaid added a comment. Herald added a reviewer: JDevlieghere. This seems fine to me with some minor nits. Also do you plan on writing a Linux API test for this which test memory regions on Linux? I couldnt locate one already written. Comment at: lldb/source/API/SBMemoryRegionInfo.cpp:125 + +bool SBMemoryRegionInfo::GetFlags(SBStream &flags) { + LLDB_RECORD_METHOD(bool, SBMemoryRegionInfo, GetFlags, (lldb::SBStream &), This function always returns true. If there is no other use of HasFlags API function then may be merge GetFlags and HasFlags by returning false in case flags are not available. Comment at: lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp:19 +enum MapKind { eMaps, eSMaps }; + May be consider converting this into a class enum. Comment at: lldb/unittests/Process/minidump/MinidumpParserTest.cpp:9 #include "Plugins/Process/minidump/MinidumpParser.h" #include "Plugins/Process/minidump/MinidumpTypes.h" This file apparently requires a clang-format run. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87442/new/ https://reviews.llvm.org/D87442 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits