本文整理汇总了C++中Error::LogIfError方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::LogIfError方法的具体用法?C++ Error::LogIfError怎么用?C++ Error::LogIfError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::LogIfError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void *
Communication::ReadThread (void *p)
{
Communication *comm = (Communication *)p;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf ("%p Communication::ReadThread () thread starting...", p);
uint8_t buf[1024];
Error error;
ConnectionStatus status = eConnectionStatusSuccess;
bool done = false;
while (!done && comm->m_read_thread_enabled)
{
size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * TimeValue::MicroSecPerSec, status, &error);
if (bytes_read > 0)
comm->AppendBytesToCache (buf, bytes_read, true, status);
else if ((bytes_read == 0)
&& status == eConnectionStatusEndOfFile)
{
if (comm->GetCloseOnEOF ())
comm->Disconnect ();
comm->AppendBytesToCache (buf, bytes_read, true, status);
}
switch (status)
{
case eConnectionStatusSuccess:
break;
case eConnectionStatusEndOfFile:
if (comm->GetCloseOnEOF())
done = true;
break;
case eConnectionStatusNoConnection: // No connection
case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection
done = true;
// Fall through...
case eConnectionStatusError: // Check GetError() for details
case eConnectionStatusTimedOut: // Request timed out
if (log)
error.LogIfError (log,
"%p Communication::ReadFromConnection () => status = %s",
p,
Communication::ConnectionStatusAsCString (status));
break;
}
}
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION);
if (log)
log->Printf ("%p Communication::ReadThread () thread exiting...", p);
// Let clients know that this thread is exiting
comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
return NULL;
}
示例2: while
void *
Communication::ReadThread (void *p)
{
Communication *comm = (Communication *)p;
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION);
if (log)
log->Printf ("%p Communication::ReadThread () thread starting...", p);
uint8_t buf[1024];
Error error;
ConnectionStatus status = eConnectionStatusSuccess;
bool done = false;
while (!done && comm->m_read_thread_enabled)
{
status = comm->BytesAvailable (UINT32_MAX, &error);
if (status == eConnectionStatusSuccess)
{
size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), status, &error);
if (bytes_read > 0)
comm->AppendBytesToCache (buf, bytes_read, true);
}
switch (status)
{
case eConnectionStatusSuccess:
break;
case eConnectionStatusNoConnection: // No connection
case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection
done = true;
// Fall through...
default:
case eConnectionStatusError: // Check GetError() for details
case eConnectionStatusTimedOut: // Request timed out
error.LogIfError(log, "%p Communication::BytesAvailable () => status = %i", p, status);
break;
}
}
if (log)
log->Printf ("%p Communication::ReadThread () thread exiting...", p);
// Let clients know that this thread is exiting
comm->m_read_thread = LLDB_INVALID_HOST_THREAD;
comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
return NULL;
}
示例3: sigemptyset
//.........这里部分代码省略.........
// variables don't make it into the child process if "argv == NULL"!!!
tmp_argv[0] = exe_path;
tmp_argv[1] = NULL;
argv = (char * const*)tmp_argv;
}
#if !defined (__APPLE__)
// manage the working directory
char current_dir[PATH_MAX];
current_dir[0] = '\0';
#endif
FileSpec working_dir{launch_info.GetWorkingDirectory()};
if (working_dir)
{
#if defined (__APPLE__)
// Set the working directory on this thread only
if (__pthread_chdir(working_dir.GetCString()) < 0) {
if (errno == ENOENT) {
error.SetErrorStringWithFormat("No such file or directory: %s",
working_dir.GetCString());
} else if (errno == ENOTDIR) {
error.SetErrorStringWithFormat("Path doesn't name a directory: %s",
working_dir.GetCString());
} else {
error.SetErrorStringWithFormat("An unknown error occurred when changing directory for process execution.");
}
return error;
}
#else
if (::getcwd(current_dir, sizeof(current_dir)) == NULL)
{
error.SetError(errno, eErrorTypePOSIX);
error.LogIfError(log, "unable to save the current directory");
return error;
}
if (::chdir(working_dir.GetCString()) == -1)
{
error.SetError(errno, eErrorTypePOSIX);
error.LogIfError(log, "unable to change working directory to %s",
working_dir.GetCString());
return error;
}
#endif
}
::pid_t result_pid = LLDB_INVALID_PROCESS_ID;
const size_t num_file_actions = launch_info.GetNumFileActions ();
if (num_file_actions > 0)
{
posix_spawn_file_actions_t file_actions;
error.SetError( ::posix_spawn_file_actions_init (&file_actions), eErrorTypePOSIX);
if (error.Fail() || log)
error.PutToLog(log, "::posix_spawn_file_actions_init ( &file_actions )");
if (error.Fail())
return error;
// Make a quick class that will cleanup the posix spawn attributes in case
// we return in the middle of this function.
lldb_utility::CleanUp <posix_spawn_file_actions_t *, int> posix_spawn_file_actions_cleanup (&file_actions, posix_spawn_file_actions_destroy);
for (size_t i=0; i<num_file_actions; ++i)
{
const FileAction *launch_file_action = launch_info.GetFileActionAtIndex(i);
if (launch_file_action)
示例4: if
lldb::thread_result_t
Communication::ReadThread (lldb::thread_arg_t p)
{
Communication *comm = (Communication *)p;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf ("%p Communication::ReadThread () thread starting...", p);
uint8_t buf[1024];
Error error;
ConnectionStatus status = eConnectionStatusSuccess;
bool done = false;
while (!done && comm->m_read_thread_enabled)
{
size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * TimeValue::MicroSecPerSec, status, &error);
if (bytes_read > 0)
comm->AppendBytesToCache (buf, bytes_read, true, status);
else if ((bytes_read == 0)
&& status == eConnectionStatusEndOfFile)
{
if (comm->GetCloseOnEOF ())
comm->Disconnect ();
comm->AppendBytesToCache (buf, bytes_read, true, status);
}
switch (status)
{
case eConnectionStatusSuccess:
break;
case eConnectionStatusEndOfFile:
done = true;
break;
case eConnectionStatusError: // Check GetError() for details
if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO)
{
// EIO on a pipe is usually caused by remote shutdown
comm->Disconnect ();
done = true;
}
if (log)
error.LogIfError (log,
"%p Communication::ReadFromConnection () => status = %s",
p,
Communication::ConnectionStatusAsCString (status));
break;
case eConnectionStatusInterrupted: // Synchronization signal from SynchronizeWithReadThread()
// The connection returns eConnectionStatusInterrupted only when there is no
// input pending to be read, so we can signal that.
comm->BroadcastEvent (eBroadcastBitNoMorePendingInput);
break;
case eConnectionStatusNoConnection: // No connection
case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection
done = true;
LLVM_FALLTHROUGH;
case eConnectionStatusTimedOut: // Request timed out
if (log)
error.LogIfError (log,
"%p Communication::ReadFromConnection () => status = %s",
p,
Communication::ConnectionStatusAsCString (status));
break;
}
}
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION);
if (log)
log->Printf ("%p Communication::ReadThread () thread exiting...", p);
comm->m_read_thread_did_exit = true;
// Let clients know that this thread is exiting
comm->BroadcastEvent (eBroadcastBitNoMorePendingInput);
comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
return NULL;
}