[Lldb-commits] [lldb] r344474 - Fix double import of _lldb module.
Author: vadimcn Date: Sun Oct 14 00:24:56 2018 New Revision: 344474 URL: http://llvm.org/viewvc/llvm-project?rev=344474&view=rev Log: Fix double import of _lldb module. Fix llvm.org/pr39054: - Register _lldb as a built-in module during initialization of script interpreter, - Reverse the order of imports in __init__.py: first try to import by absolute name, which will find the built-in module in the context of lldb (and other hosts that embed liblldb), then try relative import, in case the module is being imported from Python interpreter. This works for SWIG>=3.0.11; before that, SWIG did not support custom module import code. Differential revision: https://reviews.llvm.org/D52404 Modified: lldb/trunk/scripts/lldb.swig lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=344474&r1=344473&r2=344474&view=diff == --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Sun Oct 14 00:24:56 2018 @@ -41,12 +41,12 @@ Older swig versions will simply ignore t */ %define MODULEIMPORT "try: -# Try a relative import first -from . import $module +# Try an absolute import first. If we're being loaded from lldb, +# _lldb should be a built-in module. +import $module except ImportError: -# Maybe absolute import will work (if we're being loaded from lldb, it -# should). -import $module" +# Relative import should work if we are being loaded by Python. +from . import $module" %enddef // These versions will not generate working python modules, so error out early. #if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011 Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=344474&r1=344473&r2=344474&view=diff == --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Sun Oct 14 00:24:56 2018 @@ -132,6 +132,9 @@ public: InitializePythonHome(); +// Register _lldb as a built-in module. +PyImport_AppendInittab("_lldb", g_swig_init_callback); + // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for // calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you // call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r304832 - Use exact equality for category language matching, for all languages, except those specifically mentioned.
Author: vadimcn Date: Tue Jun 6 15:40:24 2017 New Revision: 304832 URL: http://llvm.org/viewvc/llvm-project?rev=304832&view=rev Log: Use exact equality for category language matching, for all languages, except those specifically mentioned. Modified: lldb/trunk/source/DataFormatters/TypeCategory.cpp Modified: lldb/trunk/source/DataFormatters/TypeCategory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategory.cpp?rev=304832&r1=304831&r2=304832&view=diff == --- lldb/trunk/source/DataFormatters/TypeCategory.cpp (original) +++ lldb/trunk/source/DataFormatters/TypeCategory.cpp Tue Jun 6 15:40:24 2017 @@ -36,23 +36,8 @@ TypeCategoryImpl::TypeCategoryImpl( static bool IsApplicable(lldb::LanguageType category_lang, lldb::LanguageType valobj_lang) { switch (category_lang) { - // these are not languages that LLDB would ordinarily deal with - // only allow an exact equality here, since we really don't know - // any better - case eLanguageTypeAda83: - case eLanguageTypeCobol74: - case eLanguageTypeCobol85: - case eLanguageTypeFortran77: - case eLanguageTypeFortran90: - case eLanguageTypePascal83: - case eLanguageTypeModula2: - case eLanguageTypeJava: - case eLanguageTypeAda95: - case eLanguageTypeFortran95: - case eLanguageTypePLI: - case eLanguageTypeUPC: - case eLanguageTypeD: - case eLanguageTypePython: + // Unless we know better, allow only exact equality. + default: return category_lang == valobj_lang; // the C family, we consider it as one @@ -80,7 +65,7 @@ static bool IsApplicable(lldb::LanguageT valobj_lang == eLanguageTypeC_plus_plus || valobj_lang == eLanguageTypeObjC; - default: + // Categories with unspecified language match everything. case eLanguageTypeUnknown: return true; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r313442 - Fix compatibility with OpenOCD debug stub.
Author: vadimcn Date: Fri Sep 15 20:53:13 2017 New Revision: 313442 URL: http://llvm.org/viewvc/llvm-project?rev=313442&view=rev Log: Fix compatibility with OpenOCD debug stub. OpenOCD sends register classes as two separate nodes, fixed parser to process both of them. OpenOCD returns "l" in response to "qfThreadInfo", so IsUnsupportedResponse() was false and we were ending up without any threads in the process. I think it's reasonable to assume that there's always at least one thread. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=313442&r1=313441&r2=313442&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Sep 15 20:53:13 2017 @@ -2624,8 +2624,7 @@ size_t GDBRemoteCommunicationClient::Get * tid. * Assume pid=tid=1 in such cases. */ -if (response.IsUnsupportedResponse() && thread_ids.size() == 0 && -IsConnected()) { +if (thread_ids.size() == 0 && IsConnected()) { thread_ids.push_back(1); } } else { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=313442&r1=313441&r2=313442&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Sep 15 20:53:13 2017 @@ -4168,7 +4168,6 @@ struct GdbServerTargetInfo { std::string osabi; stringVec includes; RegisterSetMap reg_set_map; - XMLNode feature_node; }; bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, @@ -4374,8 +4373,8 @@ bool ProcessGDBRemote::GetGDBServerRegis XMLNode target_node = xml_document.GetRootElement("target"); if (target_node) { - XMLNode feature_node; - target_node.ForEachChildElement([&target_info, &feature_node]( + std::vector feature_nodes; + target_node.ForEachChildElement([&target_info, &feature_nodes]( const XMLNode &node) -> bool { llvm::StringRef name = node.GetName(); if (name == "architecture") { @@ -4387,7 +4386,7 @@ bool ProcessGDBRemote::GetGDBServerRegis if (!href.empty()) target_info.includes.push_back(href.str()); } else if (name == "feature") { - feature_node = node; + feature_nodes.push_back(node); } else if (name == "groups") { node.ForEachChildElementWithName( "group", [&target_info](const XMLNode &node) -> bool { @@ -4423,7 +4422,7 @@ bool ProcessGDBRemote::GetGDBServerRegis // set the Target's architecture yet, so the ABI is also potentially // incorrect. ABISP abi_to_use_sp = ABI::FindPlugin(shared_from_this(), arch_to_use); - if (feature_node) { + for (auto &feature_node : feature_nodes) { ParseRegisters(feature_node, target_info, this->m_register_info, abi_to_use_sp, cur_reg_num, reg_offset); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r313442 - Fix compatibility with OpenOCD debug stub.
Yes, this works for OpenOCD as well. Thanks! On Mon, Sep 18, 2017 at 4:44 AM, Tamas Berghammer wrote: > Hi Vadim, > > This change broke remote debugging on Linux and Android as for some reason > LLDB sends a qfThreadInfo on those platforms before starting a process (not > sure why, will investigate when I have a bit more time) and lldb-server > sends an OK response to it. After your change it will generate a valid > thread ID what will cause LLDB to get confused and fail to lunch a process. > I submitted a fix as r313525 what should work both for OpenOCD and for > Linux/Android but can you verify the OpenOCD part? > > Thanks, > Tamas > > On Sat, Sep 16, 2017 at 4:54 AM Vadim Chugunov via lldb-commits < > lldb-commits@lists.llvm.org> wrote: > >> Author: vadimcn >> Date: Fri Sep 15 20:53:13 2017 >> New Revision: 313442 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=313442&view=rev >> Log: >> Fix compatibility with OpenOCD debug stub. >> >> OpenOCD sends register classes as two separate nodes, fixed >> parser to process both of them. >> >> OpenOCD returns "l" in response to "qfThreadInfo", so >> IsUnsupportedResponse() was false and we were ending up without any threads >> in the process. I think it's reasonable to assume that there's always at >> least one thread. >> >> Modified: >> lldb/trunk/source/Plugins/Process/gdb-remote/ >> GDBRemoteCommunicationClient.cpp >> lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp >> >> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ >> GDBRemoteCommunicationClient.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/ >> Plugins/Process/gdb-remote/GDBRemoteCommunicationClient. >> cpp?rev=313442&r1=313441&r2=313442&view=diff >> >> == >> --- lldb/trunk/source/Plugins/Process/gdb-remote/ >> GDBRemoteCommunicationClient.cpp (original) >> +++ lldb/trunk/source/Plugins/Process/gdb-remote/ >> GDBRemoteCommunicationClient.cpp Fri Sep 15 20:53:13 2017 >> @@ -2624,8 +2624,7 @@ size_t GDBRemoteCommunicationClient::Get >> * tid. >> * Assume pid=tid=1 in such cases. >> */ >> -if (response.IsUnsupportedResponse() && thread_ids.size() == 0 && >> -IsConnected()) { >> +if (thread_ids.size() == 0 && IsConnected()) { >>thread_ids.push_back(1); >> } >>} else { >> >> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ >> ProcessGDBRemote.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/ >> Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev= >> 313442&r1=313441&r2=313442&view=diff >> >> == >> --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp >> (original) >> +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp >> Fri Sep 15 20:53:13 2017 >> @@ -4168,7 +4168,6 @@ struct GdbServerTargetInfo { >>std::string osabi; >>stringVec includes; >>RegisterSetMap reg_set_map; >> - XMLNode feature_node; >> }; >> >> bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo >> &target_info, >> @@ -4374,8 +4373,8 @@ bool ProcessGDBRemote::GetGDBServerRegis >> >> XMLNode target_node = xml_document.GetRootElement("target"); >> if (target_node) { >> - XMLNode feature_node; >> - target_node.ForEachChildElement([&target_info, &feature_node]( >> + std::vector feature_nodes; >> + target_node.ForEachChildElement([&target_info, &feature_nodes]( >>const XMLNode &node) -> bool { >> llvm::StringRef name = node.GetName(); >> if (name == "architecture") { >> @@ -4387,7 +4386,7 @@ bool ProcessGDBRemote::GetGDBServerRegis >>if (!href.empty()) >> target_info.includes.push_back(href.str()); >> } else if (name == "feature") { >> - feature_node = node; >> + feature_nodes.push_back(node); >> } else if (name == "groups") { >>node.ForEachChildElementWithName( >>"group", [&target_info](const XMLNode &node) -> bool { >> @@ -4423,7 +4422,7 @@ bool ProcessGDBRemote::GetGDBServerRegis >>// set the