Lines Matching +full:generic +full:- +full:2

1 //===-- ScriptInterpreterPython.cpp ---------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-enumerations.h"
15 #include "lldb-python.h"
79 (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
101 // The table of built-in modules can only be extended before Python is
108 for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
109 if (strcmp(p->name, "readline") == 0) {
110 p->initfunc = initlldb_readline;
120 // Register _lldb as a built-in module.
127 #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
152 static str_type g_python_home = []() -> str_type {
254 path.resize(framework - rend);
298 "lldb-pythonpath": lldb_python_dir,
389 // case, _PyThreadState_Current will be NULL - and we would be unable to set
390 // the asynchronous exception - not a desirable situation
391 m_python_interpreter->SetThreadState(PyThreadState_Get());
392 m_python_interpreter->IncrementLockCount();
401 return m_python_interpreter->EnterSession(on_entry_flags, in, out, err);
409 m_python_interpreter->DecrementLockCount();
416 m_python_interpreter->LeaveSession();
450 // Reloading modules requires a different syntax in Python 2 and Python 3.
457 // WARNING: temporary code that loads Cocoa formatters - this should be done
458 // on a per-platform basis rather than loading the whole set and letting the
515 output_sp->PutCString(instructions);
516 output_sp->Flush();
538 data_up->user_source.SplitIntoLines(data);
540 if (GenerateBreakpointCommandCallbackData(data_up->user_source,
541 data_up->script_source,
552 error_sp->Printf("Warning: No command attached to breakpoint.\n");
553 error_sp->Flush();
563 data_up->user_source.SplitIntoLines(data);
565 if (GenerateWatchpointCommandCallbackData(data_up->user_source,
566 data_up->script_source,
570 wp_options->SetCallback(
575 error_sp->Printf("Warning: No command attached to breakpoint.\n");
576 error_sp->Flush();
592 log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
598 // checking that we have a valid thread state - since we use our own
601 // that is the case - since that seems to only happen when destroying the
719 SetStdHandle(top_out_sp->GetFileSP(), "stdout", m_saved_stdout, "w");
724 SetStdHandle(top_err_sp->GetFileSP(), "stderr", m_saved_stderr, "w");
849 result->AppendErrorWithFormatv(
863 // the read thread. The reason for this is that a pre-requisite for
873 ((result && result->GetInteractive()) ? 0 : Locker::NoSTDIN),
908 // The one-liner failed. Append the error message.
910 result->AppendErrorWithFormat(
917 result->AppendError("empty command passed to python\n");
965 long tid = state->thread_id;
1050 const char format[2] = "b";
1054 const char format[2] = "h";
1058 const char format[2] = "H";
1062 const char format[2] = "i";
1066 const char format[2] = "I";
1070 const char format[2] = "l";
1074 const char format[2] = "k";
1078 const char format[2] = "L";
1082 const char format[2] = "K";
1087 const char format[2] = "f";
1091 const char format[2] = "d";
1095 const char format[2] = "c";
1218 error = GenerateBreakpointCommandCallbackData(cmd_data_up->user_source,
1219 cmd_data_up->script_source,
1239 // Set a Python one-liner as the callback for the breakpoint.
1247 // auto-generated function, and return the function name in script_source.
1250 data_up->user_source.SplitIntoLines(command_body_text);
1252 data_up->user_source, data_up->script_source, uses_extra_args,
1264 // Set a Python one-liner as the callback for the watchpoint.
1275 data_up->user_source.AppendString(user_input);
1276 data_up->script_source.assign(user_input);
1279 data_up->user_source, data_up->script_source, is_callback)) {
1282 wp_options->SetCallback(
1387 // Take what the user wrote, wrap it all up inside one big auto-generated
1400 // Store the name of the auto-generated function to be called.
1425 // Store the name of the auto-generated function to be called.
1468 // Store the name of the auto-generated class
1495 StructuredData::Generic *generic = os_plugin_object_sp->GetAsGeneric();
1496 if (!generic)
1500 (PyObject *)generic->GetValue());
1524 result->Append(valobj_sp);
1573 Debugger &debugger = bkpt_sp->GetTarget().GetDebugger();
1585 class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
1600 implementor_sp->GetValue(), "__callback__", sym_ctx);
1617 implementor_sp->GetValue(), "__get_depth__", nullptr);
1636 error.SetErrorString("No target for scripted stop-hook.");
1641 error.SetErrorString("No class name for scripted stop-hook.");
1649 error.SetErrorString("No script interpreter for scripted stop-hook.");
1657 target_sp, class_name, python_interpreter->m_dictionary_name.c_str(),
1677 implementor_sp->GetValue(), exc_ctx_ref_sp, stream_sp);
1705 StructuredData::Generic *generic = plugin_module_sp->GetAsGeneric();
1706 if (!generic)
1711 TargetSP target_sp(target->shared_from_this());
1714 generic->GetValue(), setting_name, target_sp);
1737 ExecutionContext exe_ctx(valobj->GetExecutionContextRef());
1743 Debugger &debugger = target->GetDebugger();
1753 class_name, python_interpreter->m_dictionary_name.c_str(), valobj);
1820 // Store the name of the auto-generated function to be called.
1842 // Store the name of the auto-generated function to be called.
1860 StructuredData::Generic *generic = nullptr;
1862 generic = callee_wrapper_sp->GetAsGeneric();
1863 if (generic)
1864 old_callee = generic->GetValue();
1910 const char *python_function_name = bp_option_data->script_source.c_str();
1915 ExecutionContext exe_ctx(context->exe_ctx_ref);
1921 Debugger &debugger = target->GetDebugger();
1930 BreakpointSP breakpoint_sp = target->GetBreakpointByID(break_id);
1933 breakpoint_sp->FindLocationByID(break_loc_id));
1944 python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
1945 bp_loc_sp, bp_option_data->m_extra_args);
1975 const char *python_function_name = wp_option_data->script_source.c_str();
1980 ExecutionContext exe_ctx(context->exe_ctx_ref);
1986 Debugger &debugger = target->GetDebugger();
1995 WatchpointSP wp_sp = target->GetWatchpointList().FindByID(watch_id);
2005 python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
2021 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2022 if (!generic)
2024 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2044 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2045 if (!generic)
2047 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2078 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2079 if (!generic)
2081 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2103 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2104 if (!generic)
2106 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2127 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2128 if (!generic)
2130 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2151 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2152 if (!generic)
2154 auto *implementor = static_cast<PyObject *>(generic->GetValue());
2187 StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
2188 if (!generic)
2192 (PyObject *)generic->GetValue());
2229 impl_function, m_dictionary_name.c_str(), process->shared_from_this(),
2254 thread->shared_from_this())) {
2276 TargetSP target_sp(target->shared_from_this());
2304 frame->shared_from_this())) {
2329 impl_function, m_dictionary_name.c_str(), value->GetSP(), output);
2385 auto ExtendSysPath = [&](std::string directory) -> llvm::Error {
2453 module_name.resize(module_name.length() - 3);
2455 module_name.resize(module_name.length() - 4);
2464 if (module_name.find('-') != llvm::StringRef::npos) {
2558 m_old_asynch(debugger_sp->GetAsyncExecution()) {
2560 m_debugger_sp->SetAsyncExecution(false);
2562 m_debugger_sp->SetAsyncExecution(true);
2567 m_debugger_sp->SetAsyncExecution(m_old_asynch);
2620 if (!impl_obj_sp || !impl_obj_sp->IsValid()) {
2647 static_cast<PyObject *>(impl_obj_sp->GetValue()), debugger_sp,
2665 if (!impl_obj_sp || !impl_obj_sp->IsValid()) {
2693 args_arr_sp->AddStringItem(entry.ref());
2698 static_cast<PyObject *>(impl_obj_sp->GetValue()), debugger_sp,
2714 if (!impl_obj_sp || !impl_obj_sp->IsValid())
2734 static_cast<PyObject *>(impl_obj_sp->GetValue()), command);
2783 (PyObject *)cmd_obj_sp->GetValue());
2820 (PyObject *)cmd_obj_sp->GetValue());
2870 (PyObject *)cmd_obj_sp->GetValue());
2918 (PyObject *)cmd_obj_sp->GetValue());
2965 (PyObject *)cmd_obj_sp->GetValue());
3015 (PyObject *)cmd_obj_sp->GetValue());
3066 (PyObject *)cmd_obj_sp->GetValue());
3103 // RAII-based initialization which correctly handles multiple-initialization,
3104 // version- specific differences among Python 2 and Python 3, and saving and