本文整理汇总了C++中SBCommandReturnObject类的典型用法代码示例。如果您正苦于以下问题:C++ SBCommandReturnObject类的具体用法?C++ SBCommandReturnObject怎么用?C++ SBCommandReturnObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SBCommandReturnObject类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResolveCommand
void SBCommandInterpreter::ResolveCommand(const char *command_line,
SBCommandReturnObject &result) {
result.Clear();
if (command_line && IsValid()) {
m_opaque_ptr->ResolveCommand(command_line, result.ref());
} else {
result->AppendError(
"SBCommandInterpreter or the command line is not valid");
result->SetStatus(eReturnStatusFailed);
}
}
示例2:
void
SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result)
{
result.Clear();
if (m_opaque_ptr)
{
m_opaque_ptr->SourceInitFile (true, result.ref());
}
else
{
result->AppendError ("SBCommandInterpreter is not valid");
result->SetStatus (eReturnStatusFailed);
}
}
示例3: GetDebugger
void
Driver::ExecuteInitialCommands (bool before_file)
{
size_t num_commands;
std::vector<std::pair<bool, std::string> > *command_set;
if (before_file)
command_set = &(m_option_data.m_initial_commands);
else
command_set = &(m_option_data.m_after_file_commands);
num_commands = command_set->size();
SBCommandReturnObject result;
bool old_async = GetDebugger().GetAsync();
GetDebugger().SetAsync(false);
for (size_t idx = 0; idx < num_commands; idx++)
{
bool is_file = (*command_set)[idx].first;
const char *command = (*command_set)[idx].second.c_str();
char command_string[PATH_MAX * 2];
const bool dump_stream_only_if_no_immediate = true;
const char *executed_command = command;
if (is_file)
{
::snprintf (command_string, sizeof(command_string), "command source -s %i '%s'", m_option_data.m_source_quietly, command);
executed_command = command_string;
}
m_debugger.GetCommandInterpreter().HandleCommand (executed_command, result, false);
if (!m_option_data.m_source_quietly || result.Succeeded() == false)
{
const size_t output_size = result.GetOutputSize();
if (output_size > 0)
{
const char *cstr = result.GetOutput(dump_stream_only_if_no_immediate);
if (cstr)
printf ("%s", cstr);
}
const size_t error_size = result.GetErrorSize();
if (error_size > 0)
{
const char *cstr = result.GetError(dump_stream_only_if_no_immediate);
if (cstr)
printf ("%s", cstr);
}
}
if (result.Succeeded() == false)
{
const char *type = before_file ? "before file" : "after_file";
if (is_file)
::fprintf(stderr, "Aborting %s command execution, command file: '%s' failed.\n", type, command);
else
::fprintf(stderr, "Aborting %s command execution, command: '%s' failed.\n", type, command);
break;
}
result.Clear();
}
GetDebugger().SetAsync(old_async);
}
示例4: DoFallThruToAnotherDriver
//++ ------------------------------------------------------------------------------------
// Details: This function allows *this driver to call on another driver to perform work
// should this driver not be able to handle the client data input.
// SetDriverToFallThruTo() specifies the fall through to driver.
// Check the error message if the function returns a failure.
// Type: Overridden.
// Args: vCmd - (R) Command instruction to interpret.
// vwErrMsg - (W) Error description on command failing.
// Return: MIstatus::success - Command succeeded.
// MIstatus::failure - Command failed.
// Throws: None.
//--
bool Driver::DoFallThruToAnotherDriver( const CMIUtilString & vCmd, CMIUtilString & vwErrMsg )
{
bool bOk = MIstatus::success;
vwErrMsg.empty();
// ToDo: Implement do work on other driver after this driver said "Give up you try"
// This may nto be required if the feature to 'fall through' is not required
SBCommandReturnObject returnObj = lldb::SBCommandReturnObject();
SBCommandInterpreter cmdIntrp = m_debugger.GetCommandInterpreter();
const lldb::ReturnStatus cmdResult = cmdIntrp.HandleCommand( vCmd.c_str(), returnObj ); MIunused( cmdResult );
if( returnObj.Succeeded() == false )
{
bOk = MIstatus::failure;
vwErrMsg = returnObj.GetError();
}
return bOk;
}
示例5: HandleCommand
lldb::ReturnStatus SBCommandInterpreter::HandleCommand(
const char *command_line, SBExecutionContext &override_context,
SBCommandReturnObject &result, bool add_to_history) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", "
"SBCommandReturnObject(%p), add_to_history=%i)",
static_cast<void *>(m_opaque_ptr), command_line,
static_cast<void *>(result.get()), add_to_history);
ExecutionContext ctx, *ctx_ptr;
if (override_context.get()) {
ctx = override_context.get()->Lock(true);
ctx_ptr = &ctx;
} else
ctx_ptr = nullptr;
result.Clear();
if (command_line && IsValid()) {
result.ref().SetInteractive(false);
m_opaque_ptr->HandleCommand(command_line,
add_to_history ? eLazyBoolYes : eLazyBoolNo,
result.ref(), ctx_ptr);
} else {
result->AppendError(
"SBCommandInterpreter or the command line is not valid");
result->SetStatus(eReturnStatusFailed);
}
// We need to get the value again, in case the command disabled the log!
log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
if (log) {
SBStream sstr;
result.GetDescription(sstr);
log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", "
"SBCommandReturnObject(%p): %s, add_to_history=%i) => %i",
static_cast<void *>(m_opaque_ptr), command_line,
static_cast<void *>(result.get()), sstr.GetData(),
add_to_history, result.GetStatus());
}
return result.GetStatus();
}
示例6: target_sp
void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
SBCommandReturnObject &result) {
result.Clear();
if (IsValid()) {
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
m_opaque_ptr->SourceInitFile(true, result.ref());
} else {
result->AppendError("SBCommandInterpreter is not valid");
result->SetStatus(eReturnStatusFailed);
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf(
"SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory "
"(&SBCommandReturnObject(%p))",
static_cast<void *>(m_opaque_ptr), static_cast<void *>(result.get()));
}
示例7: target_sp
void
SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result)
{
result.Clear();
if (m_opaque_ptr)
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
m_opaque_ptr->SourceInitFile (true, result.ref());
}
else
{
result->AppendError ("SBCommandInterpreter is not valid");
result->SetStatus (eReturnStatusFailed);
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory (&SBCommandReturnObject(%p))",
m_opaque_ptr, result.get());
}
示例8: target_sp
void
SBDebugger::HandleCommand (const char *command)
{
if (m_opaque_sp)
{
TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
SBCommandReturnObject result;
sb_interpreter.HandleCommand (command, result, false);
if (GetErrorFileHandle() != NULL)
result.PutError (GetErrorFileHandle());
if (GetOutputFileHandle() != NULL)
result.PutOutput (GetOutputFileHandle());
if (m_opaque_sp->GetAsyncExecution() == false)
{
SBProcess process(GetCommandInterpreter().GetProcess ());
ProcessSP process_sp (process.GetSP());
if (process_sp)
{
EventSP event_sp;
Listener &lldb_listener = m_opaque_sp->GetListener();
while (lldb_listener.GetNextEventForBroadcaster (process_sp.get(), event_sp))
{
SBEvent event(event_sp);
HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle());
}
}
}
}
}
示例9: sizeof
void
SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result)
{
if (m_opaque_sp)
{
const StateType event_state = SBProcess::GetStateFromEvent (event);
char message[1024];
::snprintf (message,
sizeof (message),
"Process %d %s\n",
m_opaque_sp->GetID(),
SBDebugger::StateAsCString (event_state));
result.AppendMessage (message);
}
}
示例10: log
lldb::ReturnStatus
SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p), add_to_history=%i)",
m_opaque_ptr, command_line, result.get(), add_to_history);
result.Clear();
if (command_line && m_opaque_ptr)
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref());
}
else
{
result->AppendError ("SBCommandInterpreter or the command line is not valid");
result->SetStatus (eReturnStatusFailed);
}
// We need to get the value again, in case the command disabled the log!
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
if (log)
{
SBStream sstr;
result.GetDescription (sstr);
log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p): %s, add_to_history=%i) => %i",
m_opaque_ptr, command_line, result.get(), sstr.GetData(), add_to_history, result.GetStatus());
}
return result.GetStatus();
}
示例11: atexit
void
Driver::MainLoop ()
{
if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
{
g_old_stdin_termios_is_valid = true;
atexit (reset_stdin_termios);
}
::setbuf (stdin, NULL);
::setbuf (stdout, NULL);
m_debugger.SetErrorFileHandle (stderr, false);
m_debugger.SetOutputFileHandle (stdout, false);
m_debugger.SetInputFileHandle (stdin, false); // Don't take ownership of STDIN yet...
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
struct winsize window_size;
if (isatty (STDIN_FILENO)
&& ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
m_debugger.SetTerminalWidth (window_size.ws_col);
}
SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
// Before we handle any options from the command line, we parse the
// .lldbinit file in the user's home directory.
SBCommandReturnObject result;
sb_interpreter.SourceInitFileInHomeDirectory(result);
if (GetDebugMode())
{
result.PutError (m_debugger.GetErrorFileHandle());
result.PutOutput (m_debugger.GetOutputFileHandle());
}
// Now we handle options we got from the command line
SBStream commands_stream;
// First source in the commands specified to be run before the file arguments are processed.
WriteCommandsForSourcing(eCommandPlacementBeforeFile, commands_stream);
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
{
char arch_name[64];
if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
commands_stream.Printf("target create --arch=%s %s", arch_name, EscapeString(m_option_data.m_args[0]).c_str());
else
commands_stream.Printf("target create %s", EscapeString(m_option_data.m_args[0]).c_str());
if (!m_option_data.m_core_file.empty())
{
commands_stream.Printf(" --core %s", EscapeString(m_option_data.m_core_file).c_str());
}
commands_stream.Printf("\n");
if (num_args > 1)
{
commands_stream.Printf ("settings set -- target.run-args ");
for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
commands_stream.Printf(" %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
commands_stream.Printf("\n");
}
}
else if (!m_option_data.m_core_file.empty())
{
commands_stream.Printf("target create --core %s\n", EscapeString(m_option_data.m_core_file).c_str());
}
else if (!m_option_data.m_process_name.empty())
{
commands_stream.Printf ("process attach --name %s", EscapeString(m_option_data.m_process_name).c_str());
if (m_option_data.m_wait_for)
commands_stream.Printf(" --waitfor");
commands_stream.Printf("\n");
}
else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid)
{
commands_stream.Printf ("process attach --pid %" PRIu64 "\n", m_option_data.m_process_pid);
}
WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
if (GetDebugMode())
{
result.PutError(m_debugger.GetErrorFileHandle());
result.PutOutput(m_debugger.GetOutputFileHandle());
}
bool handle_events = true;
bool spawn_thread = false;
if (m_option_data.m_repl)
{
const char *repl_options = NULL;
//.........这里部分代码省略.........
示例12: atexit
void
Driver::MainLoop ()
{
if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
{
g_old_stdin_termios_is_valid = true;
atexit (reset_stdin_termios);
}
::setbuf (stdin, NULL);
::setbuf (stdout, NULL);
m_debugger.SetErrorFileHandle (stderr, false);
m_debugger.SetOutputFileHandle (stdout, false);
m_debugger.SetInputFileHandle (stdin, true);
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
struct winsize window_size;
if (isatty (STDIN_FILENO)
&& ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
m_debugger.SetTerminalWidth (window_size.ws_col);
}
SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
// Before we handle any options from the command line, we parse the
// .lldbinit file in the user's home directory.
SBCommandReturnObject result;
sb_interpreter.SourceInitFileInHomeDirectory(result);
if (GetDebugMode())
{
result.PutError (m_debugger.GetErrorFileHandle());
result.PutOutput (m_debugger.GetOutputFileHandle());
}
// Now we handle options we got from the command line
// First source in the commands specified to be run before the file arguments are processed.
ExecuteInitialCommands(true);
// Was there a core file specified?
std::string core_file_spec("");
if (!m_option_data.m_core_file.empty())
core_file_spec.append("--core ").append(m_option_data.m_core_file);
char command_string[PATH_MAX * 2];
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
{
char arch_name[64];
if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
::snprintf (command_string,
sizeof (command_string),
"target create --arch=%s %s \"%s\"",
arch_name,
core_file_spec.c_str(),
m_option_data.m_args[0].c_str());
else
::snprintf (command_string,
sizeof(command_string),
"target create %s \"%s\"",
core_file_spec.c_str(),
m_option_data.m_args[0].c_str());
m_debugger.HandleCommand (command_string);
if (num_args > 1)
{
m_debugger.HandleCommand ("settings clear target.run-args");
char arg_cstr[1024];
for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
{
::snprintf (arg_cstr,
sizeof(arg_cstr),
"settings append target.run-args \"%s\"",
m_option_data.m_args[arg_idx].c_str());
m_debugger.HandleCommand (arg_cstr);
}
}
}
else if (!core_file_spec.empty())
{
::snprintf (command_string,
sizeof(command_string),
"target create %s",
core_file_spec.c_str());
m_debugger.HandleCommand (command_string);;
}
else if (!m_option_data.m_process_name.empty())
{
::snprintf (command_string,
sizeof(command_string),
"process attach --name '%s'%s",
m_option_data.m_process_name.c_str(),
m_option_data.m_wait_for ? " --waitfor" : "");
m_debugger.HandleCommand (command_string);
}
else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid)
//.........这里部分代码省略.........
示例13: atexit
void
Driver::MainLoop ()
{
if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
{
g_old_stdin_termios_is_valid = true;
atexit (reset_stdin_termios);
}
::setbuf (stdin, NULL);
::setbuf (stdout, NULL);
m_debugger.SetErrorFileHandle (stderr, false);
m_debugger.SetOutputFileHandle (stdout, false);
m_debugger.SetInputFileHandle (stdin, false); // Don't take ownership of STDIN yet...
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
struct winsize window_size;
if (isatty (STDIN_FILENO)
&& ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
m_debugger.SetTerminalWidth (window_size.ws_col);
}
SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
// Before we handle any options from the command line, we parse the
// .lldbinit file in the user's home directory.
SBCommandReturnObject result;
sb_interpreter.SourceInitFileInHomeDirectory(result);
if (GetDebugMode())
{
result.PutError (m_debugger.GetErrorFileHandle());
result.PutOutput (m_debugger.GetOutputFileHandle());
}
// Now we handle options we got from the command line
SBStream commands_stream;
// First source in the commands specified to be run before the file arguments are processed.
WriteInitialCommands(true, commands_stream);
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
{
char arch_name[64];
if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
commands_stream.Printf("target create --arch=%s \"%s\"", arch_name, m_option_data.m_args[0].c_str());
else
commands_stream.Printf("target create \"%s\"", m_option_data.m_args[0].c_str());
if (!m_option_data.m_core_file.empty())
{
commands_stream.Printf(" --core \"%s\"", m_option_data.m_core_file.c_str());
}
commands_stream.Printf("\n");
if (num_args > 1)
{
commands_stream.Printf ("settings set -- target.run-args ");
for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
{
const char *arg_cstr = m_option_data.m_args[arg_idx].c_str();
if (strchr(arg_cstr, '"') == NULL)
commands_stream.Printf(" \"%s\"", arg_cstr);
else
commands_stream.Printf(" '%s'", arg_cstr);
}
commands_stream.Printf("\n");
}
}
else if (!m_option_data.m_core_file.empty())
{
commands_stream.Printf("target create --core \"%s\"\n", m_option_data.m_core_file.c_str());
}
else if (!m_option_data.m_process_name.empty())
{
commands_stream.Printf ("process attach --name \"%s\"", m_option_data.m_process_name.c_str());
if (m_option_data.m_wait_for)
commands_stream.Printf(" --waitfor");
commands_stream.Printf("\n");
}
else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid)
{
commands_stream.Printf ("process attach --pid %" PRIu64 "\n", m_option_data.m_process_pid);
}
WriteInitialCommands(false, commands_stream);
// Now that all option parsing is done, we try and parse the .lldbinit
// file in the current working directory
sb_interpreter.SourceInitFileInCurrentWorkingDirectory (result);
if (GetDebugMode())
{
result.PutError(m_debugger.GetErrorFileHandle());
//.........这里部分代码省略.........