[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
kastiglione wrote: Open to alternative rewordings that include "backtrace". https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/92618 None >From 1564ae4ce3a56fc1f11e03e82e0da1e01f25f3ed Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 16 May 2024 14:01:22 -0700 Subject: [PATCH] [lldb] Add the word "backtrace" to bt help string --- lldb/source/Commands/CommandObjectThread.cpp | 4 ++-- lldb/source/Interpreter/CommandInterpreter.cpp | 10 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 4397ee14ea074..db96ee2cec383 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -114,8 +114,8 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { CommandObjectThreadBacktrace(CommandInterpreter ) : CommandObjectIterateOverThreads( interpreter, "thread backtrace", -"Show thread call stacks. Defaults to the current thread, thread " -"indexes can be specified as arguments.\n" +"Show backtraces of thread call stacks. Defaults to the current " +"thread, thread indexes can be specified as arguments.\n" "Use the thread-index \"all\" to see all threads.\n" "Use the thread-index \"unique\" to see threads grouped by unique " "call stacks.\n" diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 4c58ecc3c1848..3e470a6989bbf 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -816,11 +816,11 @@ void CommandInterpreter::LoadCommandDictionary() { std::unique_ptr bt_regex_cmd_up( new CommandObjectRegexCommand( *this, "_regexp-bt", - "Show the current thread's call stack. Any numeric argument " - "displays at most that many " - "frames. The argument 'all' displays all threads. Use 'settings" - " set frame-format' to customize the printing of individual frames " - "and 'settings set thread-format' to customize the thread header.", + "Show backtrace of the current thread's call stack. Any numeric " + "argument displays at most that many frames. The argument 'all' " + "displays all threads. Use 'settings set frame-format' to customize " + "the printing of individual frames and 'settings set thread-format' " + "to customize the thread header.", "bt [ | all]", 0, false)); if (bt_regex_cmd_up) { // accept but don't document "bt -c " -- before bt was a regex ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/91868 >From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 30 Apr 2024 10:45:10 -0700 Subject: [PATCH 1/4] [lldb] Support custom LLVM formatting for variables (#81196) Adds support for applying LLVM formatting to variables. The reason for this is to support cases such as the following. Let's say you have two separate bytes that you want to print as a combined hex value. Consider the following summary string: ``` ${var.byte1%x}${var.byte2%x} ``` The output of this will be: `0x120x34`. That is, a `0x` prefix is unconditionally applied to each byte. This is unlike printf formatting where you must include the `0x` yourself. Currently, there's no way to do this with summary strings, instead you'll need a summary provider in python or c++. This change introduces formatting support using LLVM's formatter system. This allows users to achieve the desired custom formatting using: ``` ${var.byte1:x-}${var.byte2:x-} ``` Here, each variable is suffixed with `:x-`. This is passed to the LLVM formatter as `{0:x-}`. For integer values, `x` declares the output as hex, and `-` declares that no `0x` prefix is to be used. Further, one could write: ``` ${var.byte1:x-2}${var.byte2:x-2} ``` Where the added `2` results in these bytes being written with a minimum of 2 digits. An alternative considered was to add a new format specifier that would print hex values without the `0x` prefix. The reason that approach was not taken is because in addition to forcing a `0x` prefix, hex values are also forced to use leading zeros. This approach lets the user have full control over formatting. --- lldb/docs/use/variable.rst| 9 +++ lldb/source/Core/FormatEntity.cpp | 70 --- .../custom-printf-summary/Makefile| 2 + .../TestCustomSummaryLLVMFormat.py| 20 ++ .../custom-printf-summary/main.c | 13 5 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index 8eaed6405315b..e9175b25336ba 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -460,6 +460,15 @@ summary strings, regardless of the format they have applied to their types. To do that, you can use %format inside an expression path, as in ${var.x->x%u}, which would display the value of x as an unsigned integer. +Additionally, custom output can be achieved by using an LLVM format string, +commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and +``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``), +which unconditionally inserts a ``0x`` prefix, and also zero pads the value to +match the size of the type. The latter uses ``llvm::formatv`` formatting +(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no +padding. This raw control is useful when composing multiple pieces into a +larger whole. + You can also use some other special format markers, not available for formats themselves, but which carry a special meaning when used in this context: diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index ba62e26252591..da5b1cfce74ac 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -57,6 +57,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Regex.h" #include "llvm/TargetParser/Triple.h" #include @@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", llvm::Regex::IgnoreCase}; + +static bool DumpValueWithLLVMFormat(Stream , llvm::StringRef options, +ValueObject ) { + std::string formatted; + std::string llvm_format = ("{0:" + options + "}").str(); + + // Options supported by format_provider for integral arithmetic types. + // See table in FormatProviders.h. + + auto type_info = valobj.GetTypeInfo(); + if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) { +if (type_info & eTypeIsSigned) { + bool success = false; + int64_t integer = valobj.GetValueAsSigned(0, ); + if (success) +formatted = llvm::formatv(llvm_format.data(), integer); +} else { + bool success = false; + uint64_t integer = valobj.GetValueAsUnsigned(0, ); + if (success) +formatted = llvm::formatv(llvm_format.data(), integer); +} + } + + if (formatted.empty()) +return false;
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/91868 >From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 30 Apr 2024 10:45:10 -0700 Subject: [PATCH 1/3] [lldb] Support custom LLVM formatting for variables (#81196) Adds support for applying LLVM formatting to variables. The reason for this is to support cases such as the following. Let's say you have two separate bytes that you want to print as a combined hex value. Consider the following summary string: ``` ${var.byte1%x}${var.byte2%x} ``` The output of this will be: `0x120x34`. That is, a `0x` prefix is unconditionally applied to each byte. This is unlike printf formatting where you must include the `0x` yourself. Currently, there's no way to do this with summary strings, instead you'll need a summary provider in python or c++. This change introduces formatting support using LLVM's formatter system. This allows users to achieve the desired custom formatting using: ``` ${var.byte1:x-}${var.byte2:x-} ``` Here, each variable is suffixed with `:x-`. This is passed to the LLVM formatter as `{0:x-}`. For integer values, `x` declares the output as hex, and `-` declares that no `0x` prefix is to be used. Further, one could write: ``` ${var.byte1:x-2}${var.byte2:x-2} ``` Where the added `2` results in these bytes being written with a minimum of 2 digits. An alternative considered was to add a new format specifier that would print hex values without the `0x` prefix. The reason that approach was not taken is because in addition to forcing a `0x` prefix, hex values are also forced to use leading zeros. This approach lets the user have full control over formatting. --- lldb/docs/use/variable.rst| 9 +++ lldb/source/Core/FormatEntity.cpp | 70 --- .../custom-printf-summary/Makefile| 2 + .../TestCustomSummaryLLVMFormat.py| 20 ++ .../custom-printf-summary/main.c | 13 5 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index 8eaed6405315b..e9175b25336ba 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -460,6 +460,15 @@ summary strings, regardless of the format they have applied to their types. To do that, you can use %format inside an expression path, as in ${var.x->x%u}, which would display the value of x as an unsigned integer. +Additionally, custom output can be achieved by using an LLVM format string, +commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and +``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``), +which unconditionally inserts a ``0x`` prefix, and also zero pads the value to +match the size of the type. The latter uses ``llvm::formatv`` formatting +(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no +padding. This raw control is useful when composing multiple pieces into a +larger whole. + You can also use some other special format markers, not available for formats themselves, but which carry a special meaning when used in this context: diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index ba62e26252591..da5b1cfce74ac 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -57,6 +57,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Regex.h" #include "llvm/TargetParser/Triple.h" #include @@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", llvm::Regex::IgnoreCase}; + +static bool DumpValueWithLLVMFormat(Stream , llvm::StringRef options, +ValueObject ) { + std::string formatted; + std::string llvm_format = ("{0:" + options + "}").str(); + + // Options supported by format_provider for integral arithmetic types. + // See table in FormatProviders.h. + + auto type_info = valobj.GetTypeInfo(); + if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) { +if (type_info & eTypeIsSigned) { + bool success = false; + int64_t integer = valobj.GetValueAsSigned(0, ); + if (success) +formatted = llvm::formatv(llvm_format.data(), integer); +} else { + bool success = false; + uint64_t integer = valobj.GetValueAsUnsigned(0, ); + if (success) +formatted = llvm::formatv(llvm_format.data(), integer); +} + } + + if (formatted.empty()) +return false;
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
kastiglione wrote: @adrian-prantl updated the description: > Re-apply https://github.com/llvm/llvm-project/pull/81196, with a fix that > handles the absence of llvm formatting: > https://github.com/llvm/llvm-project/commit/3ba650e91eded3543764f37921dcce3bb47d425f https://github.com/llvm/llvm-project/pull/91868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/91868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/91868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/91868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/91868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb Support custom LLVM formatting for variables (PR #91868)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/91868 - **[lldb] Support custom LLVM formatting for variables (#81196)** - **[lldb] Handle non-existent llvm_format** >From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 30 Apr 2024 10:45:10 -0700 Subject: [PATCH 1/2] [lldb] Support custom LLVM formatting for variables (#81196) Adds support for applying LLVM formatting to variables. The reason for this is to support cases such as the following. Let's say you have two separate bytes that you want to print as a combined hex value. Consider the following summary string: ``` ${var.byte1%x}${var.byte2%x} ``` The output of this will be: `0x120x34`. That is, a `0x` prefix is unconditionally applied to each byte. This is unlike printf formatting where you must include the `0x` yourself. Currently, there's no way to do this with summary strings, instead you'll need a summary provider in python or c++. This change introduces formatting support using LLVM's formatter system. This allows users to achieve the desired custom formatting using: ``` ${var.byte1:x-}${var.byte2:x-} ``` Here, each variable is suffixed with `:x-`. This is passed to the LLVM formatter as `{0:x-}`. For integer values, `x` declares the output as hex, and `-` declares that no `0x` prefix is to be used. Further, one could write: ``` ${var.byte1:x-2}${var.byte2:x-2} ``` Where the added `2` results in these bytes being written with a minimum of 2 digits. An alternative considered was to add a new format specifier that would print hex values without the `0x` prefix. The reason that approach was not taken is because in addition to forcing a `0x` prefix, hex values are also forced to use leading zeros. This approach lets the user have full control over formatting. --- lldb/docs/use/variable.rst| 9 +++ lldb/source/Core/FormatEntity.cpp | 70 --- .../custom-printf-summary/Makefile| 2 + .../TestCustomSummaryLLVMFormat.py| 20 ++ .../custom-printf-summary/main.c | 13 5 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index 8eaed6405315b..e9175b25336ba 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -460,6 +460,15 @@ summary strings, regardless of the format they have applied to their types. To do that, you can use %format inside an expression path, as in ${var.x->x%u}, which would display the value of x as an unsigned integer. +Additionally, custom output can be achieved by using an LLVM format string, +commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and +``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``), +which unconditionally inserts a ``0x`` prefix, and also zero pads the value to +match the size of the type. The latter uses ``llvm::formatv`` formatting +(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no +padding. This raw control is useful when composing multiple pieces into a +larger whole. + You can also use some other special format markers, not available for formats themselves, but which carry a special meaning when used in this context: diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index ba62e26252591..da5b1cfce74ac 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -57,6 +57,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Regex.h" #include "llvm/TargetParser/Triple.h" #include @@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", llvm::Regex::IgnoreCase}; + +static bool DumpValueWithLLVMFormat(Stream , llvm::StringRef options, +ValueObject ) { + std::string formatted; + std::string llvm_format = ("{0:" + options + "}").str(); + + // Options supported by format_provider for integral arithmetic types. + // See table in FormatProviders.h. + + auto type_info = valobj.GetTypeInfo(); + if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) { +if (type_info & eTypeIsSigned) { + bool success = false; + int64_t integer = valobj.GetValueAsSigned(0, ); + if (success) +formatted = llvm::formatv(llvm_format.data(), integer); +} else { + bool success = false; + uint64_t integer = valobj.GetValueAsUnsigned(0, ); + if (success) +
[Lldb-commits] [lldb] baffaf0 - [lldb] Add required skipIfLLVMTargetMissing for X86 (NFC)
Author: Dave Lee Date: 2024-05-11T11:48:31-07:00 New Revision: baffaf000fd4667f33b3756d0d3b645b1d926b44 URL: https://github.com/llvm/llvm-project/commit/baffaf000fd4667f33b3756d0d3b645b1d926b44 DIFF: https://github.com/llvm/llvm-project/commit/baffaf000fd4667f33b3756d0d3b645b1d926b44.diff LOG: [lldb] Add required skipIfLLVMTargetMissing for X86 (NFC) Added: Modified: lldb/test/API/macosx/rosetta/TestRosetta.py lldb/test/API/macosx/universal64/TestUniversal64.py Removed: diff --git a/lldb/test/API/macosx/rosetta/TestRosetta.py b/lldb/test/API/macosx/rosetta/TestRosetta.py index ce40de475ef16..a812f558a8fc9 100644 --- a/lldb/test/API/macosx/rosetta/TestRosetta.py +++ b/lldb/test/API/macosx/rosetta/TestRosetta.py @@ -40,6 +40,7 @@ class TestRosetta(TestBase): NO_DEBUG_INFO_TESTCASE = True @skipUnlessAppleSilicon +@skipIfLLVMTargetMissing("X86") @skipIfDarwinEmbedded def test_rosetta(self): """There can be many tests in a test case - describe this test here.""" diff --git a/lldb/test/API/macosx/universal64/TestUniversal64.py b/lldb/test/API/macosx/universal64/TestUniversal64.py index 98661443086ef..893ff14d81138 100644 --- a/lldb/test/API/macosx/universal64/TestUniversal64.py +++ b/lldb/test/API/macosx/universal64/TestUniversal64.py @@ -17,6 +17,7 @@ def do_test(self): # actually launch them here. # The Makefile manually invokes clang. +@skipIfLLVMTargetMissing("X86") @skipIfAsan @skipUnlessDarwin @skipIfDarwinEmbedded @@ -26,6 +27,7 @@ def test_universal64_executable(self): self.do_test() # The Makefile manually invokes clang. +@skipIfLLVMTargetMissing("X86") @skipIfAsan @skipUnlessDarwin @skipIfDarwinEmbedded ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Consult Language plugin in GetDisplayDemangledName (PR #90294)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/90294 ___ 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)
@@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^"]+), "(?P.*)",.*\)' kastiglione wrote: to combine my feedback with Adrian's: ```python r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P[^"]*)",.*\)' ``` 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 Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P.*)",.*\)' kastiglione wrote: looks like you have comment and name swapped 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 Python script to generate SBLanguages.h (PR #90753)
https://github.com/kastiglione edited 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 Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') kastiglione wrote: ```suggestion REGEX = re.compile(r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P.*)",.*\)') ``` 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 Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") kastiglione wrote: these would benefit from using named captures, ex: ```suggestion f.write(f" /// {match.group("whatever_group_4_is")}.\n") f.write(f" eLanguageName{match.group("name")} = {match.group("value")},\n") ``` 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 Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) kastiglione wrote: since the regex is anchored to the start (`^`), this should probably be match (in which case you can remove the `^` if you want) 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] Support custom LLVM formatting for variables (PR #81196)
kastiglione wrote: revert: 0f628fdb1aa8be97a5d86c3259b8caaa997790ec apologies, thanks for reporting @aaupov. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0f628fd - Revert "[lldb] Support custom LLVM formatting for variables (#81196)"
Author: Dave Lee Date: 2024-04-30T16:15:19-07:00 New Revision: 0f628fdb1aa8be97a5d86c3259b8caaa997790ec URL: https://github.com/llvm/llvm-project/commit/0f628fdb1aa8be97a5d86c3259b8caaa997790ec DIFF: https://github.com/llvm/llvm-project/commit/0f628fdb1aa8be97a5d86c3259b8caaa997790ec.diff LOG: Revert "[lldb] Support custom LLVM formatting for variables (#81196)" This reverts commit 7a8d15e919dde70118dbfa34e927be1705ded67d. Added: Modified: lldb/docs/use/variable.rst lldb/source/Core/FormatEntity.cpp Removed: lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst index e9175b25336ba9..8eaed6405315b4 100644 --- a/lldb/docs/use/variable.rst +++ b/lldb/docs/use/variable.rst @@ -460,15 +460,6 @@ summary strings, regardless of the format they have applied to their types. To do that, you can use %format inside an expression path, as in ${var.x->x%u}, which would display the value of x as an unsigned integer. -Additionally, custom output can be achieved by using an LLVM format string, -commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and -``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``), -which unconditionally inserts a ``0x`` prefix, and also zero pads the value to -match the size of the type. The latter uses ``llvm::formatv`` formatting -(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no -padding. This raw control is useful when composing multiple pieces into a -larger whole. - You can also use some other special format markers, not available for formats themselves, but which carry a special meaning when used in this context: diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index da5b1cfce74ac8..ba62e26252591f 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -57,7 +57,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/Regex.h" #include "llvm/TargetParser/Triple.h" #include @@ -659,38 +658,6 @@ static char ConvertValueObjectStyleToChar( return '\0'; } -static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", llvm::Regex::IgnoreCase}; - -static bool DumpValueWithLLVMFormat(Stream , llvm::StringRef options, -ValueObject ) { - std::string formatted; - std::string llvm_format = ("{0:" + options + "}").str(); - - // Options supported by format_provider for integral arithmetic types. - // See table in FormatProviders.h. - - auto type_info = valobj.GetTypeInfo(); - if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) { -if (type_info & eTypeIsSigned) { - bool success = false; - int64_t integer = valobj.GetValueAsSigned(0, ); - if (success) -formatted = llvm::formatv(llvm_format.data(), integer); -} else { - bool success = false; - uint64_t integer = valobj.GetValueAsUnsigned(0, ); - if (success) -formatted = llvm::formatv(llvm_format.data(), integer); -} - } - - if (formatted.empty()) -return false; - - s.Write(formatted.data(), formatted.size()); - return true; -} - static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -761,12 +728,9 @@ static bool DumpValue(Stream , const SymbolContext *sc, return RunScriptFormatKeyword(s, sc, exe_ctx, valobj, entry.string.c_str()); } - auto split = llvm::StringRef(entry.string).split(':'); - auto subpath = split.first; - auto llvm_format = split.second; - + llvm::StringRef subpath(entry.string); // simplest case ${var}, just print valobj's value - if (subpath.empty()) { + if (entry.string.empty()) { if (entry.printf_format.empty() && entry.fmt == eFormatDefault && entry.number == ValueObject::eValueObjectRepresentationStyleValue) was_plain_var = true; @@ -775,7 +739,7 @@ static bool DumpValue(Stream , const SymbolContext *sc, target = valobj; } else // this is ${var.something} or multiple .something nested { -if (subpath[0] == '[') +if (entry.string[0] == '[') was_var_indexed = true; ScanBracketedRange(subpath, close_bracket_index, var_name_final_if_array_range, index_lower, @@ -783,11 +747,14 @@ static bool DumpValue(Stream , const SymbolContext *sc, Status error; -LLDB_LOG(log, "[Debugger::FormatPrompt] symbol to expand: {0}", subpath); +const std::string _path = entry.string; + +
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/81196 >From 81a2034ff2b41e30a1f5b82c86b4d5d4c429ed52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 8 Feb 2024 13:59:12 -0800 Subject: [PATCH 1/9] [lldb] Support custom printf formatting for variables --- lldb/source/Core/FormatEntity.cpp | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e9a..0e929203935304 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -883,8 +883,29 @@ static bool DumpValue(Stream , const SymbolContext *sc, } if (!is_array_range) { -LLDB_LOGF(log, - "[Debugger::FormatPrompt] dumping ordinary printable output"); +if (!entry.printf_format.empty()) { + auto type_info = target->GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + bool success = false; + auto integer = target->GetValueAsSigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} else { + bool success = false; + auto integer = target->GetValueAsUnsigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} + } +} +LLDB_LOGF(log, "dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); } else { >From 335ab1de4b39257e3bbb3bd969a0dd6991747558 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 13 Feb 2024 13:26:35 -0800 Subject: [PATCH 2/9] Factor out DumpValueWithPrintf; Add test --- lldb/source/Core/FormatEntity.cpp | 45 +++ .../custom-printf-summary/Makefile| 2 + .../TestCustomPrintfSummary.py| 11 + .../custom-printf-summary/main.c | 13 ++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomPrintfSummary.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 0e929203935304..57a05507d844cf 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -658,6 +658,25 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithPrintf(Stream , llvm::StringRef format, +ValueObject ) { + auto type_info = target.GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + if (auto integer = target.GetValueAsSigned()) { +s.Printf(format.data(), *integer); +return true; + } +} else { + if (auto integer = target.GetValueAsUnsigned()) { +s.Printf(format.data(), *integer); +return true; + } +} + } + return false; +} + static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -884,25 +903,13 @@ static bool DumpValue(Stream , const SymbolContext *sc, if (!is_array_range) { if (!entry.printf_format.empty()) { - auto type_info = target->GetTypeInfo(); - if (type_info & eTypeIsInteger) { -if (type_info & eTypeIsSigned) { - bool success = false; - auto integer = target->GetValueAsSigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} else { - bool success = false; - auto integer = target->GetValueAsUnsigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} + if (DumpValueWithPrintf(s, entry.printf_format, *target)) { +LLDB_LOGF(log, "dumping using printf format"); +return true; + } else { +LLDB_LOG(log, + "unsupported printf format '{0}' - for type info flags {1}", + entry.printf_format, target->GetTypeInfo()); } } LLDB_LOGF(log, "dumping ordinary printable output"); diff --git a/lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/81196 >From 81a2034ff2b41e30a1f5b82c86b4d5d4c429ed52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 8 Feb 2024 13:59:12 -0800 Subject: [PATCH 1/8] [lldb] Support custom printf formatting for variables --- lldb/source/Core/FormatEntity.cpp | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e9a..0e929203935304 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -883,8 +883,29 @@ static bool DumpValue(Stream , const SymbolContext *sc, } if (!is_array_range) { -LLDB_LOGF(log, - "[Debugger::FormatPrompt] dumping ordinary printable output"); +if (!entry.printf_format.empty()) { + auto type_info = target->GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + bool success = false; + auto integer = target->GetValueAsSigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} else { + bool success = false; + auto integer = target->GetValueAsUnsigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} + } +} +LLDB_LOGF(log, "dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); } else { >From 335ab1de4b39257e3bbb3bd969a0dd6991747558 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 13 Feb 2024 13:26:35 -0800 Subject: [PATCH 2/8] Factor out DumpValueWithPrintf; Add test --- lldb/source/Core/FormatEntity.cpp | 45 +++ .../custom-printf-summary/Makefile| 2 + .../TestCustomPrintfSummary.py| 11 + .../custom-printf-summary/main.c | 13 ++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomPrintfSummary.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 0e929203935304..57a05507d844cf 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -658,6 +658,25 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithPrintf(Stream , llvm::StringRef format, +ValueObject ) { + auto type_info = target.GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + if (auto integer = target.GetValueAsSigned()) { +s.Printf(format.data(), *integer); +return true; + } +} else { + if (auto integer = target.GetValueAsUnsigned()) { +s.Printf(format.data(), *integer); +return true; + } +} + } + return false; +} + static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -884,25 +903,13 @@ static bool DumpValue(Stream , const SymbolContext *sc, if (!is_array_range) { if (!entry.printf_format.empty()) { - auto type_info = target->GetTypeInfo(); - if (type_info & eTypeIsInteger) { -if (type_info & eTypeIsSigned) { - bool success = false; - auto integer = target->GetValueAsSigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} else { - bool success = false; - auto integer = target->GetValueAsUnsigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} + if (DumpValueWithPrintf(s, entry.printf_format, *target)) { +LLDB_LOGF(log, "dumping using printf format"); +return true; + } else { +LLDB_LOG(log, + "unsupported printf format '{0}' - for type info flags {1}", + entry.printf_format, target->GetTypeInfo()); } } LLDB_LOGF(log, "dumping ordinary printable output"); diff --git a/lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/81196 >From 81a2034ff2b41e30a1f5b82c86b4d5d4c429ed52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 8 Feb 2024 13:59:12 -0800 Subject: [PATCH 1/7] [lldb] Support custom printf formatting for variables --- lldb/source/Core/FormatEntity.cpp | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e9a..0e929203935304 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -883,8 +883,29 @@ static bool DumpValue(Stream , const SymbolContext *sc, } if (!is_array_range) { -LLDB_LOGF(log, - "[Debugger::FormatPrompt] dumping ordinary printable output"); +if (!entry.printf_format.empty()) { + auto type_info = target->GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + bool success = false; + auto integer = target->GetValueAsSigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} else { + bool success = false; + auto integer = target->GetValueAsUnsigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} + } +} +LLDB_LOGF(log, "dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); } else { >From 335ab1de4b39257e3bbb3bd969a0dd6991747558 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 13 Feb 2024 13:26:35 -0800 Subject: [PATCH 2/7] Factor out DumpValueWithPrintf; Add test --- lldb/source/Core/FormatEntity.cpp | 45 +++ .../custom-printf-summary/Makefile| 2 + .../TestCustomPrintfSummary.py| 11 + .../custom-printf-summary/main.c | 13 ++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomPrintfSummary.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 0e929203935304..57a05507d844cf 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -658,6 +658,25 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithPrintf(Stream , llvm::StringRef format, +ValueObject ) { + auto type_info = target.GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + if (auto integer = target.GetValueAsSigned()) { +s.Printf(format.data(), *integer); +return true; + } +} else { + if (auto integer = target.GetValueAsUnsigned()) { +s.Printf(format.data(), *integer); +return true; + } +} + } + return false; +} + static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -884,25 +903,13 @@ static bool DumpValue(Stream , const SymbolContext *sc, if (!is_array_range) { if (!entry.printf_format.empty()) { - auto type_info = target->GetTypeInfo(); - if (type_info & eTypeIsInteger) { -if (type_info & eTypeIsSigned) { - bool success = false; - auto integer = target->GetValueAsSigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} else { - bool success = false; - auto integer = target->GetValueAsUnsigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} + if (DumpValueWithPrintf(s, entry.printf_format, *target)) { +LLDB_LOGF(log, "dumping using printf format"); +return true; + } else { +LLDB_LOG(log, + "unsupported printf format '{0}' - for type info flags {1}", + entry.printf_format, target->GetTypeInfo()); } } LLDB_LOGF(log, "dumping ordinary printable output"); diff --git a/lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
@@ -685,7 +686,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, sc.DumpStopContext(s, exe_scope, *this, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name, - settings); + false, settings); kastiglione wrote: I wanted to limit the initial scope of changes to just breakpoint locations. It may be that we want to change this to true, but it has not be discussed (or audited, or tested) and so I am not confident in changing this too. https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
kastiglione wrote: @jimingham I'm not sure I've understood your comment entirely. Are you saying the following? 1. Always use `GetDisplayName` when displaying a mangled name 2. Add a setting allowing the user to see `GetName` (which `GetDisplayName` will call whenever the setting is enabled) What about the cases where the context ("is the name being displayed?") is unclear at the call site? This is why I introduced the `show_function_display_name` parameter, because `DumpStopContext` could be called from either context. https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
kastiglione wrote: At the time of creation, this PR includes the changes in https://github.com/llvm/llvm-project/pull/90294. https://github.com/llvm/llvm-project/pull/90297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/90297 Adds a `show_function_display_name` parameter to `SymbolContext::DumpStopContext`. This parameter defaults to true, but `BreakpointLocation::GetDescription` sets it to true. >From 03e91b20df97103aed15e6640a7063459f0b9ae6 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 26 Apr 2024 16:14:09 -0700 Subject: [PATCH] [lldb] Display breakpoint locations using display name Adds a `show_function_display_name` parameter to `SymbolContext::DumpStopContext`. This parameter defaults to true, but `BreakpointLocation::GetDescription` sets it to true. --- lldb/include/lldb/Symbol/SymbolContext.h | 1 + lldb/include/lldb/Target/Language.h | 4 lldb/source/Breakpoint/BreakpointLocation.cpp | 2 +- lldb/source/Core/Address.cpp | 5 +++-- lldb/source/Core/Mangled.cpp | 2 ++ lldb/source/Symbol/SymbolContext.cpp | 13 +++-- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index bd33a71b46cac0..0bc707070f8504 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -158,6 +158,7 @@ class SymbolContext { Stream *s, ExecutionContextScope *exe_scope, const Address _addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name, + bool show_function_display_name = false, std::optional settings = std::nullopt) const; /// Get the address range contained within a symbol context. diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 67714e6fdf942e..ff7c60bf68bfc9 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -281,6 +281,10 @@ class Language : public PluginInterface { return mangled.GetMangledName(); } + virtual ConstString GetDisplayDemangledName(Mangled mangled) const { +return mangled.GetDemangledName(); + } + virtual void GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream ); diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index b48ec1398d63e8..41911fad41c648 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -507,7 +507,7 @@ void BreakpointLocation::GetDescription(Stream *s, else s->PutCString("where = "); sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address, - false, true, false, true, true); + false, true, false, true, true, true); } else { if (sc.module_sp) { s->EOL(); diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index b23398883fa553..5a4751bd5256eb 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -645,7 +645,8 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, pointer_sc.symbol != nullptr) { s->PutCString(": "); pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, - false, true, true, settings); + false, true, true, false, + settings); } } } @@ -685,7 +686,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, sc.DumpStopContext(s, exe_scope, *this, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name, - settings); + false, settings); } else { // We found a symbol but it was in a different section so it // isn't the symbol we should be showing, just show the section diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index b167c51fdce247..8efc4c639cca5f 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -310,6 +310,8 @@ ConstString Mangled::GetDemangledName() const { } ConstString Mangled::GetDisplayDemangledName() const { + if (Language *lang = Language::FindPlugin(GuessLanguage())) +return lang->GetDisplayDemangledName(*this); return GetDemangledName(); } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index f368896fbad490..8f26e41d192044 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -73,6 +73,7 @@ bool SymbolContext::DumpStopContext( Stream *s,
[Lldb-commits] [lldb] [lldb] Consult Language plugin in GetDisplayDemangledName (PR #90294)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/90294 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Consult Language plugin in GetDisplayDemangledName (PR #90294)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/90294 None >From a5e72126d3b0144e5fc0f5b04925f4bf394551e4 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 26 Apr 2024 16:14:09 -0700 Subject: [PATCH] [lldb] Consult Language plugin in GetDisplayDemangledName --- lldb/include/lldb/Target/Language.h | 4 lldb/source/Core/Mangled.cpp| 2 ++ 2 files changed, 6 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 67714e6fdf942e..ff7c60bf68bfc9 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -281,6 +281,10 @@ class Language : public PluginInterface { return mangled.GetMangledName(); } + virtual ConstString GetDisplayDemangledName(Mangled mangled) const { +return mangled.GetDemangledName(); + } + virtual void GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream ); diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index b167c51fdce247..8efc4c639cca5f 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -310,6 +310,8 @@ ConstString Mangled::GetDemangledName() const { } ConstString Mangled::GetDisplayDemangledName() const { + if (Language *lang = Language::FindPlugin(GuessLanguage())) +return lang->GetDisplayDemangledName(*this); return GetDemangledName(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name) add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} ) endif(LLVM_EXPORTED_SYMBOL_FILE) + if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) +if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) + set_property(TARGET ${name} APPEND_STRING PROPERTY +LINK_FLAGS " -Wl,-no_exported_symbols") +else() + message(FATAL_ERROR +"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when linker does not support \"-no_exported_symbols\"") kastiglione wrote: Prior to the addition of `-no_exported_symbols`, I used to use `-Wl,-exported_symbols_list,/dev/null` to achieve the same thing. That could be a fallback, if anyone is motivated. https://github.com/llvm/llvm-project/pull/87684 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
kastiglione wrote: Thanks for adding this! I've been using `CMAKE_EXE_LINKER_FLAGS` to `-Wl,-no_exported_symbols`, and have had no problems. https://github.com/llvm/llvm-project/pull/87684 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE option(LLVM_EXTERNALIZE_DEBUGINFO "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) +option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS kastiglione wrote: should the name reflect the opposite of the default? if so maybe `LLVM_DISABLE_EXPORTED_SYMBOLS`? https://github.com/llvm/llvm-project/pull/87684 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] Fix SyntaxWarning messages from python 3.12 (PR #86806)
https://github.com/kastiglione commented: lldb/package looks good, thanks. lldb/examples I trust lldb/test I or someone else will look at soon. https://github.com/llvm/llvm-project/pull/86806 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] Fix SyntaxWarning messages from python 3.12 (PR #86806)
@@ -1517,7 +1517,7 @@ def buildLibrary(self, sources, lib_name): "DYLIB_NAME": lib_name, "CFLAGS_EXTRAS": "%s -I%s " % (stdflag, os.path.join(os.environ["LLDB_SRC"], "include")), -"LD_EXTRAS": "-shared -l%s\liblldb.lib" % lib_dir, kastiglione wrote: hopefully someone changes this to `os.path.join` in the future. https://github.com/llvm/llvm-project/pull/86806 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] Fix SyntaxWarning messages from python 3.12 (PR #86806)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/86806 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
@@ -0,0 +1,18 @@ +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestCase(TestBase): + +def test_raw_bytes(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c")) +self.runCmd("type summary add -s '${var.ubyte:x-2}${var.sbyte:x-2}!' Bytes") +self.expect("v bytes", substrs=[" = 3001!"]) + +def test_bad_format(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c")) +self.runCmd("type summary add -s '${var.ubyte:y}!' Bytes") +self.expect("v bytes", substrs=[" = '0'!"]) kastiglione wrote: yep, I'm making that change now. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/81196 >From 81a2034ff2b41e30a1f5b82c86b4d5d4c429ed52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 8 Feb 2024 13:59:12 -0800 Subject: [PATCH 1/6] [lldb] Support custom printf formatting for variables --- lldb/source/Core/FormatEntity.cpp | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e9a..0e929203935304 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -883,8 +883,29 @@ static bool DumpValue(Stream , const SymbolContext *sc, } if (!is_array_range) { -LLDB_LOGF(log, - "[Debugger::FormatPrompt] dumping ordinary printable output"); +if (!entry.printf_format.empty()) { + auto type_info = target->GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + bool success = false; + auto integer = target->GetValueAsSigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} else { + bool success = false; + auto integer = target->GetValueAsUnsigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} + } +} +LLDB_LOGF(log, "dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); } else { >From 335ab1de4b39257e3bbb3bd969a0dd6991747558 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 13 Feb 2024 13:26:35 -0800 Subject: [PATCH 2/6] Factor out DumpValueWithPrintf; Add test --- lldb/source/Core/FormatEntity.cpp | 45 +++ .../custom-printf-summary/Makefile| 2 + .../TestCustomPrintfSummary.py| 11 + .../custom-printf-summary/main.c | 13 ++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomPrintfSummary.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 0e929203935304..57a05507d844cf 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -658,6 +658,25 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithPrintf(Stream , llvm::StringRef format, +ValueObject ) { + auto type_info = target.GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + if (auto integer = target.GetValueAsSigned()) { +s.Printf(format.data(), *integer); +return true; + } +} else { + if (auto integer = target.GetValueAsUnsigned()) { +s.Printf(format.data(), *integer); +return true; + } +} + } + return false; +} + static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -884,25 +903,13 @@ static bool DumpValue(Stream , const SymbolContext *sc, if (!is_array_range) { if (!entry.printf_format.empty()) { - auto type_info = target->GetTypeInfo(); - if (type_info & eTypeIsInteger) { -if (type_info & eTypeIsSigned) { - bool success = false; - auto integer = target->GetValueAsSigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} else { - bool success = false; - auto integer = target->GetValueAsUnsigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} + if (DumpValueWithPrintf(s, entry.printf_format, *target)) { +LLDB_LOGF(log, "dumping using printf format"); +return true; + } else { +LLDB_LOG(log, + "unsupported printf format '{0}' - for type info flags {1}", + entry.printf_format, target->GetTypeInfo()); } } LLDB_LOGF(log, "dumping ordinary printable output"); diff --git a/lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
@@ -0,0 +1,11 @@ +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestCase(TestBase): +def test(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c")) +self.runCmd("type summary add -s '${var.ubyte:x-2}${var.sbyte:x-2}!' Bytes") +self.expect("v bytes", substrs=[" = 1001!"]) kastiglione wrote: ill formatted format options cause an assert. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
@@ -658,6 +658,33 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithLLVMFormat(Stream , llvm::StringRef options, +ValueObject ) { + std::string formatted; + std::string llvm_format = ("{0:" + options + "}").str(); kastiglione wrote: > by switching over the supported options? There are many supported options, and they vary from type to type (int has different options than say strings). See [FormatProviders.h](https://llvm.org/doxygen/FormatProviders_8h_source.html) for the builtins. It would be possible to exhaustively iterate all the options llvm includes, but I'm not sure it would be worth it. Switching over them seems fragile to changes made to the source of truth in llvm. I will check/test what llvm does for invalid options. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
kastiglione wrote: @jimingham now that I've switched to llvm format, I'll loop back and follow up on your comments. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
kastiglione wrote: I've updated this PR to use llvm formatting instead of printf. For the following reasons: 1. For printf, users would have to know the system's size of the value, eg `%d` vs `%ld` etc 2. Users would have to provide different values for different systems, which limits the use/convenience of such summary strings Getting the size wrong could be any of undefined behavior, buggy, crashy, insecure. https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #81196)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/81196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support custom printf formatting for variables (PR #81196)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/81196 >From 81a2034ff2b41e30a1f5b82c86b4d5d4c429ed52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 8 Feb 2024 13:59:12 -0800 Subject: [PATCH 1/5] [lldb] Support custom printf formatting for variables --- lldb/source/Core/FormatEntity.cpp | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e9a..0e929203935304 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -883,8 +883,29 @@ static bool DumpValue(Stream , const SymbolContext *sc, } if (!is_array_range) { -LLDB_LOGF(log, - "[Debugger::FormatPrompt] dumping ordinary printable output"); +if (!entry.printf_format.empty()) { + auto type_info = target->GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + bool success = false; + auto integer = target->GetValueAsSigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} else { + bool success = false; + auto integer = target->GetValueAsUnsigned(0, ); + if (success) { +LLDB_LOGF(log, "dumping using printf format"); +s.Printf(entry.printf_format.c_str(), integer); +return true; + } +} + } +} +LLDB_LOGF(log, "dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); } else { >From 335ab1de4b39257e3bbb3bd969a0dd6991747558 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 13 Feb 2024 13:26:35 -0800 Subject: [PATCH 2/5] Factor out DumpValueWithPrintf; Add test --- lldb/source/Core/FormatEntity.cpp | 45 +++ .../custom-printf-summary/Makefile| 2 + .../TestCustomPrintfSummary.py| 11 + .../custom-printf-summary/main.c | 13 ++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomPrintfSummary.py create mode 100644 lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 0e929203935304..57a05507d844cf 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -658,6 +658,25 @@ static char ConvertValueObjectStyleToChar( return '\0'; } +static bool DumpValueWithPrintf(Stream , llvm::StringRef format, +ValueObject ) { + auto type_info = target.GetTypeInfo(); + if (type_info & eTypeIsInteger) { +if (type_info & eTypeIsSigned) { + if (auto integer = target.GetValueAsSigned()) { +s.Printf(format.data(), *integer); +return true; + } +} else { + if (auto integer = target.GetValueAsUnsigned()) { +s.Printf(format.data(), *integer); +return true; + } +} + } + return false; +} + static bool DumpValue(Stream , const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry , ValueObject *valobj) { @@ -884,25 +903,13 @@ static bool DumpValue(Stream , const SymbolContext *sc, if (!is_array_range) { if (!entry.printf_format.empty()) { - auto type_info = target->GetTypeInfo(); - if (type_info & eTypeIsInteger) { -if (type_info & eTypeIsSigned) { - bool success = false; - auto integer = target->GetValueAsSigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} else { - bool success = false; - auto integer = target->GetValueAsUnsigned(0, ); - if (success) { -LLDB_LOGF(log, "dumping using printf format"); -s.Printf(entry.printf_format.c_str(), integer); -return true; - } -} + if (DumpValueWithPrintf(s, entry.printf_format, *target)) { +LLDB_LOGF(log, "dumping using printf format"); +return true; + } else { +LLDB_LOG(log, + "unsupported printf format '{0}' - for type info flags {1}", + entry.printf_format, target->GetTypeInfo()); } } LLDB_LOGF(log, "dumping ordinary printable output"); diff --git a/lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
[Lldb-commits] [lldb] [lldb][nfc] Factor out repeated code in DWIM Print (PR #85669)
https://github.com/kastiglione approved this pull request. one request, and then looks good, thanks. https://github.com/llvm/llvm-project/pull/85669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Factor out repeated code in DWIM Print (PR #85669)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Factor out repeated code in DWIM Print (PR #85669)
@@ -129,6 +129,19 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } }; + // Dump `valobj` according to whether `po` was requested or not. + auto dump_val_object = [&](ValueObject ) { kastiglione wrote: Would you mind also applying this function to the block that handles persistent variables (I just added it in #85152). Thanks. https://github.com/llvm/llvm-project/pull/85669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Factor out repeated code in DWIM Print (PR #85669)
@@ -130,7 +130,20 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } }; - // First, try `expr` as the name of a frame variable. kastiglione wrote: 1. I'd prefer to leave the "first", "second", "third" comments. I want to be explicit that there's an order of attempts. 2. You'll need to rebase, I made a change last week that introduce some comments and code that you may need to incorporate. https://github.com/llvm/llvm-project/pull/85669 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
kastiglione wrote: > I'm not sure what you mean by "mixed language expressions". I was thinking about the case where a user attempts `p $some_c_var + 1` in Swift frame – which is valid swift as far as the debugger is concerned. https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
kastiglione wrote: I don't consider it a failure to not be able to perform mixed language expressions. But it would have to be presented to the user in a way that is understandable, which could be a challenge. Anyway, I pushed the change that scopes the lookup to the expected language. thank you for the reviews https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/85152 >From 970cf82fa3d64c5a4e1b3929c110b42974ef13cd Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 13 Mar 2024 14:49:23 -0700 Subject: [PATCH 1/3] [lldb] Fix dwim-print to not delete non-result persistent variables --- lldb/source/Commands/CommandObjectDWIMPrint.cpp| 12 ++-- lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 12 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index b183cb423111fb..5c043dfd101be6 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); +auto persistent_name = valobj_sp->GetName(); +// EvaluateExpression doesn't generate a new persistent result (`$0`) when +// the expression is already just a persistent variable (`$var`). Instead, +// the same persistent variable is reused. Take note of when a persistent +// result is created, to prevent unintentional deletion of a user's +// persistent variable. +bool did_persist_result = persistent_name != expr; + // Only mention Fix-Its if the expression evaluator applied them. // Compiler errors refer to the final expression after applying Fix-It(s). if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) { @@ -199,9 +207,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } } - if (suppress_result) + if (did_persist_result && suppress_result) if (auto result_var_sp = -target.GetPersistentVariable(valobj_sp->GetName())) { +target.GetPersistentVariable(persistent_name)) { auto language = valobj_sp->GetPreferredDisplayLanguage(); if (auto *persistent_state = target.GetPersistentExpressionStateForLanguage(language)) diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py index 040632096c70e7..c650b1e3533e08 100644 --- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -146,3 +146,15 @@ def test_void_result(self): self, "// break here", lldb.SBFileSpec("main.c") ) self.expect("dwim-print (void)15", matching=False, patterns=["(?i)error"]) + +def test_preserves_persistent_variables(self): +"""Test dwim-print does not delete persistent variables.""" +self.build() +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.c") +) +self.expect("dwim-print int $i = 15") +# Run the same expression twice and verify success. This ensures the +# first command does not delete the persistent variable. +for _ in range(2): +self.expect("dwim-print $i", startstr="(int) 15") >From 6503e22c894d9ed3f0d94d30a2165cf7f1914e47 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 15 Mar 2024 11:02:24 -0700 Subject: [PATCH 2/3] Try expr as a persistent variable --- .../Commands/CommandObjectDWIMPrint.cpp | 24 +-- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index 5c043dfd101be6..9db0c5a1e73ea1 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -23,7 +23,6 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/FormatVariadic.h" #include @@ -161,7 +160,16 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } } - // Second, also lastly, try `expr` as a source expression to evaluate. + // Second, try `expr` as a persistent variable. + if (expr.starts_with("$")) +if (auto var_sp = target.GetPersistentVariable(ConstString(expr))) + if (auto valobj_sp = var_sp->GetValueObject()) { +valobj_sp->Dump(result.GetOutputStream(), dump_options); +result.SetStatus(eReturnStatusSuccessFinishResult); +return; + } + + // Third, and lastly, try `expr` as a source expression to evaluate. { auto *exe_scope = m_exe_ctx.GetBestExecutionContextScope(); ValueObjectSP valobj_sp; @@ -170,14 +178,6 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); -auto persistent_name = valobj_sp->GetName(); -// EvaluateExpression doesn't generate a new persistent result
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
kastiglione wrote: I'll change this to scope lookup of persistent variables to the expected language. However, there's an argument to be made that `dwim-print $my_var` should work anywhere. I think that follows the spirit of "do what I mean". Maybe in the future I'll propose that in a separate change. https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); +auto persistent_name = valobj_sp->GetName(); +// EvaluateExpression doesn't generate a new persistent result (`$0`) when +// the expression is already just a persistent variable (`$var`). Instead, +// the same persistent variable is reused. Take note of when a persistent +// result is created, to prevent unintentional deletion of a user's +// persistent variable. +bool did_persist_result = persistent_name != expr; kastiglione wrote: Jim, I have updated the PR to try the expression as a persistent variable – prior to expression evaluation. My thinking is, instead of evaluating first, then asking if a persistent variable was created, it's more straight to the point to first ask "is this a persistent variable". I like the idea of trying the various kinds of variables in sequence: frame, target, persistent. https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/85152 >From 970cf82fa3d64c5a4e1b3929c110b42974ef13cd Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 13 Mar 2024 14:49:23 -0700 Subject: [PATCH 1/2] [lldb] Fix dwim-print to not delete non-result persistent variables --- lldb/source/Commands/CommandObjectDWIMPrint.cpp| 12 ++-- lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 12 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index b183cb423111fb..5c043dfd101be6 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); +auto persistent_name = valobj_sp->GetName(); +// EvaluateExpression doesn't generate a new persistent result (`$0`) when +// the expression is already just a persistent variable (`$var`). Instead, +// the same persistent variable is reused. Take note of when a persistent +// result is created, to prevent unintentional deletion of a user's +// persistent variable. +bool did_persist_result = persistent_name != expr; + // Only mention Fix-Its if the expression evaluator applied them. // Compiler errors refer to the final expression after applying Fix-It(s). if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) { @@ -199,9 +207,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } } - if (suppress_result) + if (did_persist_result && suppress_result) if (auto result_var_sp = -target.GetPersistentVariable(valobj_sp->GetName())) { +target.GetPersistentVariable(persistent_name)) { auto language = valobj_sp->GetPreferredDisplayLanguage(); if (auto *persistent_state = target.GetPersistentExpressionStateForLanguage(language)) diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py index 040632096c70e7..c650b1e3533e08 100644 --- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -146,3 +146,15 @@ def test_void_result(self): self, "// break here", lldb.SBFileSpec("main.c") ) self.expect("dwim-print (void)15", matching=False, patterns=["(?i)error"]) + +def test_preserves_persistent_variables(self): +"""Test dwim-print does not delete persistent variables.""" +self.build() +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.c") +) +self.expect("dwim-print int $i = 15") +# Run the same expression twice and verify success. This ensures the +# first command does not delete the persistent variable. +for _ in range(2): +self.expect("dwim-print $i", startstr="(int) 15") >From 6503e22c894d9ed3f0d94d30a2165cf7f1914e47 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 15 Mar 2024 11:02:24 -0700 Subject: [PATCH 2/2] Try expr as a persistent variable --- .../Commands/CommandObjectDWIMPrint.cpp | 24 +-- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index 5c043dfd101be6..9db0c5a1e73ea1 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -23,7 +23,6 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/FormatVariadic.h" #include @@ -161,7 +160,16 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } } - // Second, also lastly, try `expr` as a source expression to evaluate. + // Second, try `expr` as a persistent variable. + if (expr.starts_with("$")) +if (auto var_sp = target.GetPersistentVariable(ConstString(expr))) + if (auto valobj_sp = var_sp->GetValueObject()) { +valobj_sp->Dump(result.GetOutputStream(), dump_options); +result.SetStatus(eReturnStatusSuccessFinishResult); +return; + } + + // Third, and lastly, try `expr` as a source expression to evaluate. { auto *exe_scope = m_exe_ctx.GetBestExecutionContextScope(); ValueObjectSP valobj_sp; @@ -170,14 +178,6 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); -auto persistent_name = valobj_sp->GetName(); -// EvaluateExpression doesn't generate a new persistent result
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); +auto persistent_name = valobj_sp->GetName(); +// EvaluateExpression doesn't generate a new persistent result (`$0`) when +// the expression is already just a persistent variable (`$var`). Instead, +// the same persistent variable is reused. Take note of when a persistent +// result is created, to prevent unintentional deletion of a user's +// persistent variable. +bool did_persist_result = persistent_name != expr; kastiglione wrote: I agree that it's not ideal, but I felt it was sufficient. > what you want to test, which is whether the result of the expression was a > new expression result variable exactly. However I think peeking at the result variables is also not ideal. Both my initial stab at this, and your suggestion are deducing whether a new expression result variable was created. If I'm to change the API, I think it'd be ideal to make the API communicate have means to communicate this explicitly. There's another approach I considered taking. Before calling `EvaluateExpression`, try the expression as a persistent variable and check in the target to see if it exists, and if it does exist, use it (and avoid `EvaluateExpression` altogether). This is similar to how expressions are first treated as frame variables (and as @felipepiovezan has requested, we should try `target variable` too). https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/85152 None >From 970cf82fa3d64c5a4e1b3929c110b42974ef13cd Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 13 Mar 2024 14:49:23 -0700 Subject: [PATCH] [lldb] Fix dwim-print to not delete non-result persistent variables --- lldb/source/Commands/CommandObjectDWIMPrint.cpp| 12 ++-- lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 12 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index b183cb423111fb..5c043dfd101be6 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, ExpressionResults expr_result = target.EvaluateExpression( expr, exe_scope, valobj_sp, eval_options, _expression); +auto persistent_name = valobj_sp->GetName(); +// EvaluateExpression doesn't generate a new persistent result (`$0`) when +// the expression is already just a persistent variable (`$var`). Instead, +// the same persistent variable is reused. Take note of when a persistent +// result is created, to prevent unintentional deletion of a user's +// persistent variable. +bool did_persist_result = persistent_name != expr; + // Only mention Fix-Its if the expression evaluator applied them. // Compiler errors refer to the final expression after applying Fix-It(s). if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) { @@ -199,9 +207,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, } } - if (suppress_result) + if (did_persist_result && suppress_result) if (auto result_var_sp = -target.GetPersistentVariable(valobj_sp->GetName())) { +target.GetPersistentVariable(persistent_name)) { auto language = valobj_sp->GetPreferredDisplayLanguage(); if (auto *persistent_state = target.GetPersistentExpressionStateForLanguage(language)) diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py index 040632096c70e7..c650b1e3533e08 100644 --- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -146,3 +146,15 @@ def test_void_result(self): self, "// break here", lldb.SBFileSpec("main.c") ) self.expect("dwim-print (void)15", matching=False, patterns=["(?i)error"]) + +def test_preserves_persistent_variables(self): +"""Test dwim-print does not delete persistent variables.""" +self.build() +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.c") +) +self.expect("dwim-print int $i = 15") +# Run the same expression twice and verify success. This ensures the +# first command does not delete the persistent variable. +for _ in range(2): +self.expect("dwim-print $i", startstr="(int) 15") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/85133 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85133 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/85133 Correction to cb8f3837e2311c369ef24a077a0c34e4ff56c08f >From f5fb7236ad4df2fe9322ab00e4839e92ef29a8d3 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 13 Mar 2024 14:09:20 -0700 Subject: [PATCH] [lldb] Skip TestIndirectSymbols Correction to cb8f3837e2311c369ef24a077a0c34e4ff56c08f --- lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py index ad4cb4b12c796a..c4bbedc9289130 100644 --- a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py +++ b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py @@ -16,7 +16,7 @@ def setUp(self): @skipUnlessDarwin @add_test_categories(["pyapi"]) -@expectedFailureDarwin("rdar://120796553") +@skipIf(bugnumber="rdar://120796553") def test_with_python_api(self): """Test stepping and setting breakpoints in indirect and re-exported symbols.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/85127 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/85127 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/85127 None >From 5d0a5c8721766544067ccd8e169a5e2effeba981 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 13 Mar 2024 13:30:20 -0700 Subject: [PATCH] [lldb] XFAIL TestIndirectSymbols on darwin --- lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py index fbe6db9f892d55..ad4cb4b12c796a 100644 --- a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py +++ b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py @@ -16,6 +16,7 @@ def setUp(self): @skipUnlessDarwin @add_test_categories(["pyapi"]) +@expectedFailureDarwin("rdar://120796553") def test_with_python_api(self): """Test stepping and setting breakpoints in indirect and re-exported symbols.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
https://github.com/kastiglione approved this pull request. looks good https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") +) +if not is_exe(linker_path): +return False + +raw_linker_info = ( +subprocess.check_output([linker_path, "-version_details"]) +.rstrip() +.decode("utf-8") +) +parsed_linker_info = json.loads(raw_linker_info) +if "version" not in parsed_linker_info: +return False + +raw_version = parsed_linker_info["version"] +version = None +try: +version = int(raw_version) kastiglione wrote: `float` also isn't sufficient, since some versions can contain 3 separate numbers (ie `100.5.8`). In my related PR, I used this: ```py version_tuple = tuple(int(x) for x in version.split(".")) if (1000,) <= version_tuple <= (1109,): # handle bug ``` Comparisons of tuples appear to behave as desired. https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/84246 >From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 14:23:05 -0800 Subject: [PATCH 1/3] [lldb] Disable shell tests affected by ld64 bug --- lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test| 2 +- .../Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +- lldb/test/Shell/lit.cfg.py | 12 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test index 3df9906394f432..783bfd45c4669a 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test @@ -1,7 +1,7 @@ # Test handing of dwarf expressions specifying the location of registers, if # those expressions refer to the frame's CFA value. -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # REQUIRES: target-x86_64, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644 --- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test +++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test @@ -2,7 +2,7 @@ # points to non-executable memory. # REQUIRES: target-x86_64 -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index d75c1f532e147f..6d41dc7d8d7325 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -1,5 +1,6 @@ # -*- Python -*- +import json import os import platform import re @@ -179,3 +180,14 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") + +# Determine if a specific version of Xcode's linker contains a TLS bug. We want +# to skip TLS tests if they contain this bug. +try: +raw_version_details = subprocess.check_output(("xcrun", "ld", "-version_details")) +version_details = json.loads(raw_version_details) +version = version_details.get("version", "0") +if 1000 <= float(version) <= 1109: +config.available_features.add("ld64-tls-bug") +except: +pass >From 92f29840ba8df95b0fb8fa7fd2bf9a679e749849 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 7 Mar 2024 10:10:22 -0800 Subject: [PATCH 2/3] The bug is not TLS specific --- lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test | 2 +- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +- lldb/test/Shell/lit.cfg.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test index 783bfd45c4669a..7b5d6650fe2f75 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test @@ -1,7 +1,7 @@ # Test handing of dwarf expressions specifying the location of registers, if # those expressions refer to the frame's CFA value. -# UNSUPPORTED: system-windows, ld64-tls-bug +# UNSUPPORTED: system-windows, ld_new-bug # REQUIRES: target-x86_64, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test index a2b5ae8a9e3e5f..9bc7c78f79b26b 100644 --- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test +++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test @@ -2,7 +2,7 @@ # points to non-executable memory. # REQUIRES: target-x86_64 -# UNSUPPORTED: system-windows, ld64-tls-bug +# UNSUPPORTED: system-windows, ld_new-bug # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index 6d41dc7d8d7325..1362dfcf7c4354 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -181,13 +181,13 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") -# Determine if a specific version of Xcode's linker contains a TLS bug. We want -# to skip TLS tests if they contain this bug. +# Determine if a specific version of Xcode's linker contains a bug. We want to +# skip affected tests if they contain this bug. try: raw_version_details =
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)
@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") + +# Determine if a specific version of Xcode's linker contains a bug. We want to +# skip affected tests if they contain this bug. +try: +raw_version_details = subprocess.check_output(("xcrun", "ld", "-version_details")) +version_details = json.loads(raw_version_details) +version = version_details.get("version", "0") +if 1000 <= float(version) <= 1109: kastiglione wrote: float will be insufficient, this will need to handle versions such as `1100.1.1` https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)
kastiglione wrote: I think this should be merged, and if either end of the version range proves to be too limited, we can increase the range. https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/84263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)
kastiglione wrote: Called it `ld_new-bug`. If it's not the TLS bug, I wonder if the version range is correct. https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/84246 >From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 14:23:05 -0800 Subject: [PATCH 1/2] [lldb] Disable shell tests affected by ld64 bug --- lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test| 2 +- .../Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +- lldb/test/Shell/lit.cfg.py | 12 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test index 3df9906394f432..783bfd45c4669a 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test @@ -1,7 +1,7 @@ # Test handing of dwarf expressions specifying the location of registers, if # those expressions refer to the frame's CFA value. -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # REQUIRES: target-x86_64, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644 --- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test +++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test @@ -2,7 +2,7 @@ # points to non-executable memory. # REQUIRES: target-x86_64 -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index d75c1f532e147f..6d41dc7d8d7325 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -1,5 +1,6 @@ # -*- Python -*- +import json import os import platform import re @@ -179,3 +180,14 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") + +# Determine if a specific version of Xcode's linker contains a TLS bug. We want +# to skip TLS tests if they contain this bug. +try: +raw_version_details = subprocess.check_output(("xcrun", "ld", "-version_details")) +version_details = json.loads(raw_version_details) +version = version_details.get("version", "0") +if 1000 <= float(version) <= 1109: +config.available_features.add("ld64-tls-bug") +except: +pass >From 92f29840ba8df95b0fb8fa7fd2bf9a679e749849 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 7 Mar 2024 10:10:22 -0800 Subject: [PATCH 2/2] The bug is not TLS specific --- lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test | 2 +- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +- lldb/test/Shell/lit.cfg.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test index 783bfd45c4669a..7b5d6650fe2f75 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test @@ -1,7 +1,7 @@ # Test handing of dwarf expressions specifying the location of registers, if # those expressions refer to the frame's CFA value. -# UNSUPPORTED: system-windows, ld64-tls-bug +# UNSUPPORTED: system-windows, ld_new-bug # REQUIRES: target-x86_64, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test index a2b5ae8a9e3e5f..9bc7c78f79b26b 100644 --- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test +++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test @@ -2,7 +2,7 @@ # points to non-executable memory. # REQUIRES: target-x86_64 -# UNSUPPORTED: system-windows, ld64-tls-bug +# UNSUPPORTED: system-windows, ld_new-bug # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index 6d41dc7d8d7325..1362dfcf7c4354 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -181,13 +181,13 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") -# Determine if a specific version of Xcode's linker contains a TLS bug. We want -# to skip TLS tests if they contain this bug. +# Determine if a specific version of Xcode's linker contains a bug. We want to +# skip affected tests if they contain this bug. try: raw_version_details =
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)
@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") + kastiglione wrote: my thinking is that the darwin check is baked into the invocation of xcrun. If you think it's better to check for darwin explicitly, I will make that change it. https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log module build remarks to types log too (PR #84260)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/84260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/83504 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp (PR #84262)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/84262 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/84263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/84263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/84263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/84263 >From e5bed6b190687cc31ecb69da006bc93d9284994a Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 16:03:22 -0800 Subject: [PATCH 1/2] [lldb] Minor cleanup in StoringDiagnosticConsumer --- .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 5ce0d35378230c..7fdaa2762be56d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -80,7 +80,6 @@ class StoringDiagnosticConsumer : public clang::DiagnosticConsumer { std::shared_ptr m_os; /// Output string filled by m_os. Will be reused for different diagnostics. std::string m_output; - Log *m_log; /// A Progress with explicitly managed lifetime. std::unique_ptr m_current_progress_up; std::vector m_module_build_stack; @@ -142,12 +141,10 @@ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor { } // anonymous namespace StoringDiagnosticConsumer::StoringDiagnosticConsumer() { - m_log = GetLog(LLDBLog::Expressions); - - clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions(); + clang::DiagnosticOptions *options = new clang::DiagnosticOptions(); m_os = std::make_shared(m_output); m_diag_printer = - std::make_shared(*m_os, m_options); + std::make_shared(*m_os, options); } void StoringDiagnosticConsumer::HandleDiagnostic( >From 13bfecf4740f7a3cf8cef98a91f4560fe6a59cfd Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 16:10:37 -0800 Subject: [PATCH 2/2] more cleanup --- .../Clang/ClangModulesDeclVendor.cpp | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 7fdaa2762be56d..2a992d6b36208d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -75,9 +75,11 @@ class StoringDiagnosticConsumer : public clang::DiagnosticConsumer { std::vector m_diagnostics; /// The DiagnosticPrinter used for creating the full diagnostic messages /// that are stored in m_diagnostics. - std::shared_ptr m_diag_printer; + std::unique_ptr m_diag_printer; /// Output stream of m_diag_printer. - std::shared_ptr m_os; + std::unique_ptr m_os; + /// Diagnostics options of m_diag_printer. + std::unique_ptr m_options; /// Output string filled by m_os. Will be reused for different diagnostics. std::string m_output; /// A Progress with explicitly managed lifetime. @@ -141,10 +143,10 @@ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor { } // anonymous namespace StoringDiagnosticConsumer::StoringDiagnosticConsumer() { - clang::DiagnosticOptions *options = new clang::DiagnosticOptions(); - m_os = std::make_shared(m_output); + m_options = std::make_unique(); + m_os = std::make_unique(m_output); m_diag_printer = - std::make_shared(*m_os, options); + std::make_unique(*m_os, m_options.get()); } void StoringDiagnosticConsumer::HandleDiagnostic( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/84263 None >From e5bed6b190687cc31ecb69da006bc93d9284994a Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 16:03:22 -0800 Subject: [PATCH] [lldb] Minor cleanup in StoringDiagnosticConsumer --- .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 5ce0d35378230c..7fdaa2762be56d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -80,7 +80,6 @@ class StoringDiagnosticConsumer : public clang::DiagnosticConsumer { std::shared_ptr m_os; /// Output string filled by m_os. Will be reused for different diagnostics. std::string m_output; - Log *m_log; /// A Progress with explicitly managed lifetime. std::unique_ptr m_current_progress_up; std::vector m_module_build_stack; @@ -142,12 +141,10 @@ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor { } // anonymous namespace StoringDiagnosticConsumer::StoringDiagnosticConsumer() { - m_log = GetLog(LLDBLog::Expressions); - - clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions(); + clang::DiagnosticOptions *options = new clang::DiagnosticOptions(); m_os = std::make_shared(m_output); m_diag_printer = - std::make_shared(*m_os, m_options); + std::make_shared(*m_os, options); } void StoringDiagnosticConsumer::HandleDiagnostic( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp (PR #84262)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/84262 None >From ba079bd1d130a460e481b6c10b33f1ddd58421a3 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 16:02:13 -0800 Subject: [PATCH] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp --- .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp | 8 1 file changed, 8 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 5ce0d35378230c..cc5250ca0f7883 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -8,7 +8,6 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticFrontend.h" -#include "clang/Basic/DiagnosticSerialization.h" #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -19,20 +18,15 @@ #include "clang/Sema/Lookup.h" #include "clang/Serialization/ASTReader.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Path.h" #include "llvm/Support/Threading.h" #include "ClangHost.h" #include "ClangModulesDeclVendor.h" -#include "ModuleDependencyCollector.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/Progress.h" -#include "lldb/Host/Host.h" -#include "lldb/Host/HostInfo.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/SourceModule.h" #include "lldb/Target/Target.h" @@ -40,10 +34,8 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/StreamString.h" #include -#include using namespace lldb_private; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log module build remarks to types log too (PR #84260)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/84260 None >From c828091ab173a2c23e10649ad7b131a02ae4e6c1 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 15:55:38 -0800 Subject: [PATCH] [lldb] Log module build remarks to types log too --- .../Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 5ce0d35378230c..89e56213c1bfe0 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -191,7 +191,7 @@ void StoringDiagnosticConsumer::EndSourceFile() { bool StoringDiagnosticConsumer::HandleModuleRemark( const clang::Diagnostic ) { - Log *log = GetLog(LLDBLog::Expressions); + Log *log = GetLog(LLDBLog::Types | LLDBLog::Expressions); switch (info.getID()) { case clang::diag::remark_module_build: { const auto _name = info.getArgStdStr(0); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
kastiglione wrote: To start with option #1 I created https://github.com/llvm/llvm-project/pull/84246 https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/84246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/84246 None >From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 6 Mar 2024 14:23:05 -0800 Subject: [PATCH] [lldb] Disable shell tests affected by ld64 bug --- lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test| 2 +- .../Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +- lldb/test/Shell/lit.cfg.py | 12 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test index 3df9906394f432..783bfd45c4669a 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test @@ -1,7 +1,7 @@ # Test handing of dwarf expressions specifying the location of registers, if # those expressions refer to the frame's CFA value. -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # REQUIRES: target-x86_64, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644 --- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test +++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test @@ -2,7 +2,7 @@ # points to non-executable memory. # REQUIRES: target-x86_64 -# UNSUPPORTED: system-windows +# UNSUPPORTED: system-windows, ld64-tls-bug # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index d75c1f532e147f..6d41dc7d8d7325 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -1,5 +1,6 @@ # -*- Python -*- +import json import os import platform import re @@ -179,3 +180,14 @@ def calculate_arch_features(arch_string): if "LD_PRELOAD" in os.environ: config.available_features.add("ld_preload-present") + +# Determine if a specific version of Xcode's linker contains a TLS bug. We want +# to skip TLS tests if they contain this bug. +try: +raw_version_details = subprocess.check_output(("xcrun", "ld", "-version_details")) +version_details = json.loads(raw_version_details) +version = version_details.get("version", "0") +if 1000 <= float(version) <= 1109: +config.available_features.add("ld64-tls-bug") +except: +pass ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
kastiglione wrote: We're going to need this logic in a couple from shell tests too. Should we: 1. Duplicate the logic into lit.cfg.py? 2. Import lldbplatformutil.py into lit.cfg.py? (are there any python structure/layout issues that would complicate this?) 3. Put the logic in an independent location and have both lit.cfg.py and lldbplatformutil.py import that? https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") +) +if not is_exe(linker_path): +return False + +raw_linker_info = ( +subprocess.check_output([linker_path, "-version_details"]) +.rstrip() +.decode("utf-8") +) +parsed_linker_info = json.loads(raw_linker_info) +if "version" not in parsed_linker_info: +return False + +raw_version = parsed_linker_info["version"] kastiglione wrote: ```suggestion raw_version = parsed_linker_info.get("version") ``` https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits