Re: [Lldb-commits] [RFC] Type lookup for template types is broken...
> Anyway, the issue is that the PS4 targets don't emit DW_AT_linkage_name > attributes in the debug info, but we are still emitting an index entry > with > the mangled names. This caused the verifier to complain. > > Two interesting questions follow from this: > 1. (mainly for Paul, I guess) Should we fix the debug_names generator to > not emit the linkage name index entry for PS4 targets? I think there's a flag controlling this which is not the triple, but yes if the DIEs don't have linkage names then I think the index also shouldn't. > > 2. (for everyone) Is this verifier check actually valid? This depending on > the interpretation of the last (non-normative) paragraph of Section > 6.1.1.1 > (*). One way of reading it is that a producer is allowed to insert > additional entries into the name index. Another would be that we can also > insert additional names for existing entries. This is interesting here > because this is exactly what the the template stripping proposal would do > (add extra names to existing entries). If we don't remove that check, it > will cause the verifier to complain again. > > regards > pavel > > (*) The intent of the above rules is to provide the consumer with some > assurance that looking up an unqualified name in the index will yield all > relevant debugging information entries that provide a defining declaration > at global scope for that name. A producer may choose to implement > additional rules for what names are placed in the index, and may > communicate those rules to a cooperating consumer via an augmentation > string, described below. I read it as, if we emit additional entries, we should emit an augmentation string that says so. If the augmentation is superseded by a spec change in DWARF 6, I'm sure everybody can accommodate that too. --paulr ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit
> -Original Message- > From: llvm-commits [mailto:llvm-commits-boun...@lists.llvm.org] On Behalf > Of Jan Kratochvil via llvm-commits > Sent: Friday, April 06, 2018 5:29 PM > To: Greg Clayton > Cc: reviews+d45170+public+e75ed5903a857...@reviews.llvm.org; Jason > Molenda; lldb-commits@lists.llvm.org; llvm-commits; Davide Italiano > Subject: Re: [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in > preparation for adding DWARFTypeUnit > > On Fri, 06 Apr 2018 22:52:05 +0200, Greg Clayton wrote: > > Switching over to the LLVM parser will require some detailed work and > will > > take some time. > > So should I continue pushing the DWZ patchset even before the reuse of > LLVM > DWARFUnit happens? > > > > That being said, I am confused as to why this was reverted. The code I > added > > mirrors the LLVM code a bit better, and yes it will require some > reworking > > of your patches. > > Planned DWARFPartialUnit needs the inheritance as it was. As you have > moved > most of the data fields back to DWARFUnit I will need to create some new > superclass DWARFSomeNameUnit and move back the data fields from DWARFUnit > to > DWARFSomeNameUnit to get: > DWARFUnit->DWARFSomeNameUnit->DWARFCompileUnit > DWARFUnit->DWARFSomeNameUnit->DWARFTypeUnit > DWARFUnit->DWARFPartialUnit I have to say I am a little surprised by this hierarchy. I would have thought type units and partial units would be more alike. Type units are imported by signature not reference but otherwise I'd think they would have a lot in common: lumps of DWARF that aren't their own compilation unit. --paulr > > If you expected my DWARFUnit will serve as a superclass for > DWARFCompileUnit+DWARFTypeUnit then you should not have approved it the > way I > wrote it as my goal was DWARFPartialUnit which has very different > inheritance > requirements than DWARFTypeUnit. > > > > The DWARFUnit having an accessor to give out > > a DWARFCompileUnit was really confusing and not the right layering. > > This is how DWARFPartialUnit works, it is only a DWARFCompileUnit remapped > to > new offset. I do not see how to implement it transparently without the > accessor (and without needlessly copying all the data fields many times > into > each DWARFPartialUnit instance). > > > > So I fixed the layering. I need to submit .debug_types patches and that > > patch was needed for this and now I am back to square one. > > I will sure deal with your reverting of my revert. I just do not like the > words "fixes the layering" as it rather "changes the layering" for > different > purposes than my DWARFUnit was implemented for. > > > Jan > ___ > llvm-commits mailing list > llvm-comm...@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [RFC] Type lookup for template types is broken...
> -Original Message- > From: lldb-commits [mailto:lldb-commits-boun...@lists.llvm.org] On Behalf > Of Pavel Labath via lldb-commits > Sent: Tuesday, May 08, 2018 10:48 AM > To: fr...@apple.com > Cc: lldb-commits@lists.llvm.org > Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is > broken... > > Well.. it encodes some assumptions about how a class name looks like, > which > are probably valid for C++, but they don't have to hold for any language > frontend LLVM supports. That said, I am not saying this is worth the > trouble of adding a special "these are the additional names you are to > insert into the index" channel that clang should use to communicate this > (I > wouldn't be surprised if we make even stronger assumptions elsewhere). I > was just curious about what your thoughts here were. If you add an accelerator entry for "C" what does it point to? All the instantiations of "C"? The DWARF does not describe the template, only the concrete instances. --paulr > On Tue, 8 May 2018 at 15:29, Frédéric Riss wrote: > > > > > On May 8, 2018, at 2:23 AM, Pavel Labath wrote: > > > I am still building a picture for myself of how the accelerator tables > and > > our name lookup works, but from what I managed to learn so far, adding > an > > accelerator for "C" seems like a useful thing to do. However, this does > go > > beyond what the DWARF 5 spec says we should do (we are only required to > add > > the DW_AT_name string). We are still free to add any extra entries we > like, > > but if we're going to be relying on this, we should try to get some of > this > > into the next version of the spec. > > > > On Mon, 7 May 2018 at 22:19, Frédéric Riss via lldb-commits < > > lldb-commits@lists.llvm.org> wrote: > > > (...At least when using accelerator tables) > > > > If you apply the following patch, TestClassTemplateParameterPack.py will > > > start failing: > > > diff --git > > > a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- > pack/main.cpp > > b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- > pack/main.cpp > > > index 90e63b40f..304872a15 100644 > > --- > > > a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- > pack/main.cpp > > > +++ > > > b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- > pack/main.cpp > > > @@ -37,7 +37,7 @@ template <> struct D : D { > > > > > > int main (int argc, char const *argv[]) > > { > > -C myC; > > +C myC; //% self.runCmd("settings set > > > target.experimental.inject-local-vars false") > > > C myLesserC; > > myC.member = 64; > > (void)C().isSixteenThirtyTwo(); > > > > The test does things like invoke methods on temporary template objects: > > //% self.expect("expression -- C().isSixteenThirtyTwo()", > > > DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) > > > The above expression currently works because there’s a local of type > > > C. With injected locals, the type is made readily available to > > Clang. No type lookup is required for this to work in this setup. > > > If you stop injecting locals, the test fails. We don’t provide the > > > information to Clang to understand what C is. The reason is that when > Clang > > parses “C”, it is going to ask about “C”, not the fully > templated > > name. Our accelerator tables contain references to the full names, but > not > > to C alone and we never find it. If I change Clang and dsymutil to add > an > > accelerator for “C” each time an instance of C is seen then it nearly > > works. I just need this additional lldb patch: > > > diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp > > index 2838039ad..d2f2026bf 100644 > > --- a/source/Symbol/TypeMap.cpp > > +++ b/source/Symbol/TypeMap.cpp > > @@ -227,8 +227,11 @@ void TypeMap::RemoveMismatchedTypes(const > > > std::string &type_scope, > > > } else { > > // The type we are currently looking at doesn't exists in a > > > namespace > > > // or class, so it only matches if there is no type scope... > > -keep_match = > > -type_scope.empty() && > type_basename.compare(match_type_name) > > > == 0; > > > +if (type_scope.empty()) { > > + keep_match = type_basename.compare(match
Re: [Lldb-commits] [RFC] Type lookup for template types is broken...
So…. if the name in the type entry did not include the then the indexing would automatically do what you want; you would need to reconstruct the from the template parameter children of the DIE. Would that help? On the LLVM side we have debated the merits of in the name back and forth. I would have to investigate the current state of the world; I know that for PS4 we prefer to have the children and not put in the name, while others prefer it the other way around. If LLDB came out preferring not to have a decorated name, it should not be hard to accommodate that in Clang. Not sure where gcc/gdb stand on this point. --paulr From: fr...@apple.com [mailto:fr...@apple.com] Sent: Tuesday, May 08, 2018 12:07 PM To: Greg Clayton Cc: Robinson, Paul; lldb-commits@lists.llvm.org Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is broken... On May 8, 2018, at 9:04 AM, Greg Clayton mailto:clayb...@gmail.com>> wrote: The only way for us to find all classes whose type is "C" is to add the entry for all template classes named "C", so I would vote to add them as it is accurate. Do we currently add one for "C<12, 16>”? Yes we do, not sure it is actually useful. Fred Greg On May 8, 2018, at 8:58 AM, Frédéric Riss via lldb-commits mailto:lldb-commits@lists.llvm.org>> wrote: On May 8, 2018, at 8:30 AM, paul.robin...@sony.com<mailto:paul.robin...@sony.com> wrote: -Original Message- From: lldb-commits [mailto:lldb-commits-boun...@lists.llvm.org] On Behalf Of Pavel Labath via lldb-commits Sent: Tuesday, May 08, 2018 10:48 AM To: fr...@apple.com<mailto:fr...@apple.com> Cc: lldb-commits@lists.llvm.org<mailto:lldb-commits@lists.llvm.org> Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is broken... Well.. it encodes some assumptions about how a class name looks like, which are probably valid for C++, but they don't have to hold for any language frontend LLVM supports. That said, I am not saying this is worth the trouble of adding a special "these are the additional names you are to insert into the index" channel that clang should use to communicate this (I wouldn't be surprised if we make even stronger assumptions elsewhere). I was just curious about what your thoughts here were. If you add an accelerator entry for "C" what does it point to? All the instantiations of "C"? The DWARF does not describe the template, only the concrete instances. Yes, there would be a “C” entry for every instantiation of C. Fred --paulr On Tue, 8 May 2018 at 15:29, Frédéric Riss mailto:fr...@apple.com>> wrote: On May 8, 2018, at 2:23 AM, Pavel Labath mailto:lab...@google.com>> wrote: I am still building a picture for myself of how the accelerator tables and our name lookup works, but from what I managed to learn so far, adding an accelerator for "C" seems like a useful thing to do. However, this does go beyond what the DWARF 5 spec says we should do (we are only required to add the DW_AT_name string). We are still free to add any extra entries we like, but if we're going to be relying on this, we should try to get some of this into the next version of the spec. On Mon, 7 May 2018 at 22:19, Frédéric Riss via lldb-commits < lldb-commits@lists.llvm.org<mailto:lldb-commits@lists.llvm.org>> wrote: (...At least when using accelerator tables) If you apply the following patch, TestClassTemplateParameterPack.py will start failing: diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- pack/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- pack/main.cpp index 90e63b40f..304872a15 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- pack/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter- pack/main.cpp @@ -37,7 +37,7 @@ template <> struct D : D { int main (int argc, char const *argv[]) { -C myC; +C myC; //% self.runCmd("settings set target.experimental.inject-local-vars false") C myLesserC; myC.member = 64; (void)C().isSixteenThirtyTwo(); The test does things like invoke methods on temporary template objects: //% self.expect("expression -- C().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) The above expression currently works because there’s a local of type C. With injected locals, the type is made readily available to Clang. No type lookup is required for this to work in this setup. If you stop injecting locals, the test fails. We don’t provide the information to Clang to understand what C is. The reason is that when Clang parses “C”, it is going to ask about “C”, not the fully templated name. Our accelerator tables contain references to the full names, but not to C alone and
Re: [Lldb-commits] [RFC] Type lookup for template types is broken...
Clang can control the emission of or not in the name, using the "debugger tuning" feature. It sounds like neither LLDB nor PS4 will mind losing the in the name, and it makes the indexing simpler. If the tuning is set for GDB then we can still emit the in the names. It would make me uncomfortable to have the index and the actual DWARF be inconsistent, but given the way templates work in general (a variety of spellings all refer to the same type) it is probably better to use the un-decorated name in the index even if the DWARF itself used decorated names. This should probably be proposed as a revision for DWARF 6. --paulr From: Greg Clayton [mailto:clayb...@gmail.com] Sent: Tuesday, May 08, 2018 12:25 PM To: Robinson, Paul Cc: fr...@apple.com; lldb-commits@lists.llvm.org Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is broken... I think for display purposes, the type name should include all of the . If I have two variables, both using class C, but both have different template parameters, I want to see that in the class name and have that properly show up in the variable view. LLDB doesn't actually care about the name that is in the DWARF because we will show the type name by grabbing it from the lldb_private::CompilerType which will end up being correct. Other debuggers might just display "C" if that is what is in the DWARF. So I would caution against just putting the type basename without params in the DWARF itself. Greg On May 8, 2018, at 9:12 AM, mailto:paul.robin...@sony.com>> mailto:paul.robin...@sony.com>> wrote: So…. if the name in the type entry did not include the then the indexing would automatically do what you want; you would need to reconstruct the from the template parameter children of the DIE. Would that help? On the LLVM side we have debated the merits of in the name back and forth. I would have to investigate the current state of the world; I know that for PS4 we prefer to have the children and not put in the name, while others prefer it the other way around. If LLDB came out preferring not to have a decorated name, it should not be hard to accommodate that in Clang. Not sure where gcc/gdb stand on this point. --paulr From: fr...@apple.com<mailto:fr...@apple.com> [mailto:fr...@apple.com] Sent: Tuesday, May 08, 2018 12:07 PM To: Greg Clayton Cc: Robinson, Paul; lldb-commits@lists.llvm.org<mailto:lldb-commits@lists.llvm.org> Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is broken... On May 8, 2018, at 9:04 AM, Greg Clayton mailto:clayb...@gmail.com>> wrote: The only way for us to find all classes whose type is "C" is to add the entry for all template classes named "C", so I would vote to add them as it is accurate. Do we currently add one for "C<12, 16>”? Yes we do, not sure it is actually useful. Fred Greg On May 8, 2018, at 8:58 AM, Frédéric Riss via lldb-commits mailto:lldb-commits@lists.llvm.org>> wrote: On May 8, 2018, at 8:30 AM, paul.robin...@sony.com<mailto:paul.robin...@sony.com> wrote: -Original Message----- From: lldb-commits [mailto:lldb-commits-boun...@lists.llvm.org] On Behalf Of Pavel Labath via lldb-commits Sent: Tuesday, May 08, 2018 10:48 AM To: fr...@apple.com<mailto:fr...@apple.com> Cc: lldb-commits@lists.llvm.org<mailto:lldb-commits@lists.llvm.org> Subject: Re: [Lldb-commits] [RFC] Type lookup for template types is broken... Well.. it encodes some assumptions about how a class name looks like, which are probably valid for C++, but they don't have to hold for any language frontend LLVM supports. That said, I am not saying this is worth the trouble of adding a special "these are the additional names you are to insert into the index" channel that clang should use to communicate this (I wouldn't be surprised if we make even stronger assumptions elsewhere). I was just curious about what your thoughts here were. If you add an accelerator entry for "C" what does it point to? All the instantiations of "C"? The DWARF does not describe the template, only the concrete instances. Yes, there would be a “C” entry for every instantiation of C. Fred --paulr On Tue, 8 May 2018 at 15:29, Frédéric Riss mailto:fr...@apple.com>> wrote: On May 8, 2018, at 2:23 AM, Pavel Labath mailto:lab...@google.com>> wrote: I am still building a picture for myself of how the accelerator tables and our name lookup works, but from what I managed to learn so far, adding an accelerator for "C" seems like a useful thing to do. However, this does go beyond what the DWARF 5 spec says we should do (we are only required to add the DW_AT_name string). We are still free to add any extra entries we like, but if we're going to be relying on this, we should try to get some of this into the ne
Re: [Lldb-commits] [PATCH] D13058: LLDB-MI: Bug when evaluating strings containing characters from non-ascii range
On Sat, Sep 26, 2015 at 08:13:48AM +, Jason Molenda wrote: > NB: Greg is out for the next nine days, Enrico for the next five days. Is Enrico back now? OK to commit this if he accepts? > http://reviews.llvm.org/D13058 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] TOT svn lldb crashes trying to print argc on TOT lldb, maybe fallout from r244308 - [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support
Hi Jason, The function sext() for sign extending APInt values requires the new bit width to be greater than the current bit width. That is the reason I was just creating a new APInt instead of using sext function in cases where we need to promote to a type which has same bit width. I will do the same for promoting e_ulong type to s_longlong type to avoid the llvm assertion in sext() function. I will submit a patch for the same. Thanks and Regards, Sagar On Monday 10 August 2015 01:17 PM, Jason Molenda wrote: ( Resending with correct lldb-commits email address Cc:'ed ) Hi Sagar, I noticed this weekend that given an input program like int foo (int in) { return in + 5;} int main (int argc, char**argv) { return foo(argc); } if I put a breakpoint on foo() on an x86 system (compiled with clang, on a mac), I get an llvm assert when I backtrace: (lldb) bt Assertion failed: (width > BitWidth && "Invalid APInt SignExtend request"), function sext, file /Users/jason/work/lldb/llvm/lib/Support/APInt.cpp, line 956. The assert is being hit here - 4 0x000109cbe401 LLDB`__assert_rtn + 129 Signals.inc:517 5 0x000109c39dc8 LLDB`llvm::APInt::sext + 120 APInt.cpp:956 6 0x00010a36687d LLDB`lldb_private::Scalar::Promote + 11725 Scalar.cpp:1166 7 0x00010a36c073 LLDB`PromoteToMaxType + 307 Scalar.cpp:63 8 0x00010a36bd6d LLDB`lldb_private::Scalar::operator+= + 77 Scalar.cpp:2361 9 0x00010a46db4f LLDB`lldb_private::DWARFExpression::Evaluate + 38703 DWARFExpression.cpp:2564 10 0x00010a464399 LLDB`lldb_private::DWARFExpression::Evaluate + 1785 DWARFExpression.cpp:1325 11 0x00010a3fa9e5 LLDB`lldb_private::ValueObjectVariable::UpdateValue + 965 ValueObjectVariable.cpp:166 12 0x00010a3c4ceb LLDB`lldb_private::ValueObject::UpdateValueIfNeeded + 1483 ValueObject.cpp:236 13 0x00010a3ce0ba LLDB`lldb_private::ValueObject::GetValueAsCString + 42 ValueObject.cpp:1430 14 0x00010a379edf LLDB`lldb_private::FormatEntity::Format + 18991 FormatEntity.cpp:1800 15 0x00010a375b31 LLDB`lldb_private::FormatEntity::Format + 1665 FormatEntity.cpp:1228 16 0x00010a375b31 LLDB`lldb_private::FormatEntity::Format + 1665 FormatEntity.cpp:1228 17 0x00010a375767 LLDB`lldb_private::FormatEntity::Format + 695 FormatEntity.cpp:1204 18 0x00010aa1bc9b LLDB`lldb_private::StackFrame::DumpUsingSettingsFormat + 523 StackFrame.cpp:1379 19 0x00010aa1d036 LLDB`lldb_private::StackFrame::GetStatus + 102 StackFrame.cpp:1475 20 0x00010aa25ecd LLDB`lldb_private::StackFrameList::GetStatus + 3037 StackFrameList.cpp:936 The DWARF expression for 'argc' is 0x005c: TAG_subprogram [2] * AT_low_pc( 0x00010f70 ) AT_high_pc( 0x00010fa0 ) AT_frame_base( rbp ) AT_name( "main" ) 0x007b: TAG_formal_parameter [3] AT_location( fbreg -8 ) We create a Scalar object to represent the frame base value, lldb type s_ulong, APInt BitWidth 64, in DWARFExpression::Evaluate(): 2561 if (frame->GetFrameBaseValue(value, error_ptr)) 2562 { 2563 int64_t fbreg_offset = opcodes.GetSLEB128(&offset); -> 2564 value += fbreg_offset; So we're adding a e_slonglong (64-bit signed value, -8) to an e_ulong (64-bit unsigned, 0x7fff5fbffb10). We end up in Scalar::Promote, trying to promote the 64-bit e_ulong APInt to a 64-bit e_slonglong APInt: 1152case e_ulong: 1153switch (type) 1154{ 1164 case e_slonglong: 1165 { -> 1166 m_integer = m_integer.sext(sizeof(slonglong_t) * 8); 1167 success = true; 1168 break; and APInt::sext() asserts because the unsigned and the signed types have the same bit width. NB if I stop in main() itself, Frame::GetFrameBaseValue() happens to return a Scalar frame base value of e_ulonglong (still 64-bits) for the frame base value. This means that Scalar::Promote instead creates a new APInt object instead of trying to sign extend: 1225 case e_ulonglong: 1226 { -> 1227 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false); and it works as expected. For whatever reason, when we retrieve the frame base value higher up on the stack, we are getting an e_ulong (64-bits) which is when we have problems. J ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r244308 - [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support
Hi Ed, We do not require to handle e_void case in GetData() as we have already checked if bytes_size greater than zero. 136bool 137Scalar::GetData (DataExtractor &data, size_t limit_byte_size) const 138{ 139size_t byte_size = GetByteSize(); 140static float f_val; 141static double d_val; ->142 if (byte_size > 0) 143{ Should I still add a case for e_void to clear the warnings? Thanks and Regards, Sagar On Friday 07 August 2015 06:49 PM, Ed Maste wrote: On 7 August 2015 at 02:39, Sagar Thakur via lldb-commits wrote: Author: slthakur Date: Fri Aug 7 01:39:38 2015 New Revision: 244308 URL: http://llvm.org/viewvc/llvm-project?rev=244308&view=rev Log: [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support Noticed a few new warnings after this change: ../tools/lldb/source/Core/Scalar.cpp:151:24: warning: enumeration value 'e_void' not handled in switch [-Wswitch] switch(m_type) ^ ../tools/lldb/source/Core/Scalar.cpp:186:24: warning: enumeration value 'e_void' not handled in switch [-Wswitch] switch(m_type) ^ ../tools/lldb/source/Core/Scalar.cpp:220:20: warning: enumeration value 'e_void' not handled in switch [-Wswitch] switch(m_type) ^ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r244308 - [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support
Hi Ed, I have updated the patch http://reviews.llvm.org/D10919 to fix failures reported by Oleksiy. error: Couldn't materialize: data for register eax had size 8 but we expected 4 Errored out in Execute, couldn't PrepareToExecuteJITExpression This failure is similar to the failure I was getting in TestLldbGdbServer.py with linux/x86_64. I have fixed this issue in the updated patch http://reviews.llvm.org/D10919 Could you please check if it works for you as I don't have a FreeBSD system to test with ? Thanks and Regards, Sagar. On Monday 10 August 2015 09:23 PM, Ed Maste wrote: On 7 August 2015 at 02:39, Sagar Thakur via lldb-commits wrote: Author: slthakur Date: Fri Aug 7 01:39:38 2015 New Revision: 244308 URL: http://llvm.org/viewvc/llvm-project?rev=244308&view=rev Log: [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support This change introduced a failure on FreeBSD in test_register_expressions TestRegisters RegisterCommandsTestCase From the test log: python2.7 SBCommandInterpreter(0x804549200)::HandleCommand (command="expr/x $eax", SBCommandReturnObject(0x8023fe600), add_to_history=0) python2.7 SBCommandReturnObject(0x8023fe600)::GetError () => "error: Couldn't materialize: data for register eax had size 8 but we expected 4 Errored out in Execute, couldn't PrepareToExecuteJITExpression " python2.7 SBCommandInterpreter(0x804549200)::HandleCommand (command="expr/x $eax", SBCommandReturnObject(0x8023fe600): Status: Fail Error Message: error: Couldn't materialize: data for register eax had size 8 but we expected 4 Errored out in Execute, couldn't PrepareToExecuteJITExpression , add_to_history=0) => 6 python2.7 SBCommandReturnObject(0x8023fe600)::GetError () => "error: Couldn't materialize: data for register eax had size 8 but we expected 4 Errored out in Execute, couldn't PrepareToExecuteJITExpression " runCmd: expr/x $eax runCmd failed! error: Couldn't materialize: data for register eax had size 8 but we expected 4 Errored out in Execute, couldn't PrepareToExecuteJITExpression These tests also started failing in the last few days, but I haven't yet confirmed they are also introduced by this change. test_breakpoint_condition_inline_with_dwarf_and_run_command TestBreakpointConditions BreakpointConditionsTestCase test_breakpoint_condition_with_dwarf_and_run_command TestBreakpointConditions BreakpointConditionsTestCase ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r245217 - [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support
Hi Hans, The file RegisterContext_mips64.h was replaced with RegisterContext_mips.h in master branch. In the release branch, the file RegisterContext_mips64.h still exists. Could you please delete RegisterContext_mips64.h from the release branch ? Regards, Sagar On Tuesday 18 August 2015 02:47 AM, Hans Wennborg wrote: Merged to 3.7 in r245240. There was a conflicts because r245141 isn't on the branch. Please check that I got it right: http://llvm.org/viewvc/llvm-project?rev=245240&view=rev Thanks, Hans On Mon, Aug 17, 2015 at 1:28 PM, Greg Clayton wrote: Ok to merge. On Aug 17, 2015, at 1:26 PM, Hans Wennborg wrote: I'm OK with it if Greg approves. - Hans On Mon, Aug 17, 2015 at 7:07 AM, wrote: Hi Hans, Could you please also merge r245217 in the release branch. Thanks, Sagar -Original Message- From: lldb-commits [mailto:lldb-commits-boun...@lists.llvm.org] On Behalf Of Sagar Thakur via lldb-commits Sent: 17 August 2015 19:10 To: lldb-commits@lists.llvm.org Subject: [Lldb-commits] [lldb] r245217 - [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support Author: slthakur Date: Mon Aug 17 08:40:17 2015 New Revision: 245217 URL: http://llvm.org/viewvc/llvm-project?rev=245217&view=rev Log: [LLDB][MIPS] Fix offsets of all register sets and add MSA regset and FRE=1 mode support ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL245090: Move all clang type system DWARF type parsing into ClangASTContext.cpp.
On Thu, Aug 27, 2015 at 12:56:57PM -0700, Greg Clayton via lldb-commits wrote: > > > > Our Delphi compiler generates an alternate debug format as well - it took > > me all of yesterday to fix merge conflicts and I've still not got things > > working properly. Greg, can you please move the DWARF dependencies back > > into the SymbolFileDWARF plugin? Thanks! > > Sorry to not be clear on this: thing are correctly organized and won't be > changing. > > You will need to merge your stuff correctly into the current world. The issue is that you have added DWARF to ClangASTContext. How is another debug format plugin supposed to work in ClangASTContext now? The design had been that support for debug formats goes in plugins inside source/Plugins/SymbolFile. This was a clean interface that allowed support for other debug formats to exist by installing their plugin. Now main lldb code is polluted with DWARF code which depends on a plugin. Thanks, -Dawn ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D11102: Set the default language to use when evaluating to that of the frame's CU.
On Thu, Aug 27, 2015 at 07:58:50PM +, Greg Clayton wrote: > clayborg added a comment. > > Please wait for the OK from Jim and Sean. I've been waiting for 1.5 months already. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL245090: Move all clang type system DWARF type parsing into ClangASTContext.cpp.
On Thu, Aug 27, 2015 at 09:12:06PM +, Zachary Turner wrote: > If I'm following this discussion correctly, Greg are you saying that > ClangASTContext could be renamed to DwarfASTContext? And that for other > types of Debug info we could have PascalASTContext and PdbASTContext? > > If that's the case, then it seems there is a lot of code inside of > ClangASTContext (aka DwarfASTContext) which is not specific to DWARF, and > there's no reason that other ASTContext classes shouldn't be able to reuse > it. Renaming and reusing the ClangASTContext code would help but it's not enough - the DWARF code belongs in the DWARF plugin. Plugins should be just that - pluggable! :) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL245090: Move all clang type system DWARF type parsing into ClangASTContext.cpp.
On Thu, Aug 27, 2015 at 03:57:30PM -0700, Greg Clayton wrote: > > I can probably clean this up by making a DWARFASTParser a plug-in type and > move all DWARF parsing code over into it and place that inside the DWARF > plug-in folder. I see if I can do that quick to get the code organization > back to how we want it. Very cool!! This is exactly what I was hoping for. Thank you Greg!!! ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL246794: Roll dosep.py parallel test runner into dotest.py command line
On Fri, Sep 04, 2015 at 06:17:03PM +, Zachary Turner wrote: > To be honest I think grepping the output is the wrong way to go about > counting the tests. > [...] Log scraping is kind of a horrible thing to do, Agreed, but it was the only way to get correct totals. I would love for dosep.py to have been able to count the results correctly so I wouldn't have had to resort to "log scraping". dotest.py at least used to be able to count the totals correctly, but no longer can since it now inherrited the same bug that dosep.py had. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL246794: Roll dosep.py parallel test runner into dotest.py command line
On Fri, Sep 04, 2015 at 06:25:44PM +, Todd Fiala wrote: > tfiala added a comment. > > Dawn, the output supported by the command shouldn't have been changed. I'll > have a peek at what may have caused that to happen. All this change was > trying to do was stop the need to call dosep and roll that behavior into > dotest. Both of these commands: ./dosep.py -s --options "-v --executable $INSTALLDIR/bin/lldb" ./dotest.py -v --executable $INSTALLDIR/bin/lldb used to print results like the following: Collected 6 tests 1: test_double_type_from_block_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that double-type variables are displayed correctly from a block. ... ok 2: test_double_type_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that double-type variables are displayed correctly. ... ok 3: test_double_type_with_dwarf (TestFloatTypes.FloatTypesTestCase) Test that double-type variables are displayed correctly. ... ok 4: test_float_type_from_block_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that float-type variables are displayed correctly from a block. ... ok 5: test_float_type_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that float-type variables are displayed correctly. ... ok 6: test_float_type_with_dwarf (TestFloatTypes.FloatTypesTestCase) Test that float-type variables are displayed correctly. ... ok -- Ran 6 tests in 6.844s RESULT: PASSED (6 passes, 0 failures, 0 errors, 0 skipped, 0 expected failures, 0 unexpected successes) [TestFloatTypes.py PASSED] Now there is no equivelent to "dosep.py -s", and: ./dotest.py -v --executable $INSTALLDIR/bin/lldb prints results like the following: Testing: 395 test suites, 8 threads 0 out of 395 test suites processed - ['./dotest.py', '-v', '--executable', '/Users/testuser/build/workspace/LLVM-Clang-LLDB_master_release_OSX/llvm/build_ninja/lldb_redist/usr/local/bin/lldb'] 1 out of 395 test suites processed - TestCompileRunToBreakpointTurnaround.py [...] 395 out of 395 test suites processed - TestRecursiveTypes.py Ran 395 test suites (0 failed) (0.00%) Ran 826 test cases (0 failed) (0.00%) So we no longer have info on what tests ran, can't figure out what tests were skipped, can't calculate the correct totals, etc. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL246794: Roll dosep.py parallel test runner into dotest.py command line
On Fri, Sep 04, 2015 at 06:25:44PM +, Todd Fiala wrote: > tfiala added a comment. > > Dawn, the output supported by the command shouldn't have been changed. I'll > have a peek at what may have caused that to happen. All this change was > trying to do was stop the need to call dosep and roll that behavior into > dotest. Can you add the 'dosep.py -s -o "-v"' behavior to 'dotest.py -v'? I think that may be all that's needed in order to show the same output as before with all the desired details. Note: before the -s option was added to dosep.py, 'dosep.py -o "-v"' would only show the info that 'dotest.py -v' shows now (after your change). Afer the -s option was added to dosep.py, 'dosep.py -s -o "-v"' would report the same info as 'dotest.py -v' did before your change. I.e. dosep.py's -s option may be the key to fixing the regressions in 'dotest.py -v'. Thanks for looking into this! -Dawn ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL246794: Roll dosep.py parallel test runner into dotest.py command line
On Fri, Sep 04, 2015 at 12:40:12PM -0700, Todd Fiala wrote: > > Now there is no equivelent to "dosep.py -s", and: > >./dotest.py -v --executable $INSTALLDIR/bin/lldb > > All of dosep's args moved over to dotest. I think if you wanted dosep.py > -s behavior, you only need to use --output-on-success (long form of what > used to be -s in dosep I believe). The reason I couldn't maintain it as -s > is that dotest.py already had a -s abbreviation (for session dir > specification). Thanks! I'll give --output-on-success a try... ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [Diffusion] rL246794: Roll dosep.py parallel test runner into dotest.py command line
On Fri, Sep 04, 2015 at 12:44:36PM -0700, Todd Fiala wrote: > Please try: > > ./dotest.py --output-on-success -v --executable $INSTALLDIR/bin/lldb Yes, this appears to work. With this, I'm now back up to my old totals :) lldb_failures=0 lldb_errors=0 lldb_passes=1146 lldb_total=1378 Thank you!! I'd recommend turning --output-on-success on when -v is used so that the loss of information doesn't appear as a regression. That way, dotest.py -v will always show the same detailed info in both single and multithreaded modes. > I couldn't maintain the '-s' > mapping for the dosep option because it collided with an existing dotest.py > option for session directory specification. Understood. I don't think a short option for --output-on-success is needed if -v turns it on. A short option for --test-subdir would be useful however. Looks like these short options are still available: BHIJKLMOQUVWYZjoz. -z seems as good a choice as any :) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r247899 - [lldb-mi] Fix the handling of files in -data-info-line and -symbol-list-lines.
On Thu, Sep 17, 2015 at 10:43:53AM -0700, Sean Callanan wrote: > Dawn, > > this breaks the OS X Xcode build because it can???t find > ???../lib/Support/regex_impl.h???. > I only see that header in llvm/lib, but so far lldb-mi hasn???t had any LLVM > dependencies and it doesn???t even have the right header search paths in > Xcode. Should we be adding the LLVM headers as search paths? Yes. Can you add them please? ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r247899 - [lldb-mi] Fix the handling of files in -data-info-line and -symbol-list-lines.
On Thu, Sep 17, 2015 at 10:49:22AM -0700, Sean Callanan wrote: > Sure. What about the LLVM libraries ??? right now after fixing the header > issues I???m getting link errors: > > Undefined symbols for architecture x86_64: > "_llvm_regcomp", referenced from: > MIUtilParse::CRegexParser::CRegexParser(char const*) in MIUtilParse.o > "_llvm_regexec", referenced from: > MIUtilParse::CRegexParser::Execute(char const*, > MIUtilParse::CRegexParser::Match&, unsigned long) in MIUtilParse.o > "_llvm_regfree", referenced from: > MIUtilParse::CRegexParser::~CRegexParser() in MIUtilParse.o > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see > invocation) Please make the libraries and paths the same as for the rest of lldb. Sorry for the breakage - it builds fine in cmake/ninja. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Unique enums parsed from declarations (PR #96751)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes This is a regression from #96484 caught by @ZequanWu. Note that we will still create separate enum types for types parsed from two definitions. This is different from how we handle classes, but it is not a regression. I'm also adding the DieToType check to the class type parsing code, although in this case, the type uniqueness should be enforced by the UniqueDWARFASTType map. --- Full diff: https://github.com/llvm/llvm-project/pull/96751.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+14) - (added) lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp (+32) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f36e2af9589b8..c4a3b432ba949 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -870,6 +870,13 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, } } if (def_die) { +if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace( +def_die.GetDIE(), DIE_IS_BEING_PARSED); +!inserted) { + if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED) +return nullptr; + return it->getSecond()->shared_from_this(); +} attrs = ParsedDWARFTypeAttributes(def_die); } else { // No definition found. Proceed with the declaration die. We can use it to @@ -1798,6 +1805,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, } if (def_die) { +if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace( +def_die.GetDIE(), DIE_IS_BEING_PARSED); +!inserted) { + if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED) +return nullptr; + return it->getSecond()->shared_from_this(); +} attrs = ParsedDWARFTypeAttributes(def_die); } else { // No definition found. Proceed with the declaration die. We can use it to diff --git a/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp new file mode 100644 index 0..6fc47d7e4b53a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp @@ -0,0 +1,32 @@ +// RUN: %clangxx_host -gdwarf -c -o %t_a.o %s -DFILE_A +// RUN: %clangxx_host -gdwarf -c -o %t_b.o %s -DFILE_B +// RUN: %clangxx_host -o %t %t_a.o %t_b.o +// RUN: %lldb %t \ +// RUN: -o "target variable my_enum my_enum_ref" -o "image dump ast" \ +// RUN: -o exit | FileCheck %s + + +// CHECK: (lldb) target variable +// CHECK: (MyEnum) my_enum = MyEnum_A +// CHECK: (MyEnum &) my_enum_ref = +// CHECK-SAME: &::my_enum_ref = MyEnum_A + +// CHECK: (lldb) image dump ast +// CHECK: EnumDecl {{.*}} MyEnum +// CHECK-NEXT: EnumConstantDecl {{.*}} MyEnum_A 'MyEnum' +// CHECK-NOT: MyEnum + +enum MyEnum : int; + +extern MyEnum my_enum; + +#ifdef FILE_A +enum MyEnum : int { MyEnum_A }; + +MyEnum my_enum = MyEnum_A; + +int main() {} +#endif +#ifdef FILE_B +MyEnum &my_enum_ref = my_enum; +#endif `` https://github.com/llvm/llvm-project/pull/96751 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Don't start class definitions in ParseStructureLikeDIE (PR #96755)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes Right now, ParseStructureLikeDIE begins the class definition (which amounts to parsing the opening "{" of a class and promising to be able to fill it in later) if it finds a definition DIE. This makes sense in the current setup, where we eagerly search for the definition die (so that we will either find it in the beginning or don't find it at all), but with delayed definition searching (#92328), this created an (in my view, undesirable) inconsistency, where the final state of the type (whether it has begun its definition) depended on whether we happened to start out with a definition DIE or not. This patch attempts to pre-emptively rectify that by establishing a new invariant: the definition is never started eagerly. It can only be started in one of two ways: - we're completing the type, in which case we will start the definition, parse everything and immediately finish it - we need to parse a member (typedef, nested class, method) of the class without needing the definition itself. In this case, we just start the definition to insert the member we need. Besides the delayed definition search, I believe this setup has a couple of other benefits: - It treats ObjC and C++ classes the same way (we were never starting the definition of those) - unifies the handling of types that types that have a definition and those that do. When adding (e.g.) a nested class we would previously be going down a different code path depending on whether we've found a definition DIE for that type. Now, we're always taking the definition-not-found path (*) - it reduces the amount of time a class spends in the funny "definition started". Aside from the addition of stray addition of nested classes, we always finish the definition right after we start it. (*) Herein lies a danger, where if we're missing some calls to PrepareContextToReceiveMembers, we could trigger a crash when trying to add a member to the not-yet-started-to-be-defined classes. However, this is something that could happen before as well (if we did not have a definition for the class), and is something that would be exacerbated by #92328 (because it could happen even if we the definition exists, but we haven't found it yet). This way, it will at least happen consistently, and the fix should consist of adding a PrepareContextToReceiveMembers in the appropriate place. --- Full diff: https://github.com/llvm/llvm-project/pull/96755.diff 1 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+144-234) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f36e2af9589b8..0c3a62124eb1b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -237,20 +237,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc, return type_sp; } -static void ForcefullyCompleteType(CompilerType type) { - bool started = TypeSystemClang::StartTagDeclarationDefinition(type); - lldbassert(started && "Unable to start a class type definition."); - TypeSystemClang::CompleteTagDeclarationDefinition(type); - const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type); - auto ts_sp = type.GetTypeSystem(); - auto ts = ts_sp.dyn_cast_or_null(); - if (ts) -ts->SetDeclIsForcefullyCompleted(td); -} - -/// This function serves a similar purpose as RequireCompleteType above, but it -/// avoids completing the type if it is not immediately necessary. It only -/// ensures we _can_ complete the type later. +/// This function ensures we are able to add members (nested types, functions, +/// etc.) to this type. It does so by starting its definition even if one cannot +/// be found in the debug info. This means the type may need to be "forcibly +/// completed" later -- see CompleteTypeFromDWARF). static void PrepareContextToReceiveMembers(TypeSystemClang &ast, ClangASTImporter &ast_importer, clang::DeclContext *decl_ctx, @@ -260,14 +250,12 @@ static void PrepareContextToReceiveMembers(TypeSystemClang &ast, if (!tag_decl_ctx) return; // Non-tag context are always ready. - // We have already completed the type, or we have found its definition and are - // ready to complete it later (cf. ParseStructureLikeDIE). + // We have already completed the type or it is already prepared. if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined()) return; - // We reach this point of the tag was present in the debug info as a - // declaration only. If it was imported from another AST context (in the - // gmodules case), we can complete the type by doing a full import. + // If this tag w
[Lldb-commits] [lldb] fd35a92 - [lldb] fix(lldb/**.py): fix comparison to True/False (#94039)
Author: Eisuke Kawashima Date: 2024-06-26T15:55:15+01:00 New Revision: fd35a92300a00edaf56ae94176317390677569a4 URL: https://github.com/llvm/llvm-project/commit/fd35a92300a00edaf56ae94176317390677569a4 DIFF: https://github.com/llvm/llvm-project/commit/fd35a92300a00edaf56ae94176317390677569a4.diff LOG: [lldb] fix(lldb/**.py): fix comparison to True/False (#94039) from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or is not, never the equality operators. Co-authored-by: Eisuke Kawashima Added: Modified: lldb/examples/python/crashlog.py lldb/examples/python/disasm-stress-test.py lldb/examples/summaries/cocoa/CFString.py lldb/examples/summaries/pysummary.py lldb/examples/synthetic/bitfield/example.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/commands/command/script/welcome.py lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py lldb/test/API/functionalities/disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py lldb/test/API/tools/lldb-server/TestLldbGdbServer.py Removed: diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 1c0d717ce455c..368437ed63e46 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options): this_thread_crashed = self.app_specific_backtrace if not this_thread_crashed: this_thread_crashed = self.did_crash() -if options.crashed_only and this_thread_crashed == False: +if options.crashed_only and not this_thread_crashed: return print("%s" % self) diff --git a/lldb/examples/python/disasm-stress-test.py b/lldb/examples/python/disasm-stress-test.py index 2d3314ee8e8ff..62b2b90a2860a 100755 --- a/lldb/examples/python/disasm-stress-test.py +++ b/lldb/examples/python/disasm-stress-test.py @@ -95,13 +95,13 @@ def GetLLDBFrameworkPath(): debugger = lldb.SBDebugger.Create() -if debugger.IsValid() == False: +if not debugger.IsValid(): print("Couldn't create an SBDebugger") sys.exit(-1) target = debugger.CreateTargetWithFileAndArch(None, arg_ns.arch) -if target.IsValid() == False: +if not target.IsValid(): print("Couldn't create an SBTarget for architecture " + arg_ns.arch) sys.exit(-1) diff --git a/lldb/examples/summaries/cocoa/CFString.py b/lldb/examples/summaries/cocoa/CFString.py index 13c294ca34122..74bd927e9db21 100644 --- a/lldb/examples/summaries/cocoa/CFString.py +++ b/lldb/examples/summaries/cocoa/CFString.py @@ -253,9 +253,9 @@ def get_child_at_index(self, index): elif ( self.inline and self.explicit -and self.unicode == False -and self.special == False -and self.mutable == False +and not self.unicode +and not self.special +and not self.mutable ): return self.handle_inline_explicit() elif self.unicode: diff --git a/lldb/examples/summaries/pysummary.py b/lldb/examples/summaries/pysummary.py index e63a0bff56a13..2a05c1cbf8f28 100644 --- a/lldb/examples/summaries/pysummary.py +++ b/lldb/examples/summaries/pysummary.py @@ -2,7 +2,7 @@ def pyobj_summary(value, unused): -if value is None or value.IsValid() == False or value.GetValueAsUnsigned(0) == 0: +if value is None or not value.IsValid() or value.GetValueAsUnsigned(0) == 0: return "" refcnt = value.GetChildMemberWithName("ob_refcnt") expr = "(char*)PyString_AsString( (PyObject*)PyObject_Str( (PyObject*)0x%x) )" % ( diff --git a/lldb/examples/synthetic/bitfield/example.py b/lldb/examples/synthetic/bitfield/example.py index 2f58123268aa1..45416477bfef2 100644 --- a/lldb/examples/synthetic/bitfield/example.py +++ b/lldb/examples/synthetic/bitfield/example.py @@ -51,7 +51,7 @@ def get_child_at_index(self, index): return None if index > self.num_children(): return None -if self.valobj.IsValid() == False: +if not self.valobj.IsValid(): return None if index == 0: return self.valobj.GetChildMemberWithName("value") diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 1ad8ab6e6e462..1854f6c2c2e7b 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2446,7 +2446,7 @@ def found_str(matched): log_lines.append(pattern_li
[Lldb-commits] [lldb] [lldb] fix(lldb/**.py): fix comparison to True/False (PR #94039)
github-actions[bot] wrote: @e-kwsm Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/94039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5861145 - [lldb] fix(lldb/**.py): fix comparison to None (#94017)
Author: Eisuke Kawashima Date: 2024-06-26T15:59:07+01:00 New Revision: 586114510c5fa71d1377c7f53e68a3b12c472aa2 URL: https://github.com/llvm/llvm-project/commit/586114510c5fa71d1377c7f53e68a3b12c472aa2 DIFF: https://github.com/llvm/llvm-project/commit/586114510c5fa71d1377c7f53e68a3b12c472aa2.diff LOG: [lldb] fix(lldb/**.py): fix comparison to None (#94017) from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or is not, never the equality operators. Co-authored-by: Eisuke Kawashima Added: Modified: lldb/bindings/interface/SBBreakpointDocstrings.i lldb/bindings/interface/SBDataExtensions.i lldb/docs/use/python.rst lldb/examples/python/armv7_cortex_m_target_defintion.py lldb/packages/Python/lldbsuite/test/dotest.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/lldbutil.py lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py lldb/test/API/functionalities/step_scripted/TestStepScripted.py lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py lldb/test/API/lua_api/TestLuaAPI.py lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py lldb/test/API/python_api/event/TestEvents.py lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py lldb/test/API/python_api/type/TestTypeList.py lldb/test/API/python_api/was_interrupted/interruptible.py lldb/test/Shell/lit.cfg.py Removed: diff --git a/lldb/bindings/interface/SBBreakpointDocstrings.i b/lldb/bindings/interface/SBBreakpointDocstrings.i index 74c139d5d9fb6..dca2819a9927b 100644 --- a/lldb/bindings/interface/SBBreakpointDocstrings.i +++ b/lldb/bindings/interface/SBBreakpointDocstrings.i @@ -39,7 +39,7 @@ TestBreakpointIgnoreCount.py),:: #lldbutil.print_stacktraces(process) from lldbutil import get_stopped_thread thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) -self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint') +self.assertTrue(thread is not None, 'There should be a thread stopped due to breakpoint') frame0 = thread.GetFrameAtIndex(0) frame1 = thread.GetFrameAtIndex(1) frame2 = thread.GetFrameAtIndex(2) diff --git a/lldb/bindings/interface/SBDataExtensions.i b/lldb/bindings/interface/SBDataExtensions.i index d980e79221c6d..ddea77a088dfa 100644 --- a/lldb/bindings/interface/SBDataExtensions.i +++ b/lldb/bindings/interface/SBDataExtensions.i @@ -40,19 +40,19 @@ STRING_EXTENSION_OUTSIDE(SBData) lldbtarget = lldbdict['target'] else: lldbtarget = None -if target == None and lldbtarget != None and lldbtarget.IsValid(): +if target is None and lldbtarget is not None and lldbtarget.IsValid(): target = lldbtarget -if ptr_size == None: +if ptr_size is None: if target and target.IsValid(): ptr_size = target.addr_size else: ptr_size = 8 -if endian == None: +if endian is None: if target and target.IsValid(): endian = target.byte_order else: endian = lldbdict['eByteOrderLittle'] -if size == None: +if size is None: if value > 2147483647: size = 8 elif value < -2147483648: diff --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst index 6183d6935d80e..d9c29d95708c1 100644 --- a/lldb/docs/use/python.rst +++ b/lldb/docs/use/python.rst @@ -75,13 +75,13 @@ later explanations: 12: if root_word == word: 13: return cur_path 14: elif word < root_word: - 15: if left_child_ptr.GetValue() == None: + 15: if left_child_ptr.GetValue() is None: 16: return "" 17: else: 18: cur_path = cur_path + "L" 19: return DFS (left_child_ptr, word, cur_path) 20: else: - 21: if right_child_ptr.GetValue() == None: + 21: if right_child_ptr.GetValue() is None: 22: return "" 23: else: 24: cur_path = cur_path + "R" diff --git a/lldb/examples/python/armv7_cortex_m_target_defintion.py b/lldb/examples/python/armv7_cortex_m_target_defintion.py index 42eaa39993dae..8225670f33e6b 100755 --- a/lldb/examples/python/armv7_cortex_m_target_defintion.py +++ b/lldb/examples/python/armv7_cortex_m_target_defintion.py @@ -222,7 +222,7 @@ def get_reg_num(reg_num_dict, reg_name): def get_ta
[Lldb-commits] [lldb] [lldb] fix(lldb/**.py): fix comparison to None (PR #94017)
github-actions[bot] wrote: @e-kwsm Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/94017 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
jeffreytan81 wrote: Thanks for the update! Not sure why but the github notification system seems to fail me recently which I did not get any update emails from this thread until proactively checking now. Sounds good! Let us know the final stack/PR for the delaying forward declaration is up, we are happy to perform early testing against internal targets. cc @clayborg, @kusmour https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix the test to deal with non-deterministic output. (PR #96800)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Greg Clayton (clayborg) Changes When we check for the "struct CustomType" in the NODWP, we can just make sure that we have both types showing up, the next tests will validate the types are correct. Also added a "-DAG" to the integer and float types. This should fix the flakiness in this test. --- Full diff: https://github.com/llvm/llvm-project/pull/96800.diff 1 Files Affected: - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp (+6-16) ``diff diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp index 8dd5a5472ed4c..4df1b33dd7d91 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp @@ -30,24 +30,14 @@ // RUN: -o "type lookup CustomType" \ // RUN: -b %t | FileCheck %s --check-prefix=NODWP // NODWP: (lldb) type lookup IntegerType -// NODWP-NEXT: int -// NODWP-NEXT: unsigned int +// NODWP-DAG: int +// NODWP-DAG: unsigned int // NODWP: (lldb) type lookup FloatType -// NODWP-NEXT: double -// NODWP-NEXT: float +// NODWP-DAG: double +// NODWP-DAG: float // NODWP: (lldb) type lookup CustomType -// NODWP-NEXT: struct CustomType { -// NODWP-NEXT: typedef int IntegerType; -// NODWP-NEXT: typedef double FloatType; -// NODWP-NEXT: CustomType::IntegerType x; -// NODWP-NEXT: CustomType::FloatType y; -// NODWP-NEXT: } -// NODWP-NEXT: struct CustomType { -// NODWP-NEXT: typedef unsigned int IntegerType; -// NODWP-NEXT: typedef float FloatType; -// NODWP-NEXT: CustomType::IntegerType x; -// NODWP-NEXT: CustomType::FloatType y; -// NODWP-NEXT: } +// NODWP: struct CustomType { +// NODWP: struct CustomType { // Check when we make the .dwp file with %t.main.dwo first so it will // pick the type unit from %t.main.dwo. Verify we find only the types from `` https://github.com/llvm/llvm-project/pull/96800 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
jimingham wrote: The one thing about this that strikes me as odd is that if you have an SBValue that doesn't have a Synthetic Value, this will return the non-synthetic value. Getting the NonSynthetic Value didn't have this problem because there's always a non-synthetic value, so provided the SBValue was valid you could always hand that out. Would it make more sense to make the ValueImpl that's going to represent the synthetic value, and return an empty SBValue if it is not? https://github.com/llvm/llvm-project/pull/95959 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add the ability for Script based commands to specify their "repeat command" (PR #94823)
@@ -1827,6 +1838,15 @@ class CommandObjectScriptingObjectParsed : public CommandObjectParsed { ScriptedCommandSynchronicity GetSynchronicity() { return m_synchro; } + std::optional GetRepeatCommand(Args &args, + uint32_t index) override { +ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); +if (!scripter) + return std::nullopt; + +return scripter->GetRepeatCommandForScriptedCommand(m_cmd_obj_sp, args); + } + jimingham wrote: I was holding off on refactoring these classes till we're switching to the Scripted Interface infrastructure. https://github.com/llvm/llvm-project/pull/94823 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add the ability for Script based commands to specify their "repeat command" (PR #94823)
@@ -32,6 +37,39 @@ def check_help_options(self, cmd_name, opt_list, substrs=[]): print(f"Opt Vec\n{substrs}") self.expect("help " + cmd_name, substrs=substrs) +def run_one_repeat(self, commands, expected_num_errors): +with open(self.stdin_path, "w") as input_handle: +input_handle.write(commands) + +in_fileH = open(self.stdin_path, "r") +self.dbg.SetInputFileHandle(in_fileH, False) + +out_fileH = open(self.stdout_path, "w") +self.dbg.SetOutputFileHandle(out_fileH, False) +self.dbg.SetErrorFileHandle(out_fileH, False) + +options = lldb.SBCommandInterpreterRunOptions() +options.SetEchoCommands(False) +options.SetPrintResults(True) +options.SetPrintErrors(True) +options.SetAllowRepeats(True) + +n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter( +True, False, options, 0, False, False +) + +in_fileH.close() +out_fileH.close() + +results = None +with open(self.stdout_path, "r") as out_fileH: +results = out_fileH.read() + +print(f"RESULTS:\n{results}\nDONE") jimingham wrote: Doh. Probably can just get rid of this. https://github.com/llvm/llvm-project/pull/94823 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0ae2370 - [lldb] Do not produce field information for registers known not to exist (#95125)
Author: David Spickett Date: 2024-06-27T09:26:54+01:00 New Revision: 0ae23708ef4345f0832ba4443ce7b184248b4784 URL: https://github.com/llvm/llvm-project/commit/0ae23708ef4345f0832ba4443ce7b184248b4784 DIFF: https://github.com/llvm/llvm-project/commit/0ae23708ef4345f0832ba4443ce7b184248b4784.diff LOG: [lldb] Do not produce field information for registers known not to exist (#95125) Currently the logic is generate field information for all registers in LinuxArm64RegisterFlags and then as we walk the existing register info, only those that are in that existing info will get the new fields patched in. This works fine but on a review for FreeBSD support it was pointed out that this is not obvious from the source code. So instead I've allowed the construction of empty lists of fields, and field detection methods can return an empty field list if they think that the register will never exist. Then the pre-existing code will see the empty field list, and never look for that register in the register info. I think removing the assert is ok because the GDB classes filter out empty field lists at runtime, and anyone updating the built in field information would presumably notice if none of the fields they intended to add were displayed. mte_ctrl and svcr are the only registers that need this so far. There is no extra testing here as the behaviour is the same, it doesn't add field information to regiters that don't exist. The mechanism is just clearer now. Added: Modified: lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h lldb/source/Target/RegisterFlags.cpp Removed: diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp index 51553817921f3..8ed75d700f225 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp @@ -20,6 +20,7 @@ #define HWCAP2_BTI (1ULL << 17) #define HWCAP2_MTE (1ULL << 18) #define HWCAP2_AFP (1ULL << 20) +#define HWCAP2_SME (1ULL << 23) #define HWCAP2_EBF16 (1ULL << 32) using namespace lldb_private; @@ -27,7 +28,10 @@ using namespace lldb_private; LinuxArm64RegisterFlags::Fields LinuxArm64RegisterFlags::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) { (void)hwcap; - (void)hwcap2; + + if (!(hwcap2 & HWCAP2_SME)) +return {}; + // Represents the pseudo register that lldb-server builds, which itself // matches the architectural register SCVR. The fields match SVCR in the Arm // manual. @@ -40,7 +44,10 @@ LinuxArm64RegisterFlags::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) { LinuxArm64RegisterFlags::Fields LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2) { (void)hwcap; - (void)hwcap2; + + if (!(hwcap2 & HWCAP2_MTE)) +return {}; + // Represents the contents of NT_ARM_TAGGED_ADDR_CTRL and the value passed // to prctl(PR_TAGGED_ADDR_CTRL...). Fields are derived from the defines // used to build the value. diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h index 660bef08700f4..49b1d90db64f6 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h @@ -38,8 +38,8 @@ class LinuxArm64RegisterFlags { /// For the registers listed in this class, detect which fields are /// present. Must be called before UpdateRegisterInfos. /// If called more than once, fields will be redetected each time from - /// scratch. If you do not have access to hwcap, just pass 0 for each one, you - /// will only get unconditional fields. + /// scratch. If the target would not have this register at all, the list of + /// fields will be left empty. void DetectFields(uint64_t hwcap, uint64_t hwcap2); /// Add the field information of any registers named in this class, @@ -63,7 +63,7 @@ class LinuxArm64RegisterFlags { struct RegisterEntry { RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector) -: m_name(name), m_flags(std::string(name) + "_flags", size, {{"", 0}}), +: m_name(name), m_flags(std::string(name) + "_flags", size, {}), m_detector(detector) {} llvm::StringRef m_name; diff --git a/lldb/source/Target/RegisterFlags.cpp b/lldb/source/Target/RegisterFlags.cpp index d2fc5392f1a76..476150251221a 100644 --- a/lldb/source/Target/RegisterFlags.cpp +++ b/lldb/source/Target/RegisterFlags.cpp @@ -108,10 +108,6 @@ uint64_t RegisterFlags::Field::GetMask() const { } void RegisterFlags::SetFields(const std::vector &fields) { - // We expect that the XML processor will discard anything describing flags but - // with no fi
[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (#70392) (PR #96868)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. This just re-lands #70392 after fixing test failures. --- Patch is 60.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96868.diff 25 Files Affected: - (modified) lldb/bindings/python/python-swigsafecast.swig (+10-7) - (modified) lldb/bindings/python/python-wrapper.swig (+27-130) - (modified) lldb/include/lldb/API/SBEvent.h (+3-1) - (modified) lldb/include/lldb/API/SBStream.h (+6) - (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h (+2-2) - (added) lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (+38) - (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+11-44) - (modified) lldb/include/lldb/Target/ThreadPlanPython.h (+2) - (modified) lldb/include/lldb/lldb-forward.h (+3) - (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+13) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+1) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp (+2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp (+18-9) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp (+32-2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h (+26-3) - (added) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp (+105) - (added) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h (+48) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp (+19-9) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h (+5-17) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+6-116) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h (+3-25) - (modified) lldb/source/Target/ThreadPlanPython.cpp (+58-43) - (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+2-2) - (modified) lldb/test/API/functionalities/thread_plan/wrap_step_over.py (+1-1) - (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (+30-20) ``diff diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig index d5ea514872713..34f8c6f0ff8d3 100644 --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -37,10 +37,6 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) { return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError); } -PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr stream_sb) { - return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream); -} - PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr data_sb) { return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData); } @@ -115,9 +111,16 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) { SWIGTYPE_p_lldb__SBCommandReturnObject); } -ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) { - return ScopedPythonObject(new lldb::SBEvent(event), - SWIGTYPE_p_lldb__SBEvent); +PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) { + return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream); +} + +PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr stream_sb) { + return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream); +} + +PythonObject SWIGBridge::ToSWIGWrapper(Event *event) { + return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent); } PythonObject SWIGBridge::ToSWIGWrapper( diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index bd3de8ce5d46c..7915f7c4b2076 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -229,133 +229,6 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict); } -PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPl
[Lldb-commits] [lldb] 9a9ec22 - [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (#70392) (#96868)
Author: Med Ismail Bennani Date: 2024-06-27T01:45:30-07:00 New Revision: 9a9ec228cdcf75d01be82be5be13e1542f0fc75d URL: https://github.com/llvm/llvm-project/commit/9a9ec228cdcf75d01be82be5be13e1542f0fc75d DIFF: https://github.com/llvm/llvm-project/commit/9a9ec228cdcf75d01be82be5be13e1542f0fc75d.diff LOG: [lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392) (#96868) This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. This just re-lands #70392 after fixing test failures. Signed-off-by: Med Ismail Bennani Added: lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h Modified: lldb/bindings/python/python-swigsafecast.swig lldb/bindings/python/python-wrapper.swig lldb/include/lldb/API/SBEvent.h lldb/include/lldb/API/SBStream.h lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/include/lldb/Target/ThreadPlanPython.h lldb/include/lldb/lldb-forward.h lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h lldb/source/Target/ThreadPlanPython.cpp lldb/test/API/functionalities/step_scripted/Steps.py lldb/test/API/functionalities/thread_plan/wrap_step_over.py lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Removed: diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig index d5ea514872713..34f8c6f0ff8d3 100644 --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -37,10 +37,6 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) { return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError); } -PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr stream_sb) { - return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream); -} - PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr data_sb) { return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData); } @@ -115,9 +111,16 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) { SWIGTYPE_p_lldb__SBCommandReturnObject); } -ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) { - return ScopedPythonObject(new lldb::SBEvent(event), - SWIGTYPE_p_lldb__SBEvent); +PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) { + return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream); +} + +PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr stream_sb) { + return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream); +} + +PythonObject SWIGBridge::ToSWIGWrapper(Event *event) { + return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent); } PythonObject SWIGBridge::ToSWIGWrapper( diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index bd3de8ce5d46c..7915f7c4b2076 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -229,133 +229,6 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict); } -PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan( -const char *python_class_name, const char *session_dictionary_name, -const lldb_private::StructuredDataImpl &args_impl, -std::strin
[Lldb-commits] [lldb] ba60d8a - [lldb] Parse and display register field enums (#95768)
Author: David Spickett Date: 2024-06-27T10:03:06+01:00 New Revision: ba60d8a11af2cdd7e80e2fd968cdf52adcabf5a1 URL: https://github.com/llvm/llvm-project/commit/ba60d8a11af2cdd7e80e2fd968cdf52adcabf5a1 DIFF: https://github.com/llvm/llvm-project/commit/ba60d8a11af2cdd7e80e2fd968cdf52adcabf5a1.diff LOG: [lldb] Parse and display register field enums (#95768) This teaches lldb to parse the enum XML elements sent by lldb-server, and make use of the information in `register read` and `register info`. The format is described in https://sourceware.org/gdb/current/onlinedocs/gdb.html/Enum-Target-Types.html. The target XML parser will drop any invalid enum or evalue. If we find multiple evalue for the same value, we will use the last one we find. The order of evalues from the XML is preserved as there may be good reason they are not in numerical order. Added: Modified: lldb/include/lldb/Target/RegisterFlags.h lldb/source/Core/DumpRegisterInfo.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp lldb/source/Target/RegisterFlags.cpp lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py lldb/unittests/Core/DumpRegisterInfoTest.cpp Removed: diff --git a/lldb/include/lldb/Target/RegisterFlags.h b/lldb/include/lldb/Target/RegisterFlags.h index 1112972cf72e1..1250fd0330958 100644 --- a/lldb/include/lldb/Target/RegisterFlags.h +++ b/lldb/include/lldb/Target/RegisterFlags.h @@ -32,10 +32,15 @@ class FieldEnum { : m_value(value), m_name(std::move(name)) {} void ToXML(Stream &strm) const; + +void DumpToLog(Log *log) const; }; typedef std::vector Enumerators; + // GDB also includes a "size" that is the size of the underlying register. + // We will not store that here but instead use the size of the register + // this gets attached to when emitting XML. FieldEnum(std::string id, const Enumerators &enumerators); const Enumerators &GetEnumerators() const { return m_enumerators; } @@ -44,6 +49,8 @@ class FieldEnum { void ToXML(Stream &strm, unsigned size) const; + void DumpToLog(Log *log) const; + private: std::string m_id; Enumerators m_enumerators; diff --git a/lldb/source/Core/DumpRegisterInfo.cpp b/lldb/source/Core/DumpRegisterInfo.cpp index 8334795416902..eccc6784cd497 100644 --- a/lldb/source/Core/DumpRegisterInfo.cpp +++ b/lldb/source/Core/DumpRegisterInfo.cpp @@ -111,6 +111,11 @@ void lldb_private::DoDumpRegisterInfo( }; DumpList(strm, "In sets: ", in_sets, emit_set); - if (flags_type) + if (flags_type) { strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str()); + +std::string enumerators = flags_type->DumpEnums(terminal_width); +if (enumerators.size()) + strm << "\n\n" << enumerators; + } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 43c61fc9df6e4..3195587eb5676 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4179,21 +4179,134 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static std::vector ParseFlagsFields(XMLNode flags_node, - unsigned size) { +static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { + Log *log(GetLog(GDBRLog::Process)); + // We will use the last instance of each value. Also we preserve the order + // of declaration in the XML, as it may not be numerical. + // For example, hardware may intially release with two states that softwware + // can read from a register field: + // 0 = startup, 1 = running + // If in a future hardware release, the designers added a pre-startup state: + // 0 = startup, 1 = running, 2 = pre-startup + // Now it makes more sense to list them in this logical order as opposed to + // numerical order: + // 2 = pre-startup, 1 = startup, 0 = startup + // This only matters for "register info" but let's trust what the server + // chose regardless. + std::map enumerators; + + enum_node.ForEachChildElementWithName( + "evalue", [&enumerators, &log](const XMLNode &enumerator_node) { +std::optional name; +std::optional value; + +enumerator_node.ForEachAttribute( +[&name, &value, &log](const llvm::StringRef &attr_name, + const llvm::StringRef &attr_value) { + if (attr_name == "name") { +if (attr_value.size()) + name = attr_value; +else + LLDB_LOG(log, "ProcessGDBRemote::ParseEnumEvalues " +"Ignoring empty name in evalu
[Lldb-commits] [lldb] [lldb][AArch64] Add register field enum information (PR #96887)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes This enables XML output for enums and adds enums for 2 fields on AArch64: * mte_ctrl.tcf, which controls how tag faults are delivered. * fpcr.rmode, which sets the rounding mode for floating point operations. The other one we could do is cpsr.btype, but it is not clear what would be useful here so I'm not including it in this change. --- Full diff: https://github.com/llvm/llvm-project/pull/96887.diff 5 Files Affected: - (modified) lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp (+10-3) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+2) - (modified) lldb/test/API/commands/register/register/register_command/TestRegisters.py (+7-1) - (modified) lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py (+6-1) - (modified) lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py (+10-3) ``diff diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp index 8ed75d700f225..1242948bcb89e 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp @@ -51,16 +51,23 @@ LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2) { // Represents the contents of NT_ARM_TAGGED_ADDR_CTRL and the value passed // to prctl(PR_TAGGED_ADDR_CTRL...). Fields are derived from the defines // used to build the value. + + static const FieldEnum tcf_enum( + "tcf_enum", + {{0, "TCF_NONE"}, {1, "TCF_SYNC"}, {2, "TCF_ASYNC"}, {3, "TCF_ASYMM"}}); return {{"TAGS", 3, 18}, // 16 bit bitfield shifted up by PR_MTE_TAG_SHIFT. - {"TCF_ASYNC", 2}, - {"TCF_SYNC", 1}, + {"TCF", 1, 2, &tcf_enum}, {"TAGGED_ADDR_ENABLE", 0}}; } LinuxArm64RegisterFlags::Fields LinuxArm64RegisterFlags::DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2) { + + static const FieldEnum rmode_enum( + "rmode_enum", {{0, "RN"}, {1, "RP"}, {2, "RM"}, {3, "RZ"}}); + std::vector fpcr_fields{ - {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23}, + {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23, &rmode_enum}, // Bits 21-20 are "Stride" which is unused in AArch64 state. }; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index ae1a77e5be832..08d5f5039d516 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -3083,6 +3083,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() { if (registers_count) response.IndentMore(); + llvm::StringSet<> field_enums_seen; for (int reg_index = 0; reg_index < registers_count; reg_index++) { const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index); @@ -3096,6 +3097,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() { if (reg_info->flags_type) { response.IndentMore(); + reg_info->flags_type->EnumsToXML(response, field_enums_seen); reg_info->flags_type->ToXML(response); response.IndentLess(); } diff --git a/lldb/test/API/commands/register/register/register_command/TestRegisters.py b/lldb/test/API/commands/register/register/register_command/TestRegisters.py index 5c4f3a4bb374c..921fed1082980 100644 --- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py +++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py @@ -632,7 +632,13 @@ def test_register_read_fields(self): self.expect("register read fpsr", substrs=["= (QC = 0, IDC = 0, IXC = 0"]) # AHP/DN/FZ/RMode always present, others may vary. self.expect( -"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode = 0"] +"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode = RN"] +) + +# Should get enumerator descriptions for RMode. +self.expect( +"register info fpcr", +substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = RZ"], ) @skipUnlessPlatform(["linux"]) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index 1eaaa87d3b87d..0afac26367de0 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -583,7 +583,12 @@ def test_aarch64_sve_regs_full(self): self.expect("register read fpsr", substrs=["= (QC = 0, IDC = 0, IXC = 0"]) # AHP/DN/FZ/RMode always present, others may
[Lldb-commits] [lldb] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (PR #96894)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods started failing on various bots: - https://lab.llvm.org/buildbot/#/builders/162/builds/851 - https://lab.llvm.org/buildbot/#/builders/59/builds/650 - https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6546/ - https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/3359/ Since I'm not able to reproduce the test failure locally (tested on darwin x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can reproduce the failure or attach to a bot to investigate the issue there directly. --- Full diff: https://github.com/llvm/llvm-project/pull/96894.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py (+5-1) ``diff diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index 53901718019f9..7a4992abd8fcb 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,7 +7,6 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * - class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -16,12 +15,14 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") +@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") +@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -44,6 +45,7 @@ def step_out_with_scripted_plan(self, name): stop_desc = thread.GetStopDescription(1000) self.assertIn("Stepping out from", stop_desc, "Got right description") +@expectedFailureAll() def test_misspelled_plan_name(self): """Test that we get a useful error if we misspell the plan class name""" self.build() @@ -62,10 +64,12 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") +@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) +@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) `` https://github.com/llvm/llvm-project/pull/96894 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 204c403 - [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)
Author: Med Ismail Bennani Date: 2024-06-27T03:45:38-07:00 New Revision: 204c403b5215197ecdbdb68ca7f11402d6d9892b URL: https://github.com/llvm/llvm-project/commit/204c403b5215197ecdbdb68ca7f11402d6d9892b DIFF: https://github.com/llvm/llvm-project/commit/204c403b5215197ecdbdb68ca7f11402d6d9892b.diff LOG: [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894) After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods started failing on various bots: - https://lab.llvm.org/buildbot/#/builders/162/builds/851 - https://lab.llvm.org/buildbot/#/builders/59/builds/650 - https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6546/ - https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/3359/ Since I'm not able to reproduce the test failure locally (tested on darwin x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can reproduce it or attach to a bot to investigate the issue on it directly. Signed-off-by: Med Ismail Bennani Added: Modified: lldb/test/API/functionalities/step_scripted/TestStepScripted.py Removed: diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index 53901718019f9..7a4992abd8fcb 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,7 +7,6 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * - class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -16,12 +15,14 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") +@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") +@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -44,6 +45,7 @@ def step_out_with_scripted_plan(self, name): stop_desc = thread.GetStopDescription(1000) self.assertIn("Stepping out from", stop_desc, "Got right description") +@expectedFailureAll() def test_misspelled_plan_name(self): """Test that we get a useful error if we misspell the plan class name""" self.build() @@ -62,10 +64,12 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") +@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) +@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Fixes #92541 When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts, it assumed that the choices were target XML with registers, or no target XML at all. In the linked issue, a user has a debug stub that does have target XML, but it's missing register information. This caused us to finalize the register information using an empty set of registers got from target XML, then fail an assert when we attempted to add the fallback set. Since we think we've already completed the register information. This change adds a check to prevent that first call and expands the existing tests to check each architecture without target XML and with target XML missing register information. --- Full diff: https://github.com/llvm/llvm-project/pull/96907.diff 3 Files Affected: - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+3-1) - (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+1) - (renamed) lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py (+65-13) ``diff diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 3195587eb5676..7f1ce2303cde6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { m_registers_enum_types.clear(); std::vector registers; if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml", -registers)) +registers) && + // Target XML is not required to include register information. + (!registers.empty())) AddRemoteRegisters(registers, arch_to_use); return m_register_info_sp->GetNumRegisters() > 0; diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp index 1a817449fa958..48f9a49f8d45a 100644 --- a/lldb/source/Target/DynamicRegisterInfo.cpp +++ b/lldb/source/Target/DynamicRegisterInfo.cpp @@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo( } void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { + printf("DynamicRegisterInfo::Finalize\n"); if (m_finalized) return; diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py similarity index 82% rename from lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py rename to lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py index 8c5bad007f569..7557c8108439f 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py @@ -1,6 +1,6 @@ """ Check that lldb falls back to default register layouts when the remote provides -no target XML. +no target XML or does not include registers in the target XML. GPRS are passed to the responder to create register data to send back to lldb. Registers in SUPPL are virtual registers based on those general ones. The tests @@ -14,6 +14,7 @@ from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase import binascii +from textwrap import dedent class MyResponder(MockGDBServerResponder): @staticmethod @@ -22,8 +23,10 @@ def filecheck_to_blob(fc): val = l.split("0x")[1] yield binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode() -def __init__(self, reg_data, halt_reason): +def __init__(self, architecture, has_target_xml, reg_data, halt_reason): super().__init__() +self.architecture = architecture +self.has_target_xml = has_target_xml self.reg_data = "".join(self.filecheck_to_blob(reg_data)) self.halt_reason = halt_reason @@ -36,13 +39,19 @@ def readRegisters(self): def haltReason(self): return self.halt_reason +def qXferRead(self, obj, annex, offset, length): +if self.has_target_xml and annex == "target.xml": +return dedent(f"""\ + + +{self.architecture} + """), False + +return None, False -class TestGDBServerTargetXML(GDBRemoteTestBase): -@skipIfRemote -@skipIfLLVMTargetMissing("X86") -def test_x86_64_regs(self): -"""Test grabbing various x86_64 registers from gdbserver.""" +class TestGDBServerTargetXML(GDBRemoteTestBase): +def check_x86_64_regs(self, has_target_xml): GPRS = """ CHECK-AMD64-DAG: rax = 0x0807060504030201 CHECK-AMD64-DAG: rbx = 0x1817161514131211 @@ -125,6 +134,8 @@ def test_x86_64_regs(self): """ self.serve
[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)
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 e9b8cd0c806db00f0981fb36717077c941426302...25905a0f01c126dbebc854affd30d9ff838f259b lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py `` View the diff from darker here. ``diff --- TestGDBServerNoTargetXMLRegisters.py2024-06-27 13:12:32.00 + +++ TestGDBServerNoTargetXMLRegisters.py2024-06-27 13:39:18.296302 + @@ -13,10 +13,11 @@ from lldbsuite.test.gdbclientutils import * from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase import binascii from textwrap import dedent + class MyResponder(MockGDBServerResponder): @staticmethod def filecheck_to_blob(fc): for l in fc.strip().splitlines(): @@ -39,16 +40,21 @@ def haltReason(self): return self.halt_reason def qXferRead(self, obj, annex, offset, length): if self.has_target_xml and annex == "target.xml": -return dedent(f"""\ +return ( +dedent( +f"""\ {self.architecture} - """), False - + """ +), +False, +) + return None, False class TestGDBServerTargetXML(GDBRemoteTestBase): def check_x86_64_regs(self, has_target_xml): @@ -369,15 +375,15 @@ @skipIfRemote @skipIfLLVMTargetMissing("X86") def test_i386_regs_no_target_xml(self): """Test grabbing various i386 registers from gdbserver when there is - no target XML.""" +no target XML.""" self.check_i386_regs(False) @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("X86") def test_i386_regs_no_register_info(self): """Test grabbing various i386 registers from gdbserver when there is - target XML but it does not include register info.""" +target XML but it does not include register info.""" self.check_i386_regs(True) `` https://github.com/llvm/llvm-project/pull/96907 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2641975 - [lldb/DWARF] Unique enums parsed from declarations (#96751)
Author: Pavel Labath Date: 2024-06-27T16:36:52+02:00 New Revision: 264197516495910588d19fb19b6793e9be1bd6a3 URL: https://github.com/llvm/llvm-project/commit/264197516495910588d19fb19b6793e9be1bd6a3 DIFF: https://github.com/llvm/llvm-project/commit/264197516495910588d19fb19b6793e9be1bd6a3.diff LOG: [lldb/DWARF] Unique enums parsed from declarations (#96751) This is a regression from #96484 caught by @ZequanWu. Note that we will still create separate enum types for types parsed from two definitions. This is different from how we handle classes, but it is not a regression. I'm also adding the DieToType check to the class type parsing code, although in this case, the type uniqueness should be enforced by the UniqueDWARFASTType map. Added: lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f36e2af9589b8..c4a3b432ba949 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -870,6 +870,13 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, } } if (def_die) { +if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace( +def_die.GetDIE(), DIE_IS_BEING_PARSED); +!inserted) { + if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED) +return nullptr; + return it->getSecond()->shared_from_this(); +} attrs = ParsedDWARFTypeAttributes(def_die); } else { // No definition found. Proceed with the declaration die. We can use it to @@ -1798,6 +1805,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, } if (def_die) { +if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace( +def_die.GetDIE(), DIE_IS_BEING_PARSED); +!inserted) { + if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED) +return nullptr; + return it->getSecond()->shared_from_this(); +} attrs = ParsedDWARFTypeAttributes(def_die); } else { // No definition found. Proceed with the declaration die. We can use it to diff --git a/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp new file mode 100644 index 0..6fc47d7e4b53a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp @@ -0,0 +1,32 @@ +// RUN: %clangxx_host -gdwarf -c -o %t_a.o %s -DFILE_A +// RUN: %clangxx_host -gdwarf -c -o %t_b.o %s -DFILE_B +// RUN: %clangxx_host -o %t %t_a.o %t_b.o +// RUN: %lldb %t \ +// RUN: -o "target variable my_enum my_enum_ref" -o "image dump ast" \ +// RUN: -o exit | FileCheck %s + + +// CHECK: (lldb) target variable +// CHECK: (MyEnum) my_enum = MyEnum_A +// CHECK: (MyEnum &) my_enum_ref = +// CHECK-SAME: &::my_enum_ref = MyEnum_A + +// CHECK: (lldb) image dump ast +// CHECK: EnumDecl {{.*}} MyEnum +// CHECK-NEXT: EnumConstantDecl {{.*}} MyEnum_A 'MyEnum' +// CHECK-NOT: MyEnum + +enum MyEnum : int; + +extern MyEnum my_enum; + +#ifdef FILE_A +enum MyEnum : int { MyEnum_A }; + +MyEnum my_enum = MyEnum_A; + +int main() {} +#endif +#ifdef FILE_B +MyEnum &my_enum_ref = my_enum; +#endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8a7730f - [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (#96907)
Author: David Spickett Date: 2024-06-27T16:00:07+01:00 New Revision: 8a7730fb88445a019fe150d5db4f6642e43afd04 URL: https://github.com/llvm/llvm-project/commit/8a7730fb88445a019fe150d5db4f6642e43afd04 DIFF: https://github.com/llvm/llvm-project/commit/8a7730fb88445a019fe150d5db4f6642e43afd04.diff LOG: [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (#96907) Fixes #92541 When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts, it assumed that the choices were target XML with registers, or no target XML at all. In the linked issue, a user has a debug stub that does have target XML, but it's missing register information. This caused us to finalize the register information using an empty set of registers got from target XML, then fail an assert when we attempted to add the fallback set. Since we think we've already completed the register information. This change adds a check to prevent that first call and expands the existing tests to check each architecture without target XML and with target XML missing register information. Added: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py Modified: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Removed: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 3195587eb5676..604c92369e9a2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { m_registers_enum_types.clear(); std::vector registers; if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml", -registers)) +registers) && + // Target XML is not required to include register information. + !registers.empty()) AddRemoteRegisters(registers, arch_to_use); return m_register_info_sp->GetNumRegisters() > 0; diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py similarity index 82% rename from lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py rename to lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py index 8c5bad007f569..118f46f9974a8 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py @@ -1,6 +1,6 @@ """ Check that lldb falls back to default register layouts when the remote provides -no target XML. +no target XML or does not include registers in the target XML. GPRS are passed to the responder to create register data to send back to lldb. Registers in SUPPL are virtual registers based on those general ones. The tests @@ -14,6 +14,8 @@ from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase import binascii +from textwrap import dedent + class MyResponder(MockGDBServerResponder): @staticmethod @@ -22,8 +24,10 @@ def filecheck_to_blob(fc): val = l.split("0x")[1] yield binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode() -def __init__(self, reg_data, halt_reason): +def __init__(self, architecture, has_target_xml, reg_data, halt_reason): super().__init__() +self.architecture = architecture +self.has_target_xml = has_target_xml self.reg_data = "".join(self.filecheck_to_blob(reg_data)) self.halt_reason = halt_reason @@ -36,13 +40,24 @@ def readRegisters(self): def haltReason(self): return self.halt_reason +def qXferRead(self, obj, annex, offset, length): +if self.has_target_xml and annex == "target.xml": +return ( +dedent( +f"""\ + + + {self.architecture} +""" +), +False, +) + +return None, False -class TestGDBServerTargetXML(GDBRemoteTestBase): -@skipIfRemote -@skipIfLLVMTargetMissing("X86") -def test_x86_64_regs(self): -"""Test grabbing various x86_64 registers from gdbserver.""" +class TestGDBServerTargetXML(GDBRemoteTestBase): +def check_x86_64_regs(self, has_target_xml): GPRS = """ CHECK-AMD64-DAG: rax = 0x0807060504030201 CHECK-AMD64-DAG: rbx = 0x1817161514131211 @@ -125,6 +140,8 @@ def test_x86_64_regs(self): """ self.server.responder = MyResponder( +
[Lldb-commits] [lldb] [lldb][test] Add test-cases for packed/aligned structures (PR #96932)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Adds test that checks that LLDB correctly infers the alignment of packed structures. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes that overlapping field offsets imply a packed structure and thus sets alignment to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809. Also adds two XFAIL-ed tests: 1. where LLDB doesn't correctly infer the alignment of a derived class whose base has an explicit `DW_AT_alignment. See https://github.com/llvm/llvm-project/issues/73623. 2. where the aforementioned `InferAlignment` kicks in for overlapping fields (but in this case incorrectly since the structure isn't actually packed). --- Full diff: https://github.com/llvm/llvm-project/pull/96932.diff 4 Files Affected: - (modified) lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py (+8) - (modified) lldb/test/API/lang/cpp/alignas_base_class/main.cpp (+6) - (added) lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp (+25) - (added) lldb/test/Shell/SymbolFile/DWARF/packed.cpp (+36) ``diff diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py index 7d97b0c42b7e1..f9c99d15e5891 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py +++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py @@ -16,3 +16,11 @@ def test(self): # Verify specified class alignments. self.expect_expr("alignof(B2)", result_value="8") self.expect_expr("alignof(EmptyClassAlign8)", result_value="8") + +@no_debug_info_test + @expectedFailureAll(bugnumber="https://github.com/llvm/llvm-project/issues/73623";) +def test(self): +self.build() +self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + +self.expect_expr("alignof(Derived)", result_value="8") diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp index 9d37554957ba3..fb922c42edfc3 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp +++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp @@ -13,4 +13,10 @@ D d3g; struct alignas(8) EmptyClassAlign8 { } t; +struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {} foo; + +struct Derived : AlignedAndPackedBase { +} bar; +static_assert(alignof(Derived) == 8); + int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp new file mode 100644 index 0..79199a9237a63 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp @@ -0,0 +1,25 @@ +// XFAIL: * + +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "b main" \ +// RUN: -o "expr alignof(OverlappingFields)" \ +// RUN: -o "expr sizeof(OverlappingFields)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(OverlappingFields) +// CHECK-NEXT: ${{.*}} = 4 +// CHECK: (lldb) expr sizeof(OverlappingFields) +// CHECK-NEXT: ${{.*}} = 8 + +struct Empty {}; + +struct OverlappingFields { +char y; +[[no_unique_address]] Empty e; +int z; +} g_packed_struct; +static_assert(alignof(OverlappingFields) == 4); +static_assert(sizeof(OverlappingFields) == 8); + +int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp new file mode 100644 index 0..53b5ee624472c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp @@ -0,0 +1,36 @@ +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "b main" \ +// RUN: -o "expr alignof(packed)" \ +// RUN: -o "expr sizeof(packed)" \ +// RUN: -o "expr alignof(packed_and_aligned)" \ +// RUN: -o "expr sizeof(packed_and_aligned)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(packed) +// CHECK-NEXT: ${{.*}} = 1 +// CHECK: (lldb) expr sizeof(packed) +// CHECK-NEXT: ${{.*}} = 9 + +// CHECK: (lldb) expr alignof(packed_and_aligned) +// CHECK-NEXT: ${{.*}} = 16 +// CHECK: (lldb) expr sizeof(packed_and_aligned) +// CHECK-NEXT: ${{.*}} = 16 + +struct __attribute__((packed)) packed { +int x; +char y; +int z; +} g_packed_struct; +static_assert(alignof(packed) == 1); +static_assert(sizeof(packed) == 9); + +struct __attribute__((packed, aligned(16))) packed_and_aligned { +int x; +char y; +int z; +} g_packed_and_aligned_struct; +static_assert(alignof(packed_and_aligned) == 16); +static_assert(sizeof(packed_and_aligned) == 16); + +int main() {} `` https://github.com/llvm/llvm-project/pull/96932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list
[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to remove the XFAIL from the tests while also trying to fix them at the same time. --- Full diff: https://github.com/llvm/llvm-project/pull/96942.diff 2 Files Affected: - (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+1) - (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py (+1-4) ``diff diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py b/lldb/test/API/functionalities/step_scripted/Steps.py index 3325dba753657..b121f71538ce4 100644 --- a/lldb/test/API/functionalities/step_scripted/Steps.py +++ b/lldb/test/API/functionalities/step_scripted/Steps.py @@ -92,6 +92,7 @@ def should_stop(self, event): def stop_description(self, stream): stream.Print(f"Stepped until {self.var_name} changed.") +return True # This plan does nothing, but sets stop_mode to the diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index bb7479414dbbb..53901718019f9 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,6 +7,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * + class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -15,14 +16,12 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") -@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") -@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -63,12 +62,10 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") -@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) -@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) `` https://github.com/llvm/llvm-project/pull/96942 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b949b64 - Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (#96942)
Author: Med Ismail Bennani Date: 2024-06-27T11:28:37-07:00 New Revision: b949b6420775fe3466dc5a5bf34eab1d14e39e8f URL: https://github.com/llvm/llvm-project/commit/b949b6420775fe3466dc5a5bf34eab1d14e39e8f DIFF: https://github.com/llvm/llvm-project/commit/b949b6420775fe3466dc5a5bf34eab1d14e39e8f.diff LOG: Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (#96942) This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to remove the XFAIL from the tests while also trying to fix them at the same time. Signed-off-by: Med Ismail Bennani Added: Modified: lldb/test/API/functionalities/step_scripted/Steps.py lldb/test/API/functionalities/step_scripted/TestStepScripted.py Removed: diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py b/lldb/test/API/functionalities/step_scripted/Steps.py index 3325dba753657..b121f71538ce4 100644 --- a/lldb/test/API/functionalities/step_scripted/Steps.py +++ b/lldb/test/API/functionalities/step_scripted/Steps.py @@ -92,6 +92,7 @@ def should_stop(self, event): def stop_description(self, stream): stream.Print(f"Stepped until {self.var_name} changed.") +return True # This plan does nothing, but sets stop_mode to the diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index bb7479414dbbb..53901718019f9 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,6 +7,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * + class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -15,14 +16,12 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") -@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") -@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -63,12 +62,10 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") -@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) -@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -2838,6 +2844,14 @@ void PruneThreadPlans(); return std::nullopt; } + /// Handle thread specific async interrupt and return the original thread + /// that requested the async interrupt. It can be null if original thread + /// has exited. jimingham wrote: You should say what the `description` string is for. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 37fe152 - Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (#96946)
Author: Med Ismail Bennani Date: 2024-06-27T11:34:47-07:00 New Revision: 37fe152e0c9f47b0a9ef9663df1ddecffef6f338 URL: https://github.com/llvm/llvm-project/commit/37fe152e0c9f47b0a9ef9663df1ddecffef6f338 DIFF: https://github.com/llvm/llvm-project/commit/37fe152e0c9f47b0a9ef9663df1ddecffef6f338.diff LOG: Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (#96946) Reverts llvm/llvm-project#96942 since the test failures are still happening: https://lab.llvm.org/buildbot/#/builders/162/builds/899/ Added: Modified: lldb/test/API/functionalities/step_scripted/Steps.py lldb/test/API/functionalities/step_scripted/TestStepScripted.py Removed: diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py b/lldb/test/API/functionalities/step_scripted/Steps.py index b121f71538ce4..3325dba753657 100644 --- a/lldb/test/API/functionalities/step_scripted/Steps.py +++ b/lldb/test/API/functionalities/step_scripted/Steps.py @@ -92,7 +92,6 @@ def should_stop(self, event): def stop_description(self, stream): stream.Print(f"Stepped until {self.var_name} changed.") -return True # This plan does nothing, but sets stop_mode to the diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index 53901718019f9..bb7479414dbbb 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,7 +7,6 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * - class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -16,12 +15,14 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") +@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") +@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -62,10 +63,12 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") +@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) +@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (PR #96946)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes Reverts llvm/llvm-project#96942 since the test failures are still happening: https://lab.llvm.org/buildbot/#/builders/162/builds/899/ --- Full diff: https://github.com/llvm/llvm-project/pull/96946.diff 2 Files Affected: - (modified) lldb/test/API/functionalities/step_scripted/Steps.py (-1) - (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py (+4-1) ``diff diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py b/lldb/test/API/functionalities/step_scripted/Steps.py index b121f71538ce4..3325dba753657 100644 --- a/lldb/test/API/functionalities/step_scripted/Steps.py +++ b/lldb/test/API/functionalities/step_scripted/Steps.py @@ -92,7 +92,6 @@ def should_stop(self, event): def stop_description(self, stream): stream.Print(f"Stepped until {self.var_name} changed.") -return True # This plan does nothing, but sets stop_mode to the diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index 53901718019f9..bb7479414dbbb 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,7 +7,6 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * - class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -16,12 +15,14 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("main.c") self.runCmd("command script import Steps.py") +@expectedFailureAll() def test_standard_step_out(self): """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" self.build() self.step_out_with_scripted_plan("Steps.StepOut") +@expectedFailureAll() def test_scripted_step_out(self): """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" @@ -62,10 +63,12 @@ def test_misspelled_plan_name(self): # Make sure we didn't let the process run: self.assertEqual(stop_id, process.GetStopID(), "Process didn't run") +@expectedFailureAll() def test_checking_variable(self): """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step""" self.do_test_checking_variable(False) +@expectedFailureAll() def test_checking_variable_cli(self): """Test that we can call SBValue API's from a scripted thread plan - using cli to step""" self.do_test_checking_variable(True) `` https://github.com/llvm/llvm-project/pull/96946 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,40 @@ +//===-- TimeoutResumeAll.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_TARGET_TIMEOUTRESUMEALL_H +#define LLDB_TARGET_TIMEOUTRESUMEALL_H + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" + +namespace lldb_private { + +// Mixin class that provides capability for ThreadPlan that supports single jimingham wrote: Grammar: // Mixin class that provides the capability for ThreadPlan to support single // thread execution that resumes all threads after a timeout. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes ObjectFileMachO::SetLoadAddress sets the address of each segment in a binary in a Target, but it ignores segments that are not loaded in the virtual address space. It was marking segments that were purely BSS -- having no content in the file, but in zero-initialized memory when running in the virtual address space -- as not-loadable, unless they were named "DATA". This works pretty well for typical userland binaries, but in less Darwin environments, there may be BSS segments with other names, that ARE loadable. I looked at the origin of SectionIsLoadable's check for this, and it was a cleanup by Greg in 2018 where we had three different implementations of the idea in ObjectFileMachO and one of them skipped zero-file-size segments (BSS), which made it into the centralized SectionIsLoadable method. Also add some logging to the DynamicLoader log channel when loading a binary - it's the first place I look when debugging segment address setting bugs, and it wasn't emitting anything. rdar://129870649 --- Full diff: https://github.com/llvm/llvm-project/pull/96983.diff 1 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+26-5) ``diff diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 2979bf69bf762..164c4409747e0 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6159,10 +6159,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() { bool ObjectFileMachO::SectionIsLoadable(const Section *section) { if (!section) return false; - const bool is_dsym = (m_header.filetype == MH_DSYM); - if (section->GetFileSize() == 0 && !is_dsym && - section->GetName() != GetSegmentNameDATA()) -return false; if (section->IsThreadSpecific()) return false; if (GetModule().get() != section->GetModule().get()) @@ -6202,6 +6198,7 @@ lldb::addr_t ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage( bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset) { + Log *log(GetLog(LLDBLog::DynamicLoader)); ModuleSP module_sp = GetModule(); if (!module_sp) return false; @@ -6217,17 +6214,37 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value, // malformed. const bool warn_multiple = true; + if (log) { +std::string binary_description; +if (GetFileSpec()) { + binary_description += "path='"; + binary_description += GetFileSpec().GetPath(); + binary_description += "' "; +} +if (GetUUID()) { + binary_description += "uuid="; + binary_description += GetUUID().GetAsString(); +} +LLDB_LOGF(log, "ObjectFileMachO::SetLoadAddress %s", + binary_description.c_str()); + } if (value_is_offset) { // "value" is an offset to apply to each top level segment for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) { // Iterate through the object file sections to find all of the // sections that size on disk (to avoid __PAGEZERO) and load them SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); - if (SectionIsLoadable(section_sp.get())) + if (SectionIsLoadable(section_sp.get())) { +LLDB_LOGF(log, + "ObjectFileMachO::SetLoadAddress segment '%s' load addr is " + "0x%" PRIx64, + section_sp->GetName().AsCString(), + section_sp->GetFileAddress() + value); if (target.GetSectionLoadList().SetSectionLoadAddress( section_sp, section_sp->GetFileAddress() + value, warn_multiple)) ++num_loaded_sections; + } } } else { // "value" is the new base address of the mach_header, adjust each @@ -6242,6 +6259,10 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value, CalculateSectionLoadAddressForMemoryImage( value, mach_header_section, section_sp.get()); if (section_load_addr != LLDB_INVALID_ADDRESS) { + LLDB_LOGF(log, +"ObjectFileMachO::SetLoadAddress segment '%s' load addr is " +"0x%" PRIx64, +section_sp->GetName().AsCString(), section_load_addr); if (target.GetSectionLoadList().SetSectionLoadAddress( section_sp, section_load_addr, warn_multiple)) ++num_loaded_sections; `` https://github.com/llvm/llvm-project/pull/96983 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (PR #96985)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This patch changes `ScriptedThreadPlan::GetStopDescription` behaviour by discarding its return value since it is optional in the first place (i.e. the user doesn't need to provide a return value in their implementation). This patch also re-enables the tests that were XFAIL'd previously. --- Full diff: https://github.com/llvm/llvm-project/pull/96985.diff 5 Files Affected: - (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (+2-2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp (+2-2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h (+1-1) - (modified) lldb/source/Target/ThreadPlanPython.cpp (+3-3) - (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py (+1-4) ``diff diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h index 9130f9412cb0b..0f832b3b2029f 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h @@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface { virtual lldb::StateType GetRunState() { return lldb::eStateStepping; } - virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) { -return true; + virtual llvm::Error GetStopDescription(lldb_private::Stream *s) { +return llvm::Error::success(); } }; } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp index b7e475812f22b..8148e138ae564 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp @@ -91,7 +91,7 @@ lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() { static_cast(lldb::eStateStepping))); } -llvm::Expected +llvm::Error ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) { Status error; Dispatch("stop_description", error, s); @@ -99,7 +99,7 @@ ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) { if (error.Fail()) return error.ToError(); - return true; + return llvm::Error::success(); } #endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h index 33f086786c47b..563874a590794 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h @@ -40,7 +40,7 @@ class ScriptedThreadPlanPythonInterface : public ScriptedThreadPlanInterface, lldb::StateType GetRunState() override; - llvm::Expected GetStopDescription(lldb_private::Stream *s) override; + llvm::Error GetStopDescription(lldb_private::Stream *s) override; }; } // namespace lldb_private diff --git a/lldb/source/Target/ThreadPlanPython.cpp b/lldb/source/Target/ThreadPlanPython.cpp index 373555324ba6e..5c0beb6409b90 100644 --- a/lldb/source/Target/ThreadPlanPython.cpp +++ b/lldb/source/Target/ThreadPlanPython.cpp @@ -182,9 +182,9 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) { if (m_implementation_sp) { ScriptInterpreter *script_interp = GetScriptInterpreter(); if (script_interp) { - auto desc_or_err = m_interface->GetStopDescription(s); - if (!desc_or_err || !*desc_or_err) { -LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(), + llvm::Error err = m_interface->GetStopDescription(s); + if (err) { +LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(err), "Can't call ScriptedThreadPlan::GetStopDescription."); s->Printf("Python thread plan implemented by class %s.", m_class_name.c_str()); diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py index bb7479414dbbb..53901718019f9 100644 --- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py +++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py @@ -7,6 +7,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * + class StepScriptedTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -15,14 +16,12 @@ def setUp(self): self.main_source_file = lldb.SBFileSpec("ma
[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)
https://github.com/royitaqi created https://github.com/llvm/llvm-project/pull/97004 # Change https://github.com/llvm/llvm-project/pull/95075 accidentally removed the `targets` section from `statistics dump --summary`. Adding it back, by setting the default value to `true` in `StatisticsOptions::GetIncludeTargets()`. Updated the description for the options. Updated tests. # Verification Manually verified the fix by running `statist dump --summary` and comparing three versions of LLDB (in commit order): 1. Before https://github.com/llvm/llvm-project/pull/95075 2. After https://github.com/llvm/llvm-project/pull/95075 3. After this fix The expected result is that 1 and 3 give the same sections, while 2 is missing the `targets` section when in summary mode. The output (see Appendix) matches the expectation. # Appendix: Manual Test Output ## `statistics dump --summary` of 1 ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 724992, "bytesUnused": 714547, "bytesUsed": 10445 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.00070695, "totalDebugInfoParseTime": 2.5998e-05, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.000223, "totalSymbolTableParseTime": 0.00025798, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 3 Should be the same as above. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 516096, "bytesUnused": 510353, "bytesUsed": 5743 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.0022138, "totalDebugInfoParseTime": 0.00031701, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.0014499, "totalSymbolTableParseTime": 0.001848, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 2 Should be missing the `targets` section. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 716800, "bytesUnused": 705887, "bytesUsed": 10913 } }, "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.001374, "totalDebugInfoParseTime": 0.000174, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.00068301, "totalSymbolTableParseTime": 0.0010139, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` >From 629282a7ce68c3dc2d6e2bf491870b71a1435cee Mon Sep 17 00:00:00 2001 From: royshi Date: Thu, 27 Jun 2024 21:17:45 -0700 Subject: [PATCH] Add `targets` back into `statistics dump --summary` Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/include/lldb/Target/Statistics.h | 5 ++- lldb/source/Commands/Options.td | 7 ++-- .../commands/statistics/basic/TestStats.py| 32 --- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index 122eb3ddd711f..35bd7f8a66e05 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -144,9 +144,8 @@ struct StatisticsOptions { bool GetIncludeTargets() const { if (m_include_targets.has_value()) return m_include_targets.value(); -// `m_include_targets` has no value set, so return a value based on -// `m_summary_only`. -return !GetSummaryOnly(); +// Default to true in both default mode and summary mode. +return true; } void SetIncludeModules(bool value) { m_include_modules = value; } diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ba256e5ab917a..fa8af7cb3d762 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -1429,9 +1429,8 @@ let Command
[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (royitaqi) Changes # Change https://github.com/llvm/llvm-project/pull/95075 accidentally removed the `targets` section from `statistics dump --summary`. Adding it back, by setting the default value to `true` in `StatisticsOptions::GetIncludeTargets()`. Updated the description for the options. Updated tests. # Verification Manually verified the fix by running `statist dump --summary` and comparing three versions of LLDB (in commit order): 1. Before https://github.com/llvm/llvm-project/pull/95075 2. After https://github.com/llvm/llvm-project/pull/95075 3. After this fix The expected result is that 1 and 3 give the same sections, while 2 is missing the `targets` section when in summary mode. The output (see Appendix) matches the expectation. # Appendix: Manual Test Output ## `statistics dump --summary` of 1 ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 724992, "bytesUnused": 714547, "bytesUsed": 10445 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.00070695, "totalDebugInfoParseTime": 2.5998e-05, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.000223, "totalSymbolTableParseTime": 0.00025798, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 3 Should be the same as above. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 516096, "bytesUnused": 510353, "bytesUsed": 5743 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.0022138, "totalDebugInfoParseTime": 0.00031701, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.0014499, "totalSymbolTableParseTime": 0.001848, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 2 Should be missing the `targets` section. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 716800, "bytesUnused": 705887, "bytesUsed": 10913 } }, "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.001374, "totalDebugInfoParseTime": 0.000174, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.00068301, "totalSymbolTableParseTime": 0.0010139, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` --- Full diff: https://github.com/llvm/llvm-project/pull/97004.diff 3 Files Affected: - (modified) lldb/include/lldb/Target/Statistics.h (+2-3) - (modified) lldb/source/Commands/Options.td (+3-4) - (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+28-4) ``diff diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index 122eb3ddd711f..35bd7f8a66e05 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -144,9 +144,8 @@ struct StatisticsOptions { bool GetIncludeTargets() const { if (m_include_targets.has_value()) return m_include_targets.value(); -// `m_include_targets` has no value set, so return a value based on -// `m_summary_only`. -return !GetSummaryOnly(); +// Default to true in both default mode and summary mode. +return true; } void SetIncludeModules(bool value) { m_include_modules = value; } diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ba256e5ab917a..fa8af7cb3d762 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -1429,9 +1429,8 @@ let Command = "statistics dump" in { Arg<"Boolean">, Desc<"Dump statistics for the targets, including breakpoints, expression " "evaluations, frame variables, etc. " -"Defaults to true, unless the '--su
[Lldb-commits] [lldb] 918057c - [lldb/DWARF] Don't start class definitions in ParseStructureLikeDIE (#96755)
Author: Pavel Labath Date: 2024-06-28T09:41:48+02:00 New Revision: 918057c43aed90583eed5fe14450b2d75366b662 URL: https://github.com/llvm/llvm-project/commit/918057c43aed90583eed5fe14450b2d75366b662 DIFF: https://github.com/llvm/llvm-project/commit/918057c43aed90583eed5fe14450b2d75366b662.diff LOG: [lldb/DWARF] Don't start class definitions in ParseStructureLikeDIE (#96755) Right now, ParseStructureLikeDIE begins the class definition (which amounts to parsing the opening "{" of a class and promising to be able to fill it in later) if it finds a definition DIE. This makes sense in the current setup, where we eagerly search for the definition die (so that we will either find it in the beginning or don't find it at all), but with delayed definition searching (#92328), this created an (in my view, undesirable) inconsistency, where the final state of the type (whether it has begun its definition) depended on whether we happened to start out with a definition DIE or not. This patch attempts to pre-emptively rectify that by establishing a new invariant: the definition is never started eagerly. It can only be started in one of two ways: - we're completing the type, in which case we will start the definition, parse everything and immediately finish it - we need to parse a member (typedef, nested class, method) of the class without needing the definition itself. In this case, we just start the definition to insert the member we need. Besides the delayed definition search, I believe this setup has a couple of other benefits: - It treats ObjC and C++ classes the same way (we were never starting the definition of those) - unifies the handling of types that types that have a definition and those that do. When adding (e.g.) a nested class we would previously be going down a different code path depending on whether we've found a definition DIE for that type. Now, we're always taking the definition-not-found path (*) - it reduces the amount of time a class spends in the funny "definition started". Aside from the addition of stray addition of nested classes, we always finish the definition right after we start it. (*) Herein lies a danger, where if we're missing some calls to PrepareContextToReceiveMembers, we could trigger a crash when trying to add a member to the not-yet-started-to-be-defined classes. However, this is something that could happen before as well (if we did not have a definition for the class), and is something that would be exacerbated by #92328 (because it could happen even if we the definition exists, but we haven't found it yet). This way, it will at least happen consistently, and the fix should consist of adding a PrepareContextToReceiveMembers in the appropriate place. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index c4a3b432ba949..8e297141f4e13 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -237,20 +237,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc, return type_sp; } -static void ForcefullyCompleteType(CompilerType type) { - bool started = TypeSystemClang::StartTagDeclarationDefinition(type); - lldbassert(started && "Unable to start a class type definition."); - TypeSystemClang::CompleteTagDeclarationDefinition(type); - const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type); - auto ts_sp = type.GetTypeSystem(); - auto ts = ts_sp.dyn_cast_or_null(); - if (ts) -ts->SetDeclIsForcefullyCompleted(td); -} - -/// This function serves a similar purpose as RequireCompleteType above, but it -/// avoids completing the type if it is not immediately necessary. It only -/// ensures we _can_ complete the type later. +/// This function ensures we are able to add members (nested types, functions, +/// etc.) to this type. It does so by starting its definition even if one cannot +/// be found in the debug info. This means the type may need to be "forcibly +/// completed" later -- see CompleteTypeFromDWARF). static void PrepareContextToReceiveMembers(TypeSystemClang &ast, ClangASTImporter &ast_importer, clang::DeclContext *decl_ctx, @@ -260,14 +250,12 @@ static void PrepareContextToReceiveMembers(TypeSystemClang &ast, if (!tag_decl_ctx) return; // Non-tag context are always ready. - // We have already completed the type, or we have found its definition and are - // ready to complete it later (cf. ParseStructureLikeDIE). + // We have already completed the type or it is already prepared. if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx
[Lldb-commits] [lldb] 1130e92 - [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)
Author: Med Ismail Bennani Date: 2024-06-28T01:40:03-07:00 New Revision: 1130e923e2d7fe046101bf639bc5ebcde194c005 URL: https://github.com/llvm/llvm-project/commit/1130e923e2d7fe046101bf639bc5ebcde194c005 DIFF: https://github.com/llvm/llvm-project/commit/1130e923e2d7fe046101bf639bc5ebcde194c005.diff LOG: [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985) This patch changes `ScriptedThreadPlan::GetStopDescription` behavior by discarding its return value since it is optional in the first place (the user doesn't need to provide a return value in their implementation). This patch also addresses the test failures in TestStepScripted following 9a9ec22 and re-enables the tests that were XFAIL'd previously. The issue here was that the `Stream*` that's passed to `ThreadPlanPython::GetDescription` wasn't being passed by reference to the python method so it was never updated to reflect how the python method interacted with it. This patch solves this issue by making a temporary `StreamSP` that will be passed to the python method by reference, after what we will copy its content to the caller `Stream` pointer argument. - Signed-off-by: Med Ismail Bennani Added: Modified: lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h lldb/source/Target/ThreadPlanPython.cpp lldb/test/API/functionalities/step_scripted/TestStepScripted.py Removed: diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h index 9130f9412cb0b..ee634d15f2a9e 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h @@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface { virtual lldb::StateType GetRunState() { return lldb::eStateStepping; } - virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) { -return true; + virtual llvm::Error GetStopDescription(lldb::StreamSP &stream) { +return llvm::Error::success(); } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index e821a7db2c674..14a52709c1e61 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -575,7 +575,7 @@ class ScriptInterpreter : public PluginInterface { Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const; - Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; + lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; lldb::BreakpointSP GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const; diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 75b2a39a8d11b..65e4cbddc39a5 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const { return event.m_opaque_ptr; } -Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream( +lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream( const lldb::SBStream &stream) const { - if (stream.m_opaque_up) -return const_cast(stream).m_opaque_up.get(); + if (stream.m_opaque_up) { +lldb::StreamSP s = std::make_shared(); +*s << const_cast(stream).GetData(); +return s; + } return nullptr; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 7d072212676e1..699412e437a1a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -26,15 +26,6 @@ ScriptedPythonInterface::ScriptedPythonInterface( ScriptInterpreterPythonImpl &interpreter) : ScriptedInterface(), m_interpreter(interpreter) {} -template <> -void ScriptedPythonInterface::ReverseTransform( -lldb_private::Stream *&original_arg, python::PythonObject transformed_arg, -Status &error) { - Stream *s = ExtractValueFromP
[Lldb-commits] [lldb] [lldb][test] Remove duplicate testcase names in API test-suite (PR #97043)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes In one of my recent PRs I mistakenly had two test-cases with the same name, preventing one of them to run. Since it's an easy mistake to make (e.g., copy pasting existing test-cases), I ran following sanity-check script over `lldb/test/API`, which found couple of tests which were losing coverage because of this (or in some cases simply had duplicate tests): ``` import ast import sys filename = sys.argv[1] print(f'Checking {filename}...') tree = ast.parse(open(filename, 'r').read()) for node in ast.walk(tree): if not isinstance(node, ast.ClassDef): continue func_names = [] for child in ast.iter_child_nodes(node): if isinstance(child, ast.FunctionDef): func_names.append(child.name) seen_func_names = set() duplicate_func_names = [] for name in func_names: if name in seen_func_names: duplicate_func_names.append(name) else: seen_func_names.add(name) if len(duplicate_func_names) != 0: print(f'Multiple func names found:\n\t{duplicate_func_names}\n\tclass {node.name}\n\tfile: {filename}') ``` This patch fixes these cases. --- Full diff: https://github.com/llvm/llvm-project/pull/97043.diff 11 Files Affected: - (modified) lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py (+1-1) - (modified) lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py (-2) - (modified) lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py (-37) - (modified) lldb/test/API/functionalities/completion/TestCompletion.py (-6) - (modified) lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py (+1-1) - (modified) lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py (+1-1) - (modified) lldb/test/API/lang/cpp/diamond/TestCppDiamond.py (+1-1) - (modified) lldb/test/API/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py (-1) - (modified) lldb/test/API/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py (+1-1) - (modified) lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py (+1-1) - (modified) lldb/test/API/test_utils/TestDecorators.py (+2-2) ``diff diff --git a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py index 583c68d7bfacc..dbcd2d60d021a 100644 --- a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py +++ b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py @@ -25,7 +25,7 @@ def test_disable_empty(self): ) @no_debug_info_test -def test_enable_empty(self): +def test_enable_invalid_path(self): invalid_path = os.path.join("this", "is", "not", "a", "valid", "path") self.expect( "log enable lldb all -f " + invalid_path, diff --git a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py index 9678bd42999b3..571024417560f 100644 --- a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py +++ b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py @@ -16,8 +16,6 @@ def test_thread_backtrace_one_thread(self): """Run a simplified version of the test that just hits one breakpoint and doesn't care about synchronizing the two threads - hopefully this will run on more systems.""" - -def test_thread_backtrace_one_thread(self): self.build() ( self.inferior_target, diff --git a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py index c41e85fd670ba..12f99f07c78a8 100644 --- a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -31,43 +31,6 @@ def testStartMultipleLiveThreads(self): self.traceStopProcess() -@skipIf(oslist=no_match(["linux"]), archs=no_match(["i386", "x86_64"])) -@testSBAPIAndCommands -def testStartMultipleLiveThreadsWithStops(self): -self.build() -exe = self.getBuildArtifact("a.out") - -self.dbg.CreateTarget(exe) - -self.expect("b main") -self.expect("b 6") -self.expect("b 11") - -self.expect("r") -self.traceStartProcess() - -# We'll see here the first thread -self.expect("continue") - -# We are in thread 2 -self.expect("thread trace dump instructions", substrs=["main.cpp:9"]) -self.expect("thread trace dump instructions 2", substrs=["main.cpp:9"]) - -# We stop tracing it -self.expect("thread trace stop 2") - -# The trace is still in memory -self.expect("t
[Lldb-commits] [lldb] [lldb][test][NFC] Remove BOM characters from tests (PR #97045)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes These handful of tests had a BOM (Byte order mark) at the beginning of the file. This marker is unnecessary in our test files. The main motivation for this is that the `ast` python module breaks when passing a file to it with a BOM marker (and might break other tooling which doesn't expect it). E.g.,: ``` """Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" ^ SyntaxError: invalid non-printable character U+FEFF ``` If anyone is aware of a good reason to keep it, happy to drop this. --- Full diff: https://github.com/llvm/llvm-project/pull/97045.diff 6 Files Affected: - (modified) lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py (+1-1) - (modified) lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py (+1-1) - (modified) lldb/test/API/functionalities/load_unload/TestLoadUnload.py (+1-1) - (modified) lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py (+1-1) - (modified) lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py (+1-1) - (modified) lldb/test/API/functionalities/signal/TestSendSignal.py (+1-1) ``diff diff --git a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py index ca08591aedb39..a108ffe485efc 100644 --- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py +++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py @@ -1,4 +1,4 @@ -""" +""" Test calling a function that hits a signal set to auto-restart, make sure the call completes. """ diff --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py index 2783aaff1a0ed..0fa7bc7edf995 100644 --- a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py +++ b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py @@ -1,4 +1,4 @@ -""" +""" Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY """ diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py index 2208e520f1d56..e52fb8c87377f 100644 --- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py @@ -1,4 +1,4 @@ -""" +""" Test that breakpoint by symbol name works correctly with dynamic libs. """ diff --git a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py index 6ee99f84adda8..c423236b219f4 100644 --- a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py +++ b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py @@ -1,4 +1,4 @@ -""" +""" Test that SBProcess.LoadImageUsingPaths works correctly. """ diff --git a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py index c5f4a7c6dedc1..84033daff7730 100644 --- a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py +++ b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py @@ -1,4 +1,4 @@ -"""Test that lldb picks the correct DWARF location list entry with a return-pc out of bounds.""" +"""Test that lldb picks the correct DWARF location list entry with a return-pc out of bounds.""" import lldb from lldbsuite.test.decorators import * diff --git a/lldb/test/API/functionalities/signal/TestSendSignal.py b/lldb/test/API/functionalities/signal/TestSendSignal.py index 50435572c4d83..5b6a50a461cdf 100644 --- a/lldb/test/API/functionalities/signal/TestSendSignal.py +++ b/lldb/test/API/functionalities/signal/TestSendSignal.py @@ -1,4 +1,4 @@ -"""Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" +"""Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" import lldb `` https://github.com/llvm/llvm-project/pull/97045 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9c95617 - [lldb][test][NFC] Remove BOM characters from tests (#97045)
Author: Michael Buch Date: 2024-06-28T14:06:39+01:00 New Revision: 9c95617c796f1cd178eaf3001bce543b8acee32f URL: https://github.com/llvm/llvm-project/commit/9c95617c796f1cd178eaf3001bce543b8acee32f DIFF: https://github.com/llvm/llvm-project/commit/9c95617c796f1cd178eaf3001bce543b8acee32f.diff LOG: [lldb][test][NFC] Remove BOM characters from tests (#97045) These handful of tests had a BOM (Byte order mark) at the beginning of the file. This marker is unnecessary in our test files. The main motivation for this is that the `ast` python module breaks when passing a file to it with a BOM marker (and might break other tooling which doesn't expect it). E.g.,: ``` """Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" ^ SyntaxError: invalid non-printable character U+FEFF ``` If anyone is aware of a good reason to keep it, happy to drop this. Added: Modified: lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py lldb/test/API/functionalities/load_unload/TestLoadUnload.py lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py lldb/test/API/functionalities/signal/TestSendSignal.py Removed: diff --git a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py index ca08591aedb39..a108ffe485efc 100644 --- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py +++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py @@ -1,4 +1,4 @@ -""" +""" Test calling a function that hits a signal set to auto-restart, make sure the call completes. """ diff --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py index 2783aaff1a0ed..0fa7bc7edf995 100644 --- a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py +++ b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py @@ -1,4 +1,4 @@ -""" +""" Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY """ diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py index 2208e520f1d56..e52fb8c87377f 100644 --- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py @@ -1,4 +1,4 @@ -""" +""" Test that breakpoint by symbol name works correctly with dynamic libs. """ diff --git a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py index 6ee99f84adda8..c423236b219f4 100644 --- a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py +++ b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py @@ -1,4 +1,4 @@ -""" +""" Test that SBProcess.LoadImageUsingPaths works correctly. """ diff --git a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py index c5f4a7c6dedc1..84033daff7730 100644 --- a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py +++ b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py @@ -1,4 +1,4 @@ -"""Test that lldb picks the correct DWARF location list entry with a return-pc out of bounds.""" +"""Test that lldb picks the correct DWARF location list entry with a return-pc out of bounds.""" import lldb from lldbsuite.test.decorators import * diff --git a/lldb/test/API/functionalities/signal/TestSendSignal.py b/lldb/test/API/functionalities/signal/TestSendSignal.py index 50435572c4d83..5b6a50a461cdf 100644 --- a/lldb/test/API/functionalities/signal/TestSendSignal.py +++ b/lldb/test/API/functionalities/signal/TestSendSignal.py @@ -1,4 +1,4 @@ -"""Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" +"""Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works.""" import lldb ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 46e848a - [lldb][test] Add test-cases for packed/aligned structures (#96932)
Author: Michael Buch Date: 2024-06-28T14:15:09+01:00 New Revision: 46e848a23b212204b01abdc898a53b553d9a57c0 URL: https://github.com/llvm/llvm-project/commit/46e848a23b212204b01abdc898a53b553d9a57c0 DIFF: https://github.com/llvm/llvm-project/commit/46e848a23b212204b01abdc898a53b553d9a57c0.diff LOG: [lldb][test] Add test-cases for packed/aligned structures (#96932) Adds test that checks whether LLDB correctly infers the alignment of packed structures. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes that overlapping field offsets imply a packed structure and thus sets alignment to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809. While here, also added a test-case where we check alignment of a class whose base has an explicit `DW_AT_alignment (those don't get transitively propagated in DWARF, but don't seem like a problem for LLDB). Lastly, also added an XFAIL-ed tests where the aforementioned `InferAlignment` kicks in for overlapping fields (but in this case incorrectly since the structure isn't actually packed). Added: lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp lldb/test/Shell/SymbolFile/DWARF/packed.cpp Modified: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py lldb/test/API/lang/cpp/alignas_base_class/main.cpp Removed: diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py index 7d97b0c42b7e1..362fc2740bf52 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py +++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py @@ -16,3 +16,4 @@ def test(self): # Verify specified class alignments. self.expect_expr("alignof(B2)", result_value="8") self.expect_expr("alignof(EmptyClassAlign8)", result_value="8") +self.expect_expr("alignof(Derived)", result_value="8") diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp index 9d37554957ba3..a37919deaebdc 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp +++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp @@ -13,4 +13,11 @@ D d3g; struct alignas(8) EmptyClassAlign8 { } t; +struct alignas(8) __attribute__((packed)) AlignedAndPackedBase { +} foo; + +struct Derived : AlignedAndPackedBase { +} bar; +static_assert(alignof(Derived) == 8); + int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp new file mode 100644 index 0..1488199a3ad2d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp @@ -0,0 +1,24 @@ +// XFAIL: * + +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(OverlappingFields)" \ +// RUN: -o "expr sizeof(OverlappingFields)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(OverlappingFields) +// CHECK-NEXT: ${{.*}} = 4 +// CHECK: (lldb) expr sizeof(OverlappingFields) +// CHECK-NEXT: ${{.*}} = 8 + +struct Empty {}; + +struct OverlappingFields { + char y; + [[no_unique_address]] Empty e; + int z; +} g_overlapping_struct; +static_assert(alignof(OverlappingFields) == 4); +static_assert(sizeof(OverlappingFields) == 8); + +int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp new file mode 100644 index 0..640a2e0454c92 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp @@ -0,0 +1,35 @@ +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(packed)" \ +// RUN: -o "expr sizeof(packed)" \ +// RUN: -o "expr alignof(packed_and_aligned)" \ +// RUN: -o "expr sizeof(packed_and_aligned)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(packed) +// CHECK-NEXT: ${{.*}} = 1 +// CHECK: (lldb) expr sizeof(packed) +// CHECK-NEXT: ${{.*}} = 9 + +// CHECK: (lldb) expr alignof(packed_and_aligned) +// CHECK-NEXT: ${{.*}} = 16 +// CHECK: (lldb) expr sizeof(packed_and_aligned) +// CHECK-NEXT: ${{.*}} = 16 + +struct __attribute__((packed)) packed { + int x; + char y; + int z; +} g_packed_struct; +static_assert(alignof(packed) == 1); +static_assert(sizeof(packed) == 9); + +struct __attribute__((packed, aligned(16))) packed_and_aligned { + int x; + char y; + int z; +} g_packed_and_aligned_struct; +static_assert(alignof(packed_and_aligned) == 16); +static_assert(sizeof(packed_and_aligned) == 16); + +int main() {} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for alignof on class with overlapping bases (PR #97068)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Follow-up to https://github.com/llvm/llvm-project/pull/96932 Adds XFAILed test where LLDB incorrectly infers the alignment of a derived class whose bases are overlapping due to [[no_unique_address]]. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` assumes that overlapping base offsets imply a packed structure and thus sets alignment to 1. See discussion in https://github.com/llvm/llvm-project/pull/93809. Also adds test where LLDB correctly infers an alignment of `1` when a packed base class is overlapping with other bases. Lastly, there were a couple of `alignof` inconsistencies which I encapsulated in an XFAIL-ed `packed-alignof.cpp`. --- Full diff: https://github.com/llvm/llvm-project/pull/97068.diff 3 Files Affected: - (added) lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp (+30) - (added) lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp (+41) - (modified) lldb/test/Shell/SymbolFile/DWARF/packed.cpp (+14) ``diff diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp new file mode 100644 index 0..634d461e6ff19 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp @@ -0,0 +1,30 @@ +// XFAIL: * + +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(OverlappingDerived)" \ +// RUN: -o "expr sizeof(OverlappingDerived)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(OverlappingDerived) +// CHECK-NEXT: ${{.*}} = 4 +// CHECK: (lldb) expr sizeof(OverlappingDerived) +// CHECK-NEXT: ${{.*}} = 4 + +struct Empty {}; + +struct OverlappingBase { + [[no_unique_address]] Empty e; +}; +static_assert(sizeof(OverlappingBase) == 1); +static_assert(alignof(OverlappingBase) == 1); + +struct Base { + int mem; +}; + +struct OverlappingDerived : Base, OverlappingBase {}; +static_assert(alignof(OverlappingDerived) == 4); +static_assert(sizeof(OverlappingDerived) == 4); + +int main() { OverlappingDerived d; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp new file mode 100644 index 0..a15e88f0b65df --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp @@ -0,0 +1,41 @@ +// XFAIL: * +// +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(base)" \ +// RUN: -o "expr alignof(packed_base)" \ +// RUN: -o "expr alignof(derived)" \ +// RUN: -o "expr sizeof(derived)" \ +// RUN: -o exit | FileCheck %s + +// CHECK: (lldb) expr alignof(base) +// CHECK-NEXT: ${{.*}} = 4 +// CHECK: (lldb) expr alignof(packed_base) +// CHECK-NEXT: ${{.*}} = 1 +// CHECK: (lldb) expr alignof(derived) +// CHECK-NEXT: ${{.*}} = 2 +// CHECK: (lldb) expr sizeof(derived) +// CHECK-NEXT: ${{.*}} = 16 + +struct __attribute__((packed)) packed { + int x; + char y; + int z; +} g_packed_struct; + +// LLDB incorrectly calculates alignof(base) +struct foo {}; +struct base : foo { int x; }; +static_assert(alignof(base) == 4); + +// LLDB incorrectly calculates alignof(packed_base) +struct __attribute__((packed)) packed_base { int x; }; +static_assert(alignof(packed_base) == 1); + +struct derived : packed, packed_base { + short s; +} g_derived; +static_assert(alignof(derived) == 2); +static_assert(sizeof(derived) == 16); + +int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp index 640a2e0454c92..135808f46d7ea 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp @@ -4,6 +4,8 @@ // RUN: -o "expr sizeof(packed)" \ // RUN: -o "expr alignof(packed_and_aligned)" \ // RUN: -o "expr sizeof(packed_and_aligned)" \ +// RUN: -o "expr alignof(derived)" \ +// RUN: -o "expr sizeof(derived)" \ // RUN: -o exit | FileCheck %s // CHECK: (lldb) expr alignof(packed) @@ -16,6 +18,11 @@ // CHECK: (lldb) expr sizeof(packed_and_aligned) // CHECK-NEXT: ${{.*}} = 16 +// CHECK: (lldb) expr alignof(derived) +// CHECK-NEXT: ${{.*}} = 1 +// CHECK: (lldb) expr sizeof(derived) +// CHECK-NEXT: ${{.*}} = 13 + struct __attribute__((packed)) packed { int x; char y; @@ -32,4 +39,11 @@ struct __attribute__((packed, aligned(16))) packed_and_aligned { static_assert(alignof(packed_and_aligned) == 16); static_assert(sizeof(packed_and_aligned) == 16); +struct __attribute__((packed)) packed_base { int x; }; +static_assert(alignof(packed_base) == 1); + +struct derived : packed, packed_base {} g_derived; +static_assert(alignof(derived) == 1); +static_assert(sizeof(derived) == 13); + int main() {} `` https://github.com/llvm/llvm-project/pull/97068 __
[Lldb-commits] [lldb] a52be0c - [lldb-dap] Added "port" property to vscode "attach" command. (#91570)
Author: Santhosh Kumar Ellendula Date: 2024-06-28T10:20:50-05:00 New Revision: a52be0cc114cc58a35bee65c517adaeb66ee6d89 URL: https://github.com/llvm/llvm-project/commit/a52be0cc114cc58a35bee65c517adaeb66ee6d89 DIFF: https://github.com/llvm/llvm-project/commit/a52be0cc114cc58a35bee65c517adaeb66ee6d89.diff LOG: [lldb-dap] Added "port" property to vscode "attach" command. (#91570) Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuration to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "gdb-remote-port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } - Co-authored-by: Santhosh Kumar Ellendula Co-authored-by: Santhosh Kumar Ellendula Added: lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py lldb/tools/lldb-dap/lldb-dap.cpp lldb/tools/lldb-dap/package.json Removed: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index a9eeec1840990..a324af57b61df 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -574,6 +574,8 @@ def request_attach( coreFile=None, postRunCommands=None, sourceMap=None, +gdbRemotePort=None, +gdbRemoteHostname=None, ): args_dict = {} if pid is not None: @@ -603,6 +605,10 @@ def request_attach( args_dict["postRunCommands"] = postRunCommands if sourceMap: args_dict["sourceMap"] = sourceMap +if gdbRemotePort is not None: +args_dict["gdb-remote-port"] = gdbRemotePort +if gdbRemoteHostname is not None: +args_dict["gdb-remote-hostname"] = gdbRemoteHostname command_dict = {"command": "attach", "type": "request", "arguments": args_dict} return self.send_recv(command_dict) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 600dc2b5fe9bb..a312a88ebd7e5 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -3,6 +3,8 @@ import dap_server from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbplatformutil +import lldbgdbserverutils class DAPTestCaseBase(TestBase): @@ -299,6 +301,8 @@ def attach( sourceMap=None, sourceInitFile=False, expectFailure=False, +gdbRemotePort=None, +gdbRemoteHostname=None, ): """Build the default Makefile target, create the DAP debug adaptor, and attach to the process. @@ -329,6 +333,8 @@ def cleanup(): coreFile=coreFile, postRunCommands=postRunCommands, sourceMap=sourceMap, +gdbRemotePort=gdbRemotePort, +gdbRemoteHostname=gdbRemoteHostname, ) if expectFailure: return response @@ -485,3 +491,18 @@ def build_and_launch( launchCommands=launchCommands, expectFailure=expectFailure, ) + +def getBuiltinDebugServerTool(self): +# Tries to find simulation/lldb-server/gdbserver tool path. +server_tool = None +if lldbplatformutil.getPlatform() == "linux": +server_tool = lldbgdbserverutils.get_lldb_server_exe() +if server_tool is None: +self.dap_server.request_disconnect(terminateDebuggee=True) +self.assertIsNotNone(server_tool, "lldb-server not found.") +elif lldbplatformutil.getPlatform() == "macosx": +server_tool = lldbgdbserverutils.get_debugserver_exe() +if server_tool is None: +self.dap_server.request_disconnect(terminateDebuggee=True) +
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)
https://github.com/tedwoodward closed https://github.com/llvm/llvm-project/pull/91570 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)
https://github.com/kusmour approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/97004 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f65a52a - In `statistics dump --summary`, add back the `targets` section (#97004)
Author: royitaqi Date: 2024-06-28T12:13:13-04:00 New Revision: f65a52ab0ec22cf5c25ccf3c9d86b7635964b864 URL: https://github.com/llvm/llvm-project/commit/f65a52ab0ec22cf5c25ccf3c9d86b7635964b864 DIFF: https://github.com/llvm/llvm-project/commit/f65a52ab0ec22cf5c25ccf3c9d86b7635964b864.diff LOG: In `statistics dump --summary`, add back the `targets` section (#97004) # Change https://github.com/llvm/llvm-project/pull/95075 accidentally removed the `targets` section from `statistics dump --summary`. Adding it back, by setting the default value to `true` in `StatisticsOptions::GetIncludeTargets()`. Updated the description for the options. Updated tests. # Verification Manually verified the fix by running `statist dump --summary` and comparing three versions of LLDB (in commit order): 1. Before https://github.com/llvm/llvm-project/pull/95075 2. After https://github.com/llvm/llvm-project/pull/95075 3. After this fix The expected result is that 1 and 3 give the same sections, while 2 is missing the `targets` section when in summary mode. The output (see Appendix) matches the expectation. # Appendix: Manual Test Output ## `statistics dump --summary` of 1 ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 724992, "bytesUnused": 714547, "bytesUsed": 10445 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.00070695, "totalDebugInfoParseTime": 2.5998e-05, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.000223, "totalSymbolTableParseTime": 0.00025798, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 3 Should be the same as above. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 516096, "bytesUnused": 510353, "bytesUsed": 5743 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.0022138, "totalDebugInfoParseTime": 0.00031701, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.0014499, "totalSymbolTableParseTime": 0.001848, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 2 Should be missing the `targets` section. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 716800, "bytesUnused": 705887, "bytesUsed": 10913 } }, "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.001374, "totalDebugInfoParseTime": 0.000174, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.00068301, "totalSymbolTableParseTime": 0.0010139, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` Co-authored-by: royshi Added: Modified: lldb/include/lldb/Target/Statistics.h lldb/source/Commands/Options.td lldb/test/API/commands/statistics/basic/TestStats.py Removed: diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index 122eb3ddd711f..35bd7f8a66e05 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -144,9 +144,8 @@ struct StatisticsOptions { bool GetIncludeTargets() const { if (m_include_targets.has_value()) return m_include_targets.value(); -// `m_include_targets` has no value set, so return a value based on -// `m_summary_only`. -return !GetSummaryOnly(); +// Default to true in both default mode and summary mode. +return true; } void SetIncludeModules(bool value) { m_include_modules = value; } diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ba256e5ab917a..fa8af7cb3d762 100644 --- a/lldb/source/Commands/Options.td +
[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)
https://github.com/kusmour closed https://github.com/llvm/llvm-project/pull/97004 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f0bffb1 - Fix the test to deal with non-deterministic output. (#96800)
Author: Greg Clayton Date: 2024-06-28T09:44:11-07:00 New Revision: f0bffb15b26e65436fa6cf4de12aa85ad0566efa URL: https://github.com/llvm/llvm-project/commit/f0bffb15b26e65436fa6cf4de12aa85ad0566efa DIFF: https://github.com/llvm/llvm-project/commit/f0bffb15b26e65436fa6cf4de12aa85ad0566efa.diff LOG: Fix the test to deal with non-deterministic output. (#96800) When we check for the "struct CustomType" in the NODWP, we can just make sure that we have both types showing up, the next tests will validate the types are correct. Also added a "-DAG" to the integer and float types. This should fix the flakiness in this test. Added: Modified: lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp index 8dd5a5472ed4c..4df1b33dd7d91 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp @@ -30,24 +30,14 @@ // RUN: -o "type lookup CustomType" \ // RUN: -b %t | FileCheck %s --check-prefix=NODWP // NODWP: (lldb) type lookup IntegerType -// NODWP-NEXT: int -// NODWP-NEXT: unsigned int +// NODWP-DAG: int +// NODWP-DAG: unsigned int // NODWP: (lldb) type lookup FloatType -// NODWP-NEXT: double -// NODWP-NEXT: float +// NODWP-DAG: double +// NODWP-DAG: float // NODWP: (lldb) type lookup CustomType -// NODWP-NEXT: struct CustomType { -// NODWP-NEXT: typedef int IntegerType; -// NODWP-NEXT: typedef double FloatType; -// NODWP-NEXT: CustomType::IntegerType x; -// NODWP-NEXT: CustomType::FloatType y; -// NODWP-NEXT: } -// NODWP-NEXT: struct CustomType { -// NODWP-NEXT: typedef unsigned int IntegerType; -// NODWP-NEXT: typedef float FloatType; -// NODWP-NEXT: CustomType::IntegerType x; -// NODWP-NEXT: CustomType::FloatType y; -// NODWP-NEXT: } +// NODWP: struct CustomType { +// NODWP: struct CustomType { // Check when we make the .dwp file with %t.main.dwo first so it will // pick the type unit from %t.main.dwo. Verify we find only the types from ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" (PR #97092)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This reverts commit a2e3af5d581547d3ea53e5383d6f7f1cab45120a and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. --- Full diff: https://github.com/llvm/llvm-project/pull/97092.diff 10 Files Affected: - (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (+2-2) - (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+1-1) - (modified) lldb/include/lldb/Utility/StreamString.h (+4) - (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+6-3) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp (+2-10) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h (+4-3) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp (+4-4) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h (+1-1) - (modified) lldb/source/Target/ThreadPlanPython.cpp (+7-4) - (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py (+1-4) ``diff diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h index 9130f9412cb0b..ee634d15f2a9e 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h @@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface { virtual lldb::StateType GetRunState() { return lldb::eStateStepping; } - virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) { -return true; + virtual llvm::Error GetStopDescription(lldb::StreamSP &stream) { +return llvm::Error::success(); } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index e821a7db2c674..14a52709c1e61 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -575,7 +575,7 @@ class ScriptInterpreter : public PluginInterface { Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const; - Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; + lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; lldb::BreakpointSP GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const; diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h index 3d675caf8f3f4..3287f328a1be3 100644 --- a/lldb/include/lldb/Utility/StreamString.h +++ b/lldb/include/lldb/Utility/StreamString.h @@ -20,6 +20,8 @@ namespace lldb_private { +class ScriptInterpreter; + class StreamString : public Stream { public: StreamString(bool colors = false); @@ -45,6 +47,8 @@ class StreamString : public Stream { void FillLastLineToColumn(uint32_t column, char fill_char); protected: + friend class ScriptInterpreter; + std::string m_packet; size_t WriteImpl(const void *s, size_t length) override; }; diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 75b2a39a8d11b..fa23964a52ffe 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const { return event.m_opaque_ptr; } -Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream( +lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream( const lldb::SBStream &stream) const { - if (stream.m_opaque_up) -return const_cast(stream).m_opaque_up.get(); + if (stream.m_opaque_up) { +lldb::StreamSP s = std::make_shared(); +*s << reinterpret_cast(stream.m_opaque_up.get())->m_packet; +return s; + } return nullptr; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 7d072212676e1..699412e437a1a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -26,15 +26,6 @@ ScriptedPythonInterface::ScriptedPythonInterface( ScriptInterpreterPythonImpl &interpreter) : ScriptedInterface(), m_interpreter(interpreter) {} -template <> -void ScriptedPythonInterface::ReverseTransform( -lldb_private::Stream *&original_arg, python::PythonObject transformed_arg, -Status &error) { - Stream *s = ExtractValueFromPythonObject(transformed_arg, error); - *original_arg = *s; - original_arg->PutCString(static_
[Lldb-commits] [lldb] Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" (PR #97092)
https://github.com/jimingham approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/97092 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6cb45ae - Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" (#97092)
Author: Med Ismail Bennani Date: 2024-06-28T11:53:19-07:00 New Revision: 6cb45aea92dc87974a0064c182600228c6e94329 URL: https://github.com/llvm/llvm-project/commit/6cb45aea92dc87974a0064c182600228c6e94329 DIFF: https://github.com/llvm/llvm-project/commit/6cb45aea92dc87974a0064c182600228c6e94329.diff LOG: Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" (#97092) This reverts commit a2e3af5d581547d3ea53e5383d6f7f1cab45120a and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. Signed-off-by: Med Ismail Bennani Added: Modified: lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/include/lldb/Utility/StreamString.h lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h lldb/source/Target/ThreadPlanPython.cpp lldb/test/API/functionalities/step_scripted/TestStepScripted.py Removed: diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h index 9130f9412cb0b..ee634d15f2a9e 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h @@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface { virtual lldb::StateType GetRunState() { return lldb::eStateStepping; } - virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) { -return true; + virtual llvm::Error GetStopDescription(lldb::StreamSP &stream) { +return llvm::Error::success(); } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index e821a7db2c674..14a52709c1e61 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -575,7 +575,7 @@ class ScriptInterpreter : public PluginInterface { Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const; - Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; + lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; lldb::BreakpointSP GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const; diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h index 3d675caf8f3f4..3287f328a1be3 100644 --- a/lldb/include/lldb/Utility/StreamString.h +++ b/lldb/include/lldb/Utility/StreamString.h @@ -20,6 +20,8 @@ namespace lldb_private { +class ScriptInterpreter; + class StreamString : public Stream { public: StreamString(bool colors = false); @@ -45,6 +47,8 @@ class StreamString : public Stream { void FillLastLineToColumn(uint32_t column, char fill_char); protected: + friend class ScriptInterpreter; + std::string m_packet; size_t WriteImpl(const void *s, size_t length) override; }; diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 75b2a39a8d11b..fa23964a52ffe 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const { return event.m_opaque_ptr; } -Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream( +lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream( const lldb::SBStream &stream) const { - if (stream.m_opaque_up) -return const_cast(stream).m_opaque_up.get(); + if (stream.m_opaque_up) { +lldb::StreamSP s = std::make_shared(); +*s << reinterpret_cast(stream.m_opaque_up.get())->m_packet; +return s; + } return nullptr; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 7d072212676e1..699412e437a1a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -26,15 +26,6 @@ ScriptedPythonInterface::ScriptedPythonInterface( ScriptInterpreterPythonImpl &interpreter) : ScriptedInterface(), m_interpreter(interpreter) {} -template <> -void ScriptedPythonInterface::ReverseTransform( -lldb_private::Stream
[Lldb-commits] [lldb] a4c1813 - [lldb][test] Remove duplicate testcase names in API test-suite (#97043)
Author: Michael Buch Date: 2024-06-28T20:08:53+01:00 New Revision: a4c18137d84bc48df49ee0101bef465a955e62ac URL: https://github.com/llvm/llvm-project/commit/a4c18137d84bc48df49ee0101bef465a955e62ac DIFF: https://github.com/llvm/llvm-project/commit/a4c18137d84bc48df49ee0101bef465a955e62ac.diff LOG: [lldb][test] Remove duplicate testcase names in API test-suite (#97043) In one of my recent PRs I mistakenly had two test-cases with the same name, preventing one of them to run. Since it's an easy mistake to make (e.g., copy pasting existing test-cases), I ran following sanity-check script over `lldb/test/API`, which found couple of tests which were losing coverage because of this (or in some cases simply had duplicate tests): ``` import ast import sys filename = sys.argv[1] print(f'Checking {filename}...') tree = ast.parse(open(filename, 'r').read()) for node in ast.walk(tree): if not isinstance(node, ast.ClassDef): continue func_names = [] for child in ast.iter_child_nodes(node): if isinstance(child, ast.FunctionDef): func_names.append(child.name) seen_func_names = set() duplicate_func_names = [] for name in func_names: if name in seen_func_names: duplicate_func_names.append(name) else: seen_func_names.add(name) if len(duplicate_func_names) != 0: print(f'Multiple func names found:\n\t{duplicate_func_names}\n\tclass {node.name}\n\tfile: {filename}') ``` This patch fixes these cases. Added: Modified: lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py lldb/test/API/functionalities/completion/TestCompletion.py lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py lldb/test/API/lang/cpp/diamond/TestCppDiamond.py lldb/test/API/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py lldb/test/API/test_utils/TestDecorators.py Removed: diff --git a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py index 583c68d7bfacc..dbcd2d60d021a 100644 --- a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py +++ b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py @@ -25,7 +25,7 @@ def test_disable_empty(self): ) @no_debug_info_test -def test_enable_empty(self): +def test_enable_invalid_path(self): invalid_path = os.path.join("this", "is", "not", "a", "valid", "path") self.expect( "log enable lldb all -f " + invalid_path, diff --git a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py index 9678bd42999b3..571024417560f 100644 --- a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py +++ b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py @@ -16,8 +16,6 @@ def test_thread_backtrace_one_thread(self): """Run a simplified version of the test that just hits one breakpoint and doesn't care about synchronizing the two threads - hopefully this will run on more systems.""" - -def test_thread_backtrace_one_thread(self): self.build() ( self.inferior_target, diff --git a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py index c41e85fd670ba..12f99f07c78a8 100644 --- a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -31,43 +31,6 @@ def testStartMultipleLiveThreads(self): self.traceStopProcess() -@skipIf(oslist=no_match(["linux"]), archs=no_match(["i386", "x86_64"])) -@testSBAPIAndCommands -def testStartMultipleLiveThreadsWithStops(self): -self.build() -exe = self.getBuildArtifact("a.out") - -self.dbg.CreateTarget(exe) - -self.expect("b main") -self.expect("b 6") -self.expect("b 11") - -self.expect("r") -self.traceStartProcess() - -# We'll see here the first thread -self.expect("continue") - -# We are in thread 2 -self.expect("thread trace dump instructions", substrs=["main.cpp:9"]) -self.expect("thread trace dump instructions 2", substrs=["main.cpp:9"]) - -# We stop tracing it -self.expect("thread trace stop 2") - -# The trace is still in memory -
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,102 @@ +//===-- ThreadPlanSingleThreadTimeout.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_TARGET_THREADPLANSINGLETHREADTIMEOUT_H +#define LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H + +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/State.h" + +#include + +namespace lldb_private { + +// +// Thread plan used by single thread execution to issue timeout. This is useful +// to detect potential deadlock in single thread execution. The timeout measures +// the elapsed time from the last internal stop and gets reset by each internal +// stop to ensure we are accurately detecting execution not moving forward. +// This means this thread plan may be created/destroyed multiple times by the +// parent execution plan. +// +// When timeout happens, the thread plan resolves the potential deadlock by jimingham wrote: "When a timeout happens" https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,102 @@ +//===-- ThreadPlanSingleThreadTimeout.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_TARGET_THREADPLANSINGLETHREADTIMEOUT_H +#define LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H + +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/State.h" + +#include + +namespace lldb_private { + +// +// Thread plan used by single thread execution to issue timeout. This is useful +// to detect potential deadlock in single thread execution. The timeout measures +// the elapsed time from the last internal stop and gets reset by each internal +// stop to ensure we are accurately detecting execution not moving forward. +// This means this thread plan may be created/destroyed multiple times by the +// parent execution plan. +// +// When timeout happens, the thread plan resolves the potential deadlock by +// issuing a thread specific async interrupt to enter stop state, then all +// threads execution are resumed to resolve the potential deadlock. jimingham wrote: "then execution is resumed with all threads running to resolve the potential deadlock" https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,102 @@ +//===-- ThreadPlanSingleThreadTimeout.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_TARGET_THREADPLANSINGLETHREADTIMEOUT_H +#define LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H + +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/State.h" + +#include + +namespace lldb_private { + +// +// Thread plan used by single thread execution to issue timeout. This is useful +// to detect potential deadlock in single thread execution. The timeout measures +// the elapsed time from the last internal stop and gets reset by each internal +// stop to ensure we are accurately detecting execution not moving forward. +// This means this thread plan may be created/destroyed multiple times by the +// parent execution plan. +// +// When timeout happens, the thread plan resolves the potential deadlock by +// issuing a thread specific async interrupt to enter stop state, then all +// threads execution are resumed to resolve the potential deadlock. +// +class ThreadPlanSingleThreadTimeout : public ThreadPlan { + enum class State { +WaitTimeout,// Waiting for timeout. +AsyncInterrupt, // Async interrupt has been issued. +Done, // Finished resume all threads. + }; + +public: + struct TimeoutInfo { jimingham wrote: This isn't something you need to do in this patch, but it would be good to allow different thread plan invocations to use different timeouts, and not just depend on the thread timeout. For instance, we should be able to reimplement RunThreadPlan with this infrastructure. But the timeouts you want for expression evaluation and stepping are likely to be very different (and different executions also use different timeouts). So being able to pass in the timeout, rather than relying on one thread specific one will be necessary. We could for instance add the timeout to the TimeoutInfo and plumb that so that the ThreadPlan that mixes in TimeoutResumeAll can pass in a timeout. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,102 @@ +//===-- ThreadPlanSingleThreadTimeout.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_TARGET_THREADPLANSINGLETHREADTIMEOUT_H +#define LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H + +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/State.h" + +#include + +namespace lldb_private { + +// +// Thread plan used by single thread execution to issue timeout. This is useful +// to detect potential deadlock in single thread execution. The timeout measures +// the elapsed time from the last internal stop and gets reset by each internal +// stop to ensure we are accurately detecting execution not moving forward. +// This means this thread plan may be created/destroyed multiple times by the +// parent execution plan. +// +// When timeout happens, the thread plan resolves the potential deadlock by +// issuing a thread specific async interrupt to enter stop state, then all +// threads execution are resumed to resolve the potential deadlock. +// +class ThreadPlanSingleThreadTimeout : public ThreadPlan { + enum class State { +WaitTimeout,// Waiting for timeout. +AsyncInterrupt, // Async interrupt has been issued. +Done, // Finished resume all threads. + }; + +public: + struct TimeoutInfo { +ThreadPlanSingleThreadTimeout *m_instance = nullptr; +ThreadPlanSingleThreadTimeout::State m_last_state = State::WaitTimeout; + }; + + ~ThreadPlanSingleThreadTimeout() override; + + // If input \param thread is running in single thread mode, push a + // new ThreadPlanSingleThreadTimeout based on timeout setting from fresh new + // state. The reference of \param info is passed in so that when + // ThreadPlanSingleThreadTimeout got popped out its last state can be stored jimingham wrote: "popped out" is confusing. We just say "popped" for the most part. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) jimingham wrote: This seems like an odd thing to do in the destructor. Why is this necessary? https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); jimingham wrote: I think it would be super handy to print the time remaining here. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); jimingham wrote: definitely want the timeout in this log message. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); jimingham wrote: Also here, for debugging purposes it will be really handy to have the timeout value here. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); +} + +bool ThreadPlanSingleThreadTimeout::WillStop() { + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::WillStop()."); + + // Reset the state during stop. + m_info.m_last_state = State::WaitTimeout; + m_info.m_instance = this; jimingham wrote: I'm not clear what this m_instance variable is for? You don't use it as a pointer, so I don't think it needs to hold `this`. It seems to be a `should_resume_from_prev_state` flag. Is that right? Anyway, this is confusing. If this needs to be the `this` pointer you should say why somewhere. If it's a state variable, use a bool instead. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); +} + +bool ThreadPlanSingleThreadTimeout::WillStop() { + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::WillStop()."); + + // Reset the state during stop. + m_info.m_last_state = State::WaitTimeout; + m_info.m_instance = this; + return true; +} + +void ThreadPlanSingleThreadTimeout::DidPop() { + Log *log = GetLog(LLDBLog::Step); + { +std::lock_guard lock(m_mutex); +LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::DidPop()."); +// Tell timer thread to exit. +m_exit_flag = true; + } + m_wakeup_cv.notify_one(); + // Wait for timer thread to exit. + m_timer_thread.join(); +} + +bool ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(Event *event_ptr) { + lldb::StateType stop_state = + Process::ProcessEventData::GetStateFromEvent(event_ptr); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF( jimingham wrote: This is another place where it will probably be useful to see the timeout value if we're logging. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); +} + +bool ThreadPlanSingleThreadTimeout::WillStop() { + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::WillStop()."); + + // Reset the state during stop. + m_info.m_last_state = State::WaitTimeout; + m_info.m_instance = this; + return true; +} + +void ThreadPlanSingleThreadTimeout::DidPop() { + Log *log = GetLog(LLDBLog::Step); + { +std::lock_guard lock(m_mutex); +LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::DidPop()."); +// Tell timer thread to exit. +m_exit_flag = true; + } + m_wakeup_cv.notify_one(); + // Wait for timer thread to exit. + m_timer_thread.join(); +} + +bool ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(Event *event_ptr) { + lldb::StateType stop_state = + Process::ProcessEventData::GetStateFromEvent(event_ptr); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF( + log, + "ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(): got event: %s.", + StateAsCString(stop_state)); + return true; +} + +lldb::StateType ThreadPlanSingleThreadTimeout::GetPlanRunState() { + return GetPreviousPlan()->GetPlanRunState(); +} + +void ThreadPlanSingleThreadTimeout::TimeoutThreadFunc( +ThreadPlanSingleThreadTimeout *self) { jimingham wrote: Depending on how much this gets used, we might not want to spin up this threa
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); +} + +bool ThreadPlanSingleThreadTimeout::WillStop() { + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::WillStop()."); + + // Reset the state during stop. + m_info.m_last_state = State::WaitTimeout; + m_info.m_instance = this; + return true; +} + +void ThreadPlanSingleThreadTimeout::DidPop() { + Log *log = GetLog(LLDBLog::Step); + { +std::lock_guard lock(m_mutex); +LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::DidPop()."); +// Tell timer thread to exit. +m_exit_flag = true; + } + m_wakeup_cv.notify_one(); + // Wait for timer thread to exit. + m_timer_thread.join(); +} + +bool ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(Event *event_ptr) { + lldb::StateType stop_state = + Process::ProcessEventData::GetStateFromEvent(event_ptr); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF( + log, + "ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(): got event: %s.", + StateAsCString(stop_state)); + return true; +} + +lldb::StateType ThreadPlanSingleThreadTimeout::GetPlanRunState() { + return GetPreviousPlan()->GetPlanRunState(); +} + +void ThreadPlanSingleThreadTimeout::TimeoutThreadFunc( +ThreadPlanSingleThreadTimeout *self) { + std::unique_lock lock(self->m_mutex); + uint64_t timeout_in_ms = self->GetThread().GetSingleThreadPlanTimeou
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -0,0 +1,217 @@ +//===-- ThreadPlanStepOverRange.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Target/ThreadPlanSingleThreadTimeout.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanStepOut.h" +#include "lldb/Target/ThreadPlanStepThrough.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" + +using namespace lldb_private; +using namespace lldb; + +ThreadPlanSingleThreadTimeout::ThreadPlanSingleThreadTimeout(Thread &thread, + TimeoutInfo &info) +: ThreadPlan(ThreadPlan::eKindSingleThreadTimeout, "Single thread timeout", + thread, eVoteNo, eVoteNoOpinion), + m_info(info), m_state(State::WaitTimeout), m_exit_flag(false) { + m_timer_thread = std::thread(TimeoutThreadFunc, this); + m_info.m_instance = this; + m_state = m_info.m_last_state; +} + +ThreadPlanSingleThreadTimeout::~ThreadPlanSingleThreadTimeout() { + m_info.m_instance = nullptr; + if (m_state == State::Done) +m_state = State::WaitTimeout; +} + +void ThreadPlanSingleThreadTimeout::GetDescription( +Stream *s, lldb::DescriptionLevel level) { + s->Printf("Single thread timeout, state(%s)", StateToString(m_state).c_str()); +} + +std::string ThreadPlanSingleThreadTimeout::StateToString(State state) { + switch (state) { + case State::WaitTimeout: +return "WaitTimeout"; + case State::AsyncInterrupt: +return "AsyncInterrupt"; + case State::Done: +return "Done"; + } +} + +void ThreadPlanSingleThreadTimeout::PushNewWithTimeout(Thread &thread, + TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout pushing a brand new one"); +} + +void ThreadPlanSingleThreadTimeout::ResumeFromPrevState(Thread &thread, +TimeoutInfo &info) { + uint64_t timeout_in_ms = thread.GetSingleThreadPlanTimeout(); + if (timeout_in_ms == 0) +return; + + if (info.m_instance != nullptr) +return; + + // Do not create timeout if we are not stopping other threads. + if (!thread.GetCurrentPlan()->StopOthers()) +return; + + auto timeout_plan = new ThreadPlanSingleThreadTimeout(thread, info); + ThreadPlanSP thread_plan_sp(timeout_plan); + auto status = thread.QueueThreadPlan(thread_plan_sp, + /*abort_other_plans*/ false); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout reset from previous state"); +} + +bool ThreadPlanSingleThreadTimeout::WillStop() { + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::WillStop()."); + + // Reset the state during stop. + m_info.m_last_state = State::WaitTimeout; + m_info.m_instance = this; + return true; +} + +void ThreadPlanSingleThreadTimeout::DidPop() { + Log *log = GetLog(LLDBLog::Step); + { +std::lock_guard lock(m_mutex); +LLDB_LOGF(log, "ThreadPlanSingleThreadTimeout::DidPop()."); +// Tell timer thread to exit. +m_exit_flag = true; + } + m_wakeup_cv.notify_one(); + // Wait for timer thread to exit. + m_timer_thread.join(); +} + +bool ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(Event *event_ptr) { + lldb::StateType stop_state = + Process::ProcessEventData::GetStateFromEvent(event_ptr); + Log *log = GetLog(LLDBLog::Step); + LLDB_LOGF( + log, + "ThreadPlanSingleThreadTimeout::DoPlanExplainsStop(): got event: %s.", + StateAsCString(stop_state)); + return true; +} + +lldb::StateType ThreadPlanSingleThreadTimeout::GetPlanRunState() { + return GetPreviousPlan()->GetPlanRunState(); +} + +void ThreadPlanSingleThreadTimeout::TimeoutThreadFunc( +ThreadPlanSingleThreadTimeout *self) { + std::unique_lock lock(self->m_mutex); + uint64_t timeout_in_ms = self->GetThread().GetSingleThreadPlanTimeou
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -58,8 +58,13 @@ class ThreadPlanStepRange : public ThreadPlan { // run' plan, then just single step. bool SetNextBranchBreakpoint(); + // Whether the input stop info is caused by the next branch breakpoint. jimingham wrote: This routine does NOT distinguish between the cases where the next branch breakpoint is the ONLY breakpoint at this site, and where it's one of many breakpoints that share this site. Later, you distinguish between the two cases where this is used (e.g. in ThreadPlanStepRange::NextRangeBreakpointExplainsStop. It might be interesting to see if it makes sense to incorporate the logic that does that into IsNextBranchBreakpointStop. If it does that would allow some code reuse. If it does not, you should note in the comment here that it does not distinguish between the two cases, so someone doesn't make a mistake later on. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
jimingham wrote: I left some more comments, most of them either nits or future work - unless you want to do them here... This makes sense to me, so it's likely right. But the tests you've written so far are just about making sure that deadlocks are resolved in a simple stepping situation where nothing user-visible happens while you are stepping. We need to make sure that if the "next" is interrupted - for instance by hitting a breakpoint in the code being stepped over, that once stopped, lldb can do other step operations having stopped and they work as expected. Also, in lldb, if you do a `next` and that steps over a function that hits a breakpoint, the next stays on the stack and then "continue" will resume execution of the "next" ThreadPlan, completing the step. We should make sure that works and keeps tracking the single thread in a case where there's no deadlock to resolve, or goes on to resolve the deadlock. We also really want to make sure that the async interrupt that you use here and the one that the user uses (through SBProcess.SendAsyncInterrupt) don't interfere with one another. So step over something with a really long user step timeout, then send an asynchronous interrupt and make sure we stop with the right stop reason. And then make sure the next continues successfully after that. Also, if we can it would be nice to test that this succeeds in NOT allowing the other threads to run before the timeout elapses. You could have your worker thread stop right before code that's going to crash, and then switch to the main thread and do a bunch of steps over code that calls some function that will do a pthread yield. If the process doesn't crash after those steps, you're good. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make semantics of SupportFile equivalence explicit (PR #97126)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes This is an improved attempt to improve the semantics of SupportFile equivalence, taking into account the feedback from #95606. Pavel's comment about the lack of a concise name because the concept isn't trivial made me realize that I don't want to abstract this concept away behind a helper function. Instead, I opted for a rather verbose enum that forces the caller to consider exactly what kind of comparison is appropriate for every call. --- Full diff: https://github.com/llvm/llvm-project/pull/97126.diff 7 Files Affected: - (modified) lldb/include/lldb/Utility/SupportFile.h (+31-8) - (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+3-2) - (modified) lldb/source/Commands/CommandObjectSource.cpp (+6-2) - (modified) lldb/source/Symbol/LineEntry.cpp (+2-1) - (modified) lldb/source/Symbol/LineTable.cpp (+1-1) - (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+9-6) - (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+3-2) ``diff diff --git a/lldb/include/lldb/Utility/SupportFile.h b/lldb/include/lldb/Utility/SupportFile.h index 21b986dcaba28..4b672684e4b4e 100644 --- a/lldb/include/lldb/Utility/SupportFile.h +++ b/lldb/include/lldb/Utility/SupportFile.h @@ -11,6 +11,7 @@ #include "lldb/Utility/Checksum.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Flags.h" namespace lldb_private { @@ -30,15 +31,37 @@ class SupportFile { virtual ~SupportFile() = default; - /// Return true if both SupportFiles have the same FileSpec and, if both have - /// a valid Checksum, the Checksum is the same. - bool operator==(const SupportFile &other) const { -if (m_checksum && other.m_checksum) - return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum; -return m_file_spec == other.m_file_spec; - } + enum SupportFileEquality : uint8_t { +eEqualFileSpec = (1u << 1), +eEqualChecksum = (1u << 2), +eEqualChecksumIfSet = (1u << 3), +eEqualFileSpecAndChecksum = eEqualFileSpec | eEqualChecksum, +eEqualFileSpecAndChecksumIfSet = eEqualFileSpec | eEqualChecksumIfSet, + }; + + bool Equal(const SupportFile &other, + SupportFileEquality equality = eEqualFileSpecAndChecksum) const { +assert(!(equality & eEqualChecksum & eEqualChecksumIfSet) && + "eEqualChecksum and eEqualChecksumIfSet are mutually exclusive"); + +if (equality & eEqualFileSpec) { + if (m_file_spec != other.m_file_spec) +return false; +} - bool operator!=(const SupportFile &other) const { return !(*this == other); } +if (equality & eEqualChecksum) { + if (m_checksum != other.m_checksum) +return false; +} + +if (equality & eEqualChecksumIfSet) { + if (m_checksum && other.m_checksum) +if (m_checksum != other.m_checksum) + return false; +} + +return true; + } /// Return the file name only. Useful for resolving breakpoints by file name. const FileSpec &GetSpecOnly() const { return m_file_spec; }; diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index ff4e2a9985197..2d52cbf827ef9 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -222,8 +222,9 @@ void BreakpointResolver::SetSCMatchesByLine( auto worklist_begin = std::partition( all_scs.begin(), all_scs.end(), [&](const SymbolContext &sc) { if (sc.line_entry.GetFile() == match.line_entry.GetFile() || - *sc.line_entry.original_file_sp == - *match.line_entry.original_file_sp) { + sc.line_entry.original_file_sp->Equal( + *match.line_entry.original_file_sp, + SupportFile::eEqualFileSpecAndChecksumIfSet)) { // When a match is found, keep track of the smallest line number. closest_line = std::min(closest_line, sc.line_entry.line); return false; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 0c1267456a184..f54b712adfc46 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -747,13 +747,17 @@ class CommandObjectSourceList : public CommandObjectParsed { bool operator==(const SourceInfo &rhs) const { return function == rhs.function && - *line_entry.original_file_sp == *rhs.line_entry.original_file_sp && + line_entry.original_file_sp->Equal( + *rhs.line_entry.original_file_sp, + SupportFile::eEqualFileSpecAndChecksumIfSet) && line_entry.line == rhs.line_entry.line; } bool operator!=(const SourceInfo &rhs) const { return function != rhs.function || - *line_entry.original_file_sp != *rhs.line_entry.original_file_
[Lldb-commits] [lldb] ed95844 - [lldb][test] Add tests for alignof on class with overlapping bases (#97068)
Author: Michael Buch Date: 2024-06-29T08:38:17+01:00 New Revision: ed9584457def4a51596b9d72ce76a1bfed88fa30 URL: https://github.com/llvm/llvm-project/commit/ed9584457def4a51596b9d72ce76a1bfed88fa30 DIFF: https://github.com/llvm/llvm-project/commit/ed9584457def4a51596b9d72ce76a1bfed88fa30.diff LOG: [lldb][test] Add tests for alignof on class with overlapping bases (#97068) Follow-up to https://github.com/llvm/llvm-project/pull/96932 Adds XFAILed test where LLDB incorrectly infers the alignment of a derived class whose bases are overlapping due to [[no_unique_address]]. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` assumes that overlapping base offsets imply a packed structure and thus sets alignment to 1. See discussion in https://github.com/llvm/llvm-project/pull/93809. Also adds test where LLDB correctly infers an alignment of `1` when a packed base class is overlapping with other bases. Lastly, there were a couple of `alignof` inconsistencies which I encapsulated in an XFAIL-ed `packed-alignof.cpp`. Added: lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp Modified: lldb/test/Shell/SymbolFile/DWARF/packed.cpp Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp new file mode 100644 index 0..15d8de0e3ee98 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp @@ -0,0 +1,30 @@ +// XFAIL: * + +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(OverlappingDerived)" \ +// RUN: -o "expr sizeof(OverlappingDerived)" \ +// RUN: -o exit | FileCheck %s + +struct Empty {}; + +struct OverlappingBase { + [[no_unique_address]] Empty e; +}; +static_assert(sizeof(OverlappingBase) == 1); +static_assert(alignof(OverlappingBase) == 1); + +struct Base { + int mem; +}; + +struct OverlappingDerived : Base, OverlappingBase {}; +static_assert(alignof(OverlappingDerived) == 4); +static_assert(sizeof(OverlappingDerived) == 4); + +// CHECK: (lldb) expr alignof(OverlappingDerived) +// CHECK-NEXT: ${{.*}} = 4 +// CHECK: (lldb) expr sizeof(OverlappingDerived) +// CHECK-NEXT: ${{.*}} = 4 + +int main() { OverlappingDerived d; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp new file mode 100644 index 0..dcc02736a9be7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp @@ -0,0 +1,43 @@ +// XFAIL: * +// +// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %lldb %t \ +// RUN: -o "expr alignof(base)" \ +// RUN: -o "expr alignof(packed_base)" \ +// RUN: -o "expr alignof(derived)" \ +// RUN: -o "expr sizeof(derived)" \ +// RUN: -o exit | FileCheck %s + +struct __attribute__((packed)) packed { + int x; + char y; + int z; +} g_packed_struct; + +// LLDB incorrectly calculates alignof(base) +struct foo {}; +struct base : foo { int x; }; +static_assert(alignof(base) == 4); + +// CHECK: (lldb) expr alignof(base) +// CHECK-NEXT: ${{.*}} = 4 + +// LLDB incorrectly calculates alignof(packed_base) +struct __attribute__((packed)) packed_base { int x; }; +static_assert(alignof(packed_base) == 1); + +// CHECK: (lldb) expr alignof(packed_base) +// CHECK-NEXT: ${{.*}} = 1 + +struct derived : packed, packed_base { + short s; +} g_derived; +static_assert(alignof(derived) == 2); +static_assert(sizeof(derived) == 16); + +// CHECK: (lldb) expr alignof(derived) +// CHECK-NEXT: ${{.*}} = 2 +// CHECK: (lldb) expr sizeof(derived) +// CHECK-NEXT: ${{.*}} = 16 + +int main() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp index 640a2e0454c92..360293b1d4184 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp @@ -4,18 +4,10 @@ // RUN: -o "expr sizeof(packed)" \ // RUN: -o "expr alignof(packed_and_aligned)" \ // RUN: -o "expr sizeof(packed_and_aligned)" \ +// RUN: -o "expr alignof(derived)" \ +// RUN: -o "expr sizeof(derived)" \ // RUN: -o exit | FileCheck %s -// CHECK: (lldb) expr alignof(packed) -// CHECK-NEXT: ${{.*}} = 1 -// CHECK: (lldb) expr sizeof(packed) -// CHECK-NEXT: ${{.*}} = 9 - -// CHECK: (lldb) expr alignof(packed_and_aligned) -// CHECK-NEXT: ${{.*}} = 16 -// CHECK: (lldb) expr sizeof(packed_and_aligned) -// CHECK-NEXT: ${{.*}} = 16 - struct __attribute__((packed)) packed { int x; char y; @@ -24,6 +16,11 @@ struct __attribute__((packed)) packed { static_assert(alignof(packed) == 1); static_assert(sizeof(packed) == 9); +// CHECK: (lldb) expr alignof(packed) +// CHECK-NEXT: ${{.*}} = 1 +// CHECK: (lldb) expr sizeof(packed) +//
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)
tedwoodward wrote: > This breaks lldb-api :: > tools/lldb-server/commandline/TestGdbRemoteConnection.py on > lldb-aarch64-windows bot. > > https://lab.llvm.org/buildbot/#/builders/141/builds/376 File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-server\lldbgdbserverutils.py", line 1045, in __init__ self.name = "lldb-" + str(random.randrange(1e10)) ^^ NameError: name 'random' is not defined Looks like "import random" should have been added to lldbgdbserverutils.py when the pipe class was moved from TestGDBRemoteConnection.py. https://github.com/llvm/llvm-project/pull/91570 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)
temyurchenko wrote: > Do you need someone to land these changes on your behalf? Given that the PR is approved, perhaps, yo > Do you need someone to land these changes on your behalf? @erichkeane, perhaps you can land these, given that the PR is approved? https://github.com/llvm/llvm-project/pull/93913 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d9e659c - Revert "[lldb] Parse and display register field enums" (#97258)
Author: David Spickett Date: 2024-07-01T07:46:19+01:00 New Revision: d9e659c538516036e40330b6a98160cbda4ff100 URL: https://github.com/llvm/llvm-project/commit/d9e659c538516036e40330b6a98160cbda4ff100 DIFF: https://github.com/llvm/llvm-project/commit/d9e659c538516036e40330b6a98160cbda4ff100.diff LOG: Revert "[lldb] Parse and display register field enums" (#97258) Reverts llvm/llvm-project#95768 due to a test failure on macOS with ASAN: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/425/console Added: Modified: lldb/include/lldb/Target/RegisterFlags.h lldb/source/Core/DumpRegisterInfo.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp lldb/source/Target/RegisterFlags.cpp lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py lldb/unittests/Core/DumpRegisterInfoTest.cpp Removed: diff --git a/lldb/include/lldb/Target/RegisterFlags.h b/lldb/include/lldb/Target/RegisterFlags.h index 1250fd0330958..1112972cf72e1 100644 --- a/lldb/include/lldb/Target/RegisterFlags.h +++ b/lldb/include/lldb/Target/RegisterFlags.h @@ -32,15 +32,10 @@ class FieldEnum { : m_value(value), m_name(std::move(name)) {} void ToXML(Stream &strm) const; - -void DumpToLog(Log *log) const; }; typedef std::vector Enumerators; - // GDB also includes a "size" that is the size of the underlying register. - // We will not store that here but instead use the size of the register - // this gets attached to when emitting XML. FieldEnum(std::string id, const Enumerators &enumerators); const Enumerators &GetEnumerators() const { return m_enumerators; } @@ -49,8 +44,6 @@ class FieldEnum { void ToXML(Stream &strm, unsigned size) const; - void DumpToLog(Log *log) const; - private: std::string m_id; Enumerators m_enumerators; diff --git a/lldb/source/Core/DumpRegisterInfo.cpp b/lldb/source/Core/DumpRegisterInfo.cpp index eccc6784cd497..8334795416902 100644 --- a/lldb/source/Core/DumpRegisterInfo.cpp +++ b/lldb/source/Core/DumpRegisterInfo.cpp @@ -111,11 +111,6 @@ void lldb_private::DoDumpRegisterInfo( }; DumpList(strm, "In sets: ", in_sets, emit_set); - if (flags_type) { + if (flags_type) strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str()); - -std::string enumerators = flags_type->DumpEnums(terminal_width); -if (enumerators.size()) - strm << "\n\n" << enumerators; - } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 604c92369e9a2..060a30abee83e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4179,134 +4179,21 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { - Log *log(GetLog(GDBRLog::Process)); - // We will use the last instance of each value. Also we preserve the order - // of declaration in the XML, as it may not be numerical. - // For example, hardware may intially release with two states that softwware - // can read from a register field: - // 0 = startup, 1 = running - // If in a future hardware release, the designers added a pre-startup state: - // 0 = startup, 1 = running, 2 = pre-startup - // Now it makes more sense to list them in this logical order as opposed to - // numerical order: - // 2 = pre-startup, 1 = startup, 0 = startup - // This only matters for "register info" but let's trust what the server - // chose regardless. - std::map enumerators; - - enum_node.ForEachChildElementWithName( - "evalue", [&enumerators, &log](const XMLNode &enumerator_node) { -std::optional name; -std::optional value; - -enumerator_node.ForEachAttribute( -[&name, &value, &log](const llvm::StringRef &attr_name, - const llvm::StringRef &attr_value) { - if (attr_name == "name") { -if (attr_value.size()) - name = attr_value; -else - LLDB_LOG(log, "ProcessGDBRemote::ParseEnumEvalues " -"Ignoring empty name in evalue"); - } else if (attr_name == "value") { -uint64_t parsed_value = 0; -if (llvm::to_integer(attr_value, parsed_value)) - value = parsed_value; -else - LLDB_LOG(log, - "ProcessGDBRemote::ParseEnumEvalues " - "Invalid value \"{0}\" in " - "evalue", - attr_value.data
[Lldb-commits] [lldb] Revert "[lldb] Parse and display register field enums" (PR #97258)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Reverts llvm/llvm-project#95768 due to a test failure on macOS with ASAN: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/425/console --- Patch is 34.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97258.diff 8 Files Affected: - (modified) lldb/include/lldb/Target/RegisterFlags.h (-7) - (modified) lldb/source/Core/DumpRegisterInfo.cpp (+1-6) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+18-180) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (-5) - (modified) lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp (+3-37) - (modified) lldb/source/Target/RegisterFlags.cpp (-10) - (modified) lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (-402) - (modified) lldb/unittests/Core/DumpRegisterInfoTest.cpp (-26) ``diff diff --git a/lldb/include/lldb/Target/RegisterFlags.h b/lldb/include/lldb/Target/RegisterFlags.h index 1250fd0330958..1112972cf72e1 100644 --- a/lldb/include/lldb/Target/RegisterFlags.h +++ b/lldb/include/lldb/Target/RegisterFlags.h @@ -32,15 +32,10 @@ class FieldEnum { : m_value(value), m_name(std::move(name)) {} void ToXML(Stream &strm) const; - -void DumpToLog(Log *log) const; }; typedef std::vector Enumerators; - // GDB also includes a "size" that is the size of the underlying register. - // We will not store that here but instead use the size of the register - // this gets attached to when emitting XML. FieldEnum(std::string id, const Enumerators &enumerators); const Enumerators &GetEnumerators() const { return m_enumerators; } @@ -49,8 +44,6 @@ class FieldEnum { void ToXML(Stream &strm, unsigned size) const; - void DumpToLog(Log *log) const; - private: std::string m_id; Enumerators m_enumerators; diff --git a/lldb/source/Core/DumpRegisterInfo.cpp b/lldb/source/Core/DumpRegisterInfo.cpp index eccc6784cd497..8334795416902 100644 --- a/lldb/source/Core/DumpRegisterInfo.cpp +++ b/lldb/source/Core/DumpRegisterInfo.cpp @@ -111,11 +111,6 @@ void lldb_private::DoDumpRegisterInfo( }; DumpList(strm, "In sets: ", in_sets, emit_set); - if (flags_type) { + if (flags_type) strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str()); - -std::string enumerators = flags_type->DumpEnums(terminal_width); -if (enumerators.size()) - strm << "\n\n" << enumerators; - } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 604c92369e9a2..060a30abee83e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4179,134 +4179,21 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { - Log *log(GetLog(GDBRLog::Process)); - // We will use the last instance of each value. Also we preserve the order - // of declaration in the XML, as it may not be numerical. - // For example, hardware may intially release with two states that softwware - // can read from a register field: - // 0 = startup, 1 = running - // If in a future hardware release, the designers added a pre-startup state: - // 0 = startup, 1 = running, 2 = pre-startup - // Now it makes more sense to list them in this logical order as opposed to - // numerical order: - // 2 = pre-startup, 1 = startup, 0 = startup - // This only matters for "register info" but let's trust what the server - // chose regardless. - std::map enumerators; - - enum_node.ForEachChildElementWithName( - "evalue", [&enumerators, &log](const XMLNode &enumerator_node) { -std::optional name; -std::optional value; - -enumerator_node.ForEachAttribute( -[&name, &value, &log](const llvm::StringRef &attr_name, - const llvm::StringRef &attr_value) { - if (attr_name == "name") { -if (attr_value.size()) - name = attr_value; -else - LLDB_LOG(log, "ProcessGDBRemote::ParseEnumEvalues " -"Ignoring empty name in evalue"); - } else if (attr_name == "value") { -uint64_t parsed_value = 0; -if (llvm::to_integer(attr_value, parsed_value)) - value = parsed_value; -else - LLDB_LOG(log, - "ProcessGDBRemote::ParseEnumEvalues " - "Invalid value \"{0}\" in " - "evalue", - attr_value.data()); - } else -LLDB_LOG(log, - "ProcessGDBRemote::Pa
[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This patch adds the documentation for a subset of scripting extensions such as scripted process, scripted thread, operating system threads & scritped thread plans to the lldb website. --- Full diff: https://github.com/llvm/llvm-project/pull/97262.diff 6 Files Affected: - (modified) lldb/docs/CMakeLists.txt (+8-1) - (modified) lldb/docs/use/python.rst (+59) - (modified) lldb/examples/python/templates/operating_system.py (+9-10) - (modified) lldb/examples/python/templates/scripted_platform.py (+11-13) - (modified) lldb/examples/python/templates/scripted_process.py (+16-23) - (added) lldb/examples/python/templates/scripted_thread_plan.py (+70) ``diff diff --git a/lldb/docs/CMakeLists.txt b/lldb/docs/CMakeLists.txt index f482e91d1b10c..f327596f3ef31 100644 --- a/lldb/docs/CMakeLists.txt +++ b/lldb/docs/CMakeLists.txt @@ -25,10 +25,17 @@ if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND) # Pretend that the SWIG generated API is a Python package. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb) get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR) + add_custom_target(lldb-python-doc-package COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins" + COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/" + COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/" + COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/" + COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_thread_plan.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/" COMMENT "Copying lldb.py to pretend its a Python package.") -add_dependencies(lldb-python-doc-package swig_wrapper_python) + +add_dependencies(lldb-python-doc-package swig_wrapper_python lldb-python) # FIXME: Don't treat Sphinx warnings as errors. The files generated by # automodapi are full of warnings (partly caused by SWIG, our documentation diff --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst index d9c29d95708c1..39a488c2d84f5 100644 --- a/lldb/docs/use/python.rst +++ b/lldb/docs/use/python.rst @@ -11,6 +11,65 @@ some of these things by going through an example, explaining how to use Python scripting to find a bug in a program that searches for text in a large binary tree. +Operating System Thread Plugins +--- + +.. automodapi:: lldb.plugins.operating_system +:no-heading: +:members: +:undoc-members: +:skip: command +:skip: declaration +:skip: in_range +:skip: is_numeric_type +:skip: lldb_iter +:no-inheritance-diagram: + +Scripted Process Plugins +--- + +.. automodapi:: lldb.plugins.scripted_process +:no-heading: +:members: +:undoc-members: +:skip: ABCMeta +:skip: command +:skip: declaration +:skip: in_range +:skip: is_numeric_type +:skip: lldb_iter +:no-inheritance-diagram: + +Scripted Platform Plugins +--- + +.. automodapi:: lldb.plugins.scripted_platform +:no-heading: +:members: +:undoc-members: +:skip: ABCMeta +:skip: command +:skip: declaration +:skip: in_range +:skip: is_numeric_type +:skip: lldb_iter +:no-inheritance-diagram: + +Scripted Thread Plan Plugins +--- + +.. automodapi:: lldb.plugins.scripted_thread_plan +:no-heading: +:members: +:undoc-members: +:skip: ABCMeta +:skip: command +:skip: declaration +:skip: in_range +:skip: is_numeric_type +:skip: lldb_iter +:no-inheritance-diagram: + The Test Program and Input -- diff --git a/lldb/examples/python/templates/operating_system.py b/lldb/examples/python/templates/operating_system.py index a8053bcaa21af..e5c106de473bf 100644 --- a/lldb/examples/python/templates/operating_system.py +++ b/lldb/examples/python/templates/operating_system.py @@ -10,16 +10,15 @@ class OperatingSystem(ScriptedThread): """ Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class. -``` -thread_info = { -"tid": tid, -"name": "four", -"queue": "queue4", -"state": "stopped", -"stop_reason": "none", -"core" : 2 -} -``` +.. code-block:: python +thread_info = { +"tid": tid, +"name": "four", +"queue": "queue4", +"state":
[Lldb-commits] [lldb] [lldb/Commands] Alias `script` command to `scripting execute` (PR #97263)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This patch introduces a new top-level `scripting` command with an `execute` sub-command, that basically replaces the `script` raw command. To avoid breaking the `script` command usages, this patch also adds an `script` alias to the `scripting execute` sub-command. The reason behind this change is to have a top-level command that will cover scripting related subcommands. --- Full diff: https://github.com/llvm/llvm-project/pull/97263.diff 5 Files Affected: - (modified) lldb/source/Commands/CMakeLists.txt (+1-1) - (renamed) lldb/source/Commands/CommandObjectScripting.cpp (+31-13) - (renamed) lldb/source/Commands/CommandObjectScripting.h (+12-5) - (modified) lldb/source/Commands/Options.td (+1-1) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+7-2) ``diff diff --git a/lldb/source/Commands/CMakeLists.txt b/lldb/source/Commands/CMakeLists.txt index 6a36c5376d5c5..76397227d535d 100644 --- a/lldb/source/Commands/CMakeLists.txt +++ b/lldb/source/Commands/CMakeLists.txt @@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES CommandObjectQuit.cpp CommandObjectRegexCommand.cpp CommandObjectRegister.cpp - CommandObjectScript.cpp + CommandObjectScripting.cpp CommandObjectSession.cpp CommandObjectSettings.cpp CommandObjectSource.cpp diff --git a/lldb/source/Commands/CommandObjectScript.cpp b/lldb/source/Commands/CommandObjectScripting.cpp similarity index 68% rename from lldb/source/Commands/CommandObjectScript.cpp rename to lldb/source/Commands/CommandObjectScripting.cpp index 25f25b8e65947..72f653690e532 100644 --- a/lldb/source/Commands/CommandObjectScript.cpp +++ b/lldb/source/Commands/CommandObjectScripting.cpp @@ -1,4 +1,4 @@ -//===-- CommandObjectScript.cpp ---===// +//===-- CommandObjectScripting.cpp ===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===--===// -#include "CommandObjectScript.h" +#include "CommandObjectScripting.h" #include "lldb/Core/Debugger.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/Config.h" @@ -21,10 +21,10 @@ using namespace lldb; using namespace lldb_private; -#define LLDB_OPTIONS_script +#define LLDB_OPTIONS_scripting_execute #include "CommandOptions.inc" -Status CommandObjectScript::CommandOptions::SetOptionValue( +Status CommandObjectScriptingExecute::CommandOptions::SetOptionValue( uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) { Status error; @@ -46,27 +46,29 @@ Status CommandObjectScript::CommandOptions::SetOptionValue( return error; } -void CommandObjectScript::CommandOptions::OptionParsingStarting( +void CommandObjectScriptingExecute::CommandOptions::OptionParsingStarting( ExecutionContext *execution_context) { language = lldb::eScriptLanguageNone; } llvm::ArrayRef -CommandObjectScript::CommandOptions::GetDefinitions() { - return llvm::ArrayRef(g_script_options); +CommandObjectScriptingExecute::CommandOptions::GetDefinitions() { + return llvm::ArrayRef(g_scripting_execute_options); } -CommandObjectScript::CommandObjectScript(CommandInterpreter &interpreter) +CommandObjectScriptingExecute::CommandObjectScriptingExecute( +CommandInterpreter &interpreter) : CommandObjectRaw( - interpreter, "script", + interpreter, "scripting execute", "Invoke the script interpreter with provided code and display any " "results. Start the interactive interpreter if no code is supplied.", - "script [--language --] []") {} + "scripting execute [--language --] " + "[]") {} -CommandObjectScript::~CommandObjectScript() = default; +CommandObjectScriptingExecute::~CommandObjectScriptingExecute() = default; -void CommandObjectScript::DoExecute(llvm::StringRef command, -CommandReturnObject &result) { +void CommandObjectScriptingExecute::DoExecute(llvm::StringRef command, + CommandReturnObject &result) { // Try parsing the language option but when the command contains a raw part // separated by the -- delimiter. OptionsWithRaw raw_args(command); @@ -111,3 +113,19 @@ void CommandObjectScript::DoExecute(llvm::StringRef command, else result.SetStatus(eReturnStatusFailed); } + +#pragma mark CommandObjectMultiwordScripting + +// CommandObjectMultiwordScripting + +CommandObjectMultiwordScripting::CommandObjectMultiwordScripting( +CommandInterpreter &interpreter) +: CommandObjectMultiword( + interpreter, "scripting", + "Commands for operating on the scr
[Lldb-commits] [lldb] 208a08c - Reland "[lldb] Parse and display register field enums" (#97258)" (#97270)
Author: David Spickett Date: 2024-07-01T10:45:56+01:00 New Revision: 208a08c3b7b00c05629c3f18811aac81f17cd81b URL: https://github.com/llvm/llvm-project/commit/208a08c3b7b00c05629c3f18811aac81f17cd81b DIFF: https://github.com/llvm/llvm-project/commit/208a08c3b7b00c05629c3f18811aac81f17cd81b.diff LOG: Reland "[lldb] Parse and display register field enums" (#97258)" (#97270) This reverts commit d9e659c538516036e40330b6a98160cbda4ff100. I could not reproduce the Mac OS ASAN failure locally but I narrowed it down to the test `test_many_fields_same_enum`. This test shares an enum between x0, which is 64 bit, and cpsr, which is 32 bit. My theory is that when it does `register read x0`, an enum type is created where the undlerying enumerators are 64 bit, matching the register size. Then it does `register read cpsr` which used the cached enum type, but this register is 32 bit. This caused lldb to try to read an 8 byte value out of a 4 byte allocation: READ of size 8 at 0x60200014b874 thread T0 <...> =>0x60200014b800: fa fa fd fa fa fa fd fa fa fa fd fa fa fa[04]fa To fix this I've added the register's size in bytes to the constructed enum type's name. This means that x0 uses: __lldb_register_fields_enum_some_enum_8 And cpsr uses: __lldb_register_fields_enum_some_enum_4 If any other registers use this enum and are read, they will use the cached type as long as their size matches, otherwise we make a new type. Added: Modified: lldb/include/lldb/Target/RegisterFlags.h lldb/source/Core/DumpRegisterInfo.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp lldb/source/Target/RegisterFlags.cpp lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py lldb/unittests/Core/DumpRegisterInfoTest.cpp Removed: diff --git a/lldb/include/lldb/Target/RegisterFlags.h b/lldb/include/lldb/Target/RegisterFlags.h index 1112972cf72e1..1250fd0330958 100644 --- a/lldb/include/lldb/Target/RegisterFlags.h +++ b/lldb/include/lldb/Target/RegisterFlags.h @@ -32,10 +32,15 @@ class FieldEnum { : m_value(value), m_name(std::move(name)) {} void ToXML(Stream &strm) const; + +void DumpToLog(Log *log) const; }; typedef std::vector Enumerators; + // GDB also includes a "size" that is the size of the underlying register. + // We will not store that here but instead use the size of the register + // this gets attached to when emitting XML. FieldEnum(std::string id, const Enumerators &enumerators); const Enumerators &GetEnumerators() const { return m_enumerators; } @@ -44,6 +49,8 @@ class FieldEnum { void ToXML(Stream &strm, unsigned size) const; + void DumpToLog(Log *log) const; + private: std::string m_id; Enumerators m_enumerators; diff --git a/lldb/source/Core/DumpRegisterInfo.cpp b/lldb/source/Core/DumpRegisterInfo.cpp index 8334795416902..eccc6784cd497 100644 --- a/lldb/source/Core/DumpRegisterInfo.cpp +++ b/lldb/source/Core/DumpRegisterInfo.cpp @@ -111,6 +111,11 @@ void lldb_private::DoDumpRegisterInfo( }; DumpList(strm, "In sets: ", in_sets, emit_set); - if (flags_type) + if (flags_type) { strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str()); + +std::string enumerators = flags_type->DumpEnums(terminal_width); +if (enumerators.size()) + strm << "\n\n" << enumerators; + } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 060a30abee83e..604c92369e9a2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4179,21 +4179,134 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static std::vector ParseFlagsFields(XMLNode flags_node, - unsigned size) { +static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { + Log *log(GetLog(GDBRLog::Process)); + // We will use the last instance of each value. Also we preserve the order + // of declaration in the XML, as it may not be numerical. + // For example, hardware may intially release with two states that softwware + // can read from a register field: + // 0 = startup, 1 = running + // If in a future hardware release, the designers added a pre-startup state: + // 0 = startup, 1 = running, 2 = pre-startup + // Now it makes more sense to list them in this logical order as opposed to + // numerical order: + // 2 = pre-startup, 1 = startup, 0 = startup + // This only matters for "register info" but let's trust what the server + // chose regardless. + std::map enumerators; + + enum_node.ForEachChildElementWithName( + "evalue", [&en
[Lldb-commits] [lldb] Reland "[lldb] Parse and display register field enums" (#97258)" (PR #97270)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes This reverts commit d9e659c538516036e40330b6a98160cbda4ff100. I could not reproduce the Mac OS ASAN failure locally but I narrowed it down to the test `test_many_fields_same_enum`. This test shares an enum between x0, which is 64 bit, and cpsr, which is 32 bit. My theory is that when it does `register read x0`, an enum type is created where the undlerying enumerators are 64 bit, matching the register size. Then it does `register read cpsr` which used the cached enum type, but this register is 32 bit. This caused lldb to try to read an 8 byte value out of a 4 byte allocation: READ of size 8 at 0x60200014b874 thread T0 <...> =>0x60200014b800: fa fa fd fa fa fa fd fa fa fa fd fa fa fa[04]fa To fix this I've added the register's size in bytes to the constructed enum type's name. This means that x0 uses: __lldb_register_fields_enum_some_enum_8 And cpsr uses: __lldb_register_fields_enum_some_enum_4 If any other registers use this enum and are read, they will use the cached type as long as their size matches, otherwise we make a new type. --- Patch is 35.12 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97270.diff 8 Files Affected: - (modified) lldb/include/lldb/Target/RegisterFlags.h (+7) - (modified) lldb/source/Core/DumpRegisterInfo.cpp (+6-1) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+180-18) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+5) - (modified) lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp (+42-3) - (modified) lldb/source/Target/RegisterFlags.cpp (+10) - (modified) lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (+402) - (modified) lldb/unittests/Core/DumpRegisterInfoTest.cpp (+26) ``diff diff --git a/lldb/include/lldb/Target/RegisterFlags.h b/lldb/include/lldb/Target/RegisterFlags.h index 1112972cf72e1..1250fd0330958 100644 --- a/lldb/include/lldb/Target/RegisterFlags.h +++ b/lldb/include/lldb/Target/RegisterFlags.h @@ -32,10 +32,15 @@ class FieldEnum { : m_value(value), m_name(std::move(name)) {} void ToXML(Stream &strm) const; + +void DumpToLog(Log *log) const; }; typedef std::vector Enumerators; + // GDB also includes a "size" that is the size of the underlying register. + // We will not store that here but instead use the size of the register + // this gets attached to when emitting XML. FieldEnum(std::string id, const Enumerators &enumerators); const Enumerators &GetEnumerators() const { return m_enumerators; } @@ -44,6 +49,8 @@ class FieldEnum { void ToXML(Stream &strm, unsigned size) const; + void DumpToLog(Log *log) const; + private: std::string m_id; Enumerators m_enumerators; diff --git a/lldb/source/Core/DumpRegisterInfo.cpp b/lldb/source/Core/DumpRegisterInfo.cpp index 8334795416902..eccc6784cd497 100644 --- a/lldb/source/Core/DumpRegisterInfo.cpp +++ b/lldb/source/Core/DumpRegisterInfo.cpp @@ -111,6 +111,11 @@ void lldb_private::DoDumpRegisterInfo( }; DumpList(strm, "In sets: ", in_sets, emit_set); - if (flags_type) + if (flags_type) { strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str()); + +std::string enumerators = flags_type->DumpEnums(terminal_width); +if (enumerators.size()) + strm << "\n\n" << enumerators; + } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 060a30abee83e..604c92369e9a2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4179,21 +4179,134 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static std::vector ParseFlagsFields(XMLNode flags_node, - unsigned size) { +static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { + Log *log(GetLog(GDBRLog::Process)); + // We will use the last instance of each value. Also we preserve the order + // of declaration in the XML, as it may not be numerical. + // For example, hardware may intially release with two states that softwware + // can read from a register field: + // 0 = startup, 1 = running + // If in a future hardware release, the designers added a pre-startup state: + // 0 = startup, 1 = running, 2 = pre-startup + // Now it makes more sense to list them in this logical order as opposed to + // numerical order: + // 2 = pre-startup, 1 = startup, 0 = startup + // This only matters for "register info" but let's trust what the server + // chose regardless. + std::map enumerators; + + enum_node.ForEachChildElementWithName( + "evalue", [&enumerators, &log](const XMLNode &enumerator_node) { +std::optional name; +std::optional value
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This patch introduces a new `template` multiword sub-command to the `scripting` top-level command. As the name suggests, this sub-command operates on scripting templates, and currently has the ability to automatically discover the various scripting extensions that lldb supports. Signed-off-by: Med Ismail Bennani--- Patch is 36.11 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97273.diff 17 Files Affected: - (modified) lldb/include/lldb/Core/PluginManager.h (+25) - (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h (+7) - (modified) lldb/include/lldb/lldb-private-interfaces.h (+4) - (modified) lldb/source/Commands/CMakeLists.txt (+1-1) - (removed) lldb/source/Commands/CommandObjectScript.cpp (-113) - (removed) lldb/source/Commands/CommandObjectScript.h (-42) - (added) lldb/source/Commands/CommandObjectScripting.cpp (+290) - (added) lldb/source/Commands/CommandObjectScripting.h (+80) - (modified) lldb/source/Commands/Options.td (+8-2) - (modified) lldb/source/Core/PluginManager.cpp (+83) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+7-2) - (modified) lldb/source/Plugins/CMakeLists.txt (+3) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+5) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp (+23) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h (+12-1) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp (+18) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h (+12-1) ``diff diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index f2296e2920238..df20109e791a5 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -487,6 +487,31 @@ class PluginManager { static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions(); + // Scripted Interface + static bool + RegisterPlugin(llvm::StringRef name, llvm::StringRef description, + ScriptedInterfaceCreateInstance create_callback, + lldb::ScriptLanguage language, + std::vector command_interpreter_usages, + std::vector api_usages); + + static bool UnregisterPlugin(ScriptedInterfaceCreateInstance create_callback); + + static ScriptedInterfaceCreateInstance + GetScriptedInterfaceCreateCallbackAtIndex(uint32_t idx); + + static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx); + + static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx); + + static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx); + + static std::vector + GetScriptedInterfaceCommandInterpreterUsagesAtIndex(uint32_t idx); + + static std::vector + GetScriptedInterfaceAPIUsagesAtIndex(uint32_t idx); + // REPL static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, REPLCreateInstance create_callback, diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h index 69504dbcda5dc..23658b90bb90a 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h @@ -68,6 +68,13 @@ class ScriptedInterface { return true; } + static bool + CreateInstance(lldb::ScriptLanguage language, + std::vector command_interpreter_usages, + std::vector api_usages) { +return false; + } + protected: StructuredData::GenericSP m_object_instance_sp; }; diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h index cdd9b51d9329c..2404e28158690 100644 --- a/lldb/include/lldb/lldb-private-interfaces.h +++ b/lldb/include/lldb/lldb-private-interfaces.h @@ -124,6 +124,10 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options); +typedef bool (*ScriptedInterfaceCreateInstance)( +lldb::ScriptLanguage language, +std::vector command_interpreter_usages, +std::vector api_usages); typedef int (*ComparisonFunction)(const void *, const void *); typedef void (*DebuggerInitializeCallback)(Debugger &debugger); /// Trace diff --git a/lldb/source/Commands/CMakeLists.txt b/lldb/source/Commands/CMakeLists.txt index 6a36c5376d5c5..76397227d535d 100644 --- a/lldb/source/Commands/CMakeLists.txt +++
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This patch allows expressions to reference entities in anonymous namespaces. Previously this would have resulted in: ``` (lldb) expr foo::FooAnonymousVar error::1:6: no member named 'FooAnonymousVar' in namespace 'foo' 1 | foo::FooAnonymousVar | ~^ ``` We already allow such lookups through inline namespaces, and for the purposes of lookup, anonymous namespaces shouldn't behave any different. Fixes https://github.com/llvm/llvm-project/issues/96963. --- Full diff: https://github.com/llvm/llvm-project/pull/97275.diff 3 Files Affected: - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+14-4) - (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+5) - (modified) lldb/test/API/lang/cpp/namespace/main.cpp (+18-1) ``diff diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index cd1c500d9aa29..093d27a92d718 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -9484,14 +9484,24 @@ bool TypeSystemClang::DeclContextIsContainedInLookup( auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx; auto *other = (clang::DeclContext *)other_opaque_decl_ctx; + // If we have an inline or anonymous namespace, then the lookup of the + // parent context also includes those namespace contents. + auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) { +if (DC->isInlineNamespace()) + return true; + +if (auto const *NS = dyn_cast(DC)) + return NS->isAnonymousNamespace(); + +return false; + }; + do { // A decl context always includes its own contents in its lookup. if (decl_ctx == other) return true; - -// If we have an inline namespace, then the lookup of the parent context -// also includes the inline namespace contents. - } while (other->isInlineNamespace() && (other = other->getParent())); + } while (is_transparent_lookup_allowed(other) && + (other = other->getParent())); return false; } diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py b/lldb/test/API/lang/cpp/namespace/TestNamespace.py index d747e2be77c8e..83bfe173658cc 100644 --- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py +++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py @@ -253,3 +253,8 @@ def test_with_run_command(self): self.expect_expr( "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42" ) + +self.expect_expr("InAnon1::var_in_anon", result_type="int", result_value="10") +self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", result_value="5") +self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", result_value="15") +self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", result_type="int", result_value="5") diff --git a/lldb/test/API/lang/cpp/namespace/main.cpp b/lldb/test/API/lang/cpp/namespace/main.cpp index 6a8efa160766b..2edfab8437639 100644 --- a/lldb/test/API/lang/cpp/namespace/main.cpp +++ b/lldb/test/API/lang/cpp/namespace/main.cpp @@ -127,6 +127,22 @@ struct Foo { }; } // namespace NS2 +namespace { +namespace InAnon1 { +int var_in_anon = 10; +namespace { +inline namespace inline_ns { +int var_in_anon = 15; +namespace InAnon2 { +namespace { +int var_in_anon = 5; +} // namespace +} // namespace InAnon2 +} // namespace inline_ns +} // namespace +} // namespace InAnon1 +} // namespace + int main (int argc, char const *argv[]) { @@ -140,5 +156,6 @@ main (int argc, char const *argv[]) ::B::Bar bb; A::B::Bar ab; return Foo::myfunc(12) + bb.x() + ab.y() + NS1::NS2::Foo{}.bar() + - NS2::Foo{}.bar(); + NS2::Foo{}.bar() + InAnon1::var_in_anon + + InAnon1::InAnon2::var_in_anon + InAnon1::inline_ns::var_in_anon; } `` https://github.com/llvm/llvm-project/pull/97275 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)
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 b0f20f214ab43c800130e0d249e8ee2459b906ea...f6c801efec331a832f2f10386be9cc14c8bb9565 lldb/test/API/lang/cpp/namespace/TestNamespace.py `` View the diff from darker here. ``diff --- TestNamespace.py2024-07-01 10:08:52.00 + +++ TestNamespace.py2024-07-01 10:12:31.810901 + @@ -253,8 +253,16 @@ self.expect_expr( "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42" ) self.expect_expr("InAnon1::var_in_anon", result_type="int", result_value="10") -self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", result_value="5") -self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", result_value="15") -self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", result_type="int", result_value="5") +self.expect_expr( +"InAnon1::InAnon2::var_in_anon", result_type="int", result_value="5" +) +self.expect_expr( +"InAnon1::inline_ns::var_in_anon", result_type="int", result_value="15" +) +self.expect_expr( +"InAnon1::inline_ns::InAnon2::var_in_anon", +result_type="int", +result_value="5", +) `` https://github.com/llvm/llvm-project/pull/97275 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 48f13d4 - [clang][AST] fix ast-print of extern with >=2 declarators
Author: temyurchenko Date: 2024-07-01T09:25:27-04:00 New Revision: 48f13d48a88c14acbaea7c3ee05018bb173fb360 URL: https://github.com/llvm/llvm-project/commit/48f13d48a88c14acbaea7c3ee05018bb173fb360 DIFF: https://github.com/llvm/llvm-project/commit/48f13d48a88c14acbaea7c3ee05018bb173fb360.diff LOG: [clang][AST] fix ast-print of extern with >=2 declarators Fixes #93913 Added: clang/test/AST/ast-print-language-linkage.cpp Modified: clang/lib/AST/Decl.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp Removed: diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 16ed6d88d1cb1..ff3325543919f 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -576,13 +576,16 @@ template static bool isFirstInExternCContext(T *D) { return First->isInExternCContext(); } -static bool isSingleLineLanguageLinkage(const Decl &D) { - if (const auto *SD = dyn_cast(D.getDeclContext())) -if (!SD->hasBraces()) - return true; +static bool isUnbracedLanguageLinkage(const DeclContext *DC) { + if (const auto *SD = dyn_cast_if_present(DC)) +return !SD->hasBraces(); return false; } +static bool hasUnbracedLanguageLinkage(const Decl &D) { + return isUnbracedLanguageLinkage(D.getDeclContext()); +} + static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) { if (auto *M = D->getOwningModule()) return M->isInterfaceOrPartition(); @@ -644,7 +647,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, if (Var->getStorageClass() != SC_Extern && Var->getStorageClass() != SC_PrivateExtern && - !isSingleLineLanguageLinkage(*Var)) + !hasUnbracedLanguageLinkage(*Var)) return LinkageInfo::internal(); } @@ -2118,6 +2121,12 @@ VarDecl::VarDecl(Kind DK, ASTContext &C, DeclContext *DC, "ParmVarDeclBitfields too large!"); static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned), "NonParmVarDeclBitfields too large!"); + + // The unbraced `extern "C"` invariant is that the storage class + // specifier is omitted in the source code, i.e. SC_None (but is, + // implicitly, `extern`). + assert(!isUnbracedLanguageLinkage(DC) || SC == SC_None); + AllBits = 0; VarDeclBits.SClass = SC; // Everything else is implicitly initialized to false. @@ -2301,7 +2310,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const { // A declaration directly contained in a linkage-specification is treated // as if it contains the extern specifier for the purpose of determining // the linkage of the declared name and whether it is a definition. - if (isSingleLineLanguageLinkage(*this)) + if (hasUnbracedLanguageLinkage(*this)) return DeclarationOnly; // C99 6.9.2p2: @@ -3027,6 +3036,12 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) { assert(T.isNull() || T->isFunctionType()); + + // The unbraced `extern "C"` invariant is that the storage class + // specifier is omitted in the source code, i.e. SC_None (but is, + // implicitly, `extern`). + assert(!isUnbracedLanguageLinkage(DC) || S == SC_None); + FunctionDeclBits.SClass = S; FunctionDeclBits.IsInline = isInlineSpecified; FunctionDeclBits.IsInlineSpecified = isInlineSpecified; diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 26773a69ab9ac..b8e0ef1b40358 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out, Out << Proto; } -static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy, +static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy, QualType T, llvm::raw_ostream &Out) { StringRef prefix = T->isClassType() ? "class " @@ -643,6 +643,22 @@ static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy, Out << prefix; } +/// Return the language of the linkage spec of `D`, if applicable. +/// +/// \Return - "C" if `D` has been declared with unbraced `extern "C"` +/// - "C++" if `D` has been declared with unbraced `extern "C++"` +/// - nullptr in any other case +static const char *tryGetUnbracedLinkageLanguage(const Decl *D) { + const auto *SD = dyn_cast(D->getDeclContext()); + if (!SD || SD->hasBraces()) +return nullptr; + if (SD->getLanguage() == LinkageSpecLanguageIDs::C) +return "