本文整理汇总了C++中SBError类的典型用法代码示例。如果您正苦于以下问题:C++ SBError类的具体用法?C++ SBError怎么用?C++ SBError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SBError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main (int argc, char const *argv[], const char *envp[])
{
SBDebugger::Initialize();
SBHostOS::ThreadCreated ("<lldb.driver.main-thread>");
signal (SIGPIPE, SIG_IGN);
signal (SIGWINCH, sigwinch_handler);
signal (SIGINT, sigint_handler);
signal (SIGTSTP, sigtstp_handler);
signal (SIGCONT, sigcont_handler);
// Create a scope for driver so that the driver object will destroy itself
// before SBDebugger::Terminate() is called.
{
Driver driver;
bool exiting = false;
SBError error (driver.ParseArgs (argc, argv, stdout, exiting));
if (error.Fail())
{
const char *error_cstr = error.GetCString ();
if (error_cstr)
::fprintf (stderr, "error: %s\n", error_cstr);
}
else if (!exiting)
{
driver.MainLoop ();
}
}
SBDebugger::Terminate();
return 0;
}
示例2:
SBError
SBDebugger::RunREPL (lldb::LanguageType language, const char *repl_options)
{
SBError error;
if (m_opaque_sp)
error.ref() = m_opaque_sp->RunREPL(language, repl_options);
else
error.SetErrorString ("invalid debugger");
return error;
}
示例3: log
size_t
SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error)
{
size_t bytes_written = 0;
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ProcessSP process_sp(GetSP());
if (log)
{
log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p))...",
process_sp.get(),
addr,
src,
src_len,
sb_error.get());
}
if (process_sp)
{
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref());
}
else
{
if (log)
log->Printf ("SBProcess(%p)::WriteMemory() => error: process is running", process_sp.get());
sb_error.SetErrorString("process is running");
}
}
if (log)
{
SBStream sstr;
sb_error.GetDescription (sstr);
log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p): %s) => %zu",
process_sp.get(),
addr,
src,
src_len,
sb_error.get(),
sstr.GetData(),
bytes_written);
}
return bytes_written;
}
示例4: file
void
Driver::OptionData::AddInitialCommand (const char *command, bool before_file, bool is_file, SBError &error)
{
std::vector<std::pair<bool, std::string> > *command_set;
if (before_file)
command_set = &(m_initial_commands);
else
command_set = &(m_after_file_commands);
if (is_file)
{
SBFileSpec file(command);
if (file.Exists())
command_set->push_back (std::pair<bool, std::string> (true, optarg));
else if (file.ResolveExecutableLocation())
{
char final_path[PATH_MAX];
file.GetPath (final_path, sizeof(final_path));
std::string path_str (final_path);
command_set->push_back (std::pair<bool, std::string> (true, path_str));
}
else
error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
}
else
command_set->push_back (std::pair<bool, std::string> (false, optarg));
}
示例5: file
void
Driver::OptionData::AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, SBError &error)
{
std::vector<InitialCmdEntry> *command_set;
switch (placement)
{
case eCommandPlacementBeforeFile:
command_set = &(m_initial_commands);
break;
case eCommandPlacementAfterFile:
command_set = &(m_after_file_commands);
break;
case eCommandPlacementAfterCrash:
command_set = &(m_after_crash_commands);
break;
}
if (is_file)
{
SBFileSpec file(command);
if (file.Exists())
command_set->push_back (InitialCmdEntry(command, is_file));
else if (file.ResolveExecutableLocation())
{
char final_path[PATH_MAX];
file.GetPath (final_path, sizeof(final_path));
command_set->push_back (InitialCmdEntry(final_path, is_file));
}
else
error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
}
else
command_set->push_back (InitialCmdEntry(command, is_file));
}
示例6: SBThreadPlan
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
lldb::addr_t size, SBError &error) {
if (m_opaque_sp) {
Address *start_address = sb_start_address.get();
if (!start_address) {
return SBThreadPlan();
}
AddressRange range(*start_address, size);
SymbolContext sc;
start_address->CalculateSymbolContext(&sc);
Status plan_status;
SBThreadPlan plan =
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
false, range, sc, NULL, eAllThreads, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
return plan;
} else {
return SBThreadPlan();
}
}
示例7: value_sp
bool
SBValue::SetData (lldb::SBData &data, SBError &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
bool ret = true;
if (value_sp)
{
DataExtractor *data_extractor = data.get();
if (!data_extractor)
{
if (log)
log->Printf ("SBValue(%p)::SetData() => error: no data to set", value_sp.get());
error.SetErrorString("No data to set");
ret = false;
}
else
{
Error set_error;
value_sp->SetData(*data_extractor, set_error);
if (!set_error.Success())
{
error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
ret = false;
}
}
}
else
{
error.SetErrorStringWithFormat ("Couldn't set data: could not get SBValue: %s", locker.GetError().AsCString());
ret = false;
}
if (log)
log->Printf ("SBValue(%p)::SetData (%p) => %s",
value_sp.get(),
data.get(),
ret ? "true" : "false");
return ret;
}
示例8: log
size_t
SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
size_t bytes_read = 0;
if (log)
{
log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p))...",
m_opaque_sp.get(),
addr,
dst,
(uint32_t) dst_len,
sb_error.get());
}
if (m_opaque_sp)
{
Error error;
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error);
sb_error.SetError (error);
}
else
{
sb_error.SetErrorString ("SBProcess is invalid");
}
if (log)
{
SBStream sstr;
sb_error.GetDescription (sstr);
log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %d",
m_opaque_sp.get(),
addr,
dst,
(uint32_t) dst_len,
sb_error.get(),
sstr.GetData(),
(uint32_t) bytes_read);
}
return bytes_read;
}
示例9: listener_func
void listener_func() {
while (!g_done) {
SBEvent event;
bool got_event = g_listener.WaitForEvent(1, event);
if (got_event) {
if (!event.IsValid())
throw Exception("event is not valid in listener thread");
SBProcess process = SBProcess::GetProcessFromEvent(event);
if (process.GetState() == eStateStopped) {
SBError error = process.Continue();
if (!error.Success())
throw Exception(string("Cannot continue process from listener thread: ")
+ error.GetCString());
g_process_started.push(true);
}
}
}
}
示例10: api_locker
uint64_t
SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
{
error.Clear();
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Scalar scalar;
if (m_opaque_sp->ResolveValue (scalar))
return scalar.GetRawBits64(fail_value);
else
error.SetErrorString("could not get value");
}
else
error.SetErrorString("could not get target");
}
error.SetErrorString("invalid SBValue");
return fail_value;
}
示例11: StepInto
void SBThread::StepInto(const char *target_name, uint32_t end_line,
SBError &error, lldb::RunMode stop_other_threads) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf(
"SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
static_cast<void *>(exe_ctx.GetThreadPtr()),
target_name ? target_name : "<NULL>",
Thread::RunModeAsCString(stop_other_threads));
if (exe_ctx.HasThreadScope()) {
bool abort_other_plans = false;
Thread *thread = exe_ctx.GetThreadPtr();
StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
ThreadPlanSP new_plan_sp;
if (frame_sp && frame_sp->HasDebugInformation()) {
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
AddressRange range;
if (end_line == LLDB_INVALID_LINE_NUMBER)
range = sc.line_entry.range;
else {
if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
return;
}
const LazyBool step_out_avoids_code_without_debug_info =
eLazyBoolCalculate;
const LazyBool step_in_avoids_code_without_debug_info =
eLazyBoolCalculate;
new_plan_sp = thread->QueueThreadPlanForStepInRange(
abort_other_plans, range, sc, target_name, stop_other_threads,
step_in_avoids_code_without_debug_info,
step_out_avoids_code_without_debug_info);
} else {
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
false, abort_other_plans, stop_other_threads);
}
error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
}
示例12: QueueThreadPlanForRunToAddress
SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
SBError &error) {
if (m_opaque_sp) {
Address *address = sb_address.get();
if (!address)
return SBThreadPlan();
Status plan_status;
SBThreadPlan plan =
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress(
false, *address, false, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
return plan;
} else {
return SBThreadPlan();
}
}
示例13: atexit
//.........这里部分代码省略.........
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;
if (!m_option_data.m_repl_options.empty())
repl_options = m_option_data.m_repl_options.c_str();
SBError error (m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
if (error.Fail())
{
const char *error_cstr = error.GetCString();
if (error_cstr && error_cstr[0])
fprintf (stderr, "error: %s\n", error_cstr);
else
fprintf (stderr, "error: %u\n", error.GetError());
}
}
else
{
// Check if we have any data in the commands stream, and if so, save it to a temp file
// so we can then run the command interpreter using the file contents.
const char *commands_data = commands_stream.GetData();
const size_t commands_size = commands_stream.GetSize();
// The command file might have requested that we quit, this variable will track that.
bool quit_requested = false;
bool stopped_for_crash = false;
if (commands_data && commands_size)
{
int initial_commands_fds[2];
bool success = true;
FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
if (commands_file)
{
m_debugger.SetInputFileHandle (commands_file, true);
// Set the debugger into Sync mode when running the command file. Otherwise command files
// that run the target won't run in a sensible way.
bool old_async = m_debugger.GetAsync();
m_debugger.SetAsync(false);
示例14: ResetOptionValues
SBError
Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
{
ResetOptionValues ();
SBCommandReturnObject result;
SBError error;
std::string option_string;
struct option *long_options = NULL;
std::vector<struct option> long_options_vector;
uint32_t num_options;
for (num_options = 0; g_options[num_options].long_option != NULL; ++num_options)
/* Do Nothing. */;
if (num_options == 0)
{
if (argc > 1)
error.SetErrorStringWithFormat ("invalid number of options");
return error;
}
BuildGetOptTable (g_options, long_options_vector, num_options);
if (long_options_vector.empty())
long_options = NULL;
else
long_options = &long_options_vector.front();
if (long_options == NULL)
{
error.SetErrorStringWithFormat ("invalid long options");
return error;
}
// Build the option_string argument for call to getopt_long_only.
for (int i = 0; long_options[i].name != NULL; ++i)
{
if (long_options[i].flag == NULL)
{
option_string.push_back ((char) long_options[i].val);
switch (long_options[i].has_arg)
{
default:
case no_argument:
break;
case required_argument:
option_string.push_back (':');
break;
case optional_argument:
option_string.append ("::");
break;
}
}
}
// This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't
// know at that point whether we should read in init files yet. So we don't read them in in the
// Driver constructor, then set the flags back to "read them in" here, and then if we see the
// "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the
// main loop.
m_debugger.SkipLLDBInitFiles (false);
m_debugger.SkipAppInitFiles (false);
// Prepare for & make calls to getopt_long_only.
#if __GLIBC__
optind = 0;
#else
optreset = 1;
optind = 1;
#endif
int val;
while (1)
{
int long_options_index = -1;
val = ::getopt_long_only (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index);
if (val == -1)
break;
else if (val == '?')
{
m_option_data.m_print_help = true;
error.SetErrorStringWithFormat ("unknown or ambiguous option");
break;
}
else if (val == 0)
continue;
else
{
m_option_data.m_seen_options.insert ((char) val);
if (long_options_index == -1)
{
for (int i = 0;
long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val;
++i)
{
if (long_options[i].val == val)
//.........这里部分代码省略.........
示例15: main
int
main (int argc, char const *argv[])
{
// Use a sentry object to properly initialize/terminate LLDB.
LLDBSentry sentry;
SBDebugger debugger (SBDebugger::Create());
// Create a debugger instance so we can create a target
if (!debugger.IsValid())
fprintf (stderr, "error: failed to create a debugger object\n");
bool show_usage = false;
bool verbose = false;
bool canonical = false;
bool external_only = false;
const char *arch = NULL;
const char *platform = NULL;
std::string short_options("h?");
for (const struct option *opt = g_long_options; opt->name; ++opt)
{
if (isprint(opt->val))
{
short_options.append(1, (char)opt->val);
switch (opt->has_arg)
{
case no_argument:
break;
case required_argument:
short_options.append(1, ':');
break;
case optional_argument:
short_options.append(2, ':');
break;
}
}
}
#ifdef __GLIBC__
optind = 0;
#else
optreset = 1;
optind = 1;
#endif
char ch;
while ((ch = getopt_long_only(argc, (char * const *)argv, short_options.c_str(), g_long_options, 0)) != -1)
{
switch (ch)
{
case 0:
break;
case 'a':
if (arch != NULL)
{
fprintf (stderr, "error: the --arch option can only be specified once\n");
exit(1);
}
arch = optarg;
break;
case 'c':
canonical = true;
break;
case 'x':
external_only = true;
break;
case 'p':
platform = optarg;
break;
case 'v':
verbose = true;
break;
case 'h':
case '?':
default:
show_usage = true;
break;
}
}
argc -= optind;
argv += optind;
const bool add_dependent_libs = false;
SBError error;
for (int arg_idx = 0; arg_idx < argc; ++arg_idx)
{
// The first argument is the file path we want to look something up in
const char *exe_file_path = argv[arg_idx];
// Create a target using the executable.
SBTarget target = debugger.CreateTarget (exe_file_path,
arch,
platform,
add_dependent_libs,
error);
//.........这里部分代码省略.........