[Lldb-commits] [llvm] [libcxx] [clang-tools-extra] [libcxxabi] [mlir] [compiler-rt] [clang] [libunwind] [lld] [libc] [lldb] [flang] PR#72453 : Exceeding maximum file name length (PR #72654)
https://github.com/shahidiqbal13 updated https://github.com/llvm/llvm-project/pull/72654 >From b6bfb18e25c111baf6c95a0a4a1c3d667bb25b6d Mon Sep 17 00:00:00 2001 From: Shahid Iqbal Date: Thu, 16 Nov 2023 11:26:43 -0500 Subject: [PATCH 1/7] TESTING infra --- clang/NOTES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/NOTES.txt b/clang/NOTES.txt index f06ea8c70cd3409..c83dda52a1fc21e 100644 --- a/clang/NOTES.txt +++ b/clang/NOTES.txt @@ -4,6 +4,8 @@ //===-===// +//TESTING git infra// + To time GCC preprocessing speed without output, use: "time gcc -MM file" This is similar to -Eonly. >From 7662d4f177d32c3159c1c48b11ce3884e4ea78c8 Mon Sep 17 00:00:00 2001 From: Shahid Iqbal Date: Fri, 17 Nov 2023 09:26:31 -0500 Subject: [PATCH 2/7] PR#72453 : Exceeding maximum file name length --- llvm/include/llvm/Analysis/DOTGraphTraitsPass.h | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h index 07c08bc1cc3bcb6..f78d8ff52ee3932 100644 --- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h +++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h @@ -17,6 +17,8 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/GraphWriter.h" +#define MAX_FILENAME_LEN 255 + namespace llvm { /// Default traits class for extracting a graph from an analysis pass. @@ -94,7 +96,7 @@ void printGraphForFunction(Function &F, GraphT Graph, StringRef Name, raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF); std::string GraphName = DOTGraphTraits::getGraphName(Graph); - if (!EC) + if (!EC && (Filename.length() <= MAX_FILENAME_LEN )) WriteGraph(File, Graph, IsSimple, GraphName + " for '" + F.getName() + "' function"); else @@ -280,7 +282,7 @@ class DOTGraphTraitsModulePrinterWrapperPass : public ModulePass { raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF); std::string Title = DOTGraphTraits::getGraphName(Graph); -if (!EC) +if (!EC && (Filename.length() <= MAX_FILENAME_LEN )) WriteGraph(File, Graph, IsSimple, Title); else errs() << " error opening file for writing!"; @@ -310,7 +312,7 @@ void WriteDOTGraphToFile(Function &F, GraphT &&Graph, std::string GraphName = DOTGraphTraits::getGraphName(Graph); std::string Title = GraphName + " for '" + F.getName().str() + "' function"; - if (!EC) + if (!EC && (Filename.length() <= MAX_FILENAME_LEN )) WriteGraph(File, Graph, IsSimple, Title); else errs() << " error opening file for writing!"; >From d3d33e5bfe907b761ecb9065fe45b698c3ce0672 Mon Sep 17 00:00:00 2001 From: Shahid Iqbal Date: Fri, 17 Nov 2023 09:48:43 -0500 Subject: [PATCH 3/7] Reverted the earlier test text --- clang/NOTES.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/clang/NOTES.txt b/clang/NOTES.txt index c83dda52a1fc21e..f06ea8c70cd3409 100644 --- a/clang/NOTES.txt +++ b/clang/NOTES.txt @@ -4,8 +4,6 @@ //===-===// -//TESTING git infra// - To time GCC preprocessing speed without output, use: "time gcc -MM file" This is similar to -Eonly. >From 41c19e2ceee80cce8a60d0fd869958a0783ddb7f Mon Sep 17 00:00:00 2001 From: Shahid Iqbal Date: Fri, 17 Nov 2023 10:06:52 -0500 Subject: [PATCH 4/7] Code refactoring --- llvm/include/llvm/Analysis/DOTGraphTraitsPass.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h index f78d8ff52ee3932..f7ab6df3b4dd819 100644 --- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h +++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h @@ -96,7 +96,7 @@ void printGraphForFunction(Function &F, GraphT Graph, StringRef Name, raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF); std::string GraphName = DOTGraphTraits::getGraphName(Graph); - if (!EC && (Filename.length() <= MAX_FILENAME_LEN )) + if (!EC && (Filename.length() <= MAX_FILENAME_LEN)) WriteGraph(File, Graph, IsSimple, GraphName + " for '" + F.getName() + "' function"); else @@ -282,7 +282,7 @@ class DOTGraphTraitsModulePrinterWrapperPass : public ModulePass { raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF); std::string Title = DOTGraphTraits::getGraphName(Graph); -if (!EC && (Filename.length() <= MAX_FILENAME_LEN )) +if (!EC && (Filename.length() <= MAX_FILENAME_LEN)) WriteGraph(File, Graph, IsSimple, Title); else errs() << " error opening file for writing!"; @@ -312,7 +312,7 @@ void WriteDOTGraphToFile(Function &F, GraphT &&Graph, std::string GraphName = DOTGraphTraits::getGraphName(Graph); std::string Title = GraphName + " for '" + F.getName().str() + "' function"; - if (!EC && (Filename.length()
[Lldb-commits] [lldb] [libcxx] [llvm] [clang] [compiler-rt] [libc] [clang-tools-extra] [flang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/jeanPerier edited https://github.com/llvm/llvm-project/pull/71222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [flang] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] [clang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/jeanPerier approved this pull request. Thanks, please add the POSIX macros to use ctime_r, and looks great otherwise. https://github.com/llvm/llvm-project/pull/71222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [compiler-rt] [libcxx] [clang-tools-extra] [lldb] [llvm] [clang] [flang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
@@ -10,9 +10,26 @@ // extensions that will eventually be implemented in Fortran. #include "flang/Runtime/extensions.h" +#include "terminator.h" #include "flang/Runtime/command.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/io-api.h" +#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad +#include + +#ifdef _WIN32 +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + int error = ctime_s(buffer, bufsize, &cur_time); + RUNTIME_CHECK(terminator, error == 0); +} +#else +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + const char *res = ctime_r(&cur_time, buffer); jeanPerier wrote: Isn't some POSIX macros required here to use ctime_r?: https://linux.die.net/man/3/ctime_r You can define a fallback that sets an empty string '/0'. https://github.com/llvm/llvm-project/pull/71222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [flang] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] [clang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
@@ -10,9 +10,26 @@ // extensions that will eventually be implemented in Fortran. #include "flang/Runtime/extensions.h" +#include "terminator.h" #include "flang/Runtime/command.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/io-api.h" +#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad +#include + +#ifdef _WIN32 +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + int error = ctime_s(buffer, bufsize, &cur_time); + RUNTIME_CHECK(terminator, error == 0); +} +#else +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + const char *res = ctime_r(&cur_time, buffer); yi-wu-arm wrote: Thanks, I added a `terminator.Crash()` in the `#else` case. https://github.com/llvm/llvm-project/pull/71222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [flang] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] [clang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/yi-wu-arm updated https://github.com/llvm/llvm-project/pull/71222 >From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001 From: Yi Wu Date: Mon, 6 Nov 2023 19:55:06 + Subject: [PATCH 1/7] FDATE extension implementation: get date and time in ctime format reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html usage: CHARACTER(32) :: time CALL fdate(time) WRITE(*,*) time --- flang/docs/Intrinsics.md | 2 +- flang/include/flang/Runtime/command.h| 5 + flang/include/flang/Runtime/extensions.h | 2 ++ flang/runtime/command.cpp| 28 flang/runtime/extensions.cpp | 5 + flang/unittests/Runtime/CommandTest.cpp | 14 6 files changed, 55 insertions(+), 1 deletion(-) diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md index ab0a940e53e5538..982be8208164296 100644 --- a/flang/docs/Intrinsics.md +++ b/flang/docs/Intrinsics.md @@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures listed above but the | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE | | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY| | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC | -| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, SYSTEM_CLOCK | +| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, SYSTEM_CLOCK | | Atomic intrinsic subroutines | ATOMIC_ADD | | Collective intrinsic subroutines | CO_REDUCE | diff --git a/flang/include/flang/Runtime/command.h b/flang/include/flang/Runtime/command.h index ec6289390545479..07f6d8e169ead6c 100644 --- a/flang/include/flang/Runtime/command.h +++ b/flang/include/flang/Runtime/command.h @@ -23,6 +23,11 @@ extern "C" { // integer kind. std::int32_t RTNAME(ArgumentCount)(); +// Try to get the the current date (same format as CTIME: convert to a string) +// Return a STATUS as described in the standard. +std::int32_t RTNAME(FDate)( +const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr); + // 16.9.82 GET_COMMAND // Try to get the value of the whole command. All of the parameters are // optional. diff --git a/flang/include/flang/Runtime/extensions.h b/flang/include/flang/Runtime/extensions.h index ad592814e5acb79..92b9907860121aa 100644 --- a/flang/include/flang/Runtime/extensions.h +++ b/flang/include/flang/Runtime/extensions.h @@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit); // GNU Fortran 77 compatibility function IARGC. std::int32_t FORTRAN_PROCEDURE_NAME(iargc)(); +void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length); + // GNU Fortran 77 compatibility subroutine GETARG(N, ARG). void FORTRAN_PROCEDURE_NAME(getarg)( std::int32_t &n, std::int8_t *arg, std::int64_t length); diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp index b81a0791c5e571b..da0803c39f49b6d 100644 --- a/flang/runtime/command.cpp +++ b/flang/runtime/command.cpp @@ -14,6 +14,7 @@ #include "flang/Runtime/descriptor.h" #include #include +#include namespace Fortran::runtime { std::int32_t RTNAME(ArgumentCount)() { @@ -125,6 +126,33 @@ static bool FitsInDescriptor( kind, terminator, value); } +void removeNewLine(char *str) { + char *newlinePos = strchr(str, '\n'); + if (newlinePos != NULL) { +*newlinePos = '\0'; // Replace with null terminator + } +} + +std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) { + FillWithSpaces(*value); + + time_t current_time; + time(¤t_time); + + char *time_string = ctime(¤t_time); + removeNewLine(time_string); + std::int64_t stringLen{StringLength(time_string)}; + if (stringLen <= 0) { +return ToErrmsg(errmsg, StatMissingArgument); + } + + if (value) { +return CopyToDescriptor(*value, time_string, stringLen, errmsg); + } + + return StatOk; +} + std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor *value, const Descriptor *length, const Descriptor *errmsg, const char *sourceFile, int line) { diff --git a/flang/run
[Lldb-commits] [lldb] [libcxx] [clang] [clang-tools-extra] [flang] [compiler-rt] [libc] [llvm] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
@@ -10,9 +10,26 @@ // extensions that will eventually be implemented in Fortran. #include "flang/Runtime/extensions.h" +#include "terminator.h" #include "flang/Runtime/command.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/io-api.h" +#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad +#include + +#ifdef _WIN32 +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + int error = ctime_s(buffer, bufsize, &cur_time); + RUNTIME_CHECK(terminator, error == 0); +} +#else +inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time, +Fortran::runtime::Terminator terminator) { + const char *res = ctime_r(&cur_time, buffer); jeanPerier wrote: LGTM, thanks https://github.com/llvm/llvm-project/pull/71222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [compiler-rt] [lldb] [libc] [flang] [clang-tools-extra] [clang] [llvm] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/yi-wu-arm updated https://github.com/llvm/llvm-project/pull/71222 >From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001 From: Yi Wu Date: Mon, 6 Nov 2023 19:55:06 + Subject: [PATCH 1/7] FDATE extension implementation: get date and time in ctime format reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html usage: CHARACTER(32) :: time CALL fdate(time) WRITE(*,*) time --- flang/docs/Intrinsics.md | 2 +- flang/include/flang/Runtime/command.h| 5 + flang/include/flang/Runtime/extensions.h | 2 ++ flang/runtime/command.cpp| 28 flang/runtime/extensions.cpp | 5 + flang/unittests/Runtime/CommandTest.cpp | 14 6 files changed, 55 insertions(+), 1 deletion(-) diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md index ab0a940e53e5538..982be8208164296 100644 --- a/flang/docs/Intrinsics.md +++ b/flang/docs/Intrinsics.md @@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures listed above but the | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE | | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY| | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC | -| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, SYSTEM_CLOCK | +| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, SYSTEM_CLOCK | | Atomic intrinsic subroutines | ATOMIC_ADD | | Collective intrinsic subroutines | CO_REDUCE | diff --git a/flang/include/flang/Runtime/command.h b/flang/include/flang/Runtime/command.h index ec6289390545479..07f6d8e169ead6c 100644 --- a/flang/include/flang/Runtime/command.h +++ b/flang/include/flang/Runtime/command.h @@ -23,6 +23,11 @@ extern "C" { // integer kind. std::int32_t RTNAME(ArgumentCount)(); +// Try to get the the current date (same format as CTIME: convert to a string) +// Return a STATUS as described in the standard. +std::int32_t RTNAME(FDate)( +const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr); + // 16.9.82 GET_COMMAND // Try to get the value of the whole command. All of the parameters are // optional. diff --git a/flang/include/flang/Runtime/extensions.h b/flang/include/flang/Runtime/extensions.h index ad592814e5acb79..92b9907860121aa 100644 --- a/flang/include/flang/Runtime/extensions.h +++ b/flang/include/flang/Runtime/extensions.h @@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit); // GNU Fortran 77 compatibility function IARGC. std::int32_t FORTRAN_PROCEDURE_NAME(iargc)(); +void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length); + // GNU Fortran 77 compatibility subroutine GETARG(N, ARG). void FORTRAN_PROCEDURE_NAME(getarg)( std::int32_t &n, std::int8_t *arg, std::int64_t length); diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp index b81a0791c5e571b..da0803c39f49b6d 100644 --- a/flang/runtime/command.cpp +++ b/flang/runtime/command.cpp @@ -14,6 +14,7 @@ #include "flang/Runtime/descriptor.h" #include #include +#include namespace Fortran::runtime { std::int32_t RTNAME(ArgumentCount)() { @@ -125,6 +126,33 @@ static bool FitsInDescriptor( kind, terminator, value); } +void removeNewLine(char *str) { + char *newlinePos = strchr(str, '\n'); + if (newlinePos != NULL) { +*newlinePos = '\0'; // Replace with null terminator + } +} + +std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) { + FillWithSpaces(*value); + + time_t current_time; + time(¤t_time); + + char *time_string = ctime(¤t_time); + removeNewLine(time_string); + std::int64_t stringLen{StringLength(time_string)}; + if (stringLen <= 0) { +return ToErrmsg(errmsg, StatMissingArgument); + } + + if (value) { +return CopyToDescriptor(*value, time_string, stringLen, errmsg); + } + + return StatOk; +} + std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor *value, const Descriptor *length, const Descriptor *errmsg, const char *sourceFile, int line) { diff --git a/flang/run
[Lldb-commits] [lldb] [llvm] Add support for parsing type unit entries in .debug_names. (PR #72952)
@@ -37,19 +37,29 @@ llvm::DenseSet DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { llvm::DenseSet result; for (const DebugNames::NameIndex &ni : debug_names) { -for (uint32_t cu = 0; cu < ni.getCUCount(); ++cu) +const uint32_t num_cus = ni.getCUCount(); +for (uint32_t cu = 0; cu < num_cus; ++cu) result.insert(ni.getCUOffset(cu)); +const uint32_t num_tus = ni.getLocalTUCount(); +for (uint32_t tu = 0; tu < num_tus; ++tu) + result.insert(ni.getLocalTUOffset(tu)); } return result; } std::optional DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { + // Look for a CU offset or a local TU offset as they are both offsets into + // the .debug_info section. std::optional cu_offset = entry.getCUOffset(); - if (!cu_offset) -return std::nullopt; + if (!cu_offset) { +cu_offset = entry.getLocalTUOffset(); jeffreytan81 wrote: I would rename `cu_offset` to `unit_offset` because it can either be CU or TU now. https://github.com/llvm/llvm-project/pull/72952 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] Add support for parsing type unit entries in .debug_names. (PR #72952)
@@ -621,7 +621,10 @@ std::optional DWARFDebugNames::Entry::getCUIndex() const { if (std::optional Off = lookup(dwarf::DW_IDX_compile_unit)) return Off->getAsUnsignedConstant(); // In a per-CU index, the entries without a DW_IDX_compile_unit attribute - // implicitly refer to the single CU. + // implicitly refer to the single CU, but only if we don't have a jeffreytan81 wrote: I wonder why do we really need this check? With this check, when there is no `DW_IDX_compile_unit` but `DW_IDX_type_unit` presents, `getCUIndex` will return `nullopt`. Per my understanding, this is split dwarf (per-CU index) + TU scenario which we should return `0` instead of `nulptr`, right? https://github.com/llvm/llvm-project/pull/72952 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] Add support for parsing type unit entries in .debug_names. (PR #72952)
@@ -37,19 +37,29 @@ llvm::DenseSet DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { llvm::DenseSet result; for (const DebugNames::NameIndex &ni : debug_names) { -for (uint32_t cu = 0; cu < ni.getCUCount(); ++cu) +const uint32_t num_cus = ni.getCUCount(); +for (uint32_t cu = 0; cu < num_cus; ++cu) result.insert(ni.getCUOffset(cu)); +const uint32_t num_tus = ni.getLocalTUCount(); +for (uint32_t tu = 0; tu < num_tus; ++tu) + result.insert(ni.getLocalTUOffset(tu)); } return result; } std::optional DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { + // Look for a CU offset or a local TU offset as they are both offsets into + // the .debug_info section. std::optional cu_offset = entry.getCUOffset(); - if (!cu_offset) -return std::nullopt; + if (!cu_offset) { +cu_offset = entry.getLocalTUOffset(); clayborg wrote: Good idea https://github.com/llvm/llvm-project/pull/72952 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] Add support for parsing type unit entries in .debug_names. (PR #72952)
@@ -621,7 +621,10 @@ std::optional DWARFDebugNames::Entry::getCUIndex() const { if (std::optional Off = lookup(dwarf::DW_IDX_compile_unit)) return Off->getAsUnsignedConstant(); // In a per-CU index, the entries without a DW_IDX_compile_unit attribute - // implicitly refer to the single CU. + // implicitly refer to the single CU, but only if we don't have a clayborg wrote: We only return 0 if this DebugName::Entry doesn't have a `DW_IDX_type_unit` and if there is no valid CU index from a `DW_IDX_compile_unit `. The code is correct. https://github.com/llvm/llvm-project/pull/72952 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage (PR #73028)
https://github.com/rupprecht created https://github.com/llvm/llvm-project/pull/73028 None >From a0805cfc2b2b1c84d58c0551ccf1acfaf2326a4a Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 21 Nov 2023 11:38:43 -0800 Subject: [PATCH] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage When switching to the standard `unittest` library, various unittests fail because we provide a "bugnumber" (a github issue/rdar link), but there is no longer a way to provide an xfail reason. See: https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.expectedFailure --- .../API/functionalities/jitloader_gdb/TestJITLoaderGDB.py | 2 +- .../API/functionalities/thread/state/TestThreadStates.py | 4 ++-- lldb/test/API/lang/c/shared_lib/TestSharedLib.py | 2 +- .../TestSharedLibStrippedSymbols.py | 2 +- lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py | 8 .../TestCppReferenceToOuterClass.py | 2 +- lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py index e93f566ea7ea63c..409dcf8e19d383b 100644 --- a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -13,7 +13,7 @@ class JITLoaderGDBTestCase(TestBase): lambda: "Skipped because the test crashes the test runner", bugnumber="llvm.org/pr24702", ) -@expectedFailure("llvm.org/pr24702") +@expectedFailure # llvm.org/pr24702 def test_bogus_values(self): """Test that we handle inferior misusing the GDB JIT interface""" self.build() diff --git a/lldb/test/API/functionalities/thread/state/TestThreadStates.py b/lldb/test/API/functionalities/thread/state/TestThreadStates.py index ad1edff6ae3f354..8e937d6c22a6758 100644 --- a/lldb/test/API/functionalities/thread/state/TestThreadStates.py +++ b/lldb/test/API/functionalities/thread/state/TestThreadStates.py @@ -40,14 +40,14 @@ def test_state_after_continue(self): @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660") @expectedFailureNetBSD # thread states not properly maintained -@expectedFailure("llvm.org/pr16712") +@expectedFailure # llvm.org/pr16712 def test_state_after_expression(self): """Test thread state after expression.""" self.build() self.thread_state_after_expression_test() # thread states not properly maintained -@expectedFailure("llvm.org/pr15824 and ") +@expectedFailure # llvm.org/pr15824 and @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly", diff --git a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py index b375aa6a86e14fb..39f5a144703763e 100644 --- a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py +++ b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py @@ -34,7 +34,7 @@ def test_expr_no_preload(self): """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled""" self.common_test_expr(False) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py index f7035edddaf09b8..5fd6cc1a3172f48 100644 --- a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py +++ b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py @@ -27,7 +27,7 @@ def test_expr(self): ) @expectedFailureAll(oslist=["windows"]) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py index f88667b9dfa2ae9..1803fdcd4d87956 100644 --- a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py +++ b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py @@ -40,7 +40,7 @@ def runToBkpt(self, command): ) @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 -@expectedFailure("CU-local objects incorrectly scoped") +@expectedFailure # CU-local objects incorrectly scoped def test_scope_lookup_with_
[Lldb-commits] [lldb] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage (PR #73028)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jordan Rupprecht (rupprecht) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/73028.diff 7 Files Affected: - (modified) lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py (+1-1) - (modified) lldb/test/API/functionalities/thread/state/TestThreadStates.py (+2-2) - (modified) lldb/test/API/lang/c/shared_lib/TestSharedLib.py (+1-1) - (modified) lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py (+1-1) - (modified) lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py (+4-4) - (modified) lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py (+1-1) - (modified) lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py (+1-1) ``diff diff --git a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py index e93f566ea7ea63c..409dcf8e19d383b 100644 --- a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -13,7 +13,7 @@ class JITLoaderGDBTestCase(TestBase): lambda: "Skipped because the test crashes the test runner", bugnumber="llvm.org/pr24702", ) -@expectedFailure("llvm.org/pr24702") +@expectedFailure # llvm.org/pr24702 def test_bogus_values(self): """Test that we handle inferior misusing the GDB JIT interface""" self.build() diff --git a/lldb/test/API/functionalities/thread/state/TestThreadStates.py b/lldb/test/API/functionalities/thread/state/TestThreadStates.py index ad1edff6ae3f354..8e937d6c22a6758 100644 --- a/lldb/test/API/functionalities/thread/state/TestThreadStates.py +++ b/lldb/test/API/functionalities/thread/state/TestThreadStates.py @@ -40,14 +40,14 @@ def test_state_after_continue(self): @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660") @expectedFailureNetBSD # thread states not properly maintained -@expectedFailure("llvm.org/pr16712") +@expectedFailure # llvm.org/pr16712 def test_state_after_expression(self): """Test thread state after expression.""" self.build() self.thread_state_after_expression_test() # thread states not properly maintained -@expectedFailure("llvm.org/pr15824 and ") +@expectedFailure # llvm.org/pr15824 and @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly", diff --git a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py index b375aa6a86e14fb..39f5a144703763e 100644 --- a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py +++ b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py @@ -34,7 +34,7 @@ def test_expr_no_preload(self): """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled""" self.common_test_expr(False) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py index f7035edddaf09b8..5fd6cc1a3172f48 100644 --- a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py +++ b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py @@ -27,7 +27,7 @@ def test_expr(self): ) @expectedFailureAll(oslist=["windows"]) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py index f88667b9dfa2ae9..1803fdcd4d87956 100644 --- a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py +++ b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py @@ -40,7 +40,7 @@ def runToBkpt(self, command): ) @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 -@expectedFailure("CU-local objects incorrectly scoped") +@expectedFailure # CU-local objects incorrectly scoped def test_scope_lookup_with_run_command_globals(self): """Test scope lookup of functions in lldb.""" self.build() @@ -210,7 +210,7 @@ def test_scope_lookup_with_run_command(self): # Evaluate B::func() - should call B::func() self.expect_expr("B::func()", result_type="int", result_value="4") -@expectedFailure("lldb
[Lldb-commits] [lldb] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage (PR #73028)
rupprecht wrote: This cleanup isn't strictly required to proceed w/ unittest2->unittest; we already have a wrapper in decorators.py that we could update, from: ```py def expectedFailure(func): return unittest2.expectedFailure(func) ``` To: ```py def expectedFailure(func): if callable(func): return unittest.expectedFailure(func) return unittest.expectedFailure ``` IMHO, better to just start dropping the reason field to be more uniform; one should not have to decipher whether `@expectedFailure` is referring to the version in `unittest` or `decorators`. https://github.com/llvm/llvm-project/pull/73028 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [clang] [openmp] [llvm] [libcxx] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/70667 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] Add support for parsing type unit entries in .debug_names. (PR #72952)
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/72952 >From 749bf924a0a18493f2e1035b43b536100507bd31 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 20 Nov 2023 20:33:22 -0800 Subject: [PATCH 1/2] Add support for parsing type unit entries in .debug_names. This is a follow up patch after .debug_names can now emit local type unit entries when we compile with type units + DWARF5 + .debug_names. The pull request that added this functionality was: https://github.com/llvm/llvm-project/pull/70515 This patch makes sure that the DebugNamesDWARFIndex in LLDB will not manually need to parse type units if they have a valid index. It also fixes the index to be able to correctly extract name entries that reference type unit DIEs. Added a test to verify things work as expected. --- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 18 +-- .../DWARF/x86/debug-types-debug-names.cpp | 48 +++ .../DebugInfo/DWARF/DWARFAcceleratorTable.h | 19 +++- .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 18 ++- 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-debug-names.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 4fc3866a3b608fd..62c5417191a124d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -37,19 +37,29 @@ llvm::DenseSet DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { llvm::DenseSet result; for (const DebugNames::NameIndex &ni : debug_names) { -for (uint32_t cu = 0; cu < ni.getCUCount(); ++cu) +const uint32_t num_cus = ni.getCUCount(); +for (uint32_t cu = 0; cu < num_cus; ++cu) result.insert(ni.getCUOffset(cu)); +const uint32_t num_tus = ni.getLocalTUCount(); +for (uint32_t tu = 0; tu < num_tus; ++tu) + result.insert(ni.getLocalTUOffset(tu)); } return result; } std::optional DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { + // Look for a CU offset or a local TU offset as they are both offsets into + // the .debug_info section. std::optional cu_offset = entry.getCUOffset(); - if (!cu_offset) -return std::nullopt; + if (!cu_offset) { +cu_offset = entry.getLocalTUOffset(); +if (!cu_offset) + return std::nullopt; + } - DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset); + DWARFUnit *cu = + m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset); if (!cu) return std::nullopt; diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-debug-names.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-debug-names.cpp new file mode 100644 index 000..2b7a928c89a8f71 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-debug-names.cpp @@ -0,0 +1,48 @@ +// Test that we can use .debug_names to lookup a type that is only referenced +// from within a type unit. In the code below the type named "stype" is only +// referenced within the type unit itself and when we enable .debug_names, we +// expect the have an entry for this and to be able to find this type when +// we do a lookup. + +// REQUIRES: lld + +// RUN: %clang %s -target x86_64-pc-linux -gdwarf-5 -fdebug-types-section \ +// RUN: -gpubnames -fno-limit-debug-info -c -o %t.o +// RUN: ld.lld %t.o -o %t +// RUN: %lldb %t -o "type lookup stype" -b | FileCheck %s --check-prefix=BASE +// RUN: %lldb %t -o "type lookup bar::stype" -b | FileCheck %s --check-prefix=PART +// RUN: %lldb %t -o "type lookup foo::bar::stype" -b | FileCheck %s --check-prefix=FULL + +// BASE: (lldb) type lookup stype +// BASE-NEXT: int + +// PART: (lldb) type lookup bar::stype +// PART-NEXT: int + +// FULL: (lldb) type lookup foo::bar::stype +// FULL-NEXT: int + +namespace foo { +class bar { +public: + typedef unsigned utype; + // This type is only referenced from within the type unit and we need to + // make sure we can find it with the new type unit support in .debug_names. + typedef int stype; + +private: + utype m_unsigned; + +public: + bar(utype u) : m_unsigned(u) {} + + utype get() const { return m_unsigned; } + void set(utype u) { m_unsigned = u; } + stype gets() const { return (stype)m_unsigned; } +}; +} // namespace foo + +int main() { + foo::bar b(12); + return 0; +} diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index 1ba555a061904cc..b89536bc0c7230c 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -56,6 +56,14 @@ class DWARFAcceleratorTable { /// recorded in this Accelerator Entry. virtual std::optional getCUOffset() const = 0; +/// Returns the Offset o
[Lldb-commits] [lldb] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)
https://github.com/rupprecht created https://github.com/llvm/llvm-project/pull/73067 The @expectedFailureAll and @skipIf decorators will mark the test case as xfail/skip if _all_ conditions passed in match, including debug_info. * If debug_info is not one of the matching conditions, we can immediately evaluate the check and decide if it should be decorated. * If debug_info *is* present as a match condition, we need to defer whether or not to decorate until when the `LLDBTestCaseFactory` metaclass expands the test case into its potential variants. This is still early enough that the standard `unittest` framework will recognize the test as xfail/skip by the time the test actually runs. TestDecorators exhibits the edge cases more thoroughly. With the exception of `@expectedFailureIf` (added by this commit), all those test cases pass prior to this commit. This is a followup to 212a60ec37322f853e91e171b305479b1abff2f2. >From 22bfc5878f1f96b3138a03eea4dc856948185c89 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 21 Nov 2023 17:28:30 -0800 Subject: [PATCH] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests The @expectedFailureAll and @skipIf decorators will mark the test case as xfail/skip if _all_ conditions passed in match, including debug_info. * If debug_info is not one of the matching conditions, we can immediately evaluate the check and decide if it should be decorated. * If debug_info *is* present as a match condition, we need to defer whether or not to decorate until when the `LLDBTestCaseFactory` metaclass expands the test case into its potential variants. This is still early enough that the standard `unittest` framework will recognize the test as xfail/skip by the time the test actually runs. TestDecorators exhibits the edge cases more thoroughly. With the exception of `@expectedFailureIf` (added by this commit), all those test cases pass prior to this commit. This is a followup to 212a60ec37322f853e91e171b305479b1abff2f2. --- .../Python/lldbsuite/test/decorators.py | 53 - .../Python/lldbsuite/test/lldbtest.py | 20 lldb/test/API/test_utils/TestDecorators.py| 110 +- 3 files changed, 177 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index bb06a5ee20f2532..2398892b9e14814 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -117,6 +117,21 @@ def expectedFailure(func): return unittest2.expectedFailure(func) +def expectedFailureIf(condition, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +if condition: +return expectedFailure(func) +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + def expectedFailureIfFn(expected_fn, bugnumber=None): def expectedFailure_impl(func): if isinstance(func, type) and issubclass(func, unittest2.TestCase): @@ -178,6 +193,34 @@ def wrapper(*args, **kwargs): return skipTestIfFn_impl +def _xfailForDebugInfo(expected_fn, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__xfail_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + +def _skipForDebugInfo(expected_fn, bugnumber=None): +def skipImpl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__skip_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return skipImpl(bugnumber) +else: +return skipImpl + + def _decorateTest( mode, bugnumber=None, @@ -195,7 +238,7 @@ def _decorateTest( dwarf_version=None, setting=None, ): -def fn(self): +def fn(actual_debug_info=None): skip_for_os = _match_decorator_property( lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) @@ -208,7 +251,7 @@ def fn(self): skip_for_arch = _match_decorator_property( archs, lldbplatformutil.getArchitecture() ) -skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) +skip_for_debug_info = _match_decorator_property(debug_info, actual_debug_info) skip_for_triple = _match_decorator_property(
[Lldb-commits] [lldb] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jordan Rupprecht (rupprecht) Changes The @expectedFailureAll and @skipIf decorators will mark the test case as xfail/skip if _all_ conditions passed in match, including debug_info. * If debug_info is not one of the matching conditions, we can immediately evaluate the check and decide if it should be decorated. * If debug_info *is* present as a match condition, we need to defer whether or not to decorate until when the `LLDBTestCaseFactory` metaclass expands the test case into its potential variants. This is still early enough that the standard `unittest` framework will recognize the test as xfail/skip by the time the test actually runs. TestDecorators exhibits the edge cases more thoroughly. With the exception of `@expectedFailureIf` (added by this commit), all those test cases pass prior to this commit. This is a followup to 212a60ec37322f853e91e171b305479b1abff2f2. --- Full diff: https://github.com/llvm/llvm-project/pull/73067.diff 3 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+50-3) - (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+20) - (modified) lldb/test/API/test_utils/TestDecorators.py (+107-3) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index bb06a5ee20f2532..2398892b9e14814 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -117,6 +117,21 @@ def expectedFailure(func): return unittest2.expectedFailure(func) +def expectedFailureIf(condition, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +if condition: +return expectedFailure(func) +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + def expectedFailureIfFn(expected_fn, bugnumber=None): def expectedFailure_impl(func): if isinstance(func, type) and issubclass(func, unittest2.TestCase): @@ -178,6 +193,34 @@ def wrapper(*args, **kwargs): return skipTestIfFn_impl +def _xfailForDebugInfo(expected_fn, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__xfail_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + +def _skipForDebugInfo(expected_fn, bugnumber=None): +def skipImpl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__skip_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return skipImpl(bugnumber) +else: +return skipImpl + + def _decorateTest( mode, bugnumber=None, @@ -195,7 +238,7 @@ def _decorateTest( dwarf_version=None, setting=None, ): -def fn(self): +def fn(actual_debug_info=None): skip_for_os = _match_decorator_property( lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) @@ -208,7 +251,7 @@ def fn(self): skip_for_arch = _match_decorator_property( archs, lldbplatformutil.getArchitecture() ) -skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) +skip_for_debug_info = _match_decorator_property(debug_info, actual_debug_info) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() ) @@ -283,9 +326,13 @@ def fn(self): return reason_str if mode == DecorateMode.Skip: +if debug_info: +return _skipForDebugInfo(fn, bugnumber) return skipTestIfFn(fn, bugnumber) elif mode == DecorateMode.Xfail: -return expectedFailureIfFn(fn, bugnumber) +if debug_info: +return _xfailForDebugInfo(fn, bugnumber) +return expectedFailureIf(fn(), bugnumber) else: return None diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index dc4e322c675dc9d..872866655093d21 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1667,6 +1667,11 @@ def __new__(cls, name, bases, attrs): if original_testcase.NO_DEBUG_INFO_TESTCASE: return original_testcase +# Default implementation for skip/xfail reason based
[Lldb-commits] [lldb] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 33277a3e80aedd1a6877524feadfbcb41a88..22bfc5878f1f96b3138a03eea4dc856948185c89 lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/test_utils/TestDecorators.py `` View the diff from darker here. ``diff --- packages/Python/lldbsuite/test/lldbtest.py 2023-11-22 01:28:30.00 + +++ packages/Python/lldbsuite/test/lldbtest.py 2023-11-22 01:51:52.620205 + @@ -1710,11 +1710,13 @@ test_method.__name__ = method_name test_method.debug_info = cat xfail_reason = xfail_for_debug_info_cat_fn(cat) if xfail_reason: -test_method = unittest2.expectedFailure(xfail_reason)(test_method) +test_method = unittest2.expectedFailure(xfail_reason)( +test_method +) skip_reason = skip_for_debug_info_cat_fn(cat) if skip_reason: test_method = unittest2.skip(skip_reason)(test_method) `` https://github.com/llvm/llvm-project/pull/73067 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/73067 >From 22bfc5878f1f96b3138a03eea4dc856948185c89 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 21 Nov 2023 17:28:30 -0800 Subject: [PATCH 1/2] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests The @expectedFailureAll and @skipIf decorators will mark the test case as xfail/skip if _all_ conditions passed in match, including debug_info. * If debug_info is not one of the matching conditions, we can immediately evaluate the check and decide if it should be decorated. * If debug_info *is* present as a match condition, we need to defer whether or not to decorate until when the `LLDBTestCaseFactory` metaclass expands the test case into its potential variants. This is still early enough that the standard `unittest` framework will recognize the test as xfail/skip by the time the test actually runs. TestDecorators exhibits the edge cases more thoroughly. With the exception of `@expectedFailureIf` (added by this commit), all those test cases pass prior to this commit. This is a followup to 212a60ec37322f853e91e171b305479b1abff2f2. --- .../Python/lldbsuite/test/decorators.py | 53 - .../Python/lldbsuite/test/lldbtest.py | 20 lldb/test/API/test_utils/TestDecorators.py| 110 +- 3 files changed, 177 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index bb06a5ee20f2532..2398892b9e14814 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -117,6 +117,21 @@ def expectedFailure(func): return unittest2.expectedFailure(func) +def expectedFailureIf(condition, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +if condition: +return expectedFailure(func) +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + def expectedFailureIfFn(expected_fn, bugnumber=None): def expectedFailure_impl(func): if isinstance(func, type) and issubclass(func, unittest2.TestCase): @@ -178,6 +193,34 @@ def wrapper(*args, **kwargs): return skipTestIfFn_impl +def _xfailForDebugInfo(expected_fn, bugnumber=None): +def expectedFailure_impl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__xfail_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return expectedFailure_impl(bugnumber) +else: +return expectedFailure_impl + + +def _skipForDebugInfo(expected_fn, bugnumber=None): +def skipImpl(func): +if isinstance(func, type) and issubclass(func, unittest2.TestCase): +raise Exception("Decorator can only be used to decorate a test method") + +func.__skip_for_debug_info_cat_fn__ = expected_fn +return func + +if callable(bugnumber): +return skipImpl(bugnumber) +else: +return skipImpl + + def _decorateTest( mode, bugnumber=None, @@ -195,7 +238,7 @@ def _decorateTest( dwarf_version=None, setting=None, ): -def fn(self): +def fn(actual_debug_info=None): skip_for_os = _match_decorator_property( lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) @@ -208,7 +251,7 @@ def fn(self): skip_for_arch = _match_decorator_property( archs, lldbplatformutil.getArchitecture() ) -skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) +skip_for_debug_info = _match_decorator_property(debug_info, actual_debug_info) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() ) @@ -283,9 +326,13 @@ def fn(self): return reason_str if mode == DecorateMode.Skip: +if debug_info: +return _skipForDebugInfo(fn, bugnumber) return skipTestIfFn(fn, bugnumber) elif mode == DecorateMode.Xfail: -return expectedFailureIfFn(fn, bugnumber) +if debug_info: +return _xfailForDebugInfo(fn, bugnumber) +return expectedFailureIf(fn(), bugnumber) else: return None diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index dc4e322c675dc9d..872866655093d21 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1667,6 +1667,11 @@ def __new__(cls, name, bases, attrs
[Lldb-commits] [lldb] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage (PR #73028)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/73028 >From a0805cfc2b2b1c84d58c0551ccf1acfaf2326a4a Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 21 Nov 2023 11:38:43 -0800 Subject: [PATCH 1/2] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage When switching to the standard `unittest` library, various unittests fail because we provide a "bugnumber" (a github issue/rdar link), but there is no longer a way to provide an xfail reason. See: https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.expectedFailure --- .../API/functionalities/jitloader_gdb/TestJITLoaderGDB.py | 2 +- .../API/functionalities/thread/state/TestThreadStates.py | 4 ++-- lldb/test/API/lang/c/shared_lib/TestSharedLib.py | 2 +- .../TestSharedLibStrippedSymbols.py | 2 +- lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py | 8 .../TestCppReferenceToOuterClass.py | 2 +- lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py index e93f566ea7ea63c..409dcf8e19d383b 100644 --- a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -13,7 +13,7 @@ class JITLoaderGDBTestCase(TestBase): lambda: "Skipped because the test crashes the test runner", bugnumber="llvm.org/pr24702", ) -@expectedFailure("llvm.org/pr24702") +@expectedFailure # llvm.org/pr24702 def test_bogus_values(self): """Test that we handle inferior misusing the GDB JIT interface""" self.build() diff --git a/lldb/test/API/functionalities/thread/state/TestThreadStates.py b/lldb/test/API/functionalities/thread/state/TestThreadStates.py index ad1edff6ae3f354..8e937d6c22a6758 100644 --- a/lldb/test/API/functionalities/thread/state/TestThreadStates.py +++ b/lldb/test/API/functionalities/thread/state/TestThreadStates.py @@ -40,14 +40,14 @@ def test_state_after_continue(self): @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660") @expectedFailureNetBSD # thread states not properly maintained -@expectedFailure("llvm.org/pr16712") +@expectedFailure # llvm.org/pr16712 def test_state_after_expression(self): """Test thread state after expression.""" self.build() self.thread_state_after_expression_test() # thread states not properly maintained -@expectedFailure("llvm.org/pr15824 and ") +@expectedFailure # llvm.org/pr15824 and @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly", diff --git a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py index b375aa6a86e14fb..39f5a144703763e 100644 --- a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py +++ b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py @@ -34,7 +34,7 @@ def test_expr_no_preload(self): """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled""" self.common_test_expr(False) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py index f7035edddaf09b8..5fd6cc1a3172f48 100644 --- a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py +++ b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py @@ -27,7 +27,7 @@ def test_expr(self): ) @expectedFailureAll(oslist=["windows"]) -@expectedFailure("llvm.org/PR36712") +@expectedFailure # llvm.org/PR36712 def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py index f88667b9dfa2ae9..1803fdcd4d87956 100644 --- a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py +++ b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py @@ -40,7 +40,7 @@ def runToBkpt(self, command): ) @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 -@expectedFailure("CU-local objects incorrectly scoped") +@expectedFailure # CU-local objects incorrectly scoped def test_scope_lookup_with_ru