[Lldb-commits] [lldb] r325495 - Make gdb-client tests generate binaries in the build tree
Author: labath Date: Mon Feb 19 05:53:12 2018 New Revision: 325495 URL: http://llvm.org/viewvc/llvm-project?rev=325495&view=rev Log: Make gdb-client tests generate binaries in the build tree These were missed in the great refactor because they were added concurrently with it. Since we started running tests in a more parallel fashion they started to be flaky. This should fix it. Now that we are no longer polluting the source tree, I also delete the bit of custom cleanup code specific to these tests. Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py?rev=325495&r1=325494&r2=325495&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py Mon Feb 19 05:53:12 2018 @@ -392,24 +392,19 @@ class GDBRemoteTestBase(TestBase): NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) server = None -temp_files = None def setUp(self): TestBase.setUp(self) -self.temp_files = [] self.server = MockGDBServer() self.server.start() def tearDown(self): -for temp_file in self.temp_files: -self.RemoveTempFile(temp_file) # TestBase.tearDown will kill the process, but we need to kill it early # so its client connection closes and we can stop the server before # finally calling the base tearDown. if self.process() is not None: self.process().Kill() self.server.stop() -self.temp_files = [] TestBase.tearDown(self) def createTarget(self, yaml_path): @@ -421,9 +416,8 @@ class GDBRemoteTestBase(TestBase): during tearDown. """ yaml_base, ext = os.path.splitext(yaml_path) -obj_path = "%s" % yaml_base +obj_path = self.getBuildArtifact(yaml_base) self.yaml2obj(yaml_path, obj_path) -self.temp_files.append(obj_path) return self.dbg.CreateTarget(obj_path) def connect(self, target): ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
labath created this revision. labath added reviewers: jingham, aprantl. The paralelization patch exposed a bunch of cases where we were still touching the source tree (as these tests were now stepping on each others toes and being flaky). This patch removes such issues from breakpoint command tests. Since the only reason they were creating files was to indirectly test whether the breakpoint commands got executed (and plumbing the full build tree path to all places that needed it would be messy) I decided to modify the tests to check for a different side effect instead: modification of a global variable. This also makes the code simpler as checking the value of the global variable is easier, and there is nothing to clean up. As the tests aren't really doing anything debug-info related, I took the opportunity to also mark them as NO_DEBUG_INFO_TESTCASEs. https://reviews.llvm.org/D43464 Files: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py === --- /dev/null +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py @@ -0,0 +1,5 @@ +""" +A dummy module for testing the execution of various breakpoint commands. A +command will modify a global variable in this module and test will check its +value. +""" Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py === --- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -1,7 +1,5 @@ from __future__ import print_function - +import side_effect def function(frame, bp_loc, dict): -there = open("output2.txt", "w") -print("lldb", file=there) -there.close() +side_effect.bktptcmd = "function was here" Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py === --- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -12,12 +12,13 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class PythonBreakpointCommandSettingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -my_var = 10 +NO_DEBUG_INFO_TESTCASE = True @add_test_categories(['pyapi']) def test_step_out_python(self): @@ -69,12 +70,9 @@ self.assertTrue(got_one_in_B, "Failed to match the pattern in B") self.target.BreakpointDelete(no_files_bkpt.GetID()) -PythonBreakpointCommandSettingTestCase.my_var = 10 error = lldb.SBError() -error = body_bkpt.SetScriptCallbackBody("\ -import TestBreakpointCommandsFromPython\n\ -TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\ -print('Hit breakpoint')") +error = body_bkpt.SetScriptCallbackBody( +"import side_effect; side_effect.callback = 'callback was here'") self.assertTrue( error.Success(), "Failed to set the script callback body: %s." % @@ -84,9 +82,9 @@ "command script import --allow-reload ./bktptcmd.py") func_bkpt.SetScriptCallbackFunction("bktptcmd.function") -# We will use the function that touches a text file, so remove it -# first: -self.RemoveTempFile("output2.txt") +# Clear out canary variables +side_effect.bktptcmd = None +side_effect.callback = None # Now launch the process, and do not stop at entry point. self.process = self.target.LaunchSimple( @@ -100,11 +98,5 @@ self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.") self.thread = threads[0] -self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20) - -# Check for the function version as well, which produced this file: -# Remember to clean up after ourselves... -self.assertTrue( -os.path.isfile("output2.txt"), -"'output2.txt' exists due to breakpoint command for breakpoint function.") -self.RemoveTempFile("output2.txt") +self.assertEqual
[Lldb-commits] [lldb] r325504 - Add SBDebugger::GetBuildConfiguration and use it to skip an XML test
Author: labath Date: Mon Feb 19 07:06:28 2018 New Revision: 325504 URL: http://llvm.org/viewvc/llvm-project?rev=325504&view=rev Log: Add SBDebugger::GetBuildConfiguration and use it to skip an XML test Summary: This adds a SBDebugger::GetBuildConfiguration static function, which returns a SBStructuredData describing the the build parameters of liblldb. Right now, it just contains one entry: whether we were built with XML support. I use the new functionality to skip a test which requires XML support, but concievably the new function could be useful to other liblldb clients as well (making sure the library supports the feature they are about to use). Reviewers: zturner, jingham, clayborg, davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D4 Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/packages/Python/lldbsuite/test/decorators.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py lldb/trunk/scripts/interface/SBDebugger.i lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=325504&r1=325503&r2=325504&view=diff == --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Feb 19 07:06:28 2018 @@ -181,6 +181,8 @@ public: static const char *StateAsCString(lldb::StateType state); + static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState(lldb::StateType state); static bool StateIsStoppedState(lldb::StateType state); Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=325504&r1=325503&r2=325504&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Mon Feb 19 07:06:28 2018 @@ -763,3 +763,11 @@ def skipUnlessAddressSanitizer(func): return "Compiler cannot compile with -fsanitize=address" return None return skipTestIfFn(is_compiler_with_address_sanitizer)(func) + +def skipIfXmlSupportMissing(func): +config = lldb.SBDebugger.GetBuildConfiguration() +xml = config.GetValueForKey("xml") + +fail_value = True # More likely to notice if something goes wrong +have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) +return unittest2.skipIf(not have_xml, "requires xml support")(func) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py?rev=325504&r1=325503&r2=325504&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py Mon Feb 19 07:06:28 2018 @@ -6,7 +6,7 @@ from gdbclientutils import * class TestTargetXMLArch(GDBRemoteTestBase): -@skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples())) +@skipIfXmlSupportMissing @expectedFailureAll(archs=["i386"]) @skipIfRemote def test(self): Modified: lldb/trunk/scripts/interface/SBDebugger.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBDebugger.i?rev=325504&r1=325503&r2=325504&view=diff == --- lldb/trunk/scripts/interface/SBDebugger.i (original) +++ lldb/trunk/scripts/interface/SBDebugger.i Mon Feb 19 07:06:28 2018 @@ -320,6 +320,8 @@ public: static const char * StateAsCString (lldb::StateType state); +static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState (lldb::StateType state); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=325504&r1=325503&r2=325504&view=diff == --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Feb 19 07:06:28 2018 @@ -43,6 +43,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Host/XML.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -491,6 +492,26 @@ const char *SBDebugger::StateAsCString(S r
[Lldb-commits] [PATCH] D43333: Add SBDebugger::GetBuildConfiguration and use it to skip an XML test
This revision was automatically updated to reflect the committed changes. Closed by commit rL325504: Add SBDebugger::GetBuildConfiguration and use it to skip an XML test (authored by labath, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D4 Files: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/packages/Python/lldbsuite/test/decorators.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py lldb/trunk/scripts/interface/SBDebugger.i lldb/trunk/source/API/SBDebugger.cpp Index: lldb/trunk/scripts/interface/SBDebugger.i === --- lldb/trunk/scripts/interface/SBDebugger.i +++ lldb/trunk/scripts/interface/SBDebugger.i @@ -320,6 +320,8 @@ static const char * StateAsCString (lldb::StateType state); +static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState (lldb::StateType state); Index: lldb/trunk/include/lldb/API/SBDebugger.h === --- lldb/trunk/include/lldb/API/SBDebugger.h +++ lldb/trunk/include/lldb/API/SBDebugger.h @@ -181,6 +181,8 @@ static const char *StateAsCString(lldb::StateType state); + static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState(lldb::StateType state); static bool StateIsStoppedState(lldb::StateType state); Index: lldb/trunk/packages/Python/lldbsuite/test/decorators.py === --- lldb/trunk/packages/Python/lldbsuite/test/decorators.py +++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py @@ -763,3 +763,11 @@ return "Compiler cannot compile with -fsanitize=address" return None return skipTestIfFn(is_compiler_with_address_sanitizer)(func) + +def skipIfXmlSupportMissing(func): +config = lldb.SBDebugger.GetBuildConfiguration() +xml = config.GetValueForKey("xml") + +fail_value = True # More likely to notice if something goes wrong +have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) +return unittest2.skipIf(not have_xml, "requires xml support")(func) Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py @@ -6,7 +6,7 @@ class TestTargetXMLArch(GDBRemoteTestBase): -@skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples())) +@skipIfXmlSupportMissing @expectedFailureAll(archs=["i386"]) @skipIfRemote def test(self): Index: lldb/trunk/source/API/SBDebugger.cpp === --- lldb/trunk/source/API/SBDebugger.cpp +++ lldb/trunk/source/API/SBDebugger.cpp @@ -43,6 +43,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Host/XML.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -491,6 +492,26 @@ return lldb_private::StateAsCString(state); } +static void AddBoolConfigEntry(StructuredData::Dictionary &dict, + llvm::StringRef name, bool value, + llvm::StringRef description) { + auto entry_up = llvm::make_unique(); + entry_up->AddBooleanItem("value", value); + entry_up->AddStringItem("description", description); + dict.AddItem(name, std::move(entry_up)); +} + +SBStructuredData SBDebugger::GetBuildConfiguration() { + auto config_up = llvm::make_unique(); + AddBoolConfigEntry( + *config_up, "xml", XMLDocument::XMLEnabled(), + "A boolean value that indicates if XML support is enabled in LLDB"); + + SBStructuredData data; + data.m_impl_up->SetObjectSP(std::move(config_up)); + return data; +} + bool SBDebugger::StateIsRunningState(StateType state) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); Index: lldb/trunk/scripts/interface/SBDebugger.i === --- lldb/trunk/scripts/interface/SBDebugger.i +++ lldb/trunk/scripts/interface/SBDebugger.i @@ -320,6 +320,8 @@ static const char * StateAsCString (lldb::StateType state); +static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState (lldb::StateType state); Index: lldb/trunk/include/lldb/API/SBDebugger.h === --- lldb/trunk/include/lldb/API/SBDebugger.h +++ lldb/trunk/include/lldb/API/SBDebugger.h @@ -181,6 +181,8 @@ static
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
davide accepted this revision. davide added a comment. This revision is now accepted and ready to land. LGTM, thanks for doing this :) https://reviews.llvm.org/D43464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r325511 - Fix TestStopReplyContainsThreadPcs on 32-bit x86 (pr36013)
Author: labath Date: Mon Feb 19 07:42:48 2018 New Revision: 325511 URL: http://llvm.org/viewvc/llvm-project?rev=325511&view=rev Log: Fix TestStopReplyContainsThreadPcs on 32-bit x86 (pr36013) Summary: The issue was that we were parsing the registers into 64-bit integers and the calling swapByteOrder without regard for the actual size of the register. This switches the test to use the RegisterValue class which tracks the register size, and knows how to initialize itself from a piece of memory (so we don't need to swap byte order ourselves). Reviewers: eugene, davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D43376 Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp?rev=325511&r1=325510&r2=325511&view=diff == --- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp (original) +++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp Mon Feb 19 07:42:48 2018 @@ -9,14 +9,13 @@ #include "MessageObjects.h" #include "lldb/Interpreter/Args.h" -#include "lldb/Utility/StructuredData.h" +#include "lldb/Utility/StringExtractor.h" #include "llvm/ADT/StringExtras.h" #include "gtest/gtest.h" using namespace lldb_private; using namespace lldb; using namespace llvm; -using namespace llvm::support; namespace llgs_tests { Expected ProcessInfo::create(StringRef response) { @@ -55,36 +54,50 @@ Expected ProcessInfo::creat lldb::pid_t ProcessInfo::GetPid() const { return m_pid; } -endianness ProcessInfo::GetEndian() const { return m_endian; } +support::endianness ProcessInfo::GetEndian() const { return m_endian; } //== ThreadInfo -ThreadInfo::ThreadInfo(StringRef name, StringRef reason, - const RegisterMap ®isters, unsigned int signal) -: m_name(name.str()), m_reason(reason.str()), m_registers(registers), - m_signal(signal) {} - -StringRef ThreadInfo::ReadRegister(unsigned int register_id) const { - return m_registers.lookup(register_id); -} - -Expected -ThreadInfo::ReadRegisterAsUint64(unsigned int register_id) const { - uint64_t value; - std::string value_str(m_registers.lookup(register_id)); - if (!llvm::to_integer(value_str, value, 16)) -return make_parsing_error("ThreadInfo value for register {0}: {1}", - register_id, value_str); - - sys::swapByteOrder(value); - return value; +ThreadInfo::ThreadInfo(StringRef name, StringRef reason, RegisterMap registers, + unsigned int signal) +: m_name(name.str()), m_reason(reason.str()), + m_registers(std::move(registers)), m_signal(signal) {} + +const RegisterValue *ThreadInfo::ReadRegister(unsigned int Id) const { + auto Iter = m_registers.find(Id); + return Iter == m_registers.end() ? nullptr : &Iter->getSecond(); } //== JThreadsInfo == -Expected JThreadsInfo::Create(StringRef response, -endianness endian) { + +Expected +JThreadsInfo::parseRegisters(const StructuredData::Dictionary &Dict, + ArrayRef RegInfos) { + RegisterMap Result; + + auto KeysObj = Dict.GetKeys(); + auto Keys = KeysObj->GetAsArray(); + for (size_t i = 0; i < Keys->GetSize(); i++) { +StringRef KeyStr, ValueStr; +Keys->GetItemAtIndexAsString(i, KeyStr); +Dict.GetValueForKeyAsString(KeyStr, ValueStr); +unsigned int Register; +if (!llvm::to_integer(KeyStr, Register, 10)) + return make_parsing_error("JThreadsInfo: register key[{0}]", i); + +auto RegValOr = +parseRegisterValue(RegInfos[Register], ValueStr, support::big); +if (!RegValOr) + return RegValOr.takeError(); +Result[Register] = std::move(*RegValOr); + } + return std::move(Result); +} + +Expected JThreadsInfo::create(StringRef Response, +ArrayRef RegInfos) { JThreadsInfo jthreads_info; - StructuredData::ObjectSP json = StructuredData::ParseJSON(response); + StructuredData::ObjectSP json = StructuredData::ParseJSON(Response); StructuredData::Array *array = json->GetAsArray(); if (!array) return make_parsing_error("JThreadsInfo: JSON array"); @@ -108,23 +121,11 @@ Expected JThreadsInfo::Cre if (!register_dict) return make_parsing_error("JThreadsInfo: registers JSON obj"); -RegisterMap registers; - -auto
[Lldb-commits] [PATCH] D43376: Fix TestStopReplyContainsThreadPcs on 32-bit x86 (pr36013)
This revision was automatically updated to reflect the committed changes. Closed by commit rL325511: Fix TestStopReplyContainsThreadPcs on 32-bit x86 (pr36013) (authored by labath, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D43376 Files: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp Index: lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h === --- lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h +++ lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h @@ -59,7 +59,7 @@ llvm::Error ContinueAll(); llvm::Error ContinueThread(unsigned long thread_id); const ProcessInfo &GetProcessInfo(); - llvm::Optional GetJThreadsInfo(); + llvm::Expected GetJThreadsInfo(); const StopReply &GetLatestStopReply(); template llvm::Expected GetLatestStopReplyAs() { assert(m_stop_reply); @@ -75,8 +75,9 @@ llvm::Error SendMessage(llvm::StringRef message, std::string &response_string, PacketResult expected_result); - template - llvm::Expected SendMessage(llvm::StringRef Message); + template + llvm::Expected SendMessage(llvm::StringRef Message, + CreateArgs &&... Args); unsigned int GetPcRegisterId(); private: @@ -97,13 +98,13 @@ unsigned int m_pc_register = LLDB_INVALID_REGNUM; }; -template +template llvm::Expected -TestClient::SendMessage(llvm::StringRef Message) { +TestClient::SendMessage(llvm::StringRef Message, CreateArgs &&... Args) { std::string ResponseText; if (llvm::Error E = SendMessage(Message, ResponseText)) return std::move(E); - return P::create(ResponseText); + return P::create(ResponseText, std::forward(Args)...); } } // namespace llgs_tests Index: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h === --- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h +++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h @@ -10,7 +10,9 @@ #ifndef LLDB_SERVER_TESTS_MESSAGEOBJECTS_H #define LLDB_SERVER_TESTS_MESSAGEOBJECTS_H +#include "lldb/Core/RegisterValue.h" #include "lldb/Host/Host.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" @@ -22,8 +24,7 @@ namespace llgs_tests { class ThreadInfo; typedef llvm::DenseMap ThreadInfoMap; -typedef llvm::DenseMap U64Map; -typedef llvm::DenseMap RegisterMap; +typedef llvm::DenseMap RegisterMap; template struct Parser { using result_type = T; }; @@ -51,26 +52,30 @@ public: ThreadInfo() = default; ThreadInfo(llvm::StringRef name, llvm::StringRef reason, - const RegisterMap ®isters, unsigned int signal); + RegisterMap registers, unsigned int signal); - llvm::StringRef ReadRegister(unsigned int register_id) const; - llvm::Expected ReadRegisterAsUint64(unsigned int register_id) const; + const lldb_private::RegisterValue *ReadRegister(unsigned int Id) const; private: std::string m_name; std::string m_reason; RegisterMap m_registers; unsigned int m_signal; }; -class JThreadsInfo { +class JThreadsInfo : public Parser { public: - static llvm::Expected Create(llvm::StringRef response, - llvm::support::endianness endian); + static llvm::Expected + create(llvm::StringRef Response, + llvm::ArrayRef RegInfos); const ThreadInfoMap &GetThreadInfos() const; private: + static llvm::Expected + parseRegisters(const lldb_private::StructuredData::Dictionary &Dict, + llvm::ArrayRef RegInfos); + JThreadsInfo() = default; ThreadInfoMap m_thread_infos; }; @@ -80,13 +85,18 @@ create(llvm::StringRef Response); }; +llvm::Expected +parseRegisterValue(const lldb_private::RegisterInfo &Info, + llvm::StringRef HexValue, llvm::support::endianness Endian); + class StopReply { public: StopReply() = default; virtual ~StopReply() = default; static llvm::Expected> - create(llvm::StringRef response, llvm::support::endianness endian); + create(llvm::StringRef Response, llvm::support::endianness Endian, + llvm::ArrayRef RegInfos); // for llvm::cast<> virtual lldb_private::WaitStatus getKind() const = 0; @@ -98,15 +108,17 @@ class StopReplyStop : public StopReply { public: StopReplyStop(uint8_t Signal, lldb::tid_t ThreadId, llvm::StringRef Name, -U64Map ThreadPcs, RegisterMap Registers, llvm::StringRef Reason) +RegisterMap ThreadPcs, R
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
aprantl added a comment. Awesome! https://reviews.llvm.org/D43464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere created this revision. JDevlieghere added reviewers: aprantl, jingham, davide, labath. Before this patch, LLDB was not able to evaluate expressions that resulted in a value with a typeof-type. (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = This fixes that. The type is still printed as (typeof (i)) but at least we get a value now. (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = 1 I'm looking into printing this as `int` but will keep that for a follow-up commit either way. https://reviews.llvm.org/D43471 Files: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -4046,9 +4046,13 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingExpr()->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,9 +4259,14 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingExpr()->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); + case clang::Type::Decltype: break; case clang::Type::TemplateSpecialization: @@ -5060,7 +5069,14 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingExpr()->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,8 +5090,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -5214,6 +5228,14 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingExpr()->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType(getASTContext(), +llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,8 +5249,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -6264,9 +6284,11 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: -return 0; +return GetNumPointeeChildren( +llvm::cast(qual_type)->getUnderlyingExpr()->getType()); case clang::Type::TypeOf: -return 0; +return GetNumPointeeChildren( +llvm::cast(qual_type)->getUnderlyingType()); case clang::Type::Decltype: return 0; case clang::Type::Record: @@ -10086,4 +10108,3 @@ lldbassert(m_scratch_ast_source_ap != nullptr); return m_scratch_ast_source_ap->GetMergerUnchecked(); } - Index: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py === --- packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -253,3 +253,20 @@ self.expect('print_hi', substrs=['(int) $', '6']) + +def test_expr_commands_typeof(self): +"""Throw typeof expression at lldb.""" +self.build() + +self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_S
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere updated this revision to Diff 134935. JDevlieghere added a comment. Formatting https://reviews.llvm.org/D43471 Files: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -4046,9 +4046,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,9 +4262,17 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); + case clang::Type::Decltype: break; case clang::Type::TemplateSpecialization: @@ -5060,7 +5075,17 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,8 +5099,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -5214,6 +5237,17 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,8 +5261,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -6264,9 +6296,12 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: -return 0; +return GetNumPointeeChildren(llvm::cast(qual_type) + ->getUnderlyingExpr() + ->getType()); case clang::Type::TypeOf: -return 0; +return GetNumPointeeChildren( +llvm::cast(qual_type)->getUnderlyingType()); case clang::Type::Decltype: return 0; case clang::Type::Record: @@ -10086,4 +10121,3 @@ lldbassert(m_scratch_ast_source_ap != nullptr); return m_scratch_ast_source_ap->GetMergerUnchecked(); } - Index: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py === --- packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -253,3 +253,20 @@ self.expect('print_hi', substrs=['(int) $', '6']) + +def test_expr_commands_typeof(self): +"""Throw typeof expression at lldb.""" +self.build() + +self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) + +lldbutil.run_break_set_by_file_and_line( +self, "main.cpp", se
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
labath added a comment. Seems straight-forward enough, but technically Jim is the owner of the expression evaluator these days, so I'll leave the honours to him. Comment at: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py:270 +# output: (typeof (i)) $0 = 1 +self.expect("expression p int i; __typeof__(i) j = 1; j", +substrs=['(typeof (i)) $', Are you sure this command is actually correct? The "p" here seems odd... Comment at: source/Symbol/ClangASTContext.cpp:5264 - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: I'm guessing this means decltype doesn't work either ? https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r325519 - Two more dosep-paralellization fallout fixes
Author: labath Date: Mon Feb 19 09:23:13 2018 New Revision: 325519 URL: http://llvm.org/viewvc/llvm-project?rev=325519&view=rev Log: Two more dosep-paralellization fallout fixes The first issue is about the flaky test rerun logic. This was grouping tests by subdir and passing them into walk_and_invoke in the incorrect form. This part can be just deleted as its not needed anymore. The second problem (which I noticed while investigating the first one) was that the "-p" switch was not working in multiprocessing mode. This happened because we were returning None from process_file instead of a tuple full of empty values for tests that did not match the -p regex. Both of these would be caught earlier if python was a more strongly typed language. :/ Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dosep.py?rev=325519&r1=325518&r2=325519&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/dosep.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py Mon Feb 19 09:23:13 2018 @@ -477,22 +477,20 @@ def process_file(test_file, dotest_argv, import __main__ as main global dotest_options -if dotest_options.p and not re.search(dotest_options.p, base_name): -return +if not dotest_options.p or re.search(dotest_options.p, base_name): +script_file = main.__file__ +command = ([sys.executable, script_file] + + dotest_argv + + ["-S", dotest_options.session_file_format] + + ["--inferior", "-p", base_name, os.path.dirname(test_file)]) -script_file = main.__file__ -command = ([sys.executable, script_file] + - dotest_argv + - ["-S", dotest_options.session_file_format] + - ["--inferior", "-p", base_name, os.path.dirname(test_file)]) +timeout_name = os.path.basename(os.path.splitext(base_name)[0]).upper() -timeout_name = os.path.basename(os.path.splitext(base_name)[0]).upper() +timeout = (os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or + getDefaultTimeout(dotest_options.lldb_platform_name)) -timeout = (os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or - getDefaultTimeout(dotest_options.lldb_platform_name)) - -results.append(call_with_timeout( -command, timeout, base_name, inferior_pid_events, test_file)) +results.append(call_with_timeout( +command, timeout, base_name, inferior_pid_events, test_file)) # result = (name, status, passes, failures, unexpected_successes) timed_out = [name for name, status, _, _, _ in results @@ -1526,31 +1524,15 @@ def rerun_tests(test_subdir, tests_for_r # Sort rerun files into subdirectories. print("\nRerunning the following files:") -rerun_files_by_subdir = {} +rerun_files = [] for test_filename in tests_for_rerun.keys(): # Print the file we'll be rerunning test_relative_path = os.path.relpath( test_filename, lldbsuite.lldb_test_root) print(" {}".format(test_relative_path)) -# Store test filenames by subdir. -test_dir = os.path.dirname(test_filename) -test_basename = os.path.basename(test_filename) -if test_dir in rerun_files_by_subdir: -rerun_files_by_subdir[test_dir].append( -(test_basename, test_filename)) -else: -rerun_files_by_subdir[test_dir] = [(test_basename, test_filename)] - -# Break rerun work up by subdirectory. We do this since -# we have an invariant that states only one test file can -# be run at a time in any given subdirectory (related to -# rules around built inferior test program lifecycle). -rerun_work = [] -for files_by_subdir in rerun_files_by_subdir.values(): -rerun_work.append((test_subdir, files_by_subdir)) +rerun_files.append(test_filename) -# Run the work with the serial runner. # Do not update legacy counts, I am getting rid of # them so no point adding complicated merge logic here. rerun_thread_count = 1 @@ -1569,7 +1551,7 @@ def rerun_tests(test_subdir, tests_for_r "function named '{}'".format(rerun_runner_name)) walk_and_invoke( -rerun_work, +rerun_files, dotest_argv, rerun_thread_count, rerun_runner_func) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
davide requested changes to this revision. davide added a comment. This revision now requires changes to proceed. Jonas, this looks a good use case for using lit. Is it possible to reuse the machinery we use in `lldb/lit/Expr` ? If not, well, we know there's something we can improve :) https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r325519 - Two more dosep-paralellization fallout fixes
On Mon, Feb 19, 2018 at 9:23 AM, Pavel Labath via lldb-commits < lldb-commits@lists.llvm.org> wrote: > Author: labath > Date: Mon Feb 19 09:23:13 2018 > New Revision: 325519 > > URL: http://llvm.org/viewvc/llvm-project?rev=325519&view=rev > Log: > Two more dosep-paralellization fallout fixes > > The first issue is about the flaky test rerun logic. This was grouping > tests by subdir and passing them into walk_and_invoke in the incorrect > form. This part can be just deleted as its not needed anymore. > > The second problem (which I noticed while investigating the first one) > was that the "-p" switch was not working in multiprocessing mode. This > happened because we were returning None from process_file instead of a > tuple full of empty values for tests that did not match the -p regex. > > Both of these would be caught earlier if python was a more strongly > typed language. :/ > Thank you very much! ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere updated this revision to Diff 134942. JDevlieghere added a comment. Change to lit test https://reviews.llvm.org/D43471 Files: lit/Expr/TestTypeOfExpr.test source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -4046,9 +4046,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,9 +4262,17 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); + case clang::Type::Decltype: break; case clang::Type::TemplateSpecialization: @@ -5060,7 +5075,17 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,8 +5099,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -5214,6 +5237,17 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,8 +5261,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: @@ -6264,9 +6296,12 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: -return 0; +return GetNumPointeeChildren(llvm::cast(qual_type) + ->getUnderlyingExpr() + ->getType()); case clang::Type::TypeOf: -return 0; +return GetNumPointeeChildren( +llvm::cast(qual_type)->getUnderlyingType()); case clang::Type::Decltype: return 0; case clang::Type::Record: @@ -10086,4 +10121,3 @@ lldbassert(m_scratch_ast_source_ap != nullptr); return m_scratch_ast_source_ap->GetMergerUnchecked(); } - Index: lit/Expr/TestTypeOfExpr.test === --- /dev/null +++ lit/Expr/TestTypeOfExpr.test @@ -0,0 +1,4 @@ +# RUN: %lldb -b -s %s | FileCheck %s + +expression int i; __typeof__(i) j = 1; j +# CHECK: typeof (i)) $0 = 1 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere marked 2 inline comments as done. JDevlieghere added inline comments. Comment at: source/Symbol/ClangASTContext.cpp:5264 - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: case clang::Type::Decltype: case clang::Type::TemplateSpecialization: labath wrote: > I'm guessing this means decltype doesn't work either ? Indeed, I was thinking about doing this in a separate diff but since it's so similar I'll update this patch. https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
davide added inline comments. Comment at: lit/Expr/TestTypeOfExpr.test:2 +# RUN: %lldb -b -s %s | FileCheck %s + +expression int i; __typeof__(i) j = 1; j I really really love how concise and clear the new test is! https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere updated this revision to Diff 134954. JDevlieghere marked an inline comment as done. JDevlieghere added a comment. Do this for decltype too https://reviews.llvm.org/D43471 Files: lit/Expr/TestTypeOfDeclTypeExpr.test source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -3964,7 +3964,10 @@ case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate; case clang::Type::Decltype: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::Enum: if (pointee_or_element_clang_type) @@ -4046,9 +4049,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,11 +4265,21 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::Decltype: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::TemplateSpecialization: break; case clang::Type::DeducedTemplateSpecialization: @@ -5060,7 +5080,22 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,9 +5109,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -5214,6 +5246,22 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,9 +5275,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -6264,11 +6309,15 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: -return 0; +return GetNumPointeeChildren(llvm::cast(qual_type) + ->getUnderlyingExpr() + ->getType()); case
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere updated this revision to Diff 134955. JDevlieghere marked an inline comment as done. JDevlieghere added a comment. Make sure the lit test actually checks the lldb output instead of the # CHECK lines. Without the check-next, CHECK matches the # CHECK lines, as they are printed by lldb: (lldb) # RUN: %lldb -b -s %s | FileCheck %s (lldb) expression int i; __typeof__(i) j = 1; j (typeof (i)) $0 = 1 (lldb) # CHECK: (lldb) expression int i; __typeof__(i) j = 1; j (lldb) # CHECK-NEXT: (typeof (i)) $0 = 1 (lldb) expression int i; typeof(i) j = 1; j (typeof (i)) $1 = 1 (lldb) # CHECK: (lldb) expression int i; typeof(i) j = 1; j (lldb) # CHECK-NEXT: (typeof (i)) $1 = 1 (lldb) expression int i; decltype(i) j = 1; j (decltype(i)) $2 = 1 (lldb) # CHECK: (lldb) expression int i; decltype(i) j = 1; j (lldb) # CHECK-NEXT: (decltype(i)) $2 = 1 https://reviews.llvm.org/D43471 Files: lit/Expr/TestTypeOfDeclTypeExpr.test source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -3964,7 +3964,10 @@ case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate; case clang::Type::Decltype: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::Enum: if (pointee_or_element_clang_type) @@ -4046,9 +4049,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,11 +4265,21 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::Decltype: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::TemplateSpecialization: break; case clang::Type::DeducedTemplateSpecialization: @@ -5060,7 +5080,22 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,9 +5109,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -5214,6 +5246,22 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. The code part of this looks fine. I had a few quibbles with the test, see inline. Comment at: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py:270 +# output: (typeof (i)) $0 = 1 +self.expect("expression p int i; __typeof__(i) j = 1; j", +substrs=['(typeof (i)) $', labath wrote: > Are you sure this command is actually correct? The "p" here seems odd... Yes, all the other commands in this test that run expressions either get the stopped frame and run SBFrame.EvaluateExpression, or they spell out "expression" completely. Unless you are actually testing that an alias works, it's better not to use aliases in tests. Also, was there a reason why you didn't use TestEBasicExprCommandsTestCase.build_and_run? It looks like everything you do is done there. I was going to say you should make sure that run stopped at the breakpoint - otherwise if that fails you'll get some weird error from the expression that may be harder to diagnose. But then I noticed the build_and_run function which ALSO doesn't test that the run stopped at your breakpoint, but if all the tests used that then we could just add the check there. https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere added a comment. In https://reviews.llvm.org/D43471#1012484, @jingham wrote: > The code part of this looks fine. I had a few quibbles with the test, see > inline. Jim, it looks like you're commenting on an older version of the diff. I've since switched to checking this with lit. https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
jingham added a comment. Oh, somehow my browser hadn't updated to show the lit test. Ignore the previous comment. This is fine, except can you make the test check not depend on the particular result variable number ($0, $1, $2). You aren't testing here that the result variable numbers are monotonically increasing integers that start at zero, and it will make adding to the test annoying over time. This command output type of test is fragile because it depends on irrelevant details of command output. For instance TestCallStopAndContinue.test knows that the text we output for a stop is exactly "Execution was interrupted, reason: breakpoint" seems like more detail than a test should rely on. Similarly the exact format of the result variable seems more detail than this test needs. https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
jingham added a comment. Other than that it's fine. https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
JDevlieghere updated this revision to Diff 134965. JDevlieghere added a comment. Thanks for the review Jim! I've updated the test accordingly. https://reviews.llvm.org/D43471 Files: lit/Expr/TestTypeOfDeclTypeExpr.test source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -3964,7 +3964,10 @@ case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate; case clang::Type::Decltype: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::Enum: if (pointee_or_element_clang_type) @@ -4046,9 +4049,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,11 +4265,21 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::Decltype: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::TemplateSpecialization: break; case clang::Type::DeducedTemplateSpecialization: @@ -5060,7 +5080,22 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,9 +5109,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -5214,6 +5246,22 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,9 +5275,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -6264,11 +6309,15 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: -return 0; +return GetNumPointeeChildren(llvm::cast(qual_type) + ->getUnderlyingExpr() + ->getType()); case clang::Ty
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
jingham accepted this revision. jingham added a comment. Looks good https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
davide accepted this revision. davide added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D43471 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits