[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
jimingham wrote: Sorry to come in a little late on this, but I think we need a setting to turn this off as well. If you aren't planning to use the transcript, you shouldn't have to pay the cost for it. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcaster, CommandUsageMap m_command_usages; StreamString m_transcript_stream; + + /// Contains a list of handled commands, output and error. Each element in + /// the list is a dictionary with three keys: "command" (string), "output" + /// (list of strings) and optionally "error" (list of strings). Each string + /// in "output" and "error" is a line (without EOL characters). clayborg wrote: If we have a transcript already, can we start storing the time it took the run each command and also add this to the JSON as a "time_sec" (to indicate time in seconds) as a float value? https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -2044,6 +2052,15 @@ bool CommandInterpreter::HandleCommand(const char *command_line, m_transcript_stream << result.GetOutputData(); m_transcript_stream << result.GetErrorData(); + // Add output and error to the transcript item after splitting lines. In the + // future, other aspects of the command (e.g. perf) can be added, too. + transcript_item->AddItem( + "output", StructuredData::Array::SplitString(result.GetOutputData(), '\n', + -1, false)); + transcript_item->AddItem( + "error", StructuredData::Array::SplitString(result.GetErrorData(), '\n', + -1, false)); clayborg wrote: Can we time the "cmd_obj->Execute()" calls and add this as a key/value pair? https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/91146 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/91146 >From c7cef45aa369014650cc99d404913c17cb3c1d45 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Mon, 6 May 2024 01:10:03 +0400 Subject: [PATCH] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s Reproduced with Python 3.12.3 --- .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py| 4 ++-- .../lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 75522158b32210..8c8e4abed0b454 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -130,9 +130,9 @@ def setUp(self): self.stub_sends_two_stop_notifications_on_kill = False if configuration.lldb_platform_url: if configuration.lldb_platform_url.startswith("unix-"): -url_pattern = "(.+)://\[?(.+?)\]?/.*" +url_pattern = r"(.+)://\[?(.+?)\]?/.*" else: -url_pattern = "(.+)://(.+):\d+" +url_pattern = r"(.+)://(.+):\d+" scheme, host = re.match( url_pattern, configuration.lldb_platform_url ).groups() diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py index 61c5c3a7c865a2..d1a4119bac7815 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py @@ -50,7 +50,7 @@ def get_debugserver_exe(): _LOG_LINE_REGEX = re.compile( -r"^(lldb-server|debugserver)\s+<\s*(\d+)>" + "\s+(read|send)\s+packet:\s+(.+)$" +r"^(lldb-server|debugserver)\s+<\s*(\d+)>\s+(read|send)\s+packet:\s+(.+)$" ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jeffreytan81) Changes This PR introduces a new `ThreadPlanSingleThreadTimeout` that will be used to address potential deadlock during single-thread stepping. While debugging a target with a non-trivial number of threads (around 5000 threads in one example target), we noticed that a simple step over can take as long as 10 seconds. Enabling single-thread stepping mode significantly reduces the stepping time to around 3 seconds. However, this can introduce deadlock if we try to step over a method that depends on other threads to release a lock. To address this issue, we introduce a new `ThreadPlanSingleThreadTimeout` that can be controlled by the `target.process.thread.single-thread-plan-timeout` setting during single-thread stepping mode. The concept involves counting the elapsed time since the last internal stop to detect overall stepping progress. Once a timeout occurs, we assume the target is not making progress due to a potential deadlock, as mentioned above. We then send a new async interrupt, resume all threads, and `ThreadPlanSingleThreadTimeout` completes its task. To support this design, the major changes made in this PR are: 1. `ThreadPlanSingleThreadTimeout` is popped during every internal stop and reset (re-pushed) to the top of the stack (as a leaf node) during resume. This is achieved by always returning `true` from `ThreadPlanSingleThreadTimeout::DoPlanExplainsStop()` and `ThreadPlanSingleThreadTimeout::MischiefManaged()`. 2. A new thread-specific async interrupt stop is introduced, which can be detected/consumed by `ThreadPlanSingleThreadTimeout`. 3. The clearing of branch breakpoints in the range thread plan has been moved from `DoPlanExplainsStop()` to `ShouldStop()`, as it is not guaranteed that it will be called. The detailed design is discussed in the RFC below: [https://discourse.llvm.org/t/improve-single-thread-stepping/74599](https://discourse.llvm.org/t/improve-single-thread-stepping/74599) --- Patch is 49.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90930.diff 29 Files Affected: - (modified) lldb/include/lldb/Target/Process.h (+9-2) - (modified) lldb/include/lldb/Target/StopInfo.h (+4) - (modified) lldb/include/lldb/Target/Thread.h (+2) - (modified) lldb/include/lldb/Target/ThreadPlan.h (+5-3) - (added) lldb/include/lldb/Target/ThreadPlanSingleThreadTimeout.h (+93) - (modified) lldb/include/lldb/Target/ThreadPlanStepOut.h (+1) - (modified) lldb/include/lldb/Target/ThreadPlanStepOverRange.h (+6) - (modified) lldb/include/lldb/Target/ThreadPlanStepRange.h (+5) - (modified) lldb/include/lldb/lldb-enumerations.h (+1) - (modified) lldb/source/API/SBThread.cpp (+6) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+1-1) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+2) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+50-11) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+6) - (modified) lldb/source/Target/CMakeLists.txt (+1) - (modified) lldb/source/Target/Process.cpp (+18-5) - (modified) lldb/source/Target/StopInfo.cpp (+37) - (modified) lldb/source/Target/TargetProperties.td (+4) - (modified) lldb/source/Target/Thread.cpp (+8-1) - (modified) lldb/source/Target/ThreadPlan.cpp (+1) - (added) lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp (+234) - (modified) lldb/source/Target/ThreadPlanStepInRange.cpp (+1) - (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+18-2) - (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+45-26) - (added) lldb/test/API/functionalities/single-thread-step/Makefile (+4) - (added) lldb/test/API/functionalities/single-thread-step/TestSingleThreadStepTimeout.py (+123) - (added) lldb/test/API/functionalities/single-thread-step/main.cpp (+62) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+3) - (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+1) ``diff diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index aac0cf51680a9e..7e758dbb9f6457 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1312,11 +1312,13 @@ class Process : public std::enable_shared_from_this, size_t GetThreadStatus(Stream , bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, - uint32_t num_frames_with_source, - bool stop_format); + uint32_t num_frames_with_source, bool stop_format); void SendAsyncInterrupt(); + // Send an async interrupt and receive stop from a specific /p thread. + void SendAsyncInterrupt(Thread *thread); + // Notify this process class that modules got loaded. // // If subclasses override this method, they must call this version before @@ -3102,6
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
https://github.com/jeffreytan81 ready_for_review https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
https://github.com/jeffreytan81 edited https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/91254 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3809e20 - [lldb] Use add_custom_command for SBLanguages.h (#91254)
Author: Jonas Devlieghere Date: 2024-05-06T14:43:47-07:00 New Revision: 3809e20afc68d7d03821f0ec59b928dcf9befbf4 URL: https://github.com/llvm/llvm-project/commit/3809e20afc68d7d03821f0ec59b928dcf9befbf4 DIFF: https://github.com/llvm/llvm-project/commit/3809e20afc68d7d03821f0ec59b928dcf9befbf4.diff LOG: [lldb] Use add_custom_command for SBLanguages.h (#91254) Use add_custom_command instead of add_custom_target to generate SBLanguages.h. Added: Modified: lldb/source/API/CMakeLists.txt Removed: diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index a64c0d4a333425..798a92874f13d1 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -23,13 +23,13 @@ endif() # Target to generate SBLanguages.h from Dwarf.def. set(sb_languages_file ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) -add_custom_target( - lldb-sbapi-dwarf-enums - "${Python3_EXECUTABLE}" +add_custom_command( + COMMENT "Generating SBLanguages.h from Dwarf.def" + COMMAND "${Python3_EXECUTABLE}" ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def -o ${sb_languages_file} - BYPRODUCTS ${sb_languages_file} + OUTPUT ${sb_languages_file} DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} ) @@ -113,9 +113,7 @@ add_lldb_library(liblldb SHARED ${option_framework} SystemInitializerFull.cpp ${lldb_python_wrapper} ${lldb_lua_wrapper} - - DEPENDS -lldb-sbapi-dwarf-enums + ${sb_languages_file} LINK_LIBS lldbBreakpoint ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
JDevlieghere wrote: Good point. I can't imagine anything needing the SB header that doesn't need the rest of the framework, but if that's the case we go through a custom target. https://github.com/llvm/llvm-project/pull/91254 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)
JDevlieghere wrote: The change itself looks fine, but can you please add a bit more info to the commit message, such as the Python version you're seeing this with. https://github.com/llvm/llvm-project/pull/91146 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/91254 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
bulbazord wrote: This should work if there is exactly one thing that depends on the output of this custom command. If multiple things start depending on the generated files, you may end up with weird results. See: https://cmake.org/cmake/help/latest/command/add_custom_command.html > Do not list the output in more than one independent target that may build in > parallel or the instances of the rule may conflict. Instead, use the > [add_custom_target()](https://cmake.org/cmake/help/latest/command/add_custom_target.html#command:add_custom_target) > command to drive the command and make the other targets depend on that one. > See the [Example: Generating Files for Multiple > Targets](https://cmake.org/cmake/help/latest/command/add_custom_command.html#example-generating-files-for-multiple-targets) > below. https://github.com/llvm/llvm-project/pull/91254 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/crashlog] Update incorrect help message for `--no-crashed-only` option (PR #91162)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/91162 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)
smurfd wrote: Thanks @adrian-prantl, simple is better :) https://github.com/llvm/llvm-project/pull/91128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)
https://github.com/smurfd updated https://github.com/llvm/llvm-project/pull/91128 >From 9a90c71f6fa086cdaf3400bdc5142835a12239bd Mon Sep 17 00:00:00 2001 From: Nicklas Boman Date: Sun, 5 May 2024 17:40:51 +0200 Subject: [PATCH] lldb create API folder if it does not exist, before creating SBLanguages.h --- lldb/scripts/generate-sbapi-dwarf-enum.py | 4 1 file changed, 4 insertions(+) diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py index 464eb2afff7d6f..f7a13e5efffef5 100755 --- a/lldb/scripts/generate-sbapi-dwarf-enum.py +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -2,6 +2,7 @@ import argparse import re +import os HEADER = """\ //===-- SBLanguages.h -*- C++ -*-===// @@ -37,6 +38,9 @@ def emit_enum(input, output): with open(input, "r") as f: lines = f.readlines() +# Create output folder if it does not exist +os.makedirs(os.path.dirname(output), exist_ok=True) + # Write the output. with open(output, "w") as f: # Emit the header. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( JDevlieghere wrote: https://github.com/llvm/llvm-project/pull/91254 https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Use add_custom_command instead of add_custom_target to generate SBLanguages.h. --- Full diff: https://github.com/llvm/llvm-project/pull/91254.diff 1 Files Affected: - (modified) lldb/source/API/CMakeLists.txt (+5-7) ``diff diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index a64c0d4a333425..798a92874f13d1 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -23,13 +23,13 @@ endif() # Target to generate SBLanguages.h from Dwarf.def. set(sb_languages_file ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) -add_custom_target( - lldb-sbapi-dwarf-enums - "${Python3_EXECUTABLE}" +add_custom_command( + COMMENT "Generating SBLanguages.h from Dwarf.def" + COMMAND "${Python3_EXECUTABLE}" ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def -o ${sb_languages_file} - BYPRODUCTS ${sb_languages_file} + OUTPUT ${sb_languages_file} DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} ) @@ -113,9 +113,7 @@ add_lldb_library(liblldb SHARED ${option_framework} SystemInitializerFull.cpp ${lldb_python_wrapper} ${lldb_lua_wrapper} - - DEPENDS -lldb-sbapi-dwarf-enums + ${sb_languages_file} LINK_LIBS lldbBreakpoint `` https://github.com/llvm/llvm-project/pull/91254 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use add_custom_command for SBLanguages.h (PR #91254)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/91254 Use add_custom_command instead of add_custom_target to generate SBLanguages.h. >From 7fa130d2bb2e45f350ca8c3851d32bbec3332f8c Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 6 May 2024 11:48:24 -0700 Subject: [PATCH] [lldb] Use add_custom_command for SBLanguages.h Use add_custom_command instead of add_custom_target to generate SBLanguages.h. --- lldb/source/API/CMakeLists.txt | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index a64c0d4a333425..798a92874f13d1 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -23,13 +23,13 @@ endif() # Target to generate SBLanguages.h from Dwarf.def. set(sb_languages_file ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) -add_custom_target( - lldb-sbapi-dwarf-enums - "${Python3_EXECUTABLE}" +add_custom_command( + COMMENT "Generating SBLanguages.h from Dwarf.def" + COMMAND "${Python3_EXECUTABLE}" ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def -o ${sb_languages_file} - BYPRODUCTS ${sb_languages_file} + OUTPUT ${sb_languages_file} DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} ) @@ -113,9 +113,7 @@ add_lldb_library(liblldb SHARED ${option_framework} SystemInitializerFull.cpp ${lldb_python_wrapper} ${lldb_lua_wrapper} - - DEPENDS -lldb-sbapi-dwarf-enums + ${sb_languages_file} LINK_LIBS lldbBreakpoint ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)
@@ -37,6 +38,10 @@ def emit_enum(input, output): with open(input, "r") as f: lines = f.readlines() +# Create output folder if it does not exist +if not os.path.isdir(os.path.dirname(output)): adrian-prantl wrote: This can be simplified: https://docs.python.org/3/library/os.html ```suggestion os.makedirs(os.path.dirname(output), exist_ok=True) ``` https://github.com/llvm/llvm-project/pull/91128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)
smurfd wrote: Thanks @JDevlieghere! i do not have commit access, will you please merge this? https://github.com/llvm/llvm-project/pull/91128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90930 >From b72df8cf2a047ed731913609b58bdb4a3601e111 Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Thu, 2 May 2024 18:12:04 -0700 Subject: [PATCH 1/3] Single thread timeout feature --- lldb/include/lldb/Target/Process.h| 11 +- lldb/include/lldb/Target/StopInfo.h | 4 + lldb/include/lldb/Target/Thread.h | 2 + lldb/include/lldb/Target/ThreadPlan.h | 8 +- .../Target/ThreadPlanSingleThreadTimeout.h| 89 lldb/include/lldb/Target/ThreadPlanStepOut.h | 1 + .../lldb/Target/ThreadPlanStepOverRange.h | 5 + lldb/include/lldb/lldb-enumerations.h | 1 + lldb/source/API/SBThread.cpp | 6 + .../source/Interpreter/CommandInterpreter.cpp | 2 +- .../GDBRemoteCommunicationServerLLGS.cpp | 2 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 61 +- .../Process/gdb-remote/ProcessGDBRemote.h | 6 + lldb/source/Target/CMakeLists.txt | 1 + lldb/source/Target/Process.cpp| 23 +- lldb/source/Target/StopInfo.cpp | 37 lldb/source/Target/TargetProperties.td| 4 + lldb/source/Target/Thread.cpp | 9 +- lldb/source/Target/ThreadPlan.cpp | 1 + .../Target/ThreadPlanSingleThreadTimeout.cpp | 205 ++ lldb/source/Target/ThreadPlanStepInRange.cpp | 2 + .../source/Target/ThreadPlanStepOverRange.cpp | 17 +- lldb/source/Target/ThreadPlanStepRange.cpp| 9 +- .../single-thread-step/Makefile | 4 + .../TestSingleThreadStepTimeout.py| 123 +++ .../single-thread-step/main.cpp | 62 ++ lldb/tools/lldb-dap/JSONUtils.cpp | 3 + lldb/tools/lldb-dap/LLDBUtils.cpp | 1 + 28 files changed, 671 insertions(+), 28 deletions(-) create mode 100644 lldb/include/lldb/Target/ThreadPlanSingleThreadTimeout.h create mode 100644 lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp create mode 100644 lldb/test/API/functionalities/single-thread-step/Makefile create mode 100644 lldb/test/API/functionalities/single-thread-step/TestSingleThreadStepTimeout.py create mode 100644 lldb/test/API/functionalities/single-thread-step/main.cpp diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index aac0cf51680a9e..7e758dbb9f6457 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1312,11 +1312,13 @@ class Process : public std::enable_shared_from_this, size_t GetThreadStatus(Stream , bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, - uint32_t num_frames_with_source, - bool stop_format); + uint32_t num_frames_with_source, bool stop_format); void SendAsyncInterrupt(); + // Send an async interrupt and receive stop from a specific /p thread. + void SendAsyncInterrupt(Thread *thread); + // Notify this process class that modules got loaded. // // If subclasses override this method, they must call this version before @@ -3102,6 +3104,11 @@ void PruneThreadPlans(); // Resume will only request a resume, using this // flag to check. + lldb::tid_t m_interrupt_tid; /// The tid of the thread that issued the async + /// interrupt, used by thread plan timeout. It + /// can be LLDB_INVALID_THREAD_ID to indicate + /// user level async interrupt. + /// This is set at the beginning of Process::Finalize() to stop functions /// from looking up or creating things during or after a finalize call. std::atomic m_finalizing; diff --git a/lldb/include/lldb/Target/StopInfo.h b/lldb/include/lldb/Target/StopInfo.h index d1848fcbbbdb19..fae90364deaf0a 100644 --- a/lldb/include/lldb/Target/StopInfo.h +++ b/lldb/include/lldb/Target/StopInfo.h @@ -123,6 +123,10 @@ class StopInfo : public std::enable_shared_from_this { const char *description = nullptr, std::optional code = std::nullopt); + static lldb::StopInfoSP + CreateStopReasonWithInterrupt(Thread , int signo, +const char *description); + static lldb::StopInfoSP CreateStopReasonToTrace(Thread ); static lldb::StopInfoSP diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index c17bddf4d98b85..584093348b4c6a 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -57,6 +57,8 @@ class ThreadProperties : public Properties { bool GetStepOutAvoidsNoDebug() const; uint64_t GetMaxBacktraceDepth() const; + + uint64_t GetSingleThreadPlanTimeout() const; }; class Thread : public
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff cf3c714e4bd7b8a68793f2827080fe3388ae8bb1 d125c5a761a70b024afb16d22b4326df4071e04b -- lldb/include/lldb/Target/ThreadPlanSingleThreadTimeout.h lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp lldb/test/API/functionalities/single-thread-step/main.cpp lldb/include/lldb/Target/Process.h lldb/include/lldb/Target/StopInfo.h lldb/include/lldb/Target/Thread.h lldb/include/lldb/Target/ThreadPlan.h lldb/include/lldb/Target/ThreadPlanStepOut.h lldb/include/lldb/Target/ThreadPlanStepOverRange.h lldb/include/lldb/Target/ThreadPlanStepRange.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBThread.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadPlan.cpp lldb/source/Target/ThreadPlanStepInRange.cpp lldb/source/Target/ThreadPlanStepOverRange.cpp lldb/source/Target/ThreadPlanStepRange.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/LLDBUtils.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp b/lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp index ce214af233..00f6923446 100644 --- a/lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp +++ b/lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp @@ -75,10 +75,7 @@ void ThreadPlanSingleThreadTimeout::CreateNew(Thread ) { if (ThreadPlanSingleThreadTimeout::IsAlive()) return; - { - -s_prev_state = State::WaitTimeout; - } + { s_prev_state = State::WaitTimeout; } auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread); ThreadPlanSP thread_plan_sp(timeout_plan); auto status = thread.QueueThreadPlan(thread_plan_sp, @@ -230,5 +227,5 @@ void ThreadPlanSingleThreadTimeout::HandleTimeout() { bool ThreadPlanSingleThreadTimeout::IsAlive() { std::lock_guard lock(s_mutex); - return s_instance != nullptr; + return s_instance != nullptr; } `` https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90930 >From b72df8cf2a047ed731913609b58bdb4a3601e111 Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Thu, 2 May 2024 18:12:04 -0700 Subject: [PATCH 1/2] Single thread timeout feature --- lldb/include/lldb/Target/Process.h| 11 +- lldb/include/lldb/Target/StopInfo.h | 4 + lldb/include/lldb/Target/Thread.h | 2 + lldb/include/lldb/Target/ThreadPlan.h | 8 +- .../Target/ThreadPlanSingleThreadTimeout.h| 89 lldb/include/lldb/Target/ThreadPlanStepOut.h | 1 + .../lldb/Target/ThreadPlanStepOverRange.h | 5 + lldb/include/lldb/lldb-enumerations.h | 1 + lldb/source/API/SBThread.cpp | 6 + .../source/Interpreter/CommandInterpreter.cpp | 2 +- .../GDBRemoteCommunicationServerLLGS.cpp | 2 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 61 +- .../Process/gdb-remote/ProcessGDBRemote.h | 6 + lldb/source/Target/CMakeLists.txt | 1 + lldb/source/Target/Process.cpp| 23 +- lldb/source/Target/StopInfo.cpp | 37 lldb/source/Target/TargetProperties.td| 4 + lldb/source/Target/Thread.cpp | 9 +- lldb/source/Target/ThreadPlan.cpp | 1 + .../Target/ThreadPlanSingleThreadTimeout.cpp | 205 ++ lldb/source/Target/ThreadPlanStepInRange.cpp | 2 + .../source/Target/ThreadPlanStepOverRange.cpp | 17 +- lldb/source/Target/ThreadPlanStepRange.cpp| 9 +- .../single-thread-step/Makefile | 4 + .../TestSingleThreadStepTimeout.py| 123 +++ .../single-thread-step/main.cpp | 62 ++ lldb/tools/lldb-dap/JSONUtils.cpp | 3 + lldb/tools/lldb-dap/LLDBUtils.cpp | 1 + 28 files changed, 671 insertions(+), 28 deletions(-) create mode 100644 lldb/include/lldb/Target/ThreadPlanSingleThreadTimeout.h create mode 100644 lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp create mode 100644 lldb/test/API/functionalities/single-thread-step/Makefile create mode 100644 lldb/test/API/functionalities/single-thread-step/TestSingleThreadStepTimeout.py create mode 100644 lldb/test/API/functionalities/single-thread-step/main.cpp diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index aac0cf51680a9e..7e758dbb9f6457 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1312,11 +1312,13 @@ class Process : public std::enable_shared_from_this, size_t GetThreadStatus(Stream , bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, - uint32_t num_frames_with_source, - bool stop_format); + uint32_t num_frames_with_source, bool stop_format); void SendAsyncInterrupt(); + // Send an async interrupt and receive stop from a specific /p thread. + void SendAsyncInterrupt(Thread *thread); + // Notify this process class that modules got loaded. // // If subclasses override this method, they must call this version before @@ -3102,6 +3104,11 @@ void PruneThreadPlans(); // Resume will only request a resume, using this // flag to check. + lldb::tid_t m_interrupt_tid; /// The tid of the thread that issued the async + /// interrupt, used by thread plan timeout. It + /// can be LLDB_INVALID_THREAD_ID to indicate + /// user level async interrupt. + /// This is set at the beginning of Process::Finalize() to stop functions /// from looking up or creating things during or after a finalize call. std::atomic m_finalizing; diff --git a/lldb/include/lldb/Target/StopInfo.h b/lldb/include/lldb/Target/StopInfo.h index d1848fcbbbdb19..fae90364deaf0a 100644 --- a/lldb/include/lldb/Target/StopInfo.h +++ b/lldb/include/lldb/Target/StopInfo.h @@ -123,6 +123,10 @@ class StopInfo : public std::enable_shared_from_this { const char *description = nullptr, std::optional code = std::nullopt); + static lldb::StopInfoSP + CreateStopReasonWithInterrupt(Thread , int signo, +const char *description); + static lldb::StopInfoSP CreateStopReasonToTrace(Thread ); static lldb::StopInfoSP diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index c17bddf4d98b85..584093348b4c6a 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -57,6 +57,8 @@ class ThreadProperties : public Properties { bool GetStepOutAvoidsNoDebug() const; uint64_t GetMaxBacktraceDepth() const; + + uint64_t GetSingleThreadPlanTimeout() const; }; class Thread : public
[Lldb-commits] [lldb] [lldb/crashlog] Update incorrect help message for `--no-crashed-only` option (PR #91162)
medismailben wrote: > Since we're already using `argparse`, can we use the `BooleanOptionalAction` > to make this work automatically with the affirmative option? > https://docs.python.org/3.9/library/argparse.html#action I did that originally but I had to comment it out in 446abb5 because some testbot didn't satisfy the minimal python version requirement for `BooleanOptionalAction`. We could revert that commit and see if it breaks any bot. https://github.com/llvm/llvm-project/pull/91162 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
royitaqi wrote: I believe I have addressed all your comments, @bulbazord . I appreciate your comments so far - they all make sense and are great comments to help me improve this PR. Thank you for spending time on this. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 01/11] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList , lldb::SBStringList ); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -318,6 +318,12 @@ class SBCommandInterpreter { SBStructuredData GetStatistics(); + /// Returns a list of handled commands, output and error. Each element in + /// the list is a dictionary with three keys: "command" (string), "output" + /// (list of strings) and optionally "error" (list of strings). Each string + /// in "output" and "error" is a line (without EOL characteres). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 02/11] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap () const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcaster, CommandUsageMap
[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/91128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -85,3 +86,84 @@ def test_command_output(self): self.assertEqual(res.GetOutput(), "") self.assertIsNotNone(res.GetError()) self.assertEqual(res.GetError(), "") + +def test_structured_transcript(self): +"""Test structured transcript generation and retrieval.""" +# Get command interpreter and create a target +self.build() +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +ci = self.dbg.GetCommandInterpreter() +self.assertTrue(ci, VALID_COMMAND_INTERPRETER) + +# Send a few commands through the command interpreter +res = lldb.SBCommandReturnObject() +ci.HandleCommand("version", res) +ci.HandleCommand("an-unknown-command", res) +ci.HandleCommand("breakpoint set -f main.c -l %d" % self.line, res) +ci.HandleCommand("r", res) +ci.HandleCommand("p a", res) +total_number_of_commands = 5 + +# Retrieve the transcript and convert it into a Python object +transcript = ci.GetTranscript() +self.assertTrue(transcript.IsValid()) + +stream = lldb.SBStream() +self.assertTrue(stream) + +error = transcript.GetAsJSON(stream) +self.assertSuccess(error) + +transcript = json.loads(stream.GetData()) + +# The transcript will contain a bunch of commands that are run +# automatically. We only want to validate for the ones that are +# listed above, hence trimming to the last parts. +transcript = transcript[-total_number_of_commands:] royitaqi wrote: Hi @bulbazord , > Or is there a reason there would be more? Perhaps from some setup code? I have verified that that's indeed the case. See the [full transcript](https://pastebin.com/Gxj1Lhid). I believe the commands that are before "version" are coming from [this general setup code](https://github.com/llvm/llvm-project/blob/main/lldb/packages/Python/lldbsuite/test/lldbtest.py#L744-L767) So I think trimming make sense here, in order to isolate this test case from the setup code, which may be changed in the future. Let me add this to the comment so that it's clear to future readers. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/crashlog] Update incorrect help message for `--no-crashed-only` option (PR #91162)
https://github.com/JDevlieghere commented: Since we're already using `argparse`, can we use the `BooleanOptionalAction` to make this work automatically with the affirmative option? https://docs.python.org/3.9/library/argparse.html#action https://github.com/llvm/llvm-project/pull/91162 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Verify target stop-hooks support with scripted process (PR #91107)
@@ -100,6 +111,10 @@ def get_register_context(self) -> str: def __lldb_init_module(debugger, dict): if not "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ: +debugger.HandleCommand( JDevlieghere wrote: This seems like it would be worth documenting in a comment? https://github.com/llvm/llvm-project/pull/91107 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -85,3 +86,84 @@ def test_command_output(self): self.assertEqual(res.GetOutput(), "") self.assertIsNotNone(res.GetError()) self.assertEqual(res.GetError(), "") + +def test_structured_transcript(self): +"""Test structured transcript generation and retrieval.""" +# Get command interpreter and create a target +self.build() +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +ci = self.dbg.GetCommandInterpreter() +self.assertTrue(ci, VALID_COMMAND_INTERPRETER) + +# Send a few commands through the command interpreter +res = lldb.SBCommandReturnObject() +ci.HandleCommand("version", res) +ci.HandleCommand("an-unknown-command", res) +ci.HandleCommand("breakpoint set -f main.c -l %d" % self.line, res) +ci.HandleCommand("r", res) +ci.HandleCommand("p a", res) +total_number_of_commands = 5 + +# Retrieve the transcript and convert it into a Python object +transcript = ci.GetTranscript() +self.assertTrue(transcript.IsValid()) + +stream = lldb.SBStream() +self.assertTrue(stream) + +error = transcript.GetAsJSON(stream) +self.assertSuccess(error) + +transcript = json.loads(stream.GetData()) + +# The transcript will contain a bunch of commands that are run +# automatically. We only want to validate for the ones that are +# listed above, hence trimming to the last parts. +transcript = transcript[-total_number_of_commands:] bulbazord wrote: I think that's fine. Thanks for checking. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Remove unused DWARF value-to-name functions (PR #91010)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/91010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cf6d797 - [lldb][NFCI] Remove unused DWARF value-to-name functions (#91010)
Author: Alex Langford Date: 2024-05-06T10:11:03-07:00 New Revision: cf6d79711d8a423cade5a555db650cb46a74e565 URL: https://github.com/llvm/llvm-project/commit/cf6d79711d8a423cade5a555db650cb46a74e565 DIFF: https://github.com/llvm/llvm-project/commit/cf6d79711d8a423cade5a555db650cb46a74e565.diff LOG: [lldb][NFCI] Remove unused DWARF value-to-name functions (#91010) I was cleaning up this portion of the code and realized these are completely unused. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp index 1f0e10ef27018b..2fb0c224bf8e84 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp @@ -23,26 +23,6 @@ llvm::StringRef DW_TAG_value_to_name(dw_tag_t tag) { return s_unknown_tag_name; } -const char *DW_AT_value_to_name(uint32_t val) { - static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val); - if (llvmstr.empty()) { -snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val); -return invalid; - } - return llvmstr.data(); -} - -const char *DW_FORM_value_to_name(uint32_t val) { - static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val); - if (llvmstr.empty()) { -snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val); -return invalid; - } - return llvmstr.data(); -} - const char *DW_OP_value_to_name(uint32_t val) { static char invalid[100]; llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val); @@ -53,35 +33,5 @@ const char *DW_OP_value_to_name(uint32_t val) { return llvmstr.data(); } -const char *DW_ATE_value_to_name(uint32_t val) { - static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val); - if (llvmstr.empty()) { -snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val); -return invalid; - } - return llvmstr.data(); -} - -const char *DW_LANG_value_to_name(uint32_t val) { - static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val); - if (llvmstr.empty()) { -snprintf(invalid, sizeof(invalid), "Unknown DW_LANG constant: 0x%x", val); -return invalid; - } - return llvmstr.data(); -} - -const char *DW_LNS_value_to_name(uint32_t val) { - static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::LNStandardString(val); - if (llvmstr.empty()) { -snprintf(invalid, sizeof(invalid), "Unknown DW_LNS constant: 0x%x", val); -return invalid; - } - return llvmstr.data(); -} - } // namespace dwarf } // namespace lldb_private::plugin diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h index e87ac458fe962c..be81cb0f5df1ea 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h @@ -15,22 +15,10 @@ namespace lldb_private::plugin { namespace dwarf { -typedef uint32_t DRC_class; // Holds DRC_* class bitfields - llvm::StringRef DW_TAG_value_to_name(dw_tag_t tag); -const char *DW_AT_value_to_name(uint32_t val); - -const char *DW_FORM_value_to_name(uint32_t val); - const char *DW_OP_value_to_name(uint32_t val); -const char *DW_ATE_value_to_name(uint32_t val); - -const char *DW_LANG_value_to_name(uint32_t val); - -const char *DW_LNS_value_to_name(uint32_t val); - } // namespace dwarf } // namespace lldb_private::plugin ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Verify target stop-hooks support with scripted process (PR #91107)
@@ -100,6 +111,10 @@ def get_register_context(self) -> str: def __lldb_init_module(debugger, dict): if not "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ: +debugger.HandleCommand( medismailben wrote: I added this for when loading the file it by hand when debugging, so I don't have to type the command every time I load it in an interactive debug session. As you can see it only takes this path when `SKIP_SCRIPTED_PROCESS_LAUNCH` is set, which is not the case in the test. https://github.com/llvm/llvm-project/pull/91107 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Verify target stop-hooks support with scripted process (PR #91107)
@@ -100,6 +111,10 @@ def get_register_context(self) -> str: def __lldb_init_module(debugger, dict): if not "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ: +debugger.HandleCommand( jimingham wrote: Why do you have to add the stop hook here when the module is initialized and also in the test case? https://github.com/llvm/llvm-project/pull/91107 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [libc] [libclc] [libcxxabi] [lld] [lldb] [llvm] [mlir] Add clarifying parenthesis around non-trivial conditions in ternary expressions. (PR #90391)
@@ -801,7 +801,7 @@ static OutputDesc *addInputSec(StringMap> , auto *firstIsec = cast( cast(sec->commands[0])->sectionBases[0]); OutputSection *firstIsecOut = - firstIsec->flags & SHF_LINK_ORDER luolent wrote: Hi @MaskRay , the PR modifies all the files with non-trivial ternary operators given by Cppcheck ([issue](https://github.com/llvm/llvm-project/issues/85868)). You can find the Cppcheck report inside the comments thread of the issue. https://github.com/llvm/llvm-project/pull/90391 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
ZequanWu wrote: > You could enable logging and check for specific logging after steps. In the > test I described above if you just print the "Foo *foo" variable, it won't > need to complete the definition, you could check for logging, and then if you > print "*foo", then it should complete the definition and you should see > logging. Not sure if that is what you meant Added a test with simple template names. The example you gave doesn't delay definition DIE searching because even when `p foo`, lldb calls `ValueObject::GetNumChildren` which requires complete type, which I think is also a point of unnecessary operation. The `ValueObjectPrinter::PrintChildrenIfNeeded` below ultimately calls `GetNumChildren`: https://github.com/llvm/llvm-project/blob/1241e7692a466ceb420be2780f1c3e8bbab7d469/lldb/source/DataFormatters/ValueObjectPrinter.cpp#L90-L94. I don't see a setting to disable this. If we could avoid this, this patch could further reduce unnecessary definition DIE searching when user just want to print the value of a pointer (declaration DIE should be enough). https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
@@ -1667,13 +1791,40 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext , } if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, die, unique_decl, attrs.byte_size.value_or(-1), -*unique_ast_entry_up)) { +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration, *unique_ast_entry_up)) { type_sp = unique_ast_entry_up->m_type_sp; if (type_sp) { dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), die); +if (!attrs.is_forward_declaration) { + // If the DIE being parsed in this function is a definition and the + // entry in the map is a declaration, then we need to update the entry + // to point to the definition DIE. + if (unique_ast_entry_up->m_is_forward_declaration) { +unique_ast_entry_up->m_die = die; +unique_ast_entry_up->m_byte_size = byte_size; +unique_ast_entry_up->m_declaration = unique_decl; +unique_ast_entry_up->m_is_forward_declaration = false; +// Need to update Type ID to refer to the definition DIE. because +// it's used in ParseSubroutine to determine if we need to copy cxx +// method types from a declaration DIE to this definition DIE. +type_sp->SetID(die.GetID()); +clang_type = type_sp->GetForwardCompilerType(); +if (attrs.class_language != eLanguageTypeObjC && +attrs.class_language != eLanguageTypeObjC_plus_plus) + TypeSystemClang::StartTagDeclarationDefinition(clang_type); + +CompilerType compiler_type_no_qualifiers = +ClangUtil::RemoveFastQualifiers(clang_type); +auto result = dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace( ZequanWu wrote: It doesn't compile, because the value of the map is a DIERef, which doesn't have zero-argument constructor (can only constructed with 1 or 3 arguments). DIERef is a reference to a parsed DIE, so adding a zero-argument constructor for it doesn't quite make sense. https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
https://github.com/ZequanWu updated https://github.com/llvm/llvm-project/pull/90663 >From 4e83099b593e66f12dc21be5fbac5279e03e Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Tue, 30 Apr 2024 16:23:11 -0400 Subject: [PATCH 1/6] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 270 +++--- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 105 ++- .../SymbolFile/DWARF/SymbolFileDWARF.h| 14 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 5 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 2 + .../SymbolFile/DWARF/UniqueDWARFASTType.cpp | 95 +++--- .../SymbolFile/DWARF/UniqueDWARFASTType.h | 21 +- 7 files changed, 296 insertions(+), 216 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index bea11e0e3840af..7ad661c9a9d49b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -252,7 +252,8 @@ static void ForcefullyCompleteType(CompilerType type) { static void PrepareContextToReceiveMembers(TypeSystemClang , ClangASTImporter _importer, clang::DeclContext *decl_ctx, - DWARFDIE die, + const DWARFDIE _ctx_die, + const DWARFDIE , const char *type_name_cstr) { auto *tag_decl_ctx = clang::dyn_cast(decl_ctx); if (!tag_decl_ctx) @@ -279,6 +280,13 @@ static void PrepareContextToReceiveMembers(TypeSystemClang , type_name_cstr ? type_name_cstr : "", die.GetOffset()); } + // By searching for the definition DIE of the decl_ctx type, we will either: + // 1. Found the the definition DIE and start its definition with + // TypeSystemClang::StartTagDeclarationDefinition. + // 2. Unable to find it, then need to forcefully complete it. + die.GetDWARF()->FindDefinitionDIE(decl_ctx_die); + if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined()) +return; // We don't have a type definition and/or the import failed. We must // forcefully complete the type to avoid crashes. ForcefullyCompleteType(type); @@ -620,10 +628,11 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , if (tag == DW_TAG_typedef) { // DeclContext will be populated when the clang type is materialized in // Type::ResolveCompilerType. -PrepareContextToReceiveMembers( -m_ast, GetClangASTImporter(), -GetClangDeclContextContainingDIE(die, nullptr), die, -attrs.name.GetCString()); +DWARFDIE decl_ctx_die; +clang::DeclContext *decl_ctx = +GetClangDeclContextContainingDIE(die, _ctx_die); +PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx, + decl_ctx_die, die, attrs.name.GetCString()); if (attrs.type.IsValid()) { // Try to parse a typedef from the (DWARF embedded in the) Clang @@ -1100,32 +1109,6 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE , // struct and see if this is actually a C++ method Type *class_type = dwarf->ResolveType(decl_ctx_die); if (class_type) { - if (class_type->GetID() != decl_ctx_die.GetID() || - IsClangModuleFwdDecl(decl_ctx_die)) { - -// We uniqued the parent class of this function to another -// class so we now need to associate all dies under -// "decl_ctx_die" to DIEs in the DIE for "class_type"... -DWARFDIE class_type_die = dwarf->GetDIE(class_type->GetID()); - -if (class_type_die) { - std::vector failures; - - CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die, - class_type, failures); - - // FIXME do something with these failures that's - // smarter than just dropping them on the ground. - // Unfortunately classes don't like having stuff added - // to them after their definitions are complete... - - Type *type_ptr = dwarf->GetDIEToType()[die.GetDIE()]; - if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { -return type_ptr->shared_from_this(); - } -} - } - if (attrs.specification.IsValid()) { // We have a specification which we are going to base our // function prototype off of, so we need this type to be @@ -1260,6 +1243,39 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE , } } } + // By here, we should have already completed the c++ class_type + //
[Lldb-commits] [lldb] [lldb-dap] Don't fail when SBProcess::GetMemoryRegionInfo returns error. (PR #87649)
https://github.com/ZequanWu closed https://github.com/llvm/llvm-project/pull/87649 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7b040d0 - [lldb-dap] Don't fail when SBProcess::GetMemoryRegionInfo returns error. (#87649)
Author: Zequan Wu Date: 2024-05-06T09:55:23-04:00 New Revision: 7b040d01c59505d62d4700c75b0438269a0f7bb4 URL: https://github.com/llvm/llvm-project/commit/7b040d01c59505d62d4700c75b0438269a0f7bb4 DIFF: https://github.com/llvm/llvm-project/commit/7b040d01c59505d62d4700c75b0438269a0f7bb4.diff LOG: [lldb-dap] Don't fail when SBProcess::GetMemoryRegionInfo returns error. (#87649) `SBProcess::GetMemoryRegionInfo` uses `qMemoryRegionInfo` packet to get memory region info, but this is not supported in gdb-server and causing downstream lldb test failures. This change ignores the the error from `SBProcess::GetMemoryRegionInfo` . Reported by @tedwoodward @jerinphilip. Added: Modified: lldb/tools/lldb-dap/lldb-dap.cpp Removed: diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 8000d68dea7e36..cf52a22b18cc14 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -2774,32 +2774,28 @@ void request_dataBreakpointInfo(const llvm::json::Object ) { : "evaluation failed"); } else { uint64_t load_addr = value.GetValueAsUnsigned(); - addr = llvm::utohexstr(load_addr); - lldb::SBMemoryRegionInfo region; - lldb::SBError err = - g_dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); - if (err.Success()) { -if (!(region.IsReadable() || region.IsWritable())) { - body.try_emplace("dataId", nullptr); - body.try_emplace("description", - "memory region for address " + addr + - " has no read or write permissions"); -} else { - lldb::SBData data = value.GetPointeeData(); - if (data.IsValid()) -size = llvm::utostr(data.GetByteSize()); - else { + lldb::SBData data = value.GetPointeeData(); + if (data.IsValid()) { +size = llvm::utostr(data.GetByteSize()); +addr = llvm::utohexstr(load_addr); +lldb::SBMemoryRegionInfo region; +lldb::SBError err = +g_dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); +// Only lldb-server supports "qMemoryRegionInfo". So, don't fail this +// request if SBProcess::GetMemoryRegionInfo returns error. +if (err.Success()) { + if (!(region.IsReadable() || region.IsWritable())) { body.try_emplace("dataId", nullptr); body.try_emplace("description", - "unable to get byte size for expression: " + - name.str()); + "memory region for address " + addr + + " has no read or write permissions"); } } } else { body.try_emplace("dataId", nullptr); body.try_emplace("description", - "unable to get memory region info for address " + - addr); + "unable to get byte size for expression: " + + name.str()); } } } else { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs (PR #91189)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/91189 >From 7de5cfcc3016a9e49e289e1009bcf4cc68aa445e Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 6 May 2024 11:30:59 + Subject: [PATCH] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs The implementation is straight-forward, but comes with a big disclaimer. See #91186 for details. --- .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 ++ lldb/test/API/python_api/type/TestTypeList.py| 16 lldb/test/API/python_api/type/main.cpp | 5 + 3 files changed, 23 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a771016039e851..d0033fcd9cdfcf 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -7106,6 +7106,8 @@ TypeSystemClang::GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, for (NamedDecl *decl : record_decl->lookup(decl_name)) { if (auto *tag_decl = dyn_cast(decl)) return GetType(getASTContext().getTagDeclType(tag_decl)); + if (auto *typedef_decl = dyn_cast(decl)) +return GetType(getASTContext().getTypedefType(typedef_decl)); } break; } diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 0498396903dcbd..b028929eea4423 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -273,6 +273,22 @@ def test(self): self.DebugSBType(int_enum_uchar) self.assertEqual(int_enum_uchar.GetName(), "unsigned char") +def test_nested_typedef(self): +"""Exercise FindDirectNestedType for typedefs.""" +self.build() +target = self.dbg.CreateTarget(self.getBuildArtifact()) +self.assertTrue(target) + +with_nested_typedef = target.FindFirstType("WithNestedTypedef") +self.assertTrue(with_nested_typedef) + +# This is necessary to work around #91186 + self.assertTrue(target.FindFirstGlobalVariable("typedefed_value").GetType()) + +the_typedef = with_nested_typedef.FindDirectNestedType("TheTypedef") +self.assertTrue(the_typedef) +self.assertEqual(the_typedef.GetTypedefedType().GetName(), "int") + def test_GetByteAlign(self): """Exercise SBType::GetByteAlign""" self.build() diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 986ed3009a15f6..6acde5bb666a6e 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -53,6 +53,11 @@ enum class EnumUChar : unsigned char {}; struct alignas(128) OverAlignedStruct {}; OverAlignedStruct over_aligned_struct; +struct WithNestedTypedef { + typedef int TheTypedef; +}; +WithNestedTypedef::TheTypedef typedefed_value; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs (PR #91189)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes The implementation is straight-forward, but comes with a big disclaimer. See #91186 for details. --- Full diff: https://github.com/llvm/llvm-project/pull/91189.diff 3 Files Affected: - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2) - (modified) lldb/test/API/python_api/type/TestTypeList.py (+17) - (modified) lldb/test/API/python_api/type/main.cpp (+5) ``diff diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a771016039e851..d0033fcd9cdfcf 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -7106,6 +7106,8 @@ TypeSystemClang::GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, for (NamedDecl *decl : record_decl->lookup(decl_name)) { if (auto *tag_decl = dyn_cast(decl)) return GetType(getASTContext().getTagDeclType(tag_decl)); + if (auto *typedef_decl = dyn_cast(decl)) +return GetType(getASTContext().getTypedefType(typedef_decl)); } break; } diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 0498396903dcbd..7a1879ef8b030a 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -273,6 +273,23 @@ def test(self): self.DebugSBType(int_enum_uchar) self.assertEqual(int_enum_uchar.GetName(), "unsigned char") +def test_nested_typedef(self): +"""Exercise FindDirectNestedType for typedefs.""" +self.build() +target = self.dbg.CreateTarget(self.getBuildArtifact()) +self.assertTrue(target) + +with_nested_typedef = target.FindFirstType("WithNestedTypedef") +self.assertTrue(with_nested_typedef) + +# This is necessary to work around #91186 + self.assertTrue(target.FindFirstGlobalVariable("typedefed_value").GetType()) + +the_typedef = with_nested_typedef.FindDirectNestedType("TheTypedef") +self.assertTrue(the_typedef) +self.assertEqual(the_typedef.GetTypedefedType().GetName(), "int") + + def test_GetByteAlign(self): """Exercise SBType::GetByteAlign""" self.build() diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 986ed3009a15f6..6acde5bb666a6e 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -53,6 +53,11 @@ enum class EnumUChar : unsigned char {}; struct alignas(128) OverAlignedStruct {}; OverAlignedStruct over_aligned_struct; +struct WithNestedTypedef { + typedef int TheTypedef; +}; +WithNestedTypedef::TheTypedef typedefed_value; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); `` https://github.com/llvm/llvm-project/pull/91189 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs (PR #91189)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/91189 The implementation is straight-forward, but comes with a big disclaimer. See #91186 for details. >From 62f1917a75b4db82470cf5b2721097e6757d5dfb Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 6 May 2024 11:30:59 + Subject: [PATCH] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs The implementation is straight-forward, but comes with a big disclaimer. See #91186 for details. --- .../TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ lldb/test/API/python_api/type/TestTypeList.py | 17 + lldb/test/API/python_api/type/main.cpp | 5 + 3 files changed, 24 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a771016039e851..d0033fcd9cdfcf 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -7106,6 +7106,8 @@ TypeSystemClang::GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, for (NamedDecl *decl : record_decl->lookup(decl_name)) { if (auto *tag_decl = dyn_cast(decl)) return GetType(getASTContext().getTagDeclType(tag_decl)); + if (auto *typedef_decl = dyn_cast(decl)) +return GetType(getASTContext().getTypedefType(typedef_decl)); } break; } diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 0498396903dcbd..7a1879ef8b030a 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -273,6 +273,23 @@ def test(self): self.DebugSBType(int_enum_uchar) self.assertEqual(int_enum_uchar.GetName(), "unsigned char") +def test_nested_typedef(self): +"""Exercise FindDirectNestedType for typedefs.""" +self.build() +target = self.dbg.CreateTarget(self.getBuildArtifact()) +self.assertTrue(target) + +with_nested_typedef = target.FindFirstType("WithNestedTypedef") +self.assertTrue(with_nested_typedef) + +# This is necessary to work around #91186 + self.assertTrue(target.FindFirstGlobalVariable("typedefed_value").GetType()) + +the_typedef = with_nested_typedef.FindDirectNestedType("TheTypedef") +self.assertTrue(the_typedef) +self.assertEqual(the_typedef.GetTypedefedType().GetName(), "int") + + def test_GetByteAlign(self): """Exercise SBType::GetByteAlign""" self.build() diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 986ed3009a15f6..6acde5bb666a6e 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -53,6 +53,11 @@ enum class EnumUChar : unsigned char {}; struct alignas(128) OverAlignedStruct {}; OverAlignedStruct over_aligned_struct; +struct WithNestedTypedef { + typedef int TheTypedef; +}; +WithNestedTypedef::TheTypedef typedefed_value; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Handle UnresolvedTemplate type in TypeSystemClang.cpp after 7a484d3 (PR #91132)
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/91132 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Handle UnresolvedTemplate type in TypeSystemClang.cpp after 7a484d3 (PR #91132)
zyn0217 wrote: This had been fixed by 41574f5a6. Thanks @dwblaikie! https://github.com/llvm/llvm-project/pull/91132 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( labath wrote: I believe this should be using `add_custom_command`. Per the [cmake docs](https://cmake.org/cmake/help/latest/command/add_custom_target.html), `add_custom_target` "... has no output file and is always considered out of date even if the commands try to create a file with the name of the target". This causes an incremental clean build to always run this command and also rebuild anything that depends on it. https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 updated https://github.com/llvm/llvm-project/pull/91170 >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/6] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/6] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same folder as the lldb. +lldb_dir = os.path.dirname(lldbtest_config.lldbExec) +path = shutil.which(server_tool, path=lldb_dir) +if path is not None: +return path + +return "" + def yaml2obj(self, yaml_path, obj_path, max_size=None): """ Create an object file at the given path from a yaml file. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..96d312565f953e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -568,6 +568,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +port=None, +hostname=None ): args_dict = {} if pid is not None: @@ -597,6 +599,10 @@ def request_attach( args_dict["postRunCommands"] =
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [lldb] [llvm] [mlir] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)
@@ -1,3 +1,10 @@ +# Checkout as native, commit as LF except in specific circumstances +* text=auto +*.bat text eol=crlf +*.rc text eol=crlf +*.sln text eol=crlf ldrumm wrote: I think it makes sense to put the well-known-extension attributes in the root. I don't envision a `.sln` file ever *not* having crlf endings, so I considered it a global convenience https://github.com/llvm/llvm-project/pull/86318 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 updated https://github.com/llvm/llvm-project/pull/91170 >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/5] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/5] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same folder as the lldb. +lldb_dir = os.path.dirname(lldbtest_config.lldbExec) +path = shutil.which(server_tool, path=lldb_dir) +if path is not None: +return path + +return "" + def yaml2obj(self, yaml_path, obj_path, max_size=None): """ Create an object file at the given path from a yaml file. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..96d312565f953e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -568,6 +568,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +port=None, +hostname=None ): args_dict = {} if pid is not None: @@ -597,6 +599,10 @@ def request_attach( args_dict["postRunCommands"] =
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 updated https://github.com/llvm/llvm-project/pull/91170 >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/4] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/4] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same folder as the lldb. +lldb_dir = os.path.dirname(lldbtest_config.lldbExec) +path = shutil.which(server_tool, path=lldb_dir) +if path is not None: +return path + +return "" + def yaml2obj(self, yaml_path, obj_path, max_size=None): """ Create an object file at the given path from a yaml file. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..96d312565f953e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -568,6 +568,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +port=None, +hostname=None ): args_dict = {} if pid is not None: @@ -597,6 +599,10 @@ def request_attach( args_dict["postRunCommands"] =
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 updated https://github.com/llvm/llvm-project/pull/91170 >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/4] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/4] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same folder as the lldb. +lldb_dir = os.path.dirname(lldbtest_config.lldbExec) +path = shutil.which(server_tool, path=lldb_dir) +if path is not None: +return path + +return "" + def yaml2obj(self, yaml_path, obj_path, max_size=None): """ Create an object file at the given path from a yaml file. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..96d312565f953e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -568,6 +568,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +port=None, +hostname=None ): args_dict = {} if pid is not None: @@ -597,6 +599,10 @@ def request_attach( args_dict["postRunCommands"] =
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 updated https://github.com/llvm/llvm-project/pull/91170 >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/3] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/3] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same folder as the lldb. +lldb_dir = os.path.dirname(lldbtest_config.lldbExec) +path = shutil.which(server_tool, path=lldb_dir) +if path is not None: +return path + +return "" + def yaml2obj(self, yaml_path, obj_path, max_size=None): """ Create an object file at the given path from a yaml file. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..96d312565f953e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -568,6 +568,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +port=None, +hostname=None ): args_dict = {} if pid is not None: @@ -597,6 +599,10 @@ def request_attach( args_dict["postRunCommands"] =
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r e2c89254e12e844214d02f1d12bf29ba2ca322c7...efffdf33f5f290c318ce4dd15250be5adcbed252 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py `` View the diff from darker here. ``diff --- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-06 07:12:22.00 + +++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-06 08:07:23.404889 + @@ -571,11 +571,11 @@ terminateCommands=None, coreFile=None, postRunCommands=None, sourceMap=None, port=None, -hostname=None +hostname=None, ): args_dict = {} if pid is not None: args_dict["pid"] = pid if program is not None: @@ -602,13 +602,13 @@ if postRunCommands: args_dict["postRunCommands"] = postRunCommands if sourceMap: args_dict["sourceMap"] = sourceMap if port is not None: -args_dict['port'] = port +args_dict["port"] = port if hostname is not None: -args_dict['hostname'] = hostname +args_dict["hostname"] = hostname command_dict = {"command": "attach", "type": "request", "arguments": args_dict} return self.send_recv(command_dict) def request_configurationDone(self): command_dict = { --- packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 2024-05-03 09:47:05.00 + +++ packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 2024-05-06 08:07:23.562818 + @@ -333,14 +333,24 @@ if not (response and response["success"]): self.assertTrue( response["success"], "attach failed (%s)" % (response["message"]) ) -def attach_by_port(self, program=None, pid=None, disconnectAutomatically=True, waitFor=None, sourceInitFile=False, port=None, hostname=None): -'''Build the default Makefile target, create the VSCode debug adaptor, - and attach to the process. -''' +def attach_by_port( +self, +program=None, +pid=None, +disconnectAutomatically=True, +waitFor=None, +sourceInitFile=False, +port=None, +hostname=None, +): +"""Build the default Makefile target, create the VSCode debug adaptor, +and attach to the process. +""" + # This overloaded function helps to request attach by port number # Make sure we disconnect and terminate the VSCode debug adaptor even # if we throw an exception during the test case. def cleanup(): if disconnectAutomatically: @@ -350,11 +360,12 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # Initialize and launch the program self.dap_server.request_initialize(sourceInitFile) response = self.dap_server.request_attach( -program=program, pid=pid, waitFor=waitFor, port=port, hostname=hostname) +program=program, pid=pid, waitFor=waitFor, port=port, hostname=hostname +) return response def launch( self, program=None, --- test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py 2024-05-03 09:47:05.00 + +++ test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py 2024-05-06 08:07:23.612153 + @@ -15,106 +15,127 @@ import threading import time import sys import re + class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase): - def runTargetProgramOnPort(self, port=None, program=None): # sim_tool="hexagon-sim" # if isIUTarget(): # sim_tool="iu-sim" -target_sim_path=self.getBuiltServerTool("lldb-server") +target_sim_path = self.getBuiltServerTool("lldb-server") if target_sim_path: -target_sim_path +=' g localhost:' + port + ' ' +target_sim_path += " g localhost:" + port + " " -self.process = subprocess.Popen([target_sim_path + program], shell=True, -stdin=subprocess.PIPE, -stdout=subprocess.PIPE, -stderr=subprocess.PIPE) - +self.process = subprocess.Popen( +[target_sim_path + program], +shell=True, +stdin=subprocess.PIPE, +stdout=subprocess.PIPE, +stderr=subprocess.PIPE, +) + return self.process def
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff e2c89254e12e844214d02f1d12bf29ba2ca322c7 efffdf33f5f290c318ce4dd15250be5adcbed252 -- lldb/include/lldb/lldb-defines.h lldb/tools/lldb-dap/lldb-dap.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 2280e7217e..3d52c2e26b 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -751,7 +751,8 @@ void request_attach(const llvm::json::Object ) { return; } - if ((pid == LLDB_INVALID_PROCESS_ID || port == LLDB_INVALID_PORT_NUMBER) && wait_for) { + if ((pid == LLDB_INVALID_PROCESS_ID || port == LLDB_INVALID_PORT_NUMBER) && + wait_for) { char attach_msg[256]; auto attach_msg_len = snprintf(attach_msg, sizeof(attach_msg), "Waiting to attach to \"%s\"...", `` https://github.com/llvm/llvm-project/pull/91170 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBType::GetByteAlign (PR #90960)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/90960 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 30367cb - [lldb] Add SBType::GetByteAlign (#90960)
Author: Pavel Labath Date: 2024-05-06T10:06:51+02:00 New Revision: 30367cb5982dfdab2655401f020711311e7d78b9 URL: https://github.com/llvm/llvm-project/commit/30367cb5982dfdab2655401f020711311e7d78b9 DIFF: https://github.com/llvm/llvm-project/commit/30367cb5982dfdab2655401f020711311e7d78b9.diff LOG: [lldb] Add SBType::GetByteAlign (#90960) lldb already mostly(*) tracks this information. This just makes it available to the SB users. (*) It does not do that for typedefs right now see llvm.org/pr90958 Added: Modified: lldb/include/lldb/API/SBType.h lldb/source/API/SBType.cpp lldb/test/API/python_api/type/TestTypeList.py lldb/test/API/python_api/type/main.cpp Removed: diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 5b9ff2170b2b24..63ba91082d5769 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -150,6 +150,8 @@ class SBType { uint64_t GetByteSize(); + uint64_t GetByteAlign(); + bool IsPointerType(); bool IsReferenceType(); diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 6cecb5c9ea810b..8a063e5ad61d9d 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -25,6 +25,7 @@ #include "lldb/Utility/Stream.h" #include "llvm/ADT/APSInt.h" +#include "llvm/Support/MathExtras.h" #include #include @@ -132,6 +133,18 @@ uint64_t SBType::GetByteSize() { return 0; } +uint64_t SBType::GetByteAlign() { + LLDB_INSTRUMENT_VA(this); + + if (!IsValid()) +return 0; + + std::optional bit_align = + m_opaque_sp->GetCompilerType(/*prefer_dynamic=*/false) + .GetTypeBitAlign(nullptr); + return llvm::divideCeil(bit_align.value_or(0), 8); +} + bool SBType::IsPointerType() { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 17e27b624511cf..0498396903dcbd 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -272,3 +272,24 @@ def test(self): self.assertTrue(int_enum_uchar) self.DebugSBType(int_enum_uchar) self.assertEqual(int_enum_uchar.GetName(), "unsigned char") + +def test_GetByteAlign(self): +"""Exercise SBType::GetByteAlign""" +self.build() +spec = lldb.SBModuleSpec() +spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact())) +module = lldb.SBModule(spec) +self.assertTrue(module) + +# Invalid types should not crash. +self.assertEqual(lldb.SBType().GetByteAlign(), 0) + +# Try a type with natural alignment. +void_ptr = module.GetBasicType(lldb.eBasicTypeVoid).GetPointerType() +self.assertTrue(void_ptr) +# Not exactly guaranteed by the spec, but should be true everywhere we +# care about. +self.assertEqual(void_ptr.GetByteSize(), void_ptr.GetByteAlign()) + +# And an over-aligned type. + self.assertEqual(module.FindFirstType("OverAlignedStruct").GetByteAlign(), 128) diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 7384a3d8da16fb..986ed3009a15f6 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -50,6 +50,9 @@ enum EnumType {}; enum class ScopedEnumType {}; enum class EnumUChar : unsigned char {}; +struct alignas(128) OverAlignedStruct {}; +OverAlignedStruct over_aligned_struct; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
https://github.com/santhoshe447 created https://github.com/llvm/llvm-project/pull/91170 Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuration to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } >From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 17 Nov 2023 15:09:10 +0530 Subject: [PATCH 1/2] [lldb][test] Add the ability to extract the variable value out of the summary. --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 9d79872b029a33..0cf9d4fde49488 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -195,6 +195,9 @@ def collect_console(self, duration): def get_local_as_int(self, name, threadId=None): value = self.dap_server.get_local_variable_value(name, threadId=threadId) +# 'value' may have the variable value and summary. +# Extract the variable value since summary can have nonnumeric characters. +value = value.split(" ")[0] if value.startswith("0x"): return int(value, 16) elif value.startswith("0"): >From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Ellendula Date: Fri, 3 May 2024 02:47:05 -0700 Subject: [PATCH 2/2] [lldb-dap] Added "port" property to vscode "attach" command. Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --- lldb/include/lldb/lldb-defines.h | 1 + .../Python/lldbsuite/test/lldbtest.py | 9 ++ .../test/tools/lldb-dap/dap_server.py | 6 + .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +++ .../attach/TestDAP_attachByPortNum.py | 120 ++ lldb/tools/lldb-dap/lldb-dap.cpp | 36 +- lldb/tools/lldb-dap/package.json | 11 ++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index c7bd019c5c90eb..a1e6ee2ce468cb 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -96,6 +96,7 @@ #define LLDB_INVALID_QUEUE_ID 0 #define LLDB_INVALID_CPU_ID UINT32_MAX #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX +#define LLDB_INVALID_PORT_NUMBER 0 /// CPU Type definitions #define LLDB_ARCH_DEFAULT "systemArch" diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 5fd686c143e9f9..fb3cd22959df25 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1572,6 +1572,15 @@ def findBuiltClang(self): return os.environ["CC"] +def getBuiltServerTool(self, server_tool): +# Tries to find simulation/lldb-server/gdbserver tool at the same
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
@@ -1667,13 +1791,40 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext , } if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, die, unique_decl, attrs.byte_size.value_or(-1), -*unique_ast_entry_up)) { +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration, *unique_ast_entry_up)) { type_sp = unique_ast_entry_up->m_type_sp; if (type_sp) { dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), die); +if (!attrs.is_forward_declaration) { + // If the DIE being parsed in this function is a definition and the + // entry in the map is a declaration, then we need to update the entry + // to point to the definition DIE. + if (unique_ast_entry_up->m_is_forward_declaration) { +unique_ast_entry_up->m_die = die; +unique_ast_entry_up->m_byte_size = byte_size; +unique_ast_entry_up->m_declaration = unique_decl; +unique_ast_entry_up->m_is_forward_declaration = false; +// Need to update Type ID to refer to the definition DIE. because +// it's used in ParseSubroutine to determine if we need to copy cxx +// method types from a declaration DIE to this definition DIE. +type_sp->SetID(die.GetID()); +clang_type = type_sp->GetForwardCompilerType(); +if (attrs.class_language != eLanguageTypeObjC && +attrs.class_language != eLanguageTypeObjC_plus_plus) + TypeSystemClang::StartTagDeclarationDefinition(clang_type); + +CompilerType compiler_type_no_qualifiers = +ClangUtil::RemoveFastQualifiers(clang_type); +auto result = dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace( labath wrote: The if below is just implementing overwrite semantics, but maps already have APIs for that. How about `dwarf->GetForwardDeclCompilerTypeToDIE()[compiler_type_no_qualifiers.GetOpaqueQualType()] = *die.GetDIERef()` ? https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
@@ -154,6 +154,27 @@ static bool TagIsRecordType(dw_tag_t tag) { } } +static bool +IsForwardDeclaration(const lldb_private::plugin::dwarf::DWARFDIE , labath wrote: This shouldn't be necessary here, as this file has `using namespace lldb_private::plugin::dwarf` at the top. https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/90783 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits