[Lldb-commits] [PATCH] D99867: [lldb] Replace unneeded use of Foundation with ObjectiveC in tests (NFC)
teemperor added inline comments. Comment at: lldb/test/API/commands/frame/recognizer/main.m:1 -#import +#import kastiglione wrote: > teemperor wrote: > > teemperor wrote: > > > I guess this could also be just `stdio.h` (FWIW, the printfs in tests can > > > also be removed as they just require including system headers and are > > > essentially never useful). > > Just to be clear: I'm just saying that removing `printfs` and everything > > else that references system headers is usually always a good idea but I'm > > not asking that you should remove them here too. The `stdio.h` is perfect > > for this patch. > thanks for reviewing closely, a bunch of these changes were automated and I > am guilty of not looking closely (if the test passed then I didn't look > closer) I was actually just looking if we had a "check that we didn't load a type from Foundation"-kind of test (as that was the only thing that I could see this could break Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99867/new/ https://reviews.llvm.org/D99867 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file
JDevlieghere created this revision. JDevlieghere added a reviewer: teemperor. JDevlieghere requested review of this revision. The `memory read --outfile` command should truncate the output when unless `--append-outfile`. Fix the bug and add a test. rdar://76062318 https://reviews.llvm.org/D99890 Files: lldb/source/Commands/CommandObjectMemory.cpp lldb/test/API/functionalities/memory/read/TestMemoryRead.py Index: lldb/test/API/functionalities/memory/read/TestMemoryRead.py === --- lldb/test/API/functionalities/memory/read/TestMemoryRead.py +++ lldb/test/API/functionalities/memory/read/TestMemoryRead.py @@ -2,11 +2,12 @@ Test the 'memory read' command. """ - - import lldb -from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil +import tempfile + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * class MemoryReadTestCase(TestBase): @@ -19,27 +20,34 @@ # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') -def test_memory_read(self): -"""Test the 'memory read' command with plain and vector formats.""" +def build_run_stop(self): self.build() exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() after the variables are assigned values. -lldbutil.run_break_set_by_file_and_line( -self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) +lldbutil.run_break_set_by_file_and_line(self, +"main.cpp", +self.line, +num_expected_locations=1, +loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. -self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +self.expect("thread list", +STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. -self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, +self.expect("breakpoint list -f", +BREAKPOINT_HIT_ONCE, substrs=[' resolved, hit count = 1']) -# Test the memory read commands. +@no_debug_info_test +def test_memory_read(self): +"""Test the 'memory read' command with plain and vector formats.""" +self.build_run_stop() # (lldb) memory read -f d -c 1 `&argc` # 0x7fff5fbff9a0: 1 @@ -131,3 +139,42 @@ for o in objects_read: self.assertEqual(len(o), expected_object_length) self.assertEquals(len(objects_read), 4) + +@no_debug_info_test +def test_memory_read_file(self): +self.build_run_stop() +cmd = "memory read -f d -c 1 `&argc`" +res = lldb.SBCommandReturnObject() +self.ci.HandleCommand(cmd, res) +self.assertTrue(res.Succeeded()) + +# Record golden output. +golden_output = res.GetOutput() + +temp_file = tempfile.NamedTemporaryFile().name + +def check_file_content(expected): +with open(temp_file) as f: +lines = f.readlines() +for i, line in enumerate(lines): +expected_line = expected[i].strip() +actual_line = line.strip() +self.assertEqual( +expected_line, actual_line, +"Line {} doesn't match: expected '{}' but got '{}'". +format(i, expected_line, actual_line)) +self.assertEqual(len(expected), len(lines)) + +# Sanity check. +self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(temp_file)) +check_file_content([golden_output]) + +# Make sure the file is truncated when we run the command again. +self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(temp_file)) +check_file_content([golden_output]) + +# Make sure the file is appended when we run the command with --append-outfile. +self.runCmd( +"memory read -f d -c 1 -o '{}' --append-outfile `&argc`".format( +temp_file)) +check_file_content([golden_output, golden_output]) Index: lldb/source/Commands/CommandObjectMemory.cpp === --- lldb/source/Commands/CommandObjectMemory.cpp +++ lldb/source/Commands/CommandObjectMemory.cpp @@ -767,10 +767,11 @@ std::string path = outfile_spec.GetPath(); if (outfile_spec) { - auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; + File:
[Lldb-commits] [PATCH] D99828: Create setting to disable LanguageRuntime provided UnwindPlans
jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. This seems okay to me. Putting it in the process is right. We do "disable X" in a bunch of other places when enabled is the default, so that seems right. And I don't think there's much benefit to trying to squeeze the description into fewer letters, since you're either cutting & pasting into a script or using completion anyway. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99828/new/ https://reviews.llvm.org/D99828 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] be0ced0 - Revert "Revert "Add support for fetching signed values from tagged pointers.""
Author: Jim Ingham Date: 2021-04-05T18:18:26-07:00 New Revision: be0ced03ba9bfab6fcb1fd2c263a33bc6a359cd8 URL: https://github.com/llvm/llvm-project/commit/be0ced03ba9bfab6fcb1fd2c263a33bc6a359cd8 DIFF: https://github.com/llvm/llvm-project/commit/be0ced03ba9bfab6fcb1fd2c263a33bc6a359cd8.diff LOG: Revert "Revert "Add support for fetching signed values from tagged pointers."" This reverts commit 602ab188a7e18b97d9af95e17271e8fbee129081. The patch replicated an lldbassert for a certain type of NSNumber for tagged pointers. This really shouldn't be an assert since we don't do anything wrong with these numbers, we just don't print a summary. So this patch changed the lldbassert to a log message in reverting the revert. Added: Modified: lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py Removed: diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index d871d3470e70..e2367adaa3b1 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -351,7 +351,7 @@ static void NSNumber_FormatInt(ValueObject &valobj, Stream &stream, int value, } static void NSNumber_FormatLong(ValueObject &valobj, Stream &stream, -uint64_t value, lldb::LanguageType lang) { +int64_t value, lldb::LanguageType lang) { static ConstString g_TypeHint("NSNumber:long"); std::string prefix, suffix; @@ -426,6 +426,8 @@ bool lldb_private::formatters::NSNumberSummaryProvider( if (!process_sp) return false; + Log * log + = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS); ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) @@ -456,9 +458,17 @@ bool lldb_private::formatters::NSNumberSummaryProvider( return NSDecimalNumberSummaryProvider(valobj, stream, options); if (class_name == "NSNumber" || class_name == "__NSCFNumber") { -uint64_t value = 0; +int64_t value = 0; uint64_t i_bits = 0; -if (descriptor->GetTaggedPointerInfo(&i_bits, &value)) { +if (descriptor->GetTaggedPointerInfoSigned(&i_bits, &value)) { + // Check for "preserved" numbers. We still don't support them yet. + if (i_bits & 0x8) { +if (log) + log->Printf("Unsupported (preserved) NSNumber tagged pointer 0x%" + PRIu64, valobj_addr); +return false; + } + switch (i_bits) { case 0: NSNumber_FormatChar(valobj, stream, (char)value, options.GetLanguage()); @@ -512,7 +522,9 @@ bool lldb_private::formatters::NSNumberSummaryProvider( bool is_preserved_number = cfinfoa & 0x8; if (is_preserved_number) { - lldbassert(!static_cast("We should handle preserved numbers!")); +if (log) + log->Printf("Unsupported preserved NSNumber tagged pointer 0x%" + PRIu64, valobj_addr); return false; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h index 9ef21c6e7208..1bea314f63fc 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h @@ -41,6 +41,12 @@ class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor { return false; } + bool GetTaggedPointerInfoSigned(uint64_t *info_bits = nullptr, + int64_t *value_bits = nullptr, + uint64_t *payload = nullptr) override { +return false; + } + uint64_t GetInstanceSize() override; ObjCLanguageRuntime::ObjCISA GetISA() override { return m_objc_class_ptr; } @@ -253,7 +259,7 @@ class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor { ClassDescriptorV2Tagged( ObjCLanguageRuntime::ClassDescriptorSP actual_class_sp, - uint64_t payload) { + uint64_t u_payload, int64_t s_payload) { if (!actual_class_sp) { m_valid = false; return; @@ -264,9 +270,10 @@ class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor { return; } m_valid = true; -m_payload = payload; +m_payload = u_payload; m_info_bits = (m_payload & 0x0FULL); m_value_bits =