[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
This revision was automatically updated to reflect the committed changes. Closed by commit rL327501: Update selected thread after loading mach core (authored by JDevlieghere, committed by ). Changed prior to commit: https://reviews.llvm.org/D44139?vs=137993=138331#toc Repository: rL LLVM https://reviews.llvm.org/D44139 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml lldb/trunk/source/Target/Process.cpp Index: lldb/trunk/source/Target/Process.cpp === --- lldb/trunk/source/Target/Process.cpp +++ lldb/trunk/source/Target/Process.cpp @@ -2857,10 +2857,10 @@ // state. SetPrivateState(eStateStopped); -// Wait indefinitely for a stopped event since we just posted one above... +// Wait for a stopped event since we just posted one above... lldb::EventSP event_sp; -listener_sp->GetEvent(event_sp, llvm::None); -StateType state = ProcessEventData::GetStateFromEvent(event_sp.get()); +StateType state = +WaitForProcessToStop(seconds(10), _sp, true, listener_sp); if (!StateIsStoppedState(state, false)) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py @@ -0,0 +1,68 @@ +""" +Test basics of mach core file debugging. +""" + +from __future__ import print_function + +import shutil +import struct + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MachCoreTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +super(MachCoreTestCase, self).setUp() +self._initial_platform = lldb.DBG.GetSelectedPlatform() + +def tearDown(self): +lldb.DBG.SetSelectedPlatform(self._initial_platform) +super(MachCoreTestCase, self).tearDown() + +def test_selected_thread(self): +"""Test that the right thread is selected after a core is loaded.""" +# Create core form YAML. +self.yaml2obj("test.core.yaml", self.getBuildArtifact("test.core")) + +# Set debugger into synchronous mode +self.dbg.SetAsync(False) + +# Create a target by the debugger. +target = self.dbg.CreateTarget("") + +# Load OS plugin. +python_os_plugin_path = os.path.join(self.getSourceDir(), + 'operating_system.py') +command = "settings set target.process.python-os-plugin-path '{}'".format( +python_os_plugin_path) +self.dbg.HandleCommand(command) + +# Load core. +process = target.LoadCore(self.getBuildArtifact("test.core")) +self.assertTrue(process, PROCESS_IS_VALID) +self.assertEqual(process.GetNumThreads(), 3) + +# Verify our OS plug-in threads showed up +thread = process.GetThreadByID(0x1) +self.assertTrue(thread.IsValid( +), "Make sure there is a thread 0x1 after we load the python OS plug-in" +) +thread = process.GetThreadByID(0x2) +self.assertTrue(thread.IsValid( +), "Make sure there is a thread 0x2 after we load the python OS plug-in" +) +thread = process.GetThreadByID(0x3) +self.assertTrue(thread.IsValid( +), "Make sure there is a thread 0x3 after we load the python OS plug-in" +) + +# Verify that the correct thread is selected +thread = process.GetSelectedThread() +self.assertEqual(thread.GetThreadID(), 0x3) Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml @@ -0,0 +1,853 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0107 + cpusubtype: 0x0003 + filetype:0x0004 + ncmds: 59 + sizeofcmds: 4384 + flags: 0x + reserved:0x +LoadCommands: + - cmd: LC_THREAD +cmdsize:
[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
JDevlieghere added a comment. In https://reviews.llvm.org/D44139#1036521, @jasonmolenda wrote: > (or rather, not "conflict with the OperatingSystemPlugIn stop reason" -- but > would make it confusing to users. I think it might be best to remove > ThreadMachCore::CalculateStopInfo.) Sounds reasonable, I'll do that in a follow-up commit! Repository: rL LLVM https://reviews.llvm.org/D44139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
jasonmolenda added a comment. (or rather, not "conflict with the OperatingSystemPlugIn stop reason" -- but would make it confusing to users. I think it might be best to remove ThreadMachCore::CalculateStopInfo.) https://reviews.llvm.org/D44139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
JDevlieghere updated this revision to Diff 137993. JDevlieghere added a comment. Thanks for the review @labath! https://reviews.llvm.org/D44139 Files: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml source/Target/Process.cpp Index: source/Target/Process.cpp === --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -2857,10 +2857,10 @@ // state. SetPrivateState(eStateStopped); -// Wait indefinitely for a stopped event since we just posted one above... +// Wait for a stopped event since we just posted one above... lldb::EventSP event_sp; -listener_sp->GetEvent(event_sp, llvm::None); -StateType state = ProcessEventData::GetStateFromEvent(event_sp.get()); +StateType state = +WaitForProcessToStop(seconds(10), _sp, true, listener_sp); if (!StateIsStoppedState(state, false)) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); Index: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml === --- /dev/null +++ packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml @@ -0,0 +1,853 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0107 + cpusubtype: 0x0003 + filetype:0x0004 + ncmds: 59 + sizeofcmds: 4384 + flags: 0x + reserved:0x +LoadCommands: + - cmd: LC_THREAD +cmdsize: 208 +PayloadBytes: + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x2A + - 0x00 + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x80 + - 0xF7 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x20 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xFF + - 0xFF + - 0xFF + - 0xFF + - 0xC8 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0xD0 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xA0 + - 0x0F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x46 + - 0x02 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x2B + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x06 + - 0x00 + - 0x00 + - 0x00 + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x03 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0x00 + - 0x02 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - cmd: LC_SEGMENT_64 +cmdsize: 72 +segname: '' +vmaddr: 4294967296 +vmsize: 4096 +fileoff: 8192 +filesize:4096 +maxprot: 5 +initprot:5 +nsects: 0 +flags: 0 + - cmd: LC_SEGMENT_64 +cmdsize:
[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
labath added a comment. I'll leave the cpp change for others to approve (though it certainly looks simpler than the previous one). I just have a couple of drive-by comments on the test. Comment at: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py:32 +# Create core form YAML. +self.yaml2obj("test.core.yaml", "test.core") + this should be `getBuildArtifact("test.core") `, so it does not end up in the test tree (we may also consider changing the interface of this function to make it harder to get wrong). Comment at: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py:1-2 +#!/usr/bin/python + +import lldb It doesn't look like this is actually executable. Repository: rL LLVM https://reviews.llvm.org/D44139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44139: Update selected thread after loading mach core
JDevlieghere updated this revision to Diff 137762. JDevlieghere retitled this revision from "WIP: Update selected thread after loading mach core" to "Update selected thread after loading mach core". JDevlieghere edited the summary of this revision. JDevlieghere added a comment. - Added testcase. - Followed Jim's advice to use `WaitForProcessToStop`. - Should now do the right thing for all types of cores. Repository: rL LLVM https://reviews.llvm.org/D44139 Files: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml source/Target/Process.cpp Index: source/Target/Process.cpp === --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -2857,10 +2857,10 @@ // state. SetPrivateState(eStateStopped); -// Wait indefinitely for a stopped event since we just posted one above... +// Wait for a stopped event since we just posted one above... lldb::EventSP event_sp; -listener_sp->GetEvent(event_sp, llvm::None); -StateType state = ProcessEventData::GetStateFromEvent(event_sp.get()); +StateType state = +WaitForProcessToStop(seconds(10), _sp, true, listener_sp); if (!StateIsStoppedState(state, false)) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); Index: packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml === --- /dev/null +++ packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml @@ -0,0 +1,853 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0107 + cpusubtype: 0x0003 + filetype:0x0004 + ncmds: 59 + sizeofcmds: 4384 + flags: 0x + reserved:0x +LoadCommands: + - cmd: LC_THREAD +cmdsize: 208 +PayloadBytes: + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x2A + - 0x00 + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x80 + - 0xF7 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x20 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xFF + - 0xFF + - 0xFF + - 0xFF + - 0xC8 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0xD0 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xA0 + - 0x0F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x46 + - 0x02 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x2B + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x06 + - 0x00 + - 0x00 + - 0x00 + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x03 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0x00 + - 0x02 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - cmd: