forked from OSchip/llvm-project
Second attempt at getting the PyCallable changes in trunk
Thanks to Daniel Malea for helping test this patch for Linux happiness! llvm-svn: 185965
This commit is contained in:
parent
61a56d7a3a
commit
eff81a471a
|
@ -98,6 +98,13 @@ public:
|
|||
const char *
|
||||
GetError (bool only_if_no_immediate);
|
||||
|
||||
void
|
||||
SetError (lldb::SBError &error,
|
||||
const char *fallback_error_cstr = NULL);
|
||||
|
||||
void
|
||||
SetError (const char* error_cstr);
|
||||
|
||||
protected:
|
||||
friend class SBCommandInterpreter;
|
||||
friend class SBOptions;
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
friend class SBCommandReturnObject;
|
||||
friend class SBData;
|
||||
friend class SBDebugger;
|
||||
friend class SBCommunication;
|
||||
|
|
|
@ -142,8 +142,11 @@ public:
|
|||
AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
void
|
||||
SetError (const Error &error,
|
||||
const char *fallback_error_cstr);
|
||||
SetError (const Error &error,
|
||||
const char *fallback_error_cstr = NULL);
|
||||
|
||||
void
|
||||
SetError (const char *error_cstr);
|
||||
|
||||
lldb::ReturnStatus
|
||||
GetStatus();
|
||||
|
|
|
@ -120,7 +120,6 @@ public:
|
|||
const char *session_dictionary_name,
|
||||
lldb::DebuggerSP& debugger,
|
||||
const char* args,
|
||||
std::string& err_msg,
|
||||
lldb_private::CommandReturnObject& cmd_retobj);
|
||||
|
||||
typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name,
|
||||
|
|
|
@ -58,6 +58,13 @@ public:
|
|||
|
||||
void
|
||||
SetStatus (lldb::ReturnStatus status);
|
||||
|
||||
void
|
||||
SetError (lldb::SBError &error,
|
||||
const char *fallback_error_cstr = NULL);
|
||||
|
||||
void
|
||||
SetError (const char *error_cstr);
|
||||
|
||||
lldb::ReturnStatus
|
||||
GetStatus();
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
#ifndef __cplusplus
|
||||
#error needs C++ to build these
|
||||
#endif
|
||||
|
||||
// leaving this undefined ensures we will get a linker error if we try to use SBTypeToSWIGWrapper()
|
||||
// for a type for which we did not specialze this function
|
||||
template <typename SBClass>
|
||||
|
@ -15,6 +11,38 @@ SBTypeToSWIGWrapper (SBClass& sb_object)
|
|||
return SBTypeToSWIGWrapper(&sb_object);
|
||||
}
|
||||
|
||||
template <typename SBClass>
|
||||
PyObject*
|
||||
SBTypeToSWIGWrapper (const SBClass& sb_object)
|
||||
{
|
||||
return SBTypeToSWIGWrapper(&sb_object);
|
||||
}
|
||||
|
||||
template <>
|
||||
PyObject*
|
||||
SBTypeToSWIGWrapper (PyObject* py_object)
|
||||
{
|
||||
return py_object;
|
||||
}
|
||||
|
||||
template <>
|
||||
PyObject*
|
||||
SBTypeToSWIGWrapper (const char* c_str)
|
||||
{
|
||||
if (c_str)
|
||||
return PyString_FromString(c_str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <>
|
||||
PyObject*
|
||||
SBTypeToSWIGWrapper (unsigned int* c_int)
|
||||
{
|
||||
if (!c_int)
|
||||
return NULL;
|
||||
return PyInt_FromLong(*c_int);
|
||||
}
|
||||
|
||||
template <>
|
||||
PyObject*
|
||||
SBTypeToSWIGWrapper (lldb::SBProcess* process_sb)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,8 +8,10 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/API/SBCommandReturnObject.h"
|
||||
#include "lldb/API/SBError.h"
|
||||
#include "lldb/API/SBStream.h"
|
||||
|
||||
#include "lldb/Core/Error.h"
|
||||
#include "lldb/Core/Log.h"
|
||||
#include "lldb/Interpreter/CommandReturnObject.h"
|
||||
|
||||
|
@ -329,3 +331,22 @@ SBCommandReturnObject::Printf(const char* format, ...)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_error_cstr)
|
||||
{
|
||||
if (m_opaque_ap.get())
|
||||
{
|
||||
if (error.IsValid())
|
||||
m_opaque_ap->SetError(error.ref(), fallback_error_cstr);
|
||||
else if (fallback_error_cstr)
|
||||
m_opaque_ap->SetError(Error(), fallback_error_cstr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SBCommandReturnObject::SetError (const char *error_cstr)
|
||||
{
|
||||
if (m_opaque_ap.get() && error_cstr)
|
||||
m_opaque_ap->SetError(error_cstr);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,9 +143,19 @@ CommandReturnObject::SetError (const Error &error, const char *fallback_error_cs
|
|||
const char *error_cstr = error.AsCString();
|
||||
if (error_cstr == NULL)
|
||||
error_cstr = fallback_error_cstr;
|
||||
AppendError (error_cstr);
|
||||
SetStatus (eReturnStatusFailed);
|
||||
SetError(error_cstr);
|
||||
}
|
||||
|
||||
void
|
||||
CommandReturnObject::SetError (const char *error_cstr)
|
||||
{
|
||||
if (error_cstr)
|
||||
{
|
||||
AppendError (error_cstr);
|
||||
SetStatus (eReturnStatusFailed);
|
||||
}
|
||||
}
|
||||
|
||||
// Similar to AppendError, but do not prepend 'Error: ' to message, and
|
||||
// don't append "\n" to the end of it.
|
||||
|
||||
|
|
|
@ -115,8 +115,7 @@ LLDBSwigPythonCallCommand (const char *python_function_name,
|
|||
const char *session_dictionary_name,
|
||||
lldb::DebuggerSP& debugger,
|
||||
const char* args,
|
||||
std::string& err_msg,
|
||||
lldb_private::CommandReturnObject& cmd_retobj);
|
||||
lldb_private::CommandReturnObject &cmd_retobj);
|
||||
|
||||
extern "C" bool
|
||||
LLDBSwigPythonCallModuleInit (const char *python_module_name,
|
||||
|
@ -2963,25 +2962,25 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
|
|||
}
|
||||
|
||||
lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
|
||||
|
||||
|
||||
if (!debugger_sp.get())
|
||||
{
|
||||
error.SetErrorString("invalid Debugger pointer");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret_val;
|
||||
bool ret_val = false;
|
||||
|
||||
std::string err_msg;
|
||||
|
||||
|
||||
{
|
||||
Locker py_lock(this,
|
||||
Locker::AcquireLock | Locker::InitSession,
|
||||
Locker::FreeLock | Locker::TearDownSession);
|
||||
|
||||
|
||||
SynchronicityHandler synch_handler(debugger_sp,
|
||||
synchronicity);
|
||||
|
||||
|
||||
// we need to save the thread state when we first start the command
|
||||
// because we might decide to interrupt it while some action is taking
|
||||
// place outside of Python (e.g. printing to screen, waiting for the network, ...)
|
||||
|
@ -2995,12 +2994,11 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
|
|||
m_dictionary_name.c_str(),
|
||||
debugger_sp,
|
||||
args,
|
||||
err_msg,
|
||||
cmd_retobj);
|
||||
}
|
||||
|
||||
|
||||
if (!ret_val)
|
||||
error.SetErrorString(err_msg.c_str());
|
||||
error.SetErrorString("unable to execute script function");
|
||||
else
|
||||
error.Clear();
|
||||
|
||||
|
|
|
@ -13,9 +13,7 @@ def target_name_impl(debugger, args, result, dict):
|
|||
file = target.GetExecutable()
|
||||
print >>result, ('Current target ' + file.GetFilename())
|
||||
if args == 'fail':
|
||||
return 'a test for error in command'
|
||||
else:
|
||||
return None
|
||||
result.SetError('a test for error in command')
|
||||
|
||||
def print_wait_impl(debugger, args, result, dict):
|
||||
result.SetImmediateOutputFile(sys.stdout)
|
||||
|
@ -25,11 +23,10 @@ def print_wait_impl(debugger, args, result, dict):
|
|||
print >>result, ('Still doing long task..')
|
||||
time.sleep(1)
|
||||
print >>result, ('Done; if you saw the delays I am doing OK')
|
||||
return None
|
||||
|
||||
def check_for_synchro(debugger, args, result, dict):
|
||||
if debugger.GetAsync() == True:
|
||||
print >>result, ('I am running async')
|
||||
if debugger.GetAsync() == False:
|
||||
print >>result, ('I am running sync')
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue