[Lldb-commits] [lldb] r357034 - [Python] Remove dynamic indirection
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 26 14:57:03 PDT 2019
Author: jdevlieghere
Date: Tue Mar 26 14:57:02 2019
New Revision: 357034
URL: http://llvm.org/viewvc/llvm-project?rev=357034&view=rev
Log:
[Python] Remove dynamic indirection
Now that the Python plugin relies on the SWIG symbols, we no longer need
to dynamically resolve these functions.
Modified:
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/API/SystemInitializerFull.h
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
Modified: lldb/trunk/source/API/SystemInitializerFull.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=357034&r1=357033&r2=357034&view=diff
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.cpp (original)
+++ lldb/trunk/source/API/SystemInitializerFull.cpp Tue Mar 26 14:57:02 2019
@@ -142,7 +142,6 @@ llvm::Error SystemInitializerFull::Initi
#endif
#if !defined(LLDB_DISABLE_PYTHON)
- ScriptInterpreterPython::InitializeSWIG();
ScriptInterpreterPython::Initialize();
#endif
Modified: lldb/trunk/source/API/SystemInitializerFull.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.h?rev=357034&r1=357033&r2=357034&view=diff
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.h (original)
+++ lldb/trunk/source/API/SystemInitializerFull.h Tue Mar 26 14:57:02 2019
@@ -27,9 +27,6 @@ public:
llvm::Error Initialize() override;
void Terminate() override;
-
-private:
- void InitializeSWIG();
};
} // namespace lldb_private
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=357034&r1=357033&r2=357034&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Tue Mar 26 14:57:02 2019
@@ -71,10 +71,9 @@ extern "C" void init_lldb(void);
#define LLDBSwigPyInit init_lldb
#endif
-// these are the Pythonic implementations of the required callbacks these are
-// scripting-language specific, which is why they belong here we still need to
-// use function pointers to them instead of relying on linkage-time resolution
-// because the SWIG stuff and this file get built at different times
+// These prototypes are the Pythonic implementations of the required callbacks.
+// Although these are scripting-language specific, their definition depends on
+// the public API.
extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &sb_frame,
@@ -194,67 +193,6 @@ LLDBSWIGPython_GetDynamicSetting(void *m
#endif
-ScriptInterpreterPython::SWIGInitCallback
- ScriptInterpreterPython::g_swig_init_callback = nullptr;
-ScriptInterpreterPython::SWIGBreakpointCallbackFunction
- ScriptInterpreterPython::g_swig_breakpoint_callback = nullptr;
-ScriptInterpreterPython::SWIGWatchpointCallbackFunction
- ScriptInterpreterPython::g_swig_watchpoint_callback = nullptr;
-ScriptInterpreterPython::SWIGPythonTypeScriptCallbackFunction
- ScriptInterpreterPython::g_swig_typescript_callback = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateSyntheticProvider
- ScriptInterpreterPython::g_swig_synthetic_script = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateCommandObject
- ScriptInterpreterPython::g_swig_create_cmd = nullptr;
-ScriptInterpreterPython::SWIGPythonCalculateNumChildren
- ScriptInterpreterPython::g_swig_calc_children = nullptr;
-ScriptInterpreterPython::SWIGPythonGetChildAtIndex
- ScriptInterpreterPython::g_swig_get_child_index = nullptr;
-ScriptInterpreterPython::SWIGPythonGetIndexOfChildWithName
- ScriptInterpreterPython::g_swig_get_index_child = nullptr;
-ScriptInterpreterPython::SWIGPythonCastPyObjectToSBValue
- ScriptInterpreterPython::g_swig_cast_to_sbvalue = nullptr;
-ScriptInterpreterPython::SWIGPythonGetValueObjectSPFromSBValue
- ScriptInterpreterPython::g_swig_get_valobj_sp_from_sbvalue = nullptr;
-ScriptInterpreterPython::SWIGPythonUpdateSynthProviderInstance
- ScriptInterpreterPython::g_swig_update_provider = nullptr;
-ScriptInterpreterPython::SWIGPythonMightHaveChildrenSynthProviderInstance
- ScriptInterpreterPython::g_swig_mighthavechildren_provider = nullptr;
-ScriptInterpreterPython::SWIGPythonGetValueSynthProviderInstance
- ScriptInterpreterPython::g_swig_getvalue_provider = nullptr;
-ScriptInterpreterPython::SWIGPythonCallCommand
- ScriptInterpreterPython::g_swig_call_command = nullptr;
-ScriptInterpreterPython::SWIGPythonCallCommandObject
- ScriptInterpreterPython::g_swig_call_command_object = nullptr;
-ScriptInterpreterPython::SWIGPythonCallModuleInit
- ScriptInterpreterPython::g_swig_call_module_init = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateOSPlugin
- ScriptInterpreterPython::g_swig_create_os_plugin = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateFrameRecognizer
- ScriptInterpreterPython::g_swig_create_frame_recognizer = nullptr;
-ScriptInterpreterPython::SWIGPythonGetRecognizedArguments
- ScriptInterpreterPython::g_swig_get_recognized_arguments = nullptr;
-ScriptInterpreterPython::SWIGPythonScriptKeyword_Process
- ScriptInterpreterPython::g_swig_run_script_keyword_process = nullptr;
-ScriptInterpreterPython::SWIGPythonScriptKeyword_Thread
- ScriptInterpreterPython::g_swig_run_script_keyword_thread = nullptr;
-ScriptInterpreterPython::SWIGPythonScriptKeyword_Target
- ScriptInterpreterPython::g_swig_run_script_keyword_target = nullptr;
-ScriptInterpreterPython::SWIGPythonScriptKeyword_Frame
- ScriptInterpreterPython::g_swig_run_script_keyword_frame = nullptr;
-ScriptInterpreterPython::SWIGPythonScriptKeyword_Value
- ScriptInterpreterPython::g_swig_run_script_keyword_value = nullptr;
-ScriptInterpreterPython::SWIGPython_GetDynamicSetting
- ScriptInterpreterPython::g_swig_plugin_get = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateScriptedThreadPlan
- ScriptInterpreterPython::g_swig_thread_plan_script = nullptr;
-ScriptInterpreterPython::SWIGPythonCallThreadPlan
- ScriptInterpreterPython::g_swig_call_thread_plan = nullptr;
-ScriptInterpreterPython::SWIGPythonCreateScriptedBreakpointResolver
- ScriptInterpreterPython::g_swig_bkpt_resolver_script = nullptr;
-ScriptInterpreterPython::SWIGPythonCallBreakpointResolver
- ScriptInterpreterPython::g_swig_call_bkpt_resolver = nullptr;
-
static bool g_initialized = false;
namespace {
@@ -276,8 +214,7 @@ public:
InitializePythonHome();
// Register _lldb as a built-in module.
- PyImport_AppendInittab("_lldb",
- ScriptInterpreterPython::g_swig_init_callback);
+ PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
// Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
// calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you
@@ -1678,8 +1615,8 @@ StructuredData::GenericSP ScriptInterpre
{
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
- ret_val =
- g_swig_create_frame_recognizer(class_name, m_dictionary_name.c_str());
+ ret_val = LLDBSWIGPython_CreateFrameRecognizer(class_name,
+ m_dictionary_name.c_str());
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
@@ -1700,9 +1637,9 @@ lldb::ValueObjectListSP ScriptInterprete
if (!implementor.IsAllocated()) return ValueObjectListSP();
- PythonObject py_return(
- PyRefType::Owned,
- (PyObject *)g_swig_get_recognized_arguments(implementor.get(), frame_sp));
+ PythonObject py_return(PyRefType::Owned,
+ (PyObject *)LLDBSwigPython_GetRecognizedArguments(
+ implementor.get(), frame_sp));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred()) {
@@ -1715,8 +1652,8 @@ lldb::ValueObjectListSP ScriptInterprete
for (size_t i = 0; i < result_list.GetSize(); i++) {
PyObject *item = result_list.GetItemAtIndex(i).get();
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(item);
- auto valobj_sp = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(item);
+ auto valobj_sp = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
if (valobj_sp) result->Append(valobj_sp);
}
return result;
@@ -1737,8 +1674,8 @@ StructuredData::GenericSP ScriptInterpre
{
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
- ret_val = g_swig_create_os_plugin(class_name, m_dictionary_name.c_str(),
- process_sp);
+ ret_val = LLDBSWIGPythonCreateOSPlugin(
+ class_name, m_dictionary_name.c_str(), process_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
@@ -2022,7 +1959,7 @@ StructuredData::ObjectSP ScriptInterpret
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_thread_plan_script(
+ ret_val = LLDBSwigPythonCreateScriptedThreadPlan(
class_name, python_interpreter->m_dictionary_name.c_str(),
thread_plan_sp);
}
@@ -2039,7 +1976,7 @@ bool ScriptInterpreterPython::ScriptedTh
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- explains_stop = g_swig_call_thread_plan(
+ explains_stop = LLDBSWIGPythonCallThreadPlan(
generic->GetValue(), "explains_stop", event, script_error);
if (script_error)
return true;
@@ -2056,8 +1993,8 @@ bool ScriptInterpreterPython::ScriptedTh
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_stop = g_swig_call_thread_plan(generic->GetValue(), "should_stop",
- event, script_error);
+ should_stop = LLDBSWIGPythonCallThreadPlan(
+ generic->GetValue(), "should_stop", event, script_error);
if (script_error)
return true;
}
@@ -2073,8 +2010,8 @@ bool ScriptInterpreterPython::ScriptedTh
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- is_stale = g_swig_call_thread_plan(generic->GetValue(), "is_stale", nullptr,
- script_error);
+ is_stale = LLDBSWIGPythonCallThreadPlan(generic->GetValue(), "is_stale",
+ nullptr, script_error);
if (script_error)
return true;
}
@@ -2090,8 +2027,8 @@ lldb::StateType ScriptInterpreterPython:
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_step = g_swig_call_thread_plan(generic->GetValue(), "should_step",
- NULL, script_error);
+ should_step = LLDBSWIGPythonCallThreadPlan(
+ generic->GetValue(), "should_step", NULL, script_error);
if (script_error)
should_step = true;
}
@@ -2128,9 +2065,9 @@ ScriptInterpreterPython::CreateScriptedB
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_bkpt_resolver_script(
- class_name, python_interpreter->m_dictionary_name.c_str(),
- args_data, bkpt_sp);
+ ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver(
+ class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
+ bkpt_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
@@ -2145,9 +2082,8 @@ ScriptInterpreterPython::ScriptedBreakpo
if (implementor_sp) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_continue
- = g_swig_call_bkpt_resolver(implementor_sp->GetValue(), "__callback__",
- sym_ctx);
+ should_continue = LLDBSwigPythonCallBreakpointResolver(
+ implementor_sp->GetValue(), "__callback__", sym_ctx);
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -2163,8 +2099,8 @@ ScriptInterpreterPython::ScriptedBreakpo
if (implementor_sp) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- depth_as_int
- = g_swig_call_bkpt_resolver(implementor_sp->GetValue(), "__get_depth__", nullptr);
+ depth_as_int = LLDBSwigPythonCallBreakpointResolver(
+ implementor_sp->GetValue(), "__get_depth__", nullptr);
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -2199,8 +2135,7 @@ ScriptInterpreterPython::LoadPluginModul
StructuredData::DictionarySP ScriptInterpreterPython::GetDynamicSettings(
StructuredData::ObjectSP plugin_module_sp, Target *target,
const char *setting_name, lldb_private::Status &error) {
- if (!plugin_module_sp || !target || !setting_name || !setting_name[0] ||
- !g_swig_plugin_get)
+ if (!plugin_module_sp || !target || !setting_name || !setting_name[0])
return StructuredData::DictionarySP();
StructuredData::Generic *generic = plugin_module_sp->GetAsGeneric();
if (!generic)
@@ -2211,8 +2146,8 @@ StructuredData::DictionarySP ScriptInter
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
TargetSP target_sp(target->shared_from_this());
reply_pyobj.Reset(PyRefType::Owned,
- (PyObject *)g_swig_plugin_get(generic->GetValue(),
- setting_name, target_sp));
+ (PyObject *)LLDBSWIGPython_GetDynamicSetting(
+ generic->GetValue(), setting_name, target_sp));
PythonDictionary py_dict(PyRefType::Borrowed, reply_pyobj.get());
return py_dict.CreateStructuredDictionary();
@@ -2247,7 +2182,7 @@ ScriptInterpreterPython::CreateSynthetic
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_synthetic_script(
+ ret_val = LLDBSwigPythonCreateSyntheticProvider(
class_name, python_interpreter->m_dictionary_name.c_str(), valobj);
}
@@ -2270,8 +2205,8 @@ ScriptInterpreterPython::CreateScriptCom
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val =
- g_swig_create_cmd(class_name, m_dictionary_name.c_str(), debugger_sp);
+ ret_val = LLDBSwigPythonCreateCommandObject(
+ class_name, m_dictionary_name.c_str(), debugger_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
@@ -2369,9 +2304,9 @@ bool ScriptInterpreterPython::GetScripte
{
TypeSummaryOptionsSP options_sp(new TypeSummaryOptions(options));
- static Timer::Category func_cat("g_swig_typescript_callback");
- Timer scoped_timer(func_cat, "g_swig_typescript_callback");
- ret_val = g_swig_typescript_callback(
+ static Timer::Category func_cat("LLDBSwigPythonCallTypeScript");
+ Timer scoped_timer(func_cat, "LLDBSwigPythonCallTypeScript");
+ ret_val = LLDBSwigPythonCallTypeScript(
python_function_name, GetSessionDictionary().get(), valobj,
&new_callee, options_sp, retval);
}
@@ -2437,7 +2372,7 @@ bool ScriptInterpreterPython::Breakpoint
Locker py_lock(python_interpreter, Locker::AcquireLock |
Locker::InitSession |
Locker::NoSTDIN);
- ret_val = g_swig_breakpoint_callback(
+ ret_val = LLDBSwigPythonBreakpointCallbackFunction(
python_function_name,
python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
bp_loc_sp);
@@ -2485,7 +2420,7 @@ bool ScriptInterpreterPython::Watchpoint
Locker py_lock(python_interpreter, Locker::AcquireLock |
Locker::InitSession |
Locker::NoSTDIN);
- ret_val = g_swig_watchpoint_callback(
+ ret_val = LLDBSwigPythonWatchpointCallbackFunction(
python_function_name,
python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
wp_sp);
@@ -2510,15 +2445,12 @@ size_t ScriptInterpreterPython::Calculat
if (!implementor)
return 0;
- if (!g_swig_calc_children)
- return 0;
-
size_t ret_val = 0;
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_calc_children(implementor, max);
+ ret_val = LLDBSwigPython_CalculateNumChildren(implementor, max);
}
return ret_val;
@@ -2536,22 +2468,19 @@ lldb::ValueObjectSP ScriptInterpreterPyt
if (!implementor)
return lldb::ValueObjectSP();
- if (!g_swig_get_child_index || !g_swig_cast_to_sbvalue)
- return lldb::ValueObjectSP();
lldb::ValueObjectSP ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- void *child_ptr = g_swig_get_child_index(implementor, idx);
+ void *child_ptr = LLDBSwigPython_GetChildAtIndex(implementor, idx);
if (child_ptr != nullptr && child_ptr != Py_None) {
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(child_ptr);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
if (sb_value_ptr == nullptr)
Py_XDECREF(child_ptr);
else
- ret_val = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
+ ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
} else {
Py_XDECREF(child_ptr);
}
@@ -2572,15 +2501,12 @@ int ScriptInterpreterPython::GetIndexOfC
if (!implementor)
return UINT32_MAX;
- if (!g_swig_get_index_child)
- return UINT32_MAX;
-
int ret_val = UINT32_MAX;
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_get_index_child(implementor, child_name);
+ ret_val = LLDBSwigPython_GetIndexOfChildWithName(implementor, child_name);
}
return ret_val;
@@ -2600,13 +2526,10 @@ bool ScriptInterpreterPython::UpdateSynt
if (!implementor)
return ret_val;
- if (!g_swig_update_provider)
- return ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_update_provider(implementor);
+ ret_val = LLDBSwigPython_UpdateSynthProviderInstance(implementor);
}
return ret_val;
@@ -2626,13 +2549,12 @@ bool ScriptInterpreterPython::MightHaveC
if (!implementor)
return ret_val;
- if (!g_swig_mighthavechildren_provider)
- return ret_val;
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_mighthavechildren_provider(implementor);
+ ret_val =
+ LLDBSwigPython_MightHaveChildrenSynthProviderInstance(implementor);
}
return ret_val;
@@ -2652,21 +2574,17 @@ lldb::ValueObjectSP ScriptInterpreterPyt
if (!implementor)
return ret_val;
- if (!g_swig_getvalue_provider || !g_swig_cast_to_sbvalue ||
- !g_swig_get_valobj_sp_from_sbvalue)
- return ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- void *child_ptr = g_swig_getvalue_provider(implementor);
+ void *child_ptr = LLDBSwigPython_GetValueSynthProviderInstance(implementor);
if (child_ptr != nullptr && child_ptr != Py_None) {
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(child_ptr);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
if (sb_value_ptr == nullptr)
Py_XDECREF(child_ptr);
else
- ret_val = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
+ ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
} else {
Py_XDECREF(child_ptr);
}
@@ -2754,15 +2672,12 @@ bool ScriptInterpreterPython::RunScriptF
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_process) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ProcessSP process_sp(process->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_process(
+ ret_val = LLDBSWIGPythonRunScriptKeywordProcess(
impl_function, m_dictionary_name.c_str(), process_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2783,15 +2698,12 @@ bool ScriptInterpreterPython::RunScriptF
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_thread) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ThreadSP thread_sp(thread->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_thread(
+ ret_val = LLDBSWIGPythonRunScriptKeywordThread(
impl_function, m_dictionary_name.c_str(), thread_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2812,15 +2724,12 @@ bool ScriptInterpreterPython::RunScriptF
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_target) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
TargetSP target_sp(target->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_target(
+ ret_val = LLDBSWIGPythonRunScriptKeywordTarget(
impl_function, m_dictionary_name.c_str(), target_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2841,15 +2750,12 @@ bool ScriptInterpreterPython::RunScriptF
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_frame) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
StackFrameSP frame_sp(frame->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_frame(
+ ret_val = LLDBSWIGPythonRunScriptKeywordFrame(
impl_function, m_dictionary_name.c_str(), frame_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2870,15 +2776,12 @@ bool ScriptInterpreterPython::RunScriptF
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_value) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ValueObjectSP value_sp(value->GetSP());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_value(
+ ret_val = LLDBSWIGPythonRunScriptKeywordValue(
impl_function, m_dictionary_name.c_str(), value_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2906,11 +2809,6 @@ bool ScriptInterpreterPython::LoadScript
return false;
}
- if (!g_swig_call_module_init) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
-
lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
{
@@ -3030,8 +2928,8 @@ bool ScriptInterpreterPython::LoadScript
// if we are here, everything worked
// call __lldb_init_module(debugger,dict)
- if (!g_swig_call_module_init(basename.c_str(), m_dictionary_name.c_str(),
- debugger_sp)) {
+ if (!LLDBSwigPythonCallModuleInit(basename.c_str(),
+ m_dictionary_name.c_str(), debugger_sp)) {
error.SetErrorString("calling __lldb_init_module failed");
return false;
}
@@ -3103,11 +3001,6 @@ bool ScriptInterpreterPython::RunScriptB
return false;
}
- if (!g_swig_call_command) {
- error.SetErrorString("no helper function to run scripted commands");
- return false;
- }
-
lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
lldb::ExecutionContextRefSP exe_ctx_ref_sp(new ExecutionContextRef(exe_ctx));
@@ -3129,9 +3022,9 @@ bool ScriptInterpreterPython::RunScriptB
SynchronicityHandler synch_handler(debugger_sp, synchronicity);
std::string args_str = args.str();
- ret_val = g_swig_call_command(impl_function, m_dictionary_name.c_str(),
- debugger_sp, args_str.c_str(), cmd_retobj,
- exe_ctx_ref_sp);
+ ret_val = LLDBSwigPythonCallCommand(
+ impl_function, m_dictionary_name.c_str(), debugger_sp, args_str.c_str(),
+ cmd_retobj, exe_ctx_ref_sp);
}
if (!ret_val)
@@ -3152,11 +3045,6 @@ bool ScriptInterpreterPython::RunScriptB
return false;
}
- if (!g_swig_call_command_object) {
- error.SetErrorString("no helper function to run scripted commands");
- return false;
- }
-
lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
lldb::ExecutionContextRefSP exe_ctx_ref_sp(new ExecutionContextRef(exe_ctx));
@@ -3178,9 +3066,9 @@ bool ScriptInterpreterPython::RunScriptB
SynchronicityHandler synch_handler(debugger_sp, synchronicity);
std::string args_str = args.str();
- ret_val = g_swig_call_command_object(impl_obj_sp->GetValue(), debugger_sp,
- args_str.c_str(), cmd_retobj,
- exe_ctx_ref_sp);
+ ret_val = LLDBSwigPythonCallCommandObject(impl_obj_sp->GetValue(),
+ debugger_sp, args_str.c_str(),
+ cmd_retobj, exe_ctx_ref_sp);
}
if (!ret_val)
@@ -3397,96 +3285,6 @@ ScriptInterpreterPython::AcquireInterpre
return py_lock;
}
-void ScriptInterpreterPython::InitializeSWIG() {
-#if !defined(LLDB_DISABLE_PYTHON)
- InitializeInterpreter(
- LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction,
- LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript,
- LLDBSwigPythonCreateSyntheticProvider, LLDBSwigPythonCreateCommandObject,
- LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex,
- LLDBSwigPython_GetIndexOfChildWithName,
- LLDBSWIGPython_CastPyObjectToSBValue,
- LLDBSWIGPython_GetValueObjectSPFromSBValue,
- LLDBSwigPython_UpdateSynthProviderInstance,
- LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
- LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand,
- LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit,
- LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPython_CreateFrameRecognizer,
- LLDBSwigPython_GetRecognizedArguments,
- LLDBSWIGPythonRunScriptKeywordProcess,
- LLDBSWIGPythonRunScriptKeywordThread,
- LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame,
- LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting,
- LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan,
- LLDBSwigPythonCreateScriptedBreakpointResolver,
- LLDBSwigPythonCallBreakpointResolver);
-#endif
-}
-
-void ScriptInterpreterPython::InitializeInterpreter(
- SWIGInitCallback swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance
- swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonCreateFrameRecognizer swig_create_frame_recognizer,
- SWIGPythonGetRecognizedArguments swig_get_recognized_arguments,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan,
- SWIGPythonCreateScriptedBreakpointResolver swig_bkpt_resolver_script,
- SWIGPythonCallBreakpointResolver swig_call_bkpt_resolver) {
- g_swig_init_callback = swig_init_callback;
- g_swig_breakpoint_callback = swig_breakpoint_callback;
- g_swig_watchpoint_callback = swig_watchpoint_callback;
- g_swig_typescript_callback = swig_typescript_callback;
- g_swig_synthetic_script = swig_synthetic_script;
- g_swig_create_cmd = swig_create_cmd;
- g_swig_calc_children = swig_calc_children;
- g_swig_get_child_index = swig_get_child_index;
- g_swig_get_index_child = swig_get_index_child;
- g_swig_cast_to_sbvalue = swig_cast_to_sbvalue;
- g_swig_get_valobj_sp_from_sbvalue = swig_get_valobj_sp_from_sbvalue;
- g_swig_update_provider = swig_update_provider;
- g_swig_mighthavechildren_provider = swig_mighthavechildren_provider;
- g_swig_getvalue_provider = swig_getvalue_provider;
- g_swig_call_command = swig_call_command;
- g_swig_call_command_object = swig_call_command_object;
- g_swig_call_module_init = swig_call_module_init;
- g_swig_create_os_plugin = swig_create_os_plugin;
- g_swig_create_frame_recognizer = swig_create_frame_recognizer;
- g_swig_get_recognized_arguments = swig_get_recognized_arguments;
- g_swig_run_script_keyword_process = swig_run_script_keyword_process;
- g_swig_run_script_keyword_thread = swig_run_script_keyword_thread;
- g_swig_run_script_keyword_target = swig_run_script_keyword_target;
- g_swig_run_script_keyword_frame = swig_run_script_keyword_frame;
- g_swig_run_script_keyword_value = swig_run_script_keyword_value;
- g_swig_plugin_get = swig_plugin_get;
- g_swig_thread_plan_script = swig_thread_plan_script;
- g_swig_call_thread_plan = swig_call_thread_plan;
- g_swig_bkpt_resolver_script = swig_bkpt_resolver_script;
- g_swig_call_bkpt_resolver = swig_call_bkpt_resolver;
-}
-
void ScriptInterpreterPython::InitializePrivate() {
if (g_initialized)
return;
@@ -3502,8 +3300,7 @@ void ScriptInterpreterPython::Initialize
// initialization.
InitializePythonRAII initialize_guard;
- if (g_swig_init_callback)
- g_swig_init_callback();
+ LLDBSwigPyInit();
// Update the path python uses to search for modules to include the current
// directory.
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h?rev=357034&r1=357033&r2=357034&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h Tue Mar 26 14:57:02 2019
@@ -304,7 +304,6 @@ public:
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
- static void InitializeSWIG();
static void Initialize();
static void Terminate();
@@ -365,156 +364,9 @@ public:
PyGILState_STATE m_GILState;
};
- // FIXME: This is currently used from the InitializePythonRAII. Make this
- // private when we're able to break the dependency.
-#if PY_MAJOR_VERSION >= 3
- typedef PyObject *(*SWIGInitCallback)(void);
-#else
- typedef void (*SWIGInitCallback)(void);
-#endif
- static SWIGInitCallback g_swig_init_callback;
-
protected:
- typedef bool (*SWIGBreakpointCallbackFunction)(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &frame_sp,
- const lldb::BreakpointLocationSP &bp_loc_sp);
-
- typedef bool (*SWIGWatchpointCallbackFunction)(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp);
-
- typedef bool (*SWIGPythonTypeScriptCallbackFunction)(
- const char *python_function_name, void *session_dictionary,
- const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP &options, std::string &retval);
-
- typedef void *(*SWIGPythonCreateSyntheticProvider)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::ValueObjectSP &valobj_sp);
-
- typedef void *(*SWIGPythonCreateCommandObject)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
- typedef void *(*SWIGPythonCreateScriptedThreadPlan)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::ThreadPlanSP &thread_plan_sp);
-
- typedef bool (*SWIGPythonCallThreadPlan)(void *implementor,
- const char *method_name,
- Event *event_sp, bool &got_error);
-
- typedef void *(*SWIGPythonCreateScriptedBreakpointResolver)(
- const char *python_class_name, const char *session_dictionary_name,
- lldb_private::StructuredDataImpl *args_impl, lldb::BreakpointSP &bkpt_sp);
-
- typedef unsigned int (*SWIGPythonCallBreakpointResolver)(
- void *implementor, const char *method_name,
- lldb_private::SymbolContext *sym_ctx);
-
- typedef void *(*SWIGPythonCreateOSPlugin)(const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP &process_sp);
-
- typedef void *(*SWIGPythonCreateFrameRecognizer)(
- const char *python_class_name, const char *session_dictionary_name);
-
- typedef void *(*SWIGPythonGetRecognizedArguments)(
- void *implementor, const lldb::StackFrameSP &frame_sp);
-
- typedef size_t (*SWIGPythonCalculateNumChildren)(void *implementor,
- uint32_t max);
-
- typedef void *(*SWIGPythonGetChildAtIndex)(void *implementor, uint32_t idx);
-
- typedef int (*SWIGPythonGetIndexOfChildWithName)(void *implementor,
- const char *child_name);
-
- typedef void *(*SWIGPythonCastPyObjectToSBValue)(void *data);
-
- typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue)(
- void *data);
-
- typedef bool (*SWIGPythonUpdateSynthProviderInstance)(void *data);
-
- typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance)(void *data);
-
- typedef void *(*SWIGPythonGetValueSynthProviderInstance)(void *implementor);
-
- typedef bool (*SWIGPythonCallCommand)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::DebuggerSP &debugger, const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- typedef bool (*SWIGPythonCallCommandObject)(
- void *implementor, lldb::DebuggerSP &debugger, const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- typedef bool (*SWIGPythonCallModuleInit)(const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP &debugger);
-
- typedef bool (*SWIGPythonScriptKeyword_Process)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ProcessSP &process, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Thread)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ThreadSP &thread, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Target)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::TargetSP &target, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Frame)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::StackFrameSP &frame, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Value)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ValueObjectSP &value, std::string &output);
-
- typedef void *(*SWIGPython_GetDynamicSetting)(
- void *module, const char *setting, const lldb::TargetSP &target_sp);
-
static void InitializePrivate();
- static void InitializeInterpreter(
- SWIGInitCallback python_swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance
- swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonCreateFrameRecognizer swig_create_frame_recognizer,
- SWIGPythonGetRecognizedArguments swig_get_recognized_arguments,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan,
- SWIGPythonCreateScriptedBreakpointResolver swig_bkpt_resolver_script,
- SWIGPythonCallBreakpointResolver swig_call_breakpoint_resolver);
-
class SynchronicityHandler {
private:
lldb::DebuggerSP m_debugger_sp;
@@ -587,38 +439,6 @@ protected:
bool m_valid_session;
uint32_t m_lock_count;
PyThreadState *m_command_thread_state;
-
- static SWIGBreakpointCallbackFunction g_swig_breakpoint_callback;
- static SWIGWatchpointCallbackFunction g_swig_watchpoint_callback;
- static SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback;
- static SWIGPythonCreateSyntheticProvider g_swig_synthetic_script;
- static SWIGPythonCreateCommandObject g_swig_create_cmd;
- static SWIGPythonCalculateNumChildren g_swig_calc_children;
- static SWIGPythonGetChildAtIndex g_swig_get_child_index;
- static SWIGPythonGetIndexOfChildWithName g_swig_get_index_child;
- static SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue;
- static SWIGPythonGetValueObjectSPFromSBValue
- g_swig_get_valobj_sp_from_sbvalue;
- static SWIGPythonUpdateSynthProviderInstance g_swig_update_provider;
- static SWIGPythonMightHaveChildrenSynthProviderInstance
- g_swig_mighthavechildren_provider;
- static SWIGPythonGetValueSynthProviderInstance g_swig_getvalue_provider;
- static SWIGPythonCallCommand g_swig_call_command;
- static SWIGPythonCallCommandObject g_swig_call_command_object;
- static SWIGPythonCallModuleInit g_swig_call_module_init;
- static SWIGPythonCreateOSPlugin g_swig_create_os_plugin;
- static SWIGPythonCreateFrameRecognizer g_swig_create_frame_recognizer;
- static SWIGPythonGetRecognizedArguments g_swig_get_recognized_arguments;
- static SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process;
- static SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread;
- static SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target;
- static SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame;
- static SWIGPythonScriptKeyword_Value g_swig_run_script_keyword_value;
- static SWIGPython_GetDynamicSetting g_swig_plugin_get;
- static SWIGPythonCreateScriptedThreadPlan g_swig_thread_plan_script;
- static SWIGPythonCallThreadPlan g_swig_call_thread_plan;
- static SWIGPythonCreateScriptedBreakpointResolver g_swig_bkpt_resolver_script;
- static SWIGPythonCallBreakpointResolver g_swig_call_bkpt_resolver;
};
} // namespace lldb_private
More information about the lldb-commits
mailing list