[llvm-branch-commits] [lldb] r198719 - Fixed remaining test suite failures on this branch.
Greg Clayton
gclayton at apple.com
Tue Jan 7 15:40:47 PST 2014
Author: gclayton
Date: Tue Jan 7 17:40:46 2014
New Revision: 198719
URL: http://llvm.org/viewvc/llvm-project?rev=198719&view=rev
Log:
Fixed remaining test suite failures on this branch.
Removed:
lldb/branches/iohandler/test/python_api/default-constructor/sb_inputreader.py
lldb/branches/iohandler/test/python_api/input_reader/
Modified:
lldb/branches/iohandler/include/lldb/Core/Debugger.h
lldb/branches/iohandler/include/lldb/Interpreter/PythonDataObjects.h
lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreter.h
lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreterPython.h
lldb/branches/iohandler/source/Commands/CommandObjectProcess.cpp
lldb/branches/iohandler/source/Core/Debugger.cpp
lldb/branches/iohandler/source/Core/IOHandler.cpp
lldb/branches/iohandler/source/Host/common/Editline.cpp
lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp
lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.h
lldb/branches/iohandler/source/Plugins/Process/Utility/UnwindLLDB.cpp
lldb/branches/iohandler/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/branches/iohandler/source/Symbol/ClangASTType.cpp
lldb/branches/iohandler/source/Target/Process.cpp
lldb/branches/iohandler/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
lldb/branches/iohandler/test/functionalities/command_source/TestCommandSource.py
lldb/branches/iohandler/test/functionalities/conditional_break/.lldb
lldb/branches/iohandler/test/functionalities/conditional_break/conditional_break.py
lldb/branches/iohandler/test/functionalities/connect_remote/EchoServer.py
lldb/branches/iohandler/test/functionalities/connect_remote/TestConnectRemote.py
lldb/branches/iohandler/test/functionalities/inferior-assert/TestInferiorAssert.py
lldb/branches/iohandler/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
lldb/branches/iohandler/test/python_api/default-constructor/sb_debugger.py
Modified: lldb/branches/iohandler/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Core/Debugger.h?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Core/Debugger.h (original)
+++ lldb/branches/iohandler/include/lldb/Core/Debugger.h Tue Jan 7 17:40:46 2014
@@ -107,6 +107,8 @@ public:
{
return m_error_file_sp;
}
+
+
void
SetInputFileHandle (FILE *fh, bool tranfer_ownership);
@@ -187,12 +189,16 @@ public:
void
DispatchInputEndOfFile ();
+ //------------------------------------------------------------------
+ // If any of the streams are not set, set them to the in/out/err
+ // stream of the top most input reader to ensure they at least have
+ // something
+ //------------------------------------------------------------------
void
- GetIOHandlerFiles (IOHandler &reader);
+ AdoptTopIOHandlerFilesIfInvalid (lldb::StreamFileSP &in,
+ lldb::StreamFileSP &out,
+ lldb::StreamFileSP &err);
-// bool
-// TryPushIOHandler (const lldb::IOHandlerSP& reader_sp);
-//
void
PushIOHandler (const lldb::IOHandlerSP& reader_sp);
Modified: lldb/branches/iohandler/include/lldb/Interpreter/PythonDataObjects.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Interpreter/PythonDataObjects.h?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Interpreter/PythonDataObjects.h (original)
+++ lldb/branches/iohandler/include/lldb/Interpreter/PythonDataObjects.h Tue Jan 7 17:40:46 2014
@@ -86,7 +86,7 @@ namespace lldb_private {
{
return m_py_obj;
}
-
+
PythonString
Repr ();
Modified: lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreter.h?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreter.h Tue Jan 7 17:40:46 2014
@@ -245,11 +245,13 @@ public:
return true;
}
- virtual bool
+ virtual Error
ExecuteMultipleLines (const char *in_string,
const ExecuteScriptOptions &options = ExecuteScriptOptions())
{
- return true;
+ Error error;
+ error.SetErrorString("not implemented");
+ return error;
}
virtual bool
Modified: lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreterPython.h (original)
+++ lldb/branches/iohandler/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Jan 7 17:40:46 2014
@@ -52,7 +52,7 @@ public:
void *ret_value,
const ExecuteScriptOptions &options = ExecuteScriptOptions());
- bool
+ lldb_private::Error
ExecuteMultipleLines (const char *in_string,
const ExecuteScriptOptions &options = ExecuteScriptOptions());
Modified: lldb/branches/iohandler/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Commands/CommandObjectProcess.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/branches/iohandler/source/Commands/CommandObjectProcess.cpp Tue Jan 7 17:40:46 2014
@@ -532,37 +532,36 @@ protected:
if (error.Success())
{
+ ListenerSP listener_sp (new Listener("lldb.CommandObjectProcessAttach.DoExecute.attach.hijack"));
+ m_options.attach_info.SetHijackListener(listener_sp);
+ process->HijackProcessEvents(listener_sp.get());
error = process->Attach (m_options.attach_info);
if (error.Success())
{
result.SetStatus (eReturnStatusSuccessContinuingNoResult);
- }
- else
- {
- result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- // If we're synchronous, wait for the stopped event and report that.
- // Otherwise just return.
- // FIXME: in the async case it will now be possible to get to the command
- // interpreter with a state eStateAttaching. Make sure we handle that correctly.
- StateType state = process->WaitForProcessToStop (NULL, NULL, false);
-
- result.SetDidChangeProcessState (true);
+ StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get());
- if (state == eStateStopped)
- {
- result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ process->RestoreProcessEvents();
+
+ result.SetDidChangeProcessState (true);
+
+ if (state == eStateStopped)
+ {
+ result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ else
+ {
+ result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
+ process->Destroy();
+ result.SetStatus (eReturnStatusFailed);
+ }
}
else
{
- result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
- process->Destroy();
+ result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
result.SetStatus (eReturnStatusFailed);
- return false;
}
}
}
Modified: lldb/branches/iohandler/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/Debugger.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/Debugger.cpp (original)
+++ lldb/branches/iohandler/source/Core/Debugger.cpp Tue Jan 7 17:40:46 2014
@@ -886,7 +886,7 @@ Debugger::RunIOHandler (const IOHandlerS
}
void
-Debugger::GetIOHandlerFiles (IOHandler &reader)
+Debugger::AdoptTopIOHandlerFilesIfInvalid (StreamFileSP &in, StreamFileSP &out, StreamFileSP &err)
{
// Before an IOHandler runs, it must have in/out/err streams.
// This function is called when one ore more of the streams
@@ -897,69 +897,44 @@ Debugger::GetIOHandlerFiles (IOHandler &
Mutex::Locker locker (m_input_reader_stack.GetMutex());
IOHandlerSP top_reader_sp (m_input_reader_stack.Top());
// If no STDIN has been set, then set it appropriately
- if (!reader.GetInputStreamFile())
+ if (!in)
{
if (top_reader_sp)
- reader.GetInputStreamFile() = top_reader_sp->GetInputStreamFile();
+ in = top_reader_sp->GetInputStreamFile();
else
- reader.GetInputStreamFile() = GetInputFile();
+ in = GetInputFile();
// If there is nothing, use stdin
- if (!reader.GetInputStreamFile())
- reader.GetInputStreamFile() = StreamFileSP(new StreamFile(stdin, false));
+ if (!in)
+ in = StreamFileSP(new StreamFile(stdin, false));
}
// If no STDOUT has been set, then set it appropriately
- if (!reader.GetOutputStreamFile())
+ if (!out)
{
if (top_reader_sp)
- reader.GetOutputStreamFile() = top_reader_sp->GetOutputStreamFile();
+ out = top_reader_sp->GetOutputStreamFile();
else
- reader.GetOutputStreamFile() = GetOutputFile();
-
+ out = GetOutputFile();
+
// If there is nothing, use stdout
- if (!reader.GetOutputStreamFile())
- reader.GetOutputStreamFile() = StreamFileSP(new StreamFile(stdout, false));
+ if (!out)
+ out = StreamFileSP(new StreamFile(stdout, false));
}
// If no STDERR has been set, then set it appropriately
- if (!reader.GetErrorStreamFile())
+ if (!err)
{
if (top_reader_sp)
- reader.GetErrorStreamFile() = top_reader_sp->GetErrorStreamFile();
+ err = top_reader_sp->GetErrorStreamFile();
else
- reader.GetErrorStreamFile() = GetErrorFile();
-
+ err = GetErrorFile();
+
// If there is nothing, use stderr
- if (!reader.GetErrorStreamFile())
- reader.GetErrorStreamFile() = StreamFileSP(new StreamFile(stdout, false));
-
+ if (!err)
+ err = StreamFileSP(new StreamFile(stdout, false));
+
}
}
-//bool
-//Debugger::TryPushIOHandler (const IOHandlerSP& reader_sp)
-//{
-// if (!reader_sp)
-// return false;
-//
-// Mutex::Locker locker;
-//
-// if (locker.TryLock(m_input_reader_stack.GetMutex()))
-// {
-// // Got the current top input reader...
-// IOHandlerSP top_reader_sp (m_input_reader_stack.Top());
-//
-// // Push our new input reader
-// m_input_reader_stack.Push (reader_sp);
-//
-// // Interrupt the top input reader to it will exit its Run() function
-// // and let this new input reader take over
-// if (top_reader_sp)
-// top_reader_sp->Deactivate();
-// return true;
-// }
-// return false;
-//}
-//
void
Debugger::PushIOHandler (const IOHandlerSP& reader_sp)
{
Modified: lldb/branches/iohandler/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/IOHandler.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/IOHandler.cpp (original)
+++ lldb/branches/iohandler/source/Core/IOHandler.cpp Tue Jan 7 17:40:46 2014
@@ -58,10 +58,11 @@ IOHandler::IOHandler (Debugger &debugger
m_done (false),
m_active (false)
{
- // If any files are not specified, then adopt them from the
- // top input reader.
+ // If any files are not specified, then adopt them from the top input reader.
if (!m_input_sp || !m_output_sp || !m_error_sp)
- debugger.GetIOHandlerFiles (*this);
+ debugger.AdoptTopIOHandlerFilesIfInvalid (m_input_sp,
+ m_output_sp,
+ m_error_sp);
}
IOHandler::~IOHandler()
Modified: lldb/branches/iohandler/source/Host/common/Editline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Host/common/Editline.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Host/common/Editline.cpp (original)
+++ lldb/branches/iohandler/source/Host/common/Editline.cpp Tue Jan 7 17:40:46 2014
@@ -102,6 +102,12 @@ Editline::~Editline()
{
SaveHistory();
+ if (m_history)
+ {
+ ::history_end (m_history);
+ m_history = NULL;
+ }
+
// Disable edit mode to stop the terminal from flushing all input
// during the call to el_end() since we expect to have multiple editline
// instances in this program.
@@ -109,11 +115,6 @@ Editline::~Editline()
::el_end(m_editline);
m_editline = NULL;
- if (m_history)
- {
- ::history_end (m_history);
- m_history = NULL;
- }
}
void
@@ -148,7 +149,8 @@ Editline::SaveHistory ()
{
if (m_history)
{
- ::history (m_history, &m_history_event, H_SAVE, GetHistoryFile().GetPath().c_str());
+ std::string history_path = GetHistoryFile().GetPath();
+ ::history (m_history, &m_history_event, H_SAVE, history_path.c_str());
return true;
}
return false;
Modified: lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp Tue Jan 7 17:40:46 2014
@@ -27,6 +27,8 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/WatchpointOptions.h"
+#include "lldb/Core/Communication.h"
+#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
@@ -67,6 +69,9 @@ _check_and_flush (FILE *stream)
return fflush (stream) || prev_fail ? EOF : 0;
}
+static std::string
+ReadPythonBacktrace (PyObject* py_backtrace);
+
ScriptInterpreterPython::Locker::Locker (ScriptInterpreterPython *py_interpreter,
uint16_t on_entry,
uint16_t on_leave,
@@ -518,33 +523,92 @@ ScriptInterpreterPython::GetEmbeddedInte
return (bool)m_run_one_line_function;
}
+static void
+ReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
+{
+ if (src && src_len)
+ {
+ Stream *strm = (Stream *)baton;
+ strm->Write(src, src_len);
+ strm->Flush();
+ }
+}
+
bool
ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObject *result, const ExecuteScriptOptions &options)
{
if (!m_valid_session)
return false;
- // We want to call run_one_line, passing in the dictionary and the command string. We cannot do this through
- // PyRun_SimpleString here because the command string may contain escaped characters, and putting it inside
- // another string to pass to PyRun_SimpleString messes up the escaping. So we use the following more complicated
- // method to pass the command string directly down to Python.
- Debugger &debugger = m_interpreter.GetDebugger();
-
- Locker locker(this,
- ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession,
- debugger.GetInputFile()->GetFile().GetStream(),
- debugger.GetOutputFile()->GetFile().GetStream(),
- debugger.GetErrorFile()->GetFile().GetStream());
-
- bool success = false;
-
-
- if (command)
+ if (command && command[0])
{
+ // We want to call run_one_line, passing in the dictionary and the command string. We cannot do this through
+ // PyRun_SimpleString here because the command string may contain escaped characters, and putting it inside
+ // another string to pass to PyRun_SimpleString messes up the escaping. So we use the following more complicated
+ // method to pass the command string directly down to Python.
+ Debugger &debugger = m_interpreter.GetDebugger();
+
+ StreamFileSP input_file_sp;
+ StreamFileSP output_file_sp;
+ StreamFileSP error_file_sp;
+ Communication output_comm ("lldb.ScriptInterpreterPython.ExecuteOneLine.comm");
+ int pipe_fds[2] = { -1, -1 };
+
+ if (options.GetEnableIO())
+ {
+ if (result)
+ {
+ input_file_sp = debugger.GetInputFile();
+ // Set output to a temporary file so we can forward the results on to the result object
+
+ int err = pipe(pipe_fds);
+ if (err == 0)
+ {
+ std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor(pipe_fds[0], false));
+ if (conn_ap->IsConnected())
+ {
+ output_comm.SetConnection(conn_ap.release());
+ output_comm.SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived, &result->GetOutputStream());
+ output_comm.StartReadThread();
+ output_file_sp.reset(new StreamFile(pipe_fds[1], false));
+ // Set the options so we can open our pipe fd for writing when we call GetStream() below...
+ output_file_sp->GetFile().SetOptions(File::eOpenOptionWrite);
+ error_file_sp = output_file_sp;
+ // Don't buffer the output
+ ::setbuf (output_file_sp->GetFile().GetStream(), NULL);
+
+ result->SetImmediateOutputFile(debugger.GetOutputFile()->GetFile().GetStream());
+ result->SetImmediateErrorFile(debugger.GetErrorFile()->GetFile().GetStream());
+ }
+ }
+ }
+ if (!input_file_sp || !output_file_sp || !error_file_sp)
+ debugger.AdoptTopIOHandlerFilesIfInvalid(input_file_sp, output_file_sp, error_file_sp);
+ }
+ else
+ {
+ input_file_sp.reset (new StreamFile ());
+ input_file_sp->GetFile().Open("/dev/null", File::eOpenOptionRead);
+ output_file_sp.reset (new StreamFile ());
+ output_file_sp->GetFile().Open("/dev/null", File::eOpenOptionWrite);
+ error_file_sp = output_file_sp;
+ }
+
+ FILE *in_file = input_file_sp->GetFile().GetStream();
+ FILE *out_file = output_file_sp->GetFile().GetStream();
+ FILE *err_file = error_file_sp->GetFile().GetStream();
+ Locker locker(this,
+ ScriptInterpreterPython::Locker::AcquireLock |
+ ScriptInterpreterPython::Locker::InitSession |
+ (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
+ ScriptInterpreterPython::Locker::FreeAcquiredLock |
+ ScriptInterpreterPython::Locker::TearDownSession,
+ in_file,
+ out_file,
+ err_file);
+
+ bool success = false;
+
// Find the correct script interpreter dictionary in the main module.
PythonDictionary &session_dict = GetSessionDictionary ();
if (session_dict)
@@ -577,6 +641,20 @@ ScriptInterpreterPython::ExecuteOneLine
}
}
+ // Flush our output and error file handles
+ ::fflush (out_file);
+ if (out_file != err_file)
+ ::fflush (err_file);
+
+ if (pipe_fds[0] != -1)
+ {
+ // Close write end of pipe so our communication thread exits
+ ::close (pipe_fds[1]);
+ output_comm.StopReadThread();
+ ::close (pipe_fds[0]);
+ }
+
+
if (success)
return true;
@@ -873,10 +951,10 @@ ScriptInterpreterPython::ExecuteOneLineW
return ret_success;
}
-bool
+Error
ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const ExecuteScriptOptions &options)
{
-
+ Error error;
Locker locker(this,
ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
@@ -925,19 +1003,33 @@ ScriptInterpreterPython::ExecuteMultiple
py_error = PyErr_Occurred ();
if (py_error != NULL)
{
- puts(in_string);
- _PyObject_Dump (py_error);
- PyErr_Print();
- success = false;
+// puts(in_string);
+// _PyObject_Dump (py_error);
+// PyErr_Print();
+// success = false;
+
+ PyObject *type = NULL;
+ PyObject *value = NULL;
+ PyObject *traceback = NULL;
+ PyErr_Fetch (&type,&value,&traceback);
+
+ // get the backtrace
+ std::string bt = ReadPythonBacktrace(traceback);
+
+ if (value && value != Py_None)
+ error.SetErrorStringWithFormat("%s\n%s", PyString_AsString(PyObject_Str(value)),bt.c_str());
+ else
+ error.SetErrorStringWithFormat("%s",bt.c_str());
+ Py_XDECREF(type);
+ Py_XDECREF(value);
+ Py_XDECREF(traceback);
if (options.GetMaskoutErrors())
{
- if (PyErr_GivenExceptionMatches (py_error, PyExc_SyntaxError))
- PyErr_Print ();
PyErr_Clear();
}
}
- return success;
+ return error;
}
@@ -1009,7 +1101,7 @@ ScriptInterpreterPython::ExportFunctionD
// Convert StringList to one long, newline delimited, const char *.
std::string function_def_string(function_def.CopyList());
- return ExecuteMultipleLines (function_def_string.c_str(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false));
+ return ExecuteMultipleLines (function_def_string.c_str(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false)).Success();
}
bool
@@ -2114,7 +2206,7 @@ ScriptInterpreterPython::LoadScriptingMo
command_stream.Printf("if not (sys.path.__contains__('%s')):\n sys.path.insert(1,'%s');\n\n",
directory.c_str(),
directory.c_str());
- bool syspath_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false));
+ bool syspath_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false)).Success();
if (!syspath_retval)
{
error.SetErrorString("Python sys.path handling failed");
@@ -2177,47 +2269,9 @@ ScriptInterpreterPython::LoadScriptingMo
else
command_stream.Printf("import %s",basename.c_str());
- bool import_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false).SetMaskoutErrors(false));
- PyObject* py_error = PyErr_Occurred(); // per Python docs: "you do not need to Py_DECREF()" the return of this function
-
- if (py_error || !import_retval) // check for failure of the import
- {
- if (py_error) // if we have a Python error..
- {
- PyObject *type = NULL,*value = NULL,*traceback = NULL;
- PyErr_Fetch (&type,&value,&traceback);
-
- if (PyErr_GivenExceptionMatches (py_error, PyExc_ImportError)) // and it is an ImportError
- {
- if (value && value != Py_None)
- error.SetErrorString(PyString_AsString(PyObject_Str(value)));
- else
- error.SetErrorString("ImportError raised by imported module");
- }
- else // any other error
- {
- // get the backtrace
- std::string bt = ReadPythonBacktrace(traceback);
-
- if (value && value != Py_None)
- error.SetErrorStringWithFormat("Python error raised while importing module: %s - traceback: %s", PyString_AsString(PyObject_Str(value)),bt.c_str());
- else
- error.SetErrorStringWithFormat("Python raised an error while importing module - traceback: %s",bt.c_str());
- }
-
- Py_XDECREF(type);
- Py_XDECREF(value);
- Py_XDECREF(traceback);
- }
- else // we failed but have no error to explain why
- {
- error.SetErrorString("unknown error while importing module");
- }
-
- // anyway, clear the error indicator and return false
- PyErr_Clear();
+ error = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false));
+ if (error.Fail())
return false;
- }
// if we are here, everything worked
// call __lldb_init_module(debugger,dict)
Modified: lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Jan 7 17:40:46 2014
@@ -120,7 +120,7 @@ RegisterContextLLDB::InitializeZerothFra
current_pc = abi->FixCodeAddress(current_pc);
// Initialize m_current_pc, an Address object, based on current_pc, an addr_t.
- process->GetTarget().GetSectionLoadList().ResolveLoadAddress (current_pc, m_current_pc);
+ m_current_pc.SetLoadAddress (current_pc, &process->GetTarget());
// If we don't have a Module for some reason, we're not going to find symbol/function information - just
// stick in some reasonable defaults and hope we can unwind past this frame.
@@ -285,7 +285,7 @@ RegisterContextLLDB::InitializeNonZeroth
if (abi)
pc = abi->FixCodeAddress(pc);
- process->GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc);
+ m_current_pc.SetLoadAddress (pc, &process->GetTarget());
// If we don't have a Module for some reason, we're not going to find symbol/function information - just
// stick in some reasonable defaults and hope we can unwind past this frame.
@@ -682,7 +682,7 @@ RegisterContextLLDB::GetFullUnwindPlanFo
uint32_t permissions;
addr_t current_pc_addr = m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr());
if (current_pc_addr == 0
- || (process->GetLoadAddressPermissions(current_pc_addr, permissions)
+ || (process->GetLoadAddressPermissions (current_pc_addr, permissions)
&& (permissions & ePermissionsExecutable) == 0))
{
unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
@@ -949,6 +949,12 @@ RegisterContextLLDB::IsValid () const
return m_frame_type != eNotAValidFrame;
}
+bool
+RegisterContextLLDB::IsSigtrampFrame () const
+{
+ return m_frame_type == eSigtrampFrame;
+}
+
// A skip frame is a bogus frame on the stack -- but one where we're likely to find a real frame farther
// up the stack if we keep looking. It's always the second frame in an unwind (i.e. the first frame after
// frame zero) where unwinding can be the trickiest. Ideally we'll mark up this frame in some way so the
Modified: lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.h (original)
+++ lldb/branches/iohandler/source/Plugins/Process/Utility/RegisterContextLLDB.h Tue Jan 7 17:40:46 2014
@@ -73,6 +73,9 @@ public:
IsValid () const;
bool
+ IsSigtrampFrame () const;
+
+ bool
GetCFA (lldb::addr_t& cfa);
bool
Modified: lldb/branches/iohandler/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/branches/iohandler/source/Plugins/Process/Utility/UnwindLLDB.cpp Tue Jan 7 17:40:46 2014
@@ -171,12 +171,18 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi)
}
if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa))
{
- if (log)
+ // On Mac OS X, the _sigtramp asynchronous signal trampoline frame may not have
+ // its (constructed) CFA aligned correctly -- don't do the abi alignment check for
+ // these.
+ if (reg_ctx_sp->IsSigtrampFrame() == false)
{
- log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ if (log)
+ {
+ log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ }
+ goto unwind_done;
}
- goto unwind_done;
}
if (!reg_ctx_sp->ReadPC (cursor_sp->start_pc))
{
Modified: lldb/branches/iohandler/source/Plugins/Process/mach-core/ProcessMachCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/mach-core/ProcessMachCore.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/mach-core/ProcessMachCore.cpp (original)
+++ lldb/branches/iohandler/source/Plugins/Process/mach-core/ProcessMachCore.cpp Tue Jan 7 17:40:46 2014
@@ -474,7 +474,7 @@ ProcessMachCore::GetImageInfoAddress()
// which to prefer.
if (GetCorefilePreference() == eKernelCorefile)
{
- if (m_mach_kernel_addr)
+ if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
{
return m_mach_kernel_addr;
}
@@ -482,7 +482,7 @@ ProcessMachCore::GetImageInfoAddress()
}
else
{
- if (m_dyld_addr)
+ if (m_dyld_addr != LLDB_INVALID_ADDRESS)
{
return m_dyld_addr;
}
Modified: lldb/branches/iohandler/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Symbol/ClangASTType.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Symbol/ClangASTType.cpp (original)
+++ lldb/branches/iohandler/source/Symbol/ClangASTType.cpp Tue Jan 7 17:40:46 2014
@@ -1135,7 +1135,7 @@ ClangASTType::GetTypeName () const
if (typedef_type)
{
const TypedefNameDecl *typedef_decl = typedef_type->getDecl();
- type_name = typedef_decl->getQualifiedNameAsString(printing_policy);
+ type_name = typedef_decl->getQualifiedNameAsString();
}
else
{
Modified: lldb/branches/iohandler/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Target/Process.cpp?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Target/Process.cpp (original)
+++ lldb/branches/iohandler/source/Target/Process.cpp Tue Jan 7 17:40:46 2014
@@ -4886,7 +4886,7 @@ void
Process::PopProcessIOHandler ()
{
IOHandlerSP io_handler_sp (m_process_input_reader);
- if (io_handler_sp && io_handler_sp->IsActive())
+ if (io_handler_sp)
{
io_handler_sp->Interrupt();
m_target.GetDebugger().PopIOHandler (io_handler_sp);
Modified: lldb/branches/iohandler/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py (original)
+++ lldb/branches/iohandler/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py Tue Jan 7 17:40:46 2014
@@ -22,9 +22,9 @@ class Rdar12586188TestCase(TestBase):
"""Check that we handle an ImportError in a special way when command script importing files."""
self.expect("command script import ./fail12586188.py --allow-reload",
- error=True, substrs = ['error: module importing failed: I do not want to be imported'])
+ error=True, substrs = ['raise ImportError("I do not want to be imported")'])
self.expect("command script import ./fail212586188.py --allow-reload",
- error=True, substrs = ['error: module importing failed: Python error raised while importing module: I do not want to be imported'])
+ error=True, substrs = ['raise ValueError("I do not want to be imported")'])
if __name__ == '__main__':
import atexit
Modified: lldb/branches/iohandler/test/functionalities/command_source/TestCommandSource.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/command_source/TestCommandSource.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/command_source/TestCommandSource.py (original)
+++ lldb/branches/iohandler/test/functionalities/command_source/TestCommandSource.py Tue Jan 7 17:40:46 2014
@@ -20,21 +20,14 @@ class CommandSourceTestCase(TestBase):
# the "my" package that defines the date() function.
self.runCmd("command source .lldb")
- # Let's temporarily redirect the stdout to our StringIO session object
- # in order to capture the script evaluation output.
- old_stdout = sys.stdout
- session = StringIO.StringIO()
- sys.stdout = session
-
# Python should evaluate "my.date()" successfully.
- # Pass 'check=False' so that sys.stdout gets restored unconditionally.
- self.runCmd("script my.date()", check=False)
-
- # Now restore stdout to the way we were. :-)
- sys.stdout = old_stdout
+ command_interpreter = self.dbg.GetCommandInterpreter()
+ self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+ result = lldb.SBCommandReturnObject()
+ command_interpreter.HandleCommand("script my.date()", result)
import datetime
- self.expect(session.getvalue(), "script my.date() runs successfully",
+ self.expect(result.GetOutput(), "script my.date() runs successfully",
exe=False,
substrs = [str(datetime.date.today())])
Modified: lldb/branches/iohandler/test/functionalities/conditional_break/.lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/conditional_break/.lldb?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/conditional_break/.lldb (original)
+++ lldb/branches/iohandler/test/functionalities/conditional_break/.lldb Tue Jan 7 17:40:46 2014
@@ -1,7 +1,3 @@
-#file a.out
breakpoint set -n c
-#script import sys, os
-#script sys.path.append(os.path.join(os.getcwd(), os.pardir))
command script import -r conditional_break.py
breakpoint command add 1 -F "conditional_break.stop_if_called_from_a"
-
Modified: lldb/branches/iohandler/test/functionalities/conditional_break/conditional_break.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/conditional_break/conditional_break.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/conditional_break/conditional_break.py (original)
+++ lldb/branches/iohandler/test/functionalities/conditional_break/conditional_break.py Tue Jan 7 17:40:46 2014
@@ -22,7 +22,6 @@ def stop_if_called_from_a(frame, bp_loc,
if (thread.frames[0].function.name == 'c' and thread.frames[1].function.name == 'a'):
should_stop = True
else:
- process.Continue()
should_stop = False
dbg.SetAsync(old_async)
Modified: lldb/branches/iohandler/test/functionalities/connect_remote/EchoServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/connect_remote/EchoServer.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/connect_remote/EchoServer.py (original)
+++ lldb/branches/iohandler/test/functionalities/connect_remote/EchoServer.py Tue Jan 7 17:40:46 2014
@@ -17,7 +17,11 @@ conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
- if not data: break
- conn.send(data)
- print 'Received:', data
+ if data:
+ print 'Received:', data
+ # Don't response to acks that are sent to us
+ if data != '+':
+ conn.send("+$#00")
+ else:
+ break
conn.close()
Modified: lldb/branches/iohandler/test/functionalities/connect_remote/TestConnectRemote.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/connect_remote/TestConnectRemote.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/connect_remote/TestConnectRemote.py (original)
+++ lldb/branches/iohandler/test/functionalities/connect_remote/TestConnectRemote.py Tue Jan 7 17:40:46 2014
@@ -32,10 +32,7 @@ class ConnectRemoteTestCase(TestBase):
fakeserver.expect_exact('Listening on localhost:12345')
# Connect to the fake server....
- if sys.platform.startswith('freebsd') or sys.platform.startswith("linux"):
- self.runCmd("process connect -p gdb-remote connect://localhost:12345")
- else:
- self.runCmd("process connect connect://localhost:12345")
+ self.runCmd("process connect -p gdb-remote connect://localhost:12345")
if __name__ == '__main__':
Modified: lldb/branches/iohandler/test/functionalities/inferior-assert/TestInferiorAssert.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/functionalities/inferior-assert/TestInferiorAssert.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/functionalities/inferior-assert/TestInferiorAssert.py (original)
+++ lldb/branches/iohandler/test/functionalities/inferior-assert/TestInferiorAssert.py Tue Jan 7 17:40:46 2014
@@ -169,9 +169,13 @@ class AssertingInferiorTestCase(TestBase
self.runCmd("frame select " + str(frame.GetFrameID()), RUN_SUCCEEDED)
- # TODO: Disassembly does not specify '->' for the PC for a non-terminal frame for a function with a tail call.
+ # Don't expect the function name to be in the disassembly as the assert
+ # function might be a no-return function where the PC is past the end
+ # of the function and in the next function. We also can't back the PC up
+ # because we don't know how much to back it up by on targets with opcodes
+ # that have differing sizes
self.expect("disassemble -a %s" % frame.GetPC(),
- substrs = [frame.GetFunctionName()])
+ substrs = ['->'])
def check_expr_in_main(self, thread):
depth = thread.GetNumFrames()
Modified: lldb/branches/iohandler/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py (original)
+++ lldb/branches/iohandler/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Tue Jan 7 17:40:46 2014
@@ -164,16 +164,6 @@ class APIDefaultConstructorTestCase(Test
sb_function.fuzz_obj(obj)
@python_api_test
- def test_SBInputReader(self):
- obj = lldb.SBInputReader()
- if self.TraceOn():
- print obj
- self.assertFalse(obj)
- # Do fuzz testing on the invalid obj, it should not crash lldb.
- import sb_inputreader
- sb_inputreader.fuzz_obj(obj)
-
- @python_api_test
def test_SBInstruction(self):
obj = lldb.SBInstruction()
if self.TraceOn():
Modified: lldb/branches/iohandler/test/python_api/default-constructor/sb_debugger.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/python_api/default-constructor/sb_debugger.py?rev=198719&r1=198718&r2=198719&view=diff
==============================================================================
--- lldb/branches/iohandler/test/python_api/default-constructor/sb_debugger.py (original)
+++ lldb/branches/iohandler/test/python_api/default-constructor/sb_debugger.py Tue Jan 7 17:40:46 2014
@@ -38,9 +38,6 @@ def fuzz_obj(obj):
pass
obj.DispatchInputInterrupt()
obj.DispatchInputEndOfFile()
- obj.PushInputReader(lldb.SBInputReader())
- obj.NotifyTopInputReader(lldb.eInputReaderActivate)
- obj.InputReaderIsTopReader(lldb.SBInputReader())
obj.GetInstanceName()
obj.GetDescription(lldb.SBStream())
obj.GetTerminalWidth()
Removed: lldb/branches/iohandler/test/python_api/default-constructor/sb_inputreader.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/python_api/default-constructor/sb_inputreader.py?rev=198718&view=auto
==============================================================================
--- lldb/branches/iohandler/test/python_api/default-constructor/sb_inputreader.py (original)
+++ lldb/branches/iohandler/test/python_api/default-constructor/sb_inputreader.py (removed)
@@ -1,16 +0,0 @@
-"""
-Fuzz tests an object after the default construction to make sure it does not crash lldb.
-"""
-
-import sys
-import lldb
-
-def fuzz_obj(obj):
- try:
- obj.Initialize(lldb.SBDebugger.Create(), None, 0, "$", "^", True)
- except Exception:
- pass
- obj.IsActive()
- obj.IsDone()
- obj.SetIsDone(True)
- obj.GetGranularity()
More information about the llvm-branch-commits
mailing list