Ran the static analyzer on the codebase and found a few things.

llvm-svn: 160338
This commit is contained in:
Greg Clayton 2012-07-17 03:23:13 +00:00
parent 24a8378c4f
commit 23f59509a8
42 changed files with 544 additions and 641 deletions

View File

@ -1038,7 +1038,7 @@ SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dyna
LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionResults exe_results;
ExecutionResults exe_results = eExecutionSetupError;
SBValue expr_result;
ValueObjectSP expr_value_sp;

View File

@ -754,20 +754,19 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
const bool synchronous_execution = target_sp->GetDebugger().GetAsyncExecution () == false;
if (error.Success())
{
StateType state = eStateInvalid;
if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
{
// If we are doing synchronous mode, then wait for the initial
// stop to happen, else, return and let the caller watch for
// the stop
if (synchronous_execution)
state = process_sp->WaitForProcessToStop (NULL);
process_sp->WaitForProcessToStop (NULL);
// We we are stopping at the entry point, we can return now!
return sb_process;
}
// Make sure we are stopped at the entry
state = process_sp->WaitForProcessToStop (NULL);
StateType state = process_sp->WaitForProcessToStop (NULL);
if (state == eStateStopped)
{
// resume the process to skip the entry point

View File

@ -373,14 +373,8 @@ protected:
Breakpoint *bp = NULL;
FileSpec module_spec;
bool use_module = false;
int num_modules = m_options.m_modules.GetSize();
const bool internal = false;
if ((num_modules > 0) && (break_type != eSetTypeAddress))
use_module = true;
switch (break_type)
{
case eSetTypeFileAndLine: // Breakpoint by source position
@ -1673,8 +1667,6 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter
"A set of commands for operating on breakpoints. Also see _regexp-break.",
"breakpoint <command> [<command-options>]")
{
bool status;
CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
@ -1693,14 +1685,14 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter
command_command_object->SetCommandName ("breakpoint command");
modify_command_object->SetCommandName ("breakpoint modify");
status = LoadSubCommand ("list", list_command_object);
status = LoadSubCommand ("enable", enable_command_object);
status = LoadSubCommand ("disable", disable_command_object);
status = LoadSubCommand ("clear", clear_command_object);
status = LoadSubCommand ("delete", delete_command_object);
status = LoadSubCommand ("set", set_command_object);
status = LoadSubCommand ("command", command_command_object);
status = LoadSubCommand ("modify", modify_command_object);
LoadSubCommand ("list", list_command_object);
LoadSubCommand ("enable", enable_command_object);
LoadSubCommand ("disable", disable_command_object);
LoadSubCommand ("clear", clear_command_object);
LoadSubCommand ("delete", delete_command_object);
LoadSubCommand ("set", set_command_object);
LoadSubCommand ("command", command_command_object);
LoadSubCommand ("modify", modify_command_object);
}
CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()

View File

@ -864,7 +864,6 @@ CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpret
"A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commmands').",
"command <sub-command> [<sub-command-options>] <breakpoint-id>")
{
bool status;
CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd (interpreter));
CommandObjectSP delete_command_object (new CommandObjectBreakpointCommandDelete (interpreter));
CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList (interpreter));
@ -873,9 +872,9 @@ CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpret
delete_command_object->SetCommandName ("breakpoint command delete");
list_command_object->SetCommandName ("breakpoint command list");
status = LoadSubCommand ("add", add_command_object);
status = LoadSubCommand ("delete", delete_command_object);
status = LoadSubCommand ("list", list_command_object);
LoadSubCommand ("add", add_command_object);
LoadSubCommand ("delete", delete_command_object);
LoadSubCommand ("list", list_command_object);
}
CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand ()

View File

@ -1295,8 +1295,6 @@ CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterp
"A set of commands for operating on watchpoints.",
"watchpoint <command> [<command-options>]")
{
bool status;
CommandObjectSP list_command_object (new CommandObjectWatchpointList (interpreter));
CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter));
CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter));
@ -1313,13 +1311,13 @@ CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterp
modify_command_object->SetCommandName("watchpoint modify");
set_command_object->SetCommandName("watchpoint set");
status = LoadSubCommand ("list", list_command_object);
status = LoadSubCommand ("enable", enable_command_object);
status = LoadSubCommand ("disable", disable_command_object);
status = LoadSubCommand ("delete", delete_command_object);
status = LoadSubCommand ("ignore", ignore_command_object);
status = LoadSubCommand ("modify", modify_command_object);
status = LoadSubCommand ("set", set_command_object);
LoadSubCommand ("list", list_command_object);
LoadSubCommand ("enable", enable_command_object);
LoadSubCommand ("disable", disable_command_object);
LoadSubCommand ("delete", delete_command_object);
LoadSubCommand ("ignore", ignore_command_object);
LoadSubCommand ("modify", modify_command_object);
LoadSubCommand ("set", set_command_object);
}
CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint()

View File

@ -431,14 +431,6 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
case DumpStyleResolvedDescriptionNoModule:
if (IsSectionOffset())
{
AddressType addr_type = eAddressTypeLoad;
addr_t addr = GetLoadAddress (target);
if (addr == LLDB_INVALID_ADDRESS)
{
addr = GetFileAddress();
addr_type = eAddressTypeFile;
}
uint32_t pointer_size = 4;
ModuleSP module_sp (GetModule());
if (target)

View File

@ -1336,10 +1336,10 @@ Debugger::FormatPrompt
}
else if (is_pointer) // if pointer, value is the address stored
{
var_success = target->DumpPrintableRepresentation(s,
val_obj_display,
custom_format,
ValueObject::ePrintableRepresentationSpecialCasesDisable);
target->DumpPrintableRepresentation (s,
val_obj_display,
custom_format,
ValueObject::ePrintableRepresentationSpecialCasesDisable);
}
else
{

View File

@ -151,7 +151,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len)
{
if (end_token && end_token == p)
{
p += m_end_token.size();
m_end_token.size();
SetIsDone(true);
break;
}

View File

@ -186,11 +186,21 @@ SearchFilter::DoModuleIteration (const lldb::ModuleSP& module_sp, Searcher &sear
Searcher::CallbackReturn
SearchFilter::DoModuleIteration (const SymbolContext &context, Searcher &searcher)
{
Searcher::CallbackReturn shouldContinue;
if (searcher.GetDepth () >= Searcher::eDepthModule)
{
if (!context.module_sp)
if (context.module_sp)
{
if (searcher.GetDepth () == Searcher::eDepthModule)
{
SymbolContext matchingContext(context.module_sp.get());
searcher.SearchCallback (*this, matchingContext, NULL, false);
}
else
{
return DoCUIteration(context.module_sp, context, searcher);
}
}
else
{
ModuleList &target_images = m_target_sp->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
@ -208,14 +218,14 @@ SearchFilter::DoModuleIteration (const SymbolContext &context, Searcher &searche
{
SymbolContext matchingContext(m_target_sp, module_sp);
shouldContinue = searcher.SearchCallback (*this, matchingContext, NULL, false);
Searcher::CallbackReturn shouldContinue = searcher.SearchCallback (*this, matchingContext, NULL, false);
if (shouldContinue == Searcher::eCallbackReturnStop
|| shouldContinue == Searcher::eCallbackReturnPop)
return shouldContinue;
}
else
{
shouldContinue = DoCUIteration(module_sp, context, searcher);
Searcher::CallbackReturn shouldContinue = DoCUIteration(module_sp, context, searcher);
if (shouldContinue == Searcher::eCallbackReturnStop)
return shouldContinue;
else if (shouldContinue == Searcher::eCallbackReturnPop)
@ -223,20 +233,6 @@ SearchFilter::DoModuleIteration (const SymbolContext &context, Searcher &searche
}
}
}
else
{
if (searcher.GetDepth () == Searcher::eDepthModule)
{
SymbolContext matchingContext(context.module_sp.get());
shouldContinue = searcher.SearchCallback (*this, matchingContext, NULL, false);
}
else
{
return DoCUIteration(context.module_sp, context, searcher);
}
}
}
return Searcher::eCallbackReturnContinue;
}

View File

@ -173,16 +173,13 @@ UserSettingsController::RegisterChild (const UserSettingsControllerSP &child)
// Verify child is not already in m_children.
size_t num_children = m_children.size();
bool found = false;
for (size_t i = 0; i < num_children; ++i)
{
if (m_children[i].get() == child.get())
found = true;
}
{
if (m_children[i].get() == child.get())
return;
}
// Add child to m_children.
if (! found)
m_children.push_back (child);
m_children.push_back (child);
}
const ConstString &
@ -494,14 +491,12 @@ UserSettingsController::SetVariable (const char *full_dot_name,
UserSettingsControllerSP child;
ConstString child_prefix (names.GetArgumentAtIndex (0));
int num_children = GetNumChildren();
bool found = false;
for (int i = 0; i < num_children && !found; ++i)
for (int i = 0; i < num_children; ++i)
{
child = GetChildAtIndex (i);
ConstString current_prefix = child->GetLevelName();
if (current_prefix == child_prefix)
{
found = true;
std::string new_name;
for (int j = 0; j < names.GetArgumentCount(); ++j)
{
@ -513,12 +508,9 @@ UserSettingsController::SetVariable (const char *full_dot_name,
index_value);
}
}
if (!found)
{
err.SetErrorStringWithFormat ("unable to find variable '%s', cannot assign value",
full_dot_name);
return err;
}
err.SetErrorStringWithFormat ("unable to find variable '%s', cannot assign value",
full_dot_name);
return err;
}
}
}
@ -576,12 +568,10 @@ UserSettingsController::GetVariable
if (names.GetArgumentCount() > 1)
{
ConstString child_prefix (names.GetArgumentAtIndex (0));
bool found = false;
for (int i = 0; i < m_children.size() && !found; ++i)
for (int i = 0; i < m_children.size(); ++i)
{
if (child_prefix == m_children[i]->GetLevelName())
{
found = true;
child = m_children[i];
std::string new_name;
for (int j = 0; j < names.GetArgumentCount(); ++j)
@ -594,60 +584,57 @@ UserSettingsController::GetVariable
}
}
if (!found)
// Cannot be handled by a child, because name did not match any child prefixes.
// Cannot be a class-wide variable because there are too many name pieces.
if (instance_entry != NULL)
{
// Cannot be handled by a child, because name did not match any child prefixes.
// Cannot be a class-wide variable because there are too many name pieces.
var_type = instance_entry->var_type;
ConstString instance_name (names.GetArgumentAtIndex (0));
InstanceSettings *current_settings = FindSettingsForInstance (instance_name);
if (instance_entry != NULL)
if (current_settings != NULL)
{
var_type = instance_entry->var_type;
ConstString instance_name (names.GetArgumentAtIndex (0));
InstanceSettings *current_settings = FindSettingsForInstance (instance_name);
current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
else
{
// Look for instance name setting in pending settings.
if (current_settings != NULL)
std::string inst_name_str = instance_name.GetCString();
std::map<std::string, InstanceSettingsSP>::iterator pos;
pos = m_pending_settings.find (inst_name_str);
if (pos != m_pending_settings.end())
{
current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
InstanceSettingsSP settings_sp = pos->second;
settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
else
else
{
// Look for instance name setting in pending settings.
std::string inst_name_str = instance_name.GetCString();
std::map<std::string, InstanceSettingsSP>::iterator pos;
pos = m_pending_settings.find (inst_name_str);
if (pos != m_pending_settings.end())
if (m_settings.level_name.GetLength() > 0)
{
InstanceSettingsSP settings_sp = pos->second;
settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
// No valid instance name; assume they want the default settings.
m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
else
else
{
if (m_settings.level_name.GetLength() > 0)
{
// No valid instance name; assume they want the default settings.
m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
// We're at the Debugger level; use the debugger's instance settings.
StreamString tmp_name;
if (debugger_instance_name[0] != '[')
tmp_name.Printf ("[%s]", debugger_instance_name);
else
{
// We're at the Debugger level; use the debugger's instance settings.
StreamString tmp_name;
if (debugger_instance_name[0] != '[')
tmp_name.Printf ("[%s]", debugger_instance_name);
else
tmp_name.Printf ("%s", debugger_instance_name);
ConstString dbg_name (debugger_instance_name);
InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
if (dbg_settings)
dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
tmp_name.Printf ("%s", debugger_instance_name);
ConstString dbg_name (debugger_instance_name);
InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
if (dbg_settings)
dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
}
}
else
err.SetErrorString ("invalid variable name");
}
else
err.SetErrorString ("invalid variable name");
}
else
{
@ -1194,14 +1181,11 @@ UserSettingsController::FindSettingsDescriptions (CommandInterpreter &interprete
else if (num_pieces == 1)
{
ConstString var_name (names.GetArgumentAtIndex (0));
bool is_global = false;
const SettingEntry *setting_entry = usc_sp->GetGlobalEntry (var_name);
if (setting_entry == NULL)
setting_entry = usc_sp->GetInstanceEntry (var_name);
else
is_global = true;
// Check to see if it is a global or instance variable name.
if (setting_entry != NULL)
@ -1773,21 +1757,18 @@ UserSettingsController::CompleteSettingsNames (const UserSettingsControllerSP& u
else
{
// 'next_name' must be a child name. Find the correct child and pass the remaining piece to be resolved.
bool found = false;
int num_children = my_usc_sp->GetNumChildren();
ConstString child_level (next_name.c_str());
for (int i = 0; i < num_children; ++i)
{
if (my_usc_sp->GetChildAtIndex (i)->GetLevelName() == child_level)
{
found = true;
return UserSettingsController::CompleteSettingsNames (my_usc_sp->GetChildAtIndex (i),
partial_setting_name_pieces,
word_complete, matches);
}
}
if (!found)
return 0;
return 0;
}
}
else if (num_name_pieces == 1)

View File

@ -2344,8 +2344,10 @@ ValueObject::GetValuesForExpressionPath(const char* expression,
ValueObjectSP final_value = ret_val->Dereference(error);
if (error.Fail() || !final_value.get())
{
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonDereferencingFailed;
*final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
if (reason_to_stop)
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonDereferencingFailed;
if (final_value_type)
*final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
return 0;
}
else
@ -2361,8 +2363,10 @@ ValueObject::GetValuesForExpressionPath(const char* expression,
ValueObjectSP final_value = ret_val->AddressOf(error);
if (error.Fail() || !final_value.get())
{
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonTakingAddressFailed;
*final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
if (reason_to_stop)
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonTakingAddressFailed;
if (final_value_type)
*final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
return 0;
}
else
@ -3770,9 +3774,9 @@ ValueObject::EvaluationPoint::SyncWithProcessState()
if (current_mod_id.GetStopID() == 0)
return false;
bool changed;
if (m_mod_id.IsValid())
bool changed = false;
const bool was_valid = m_mod_id.IsValid();
if (was_valid)
{
if (m_mod_id == current_mod_id)
{
@ -3804,6 +3808,7 @@ ValueObject::EvaluationPoint::SyncWithProcessState()
{
// We used to have a frame, but now it is gone
SetInvalid();
changed = was_valid;
}
}
}
@ -3811,6 +3816,7 @@ ValueObject::EvaluationPoint::SyncWithProcessState()
{
// We used to have a thread, but now it is gone
SetInvalid();
changed = was_valid;
}
}

View File

@ -461,11 +461,16 @@ private:
case eMsgSend_stret:
target_object = call_inst->getArgOperand(1);
selector = call_inst->getArgOperand(2);
break;
case eMsgSendSuper:
case eMsgSendSuper_stret:
return true;
}
// These objects should always be valid according to Sean Calannan
assert (target_object);
assert (selector);
// Insert an instruction to cast the receiver id to int8_t*
BitCastInst *bit_cast = new BitCastInst(target_object,

View File

@ -634,7 +634,7 @@ public:
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
lldb_private::Value resolved_value;
lldb_private::ClangExpressionVariable::FlagType flags;
lldb_private::ClangExpressionVariable::FlagType flags = 0;
if (global_value)
{

View File

@ -161,16 +161,15 @@ TerminalState::Save (int fd, bool save_process_group)
bool
TerminalState::Restore () const
{
int result = 0;
if (IsValid())
{
const int fd = m_tty.GetFileDescriptor();
if (TFlagsIsValid())
result = fcntl (fd, F_SETFL, m_tflags);
fcntl (fd, F_SETFL, m_tflags);
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (TTYStateIsValid())
result = tcsetattr (fd, TCSANOW, m_termios_ap.get());
tcsetattr (fd, TCSANOW, m_termios_ap.get());
#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (ProcessGroupIsValid())
@ -179,7 +178,7 @@ TerminalState::Restore () const
void (*saved_sigttou_callback) (int) = NULL;
saved_sigttou_callback = (void (*)(int)) signal (SIGTTOU, SIG_IGN);
// Set the process group
result = tcsetpgrp (fd, m_process_group);
tcsetpgrp (fd, m_process_group);
// Restore the original signal handler.
signal (SIGTTOU, saved_sigttou_callback);
}

View File

@ -114,7 +114,11 @@ public:
{
if (m_pool)
{
[m_pool release];
if (objc_collectingEnabled())
[m_pool drain];
else
[m_pool release];
m_pool = nil;
}
}
@ -232,6 +236,8 @@ Host::LaunchApplication (const FileSpec &app_file_spec)
::pid_t pid = LLDB_INVALID_PROCESS_ID;
error = ::GetProcessPID(&psn, &pid);
if (error != noErr)
return LLDB_INVALID_PROCESS_ID;
return pid;
#endif
}
@ -292,164 +298,164 @@ WaitForProcessToSIGSTOP (const lldb::pid_t pid, const int timeout_in_seconds)
}
#if !defined(__arm__)
static lldb::pid_t
LaunchInNewTerminalWithCommandFile
(
const char **argv,
const char **envp,
const char *working_dir,
const ArchSpec *arch_spec,
bool stop_at_entry,
bool disable_aslr
)
{
if (!argv || !argv[0])
return LLDB_INVALID_PROCESS_ID;
OSStatus error = 0;
FileSpec program (argv[0], false);
std::string unix_socket_name;
char temp_file_path[PATH_MAX];
const char *tmpdir = ::getenv ("TMPDIR");
if (tmpdir == NULL)
tmpdir = "/tmp/";
::snprintf (temp_file_path, sizeof(temp_file_path), "%s%s-XXXXXX", tmpdir, program.GetFilename().AsCString());
if (::mktemp (temp_file_path) == NULL)
return LLDB_INVALID_PROCESS_ID;
unix_socket_name.assign (temp_file_path);
::strlcat (temp_file_path, ".command", sizeof (temp_file_path));
StreamFile command_file;
command_file.GetFile().Open (temp_file_path,
File::eOpenOptionWrite | File::eOpenOptionCanCreate,
File::ePermissionsDefault);
if (!command_file.GetFile().IsValid())
return LLDB_INVALID_PROCESS_ID;
FileSpec darwin_debug_file_spec;
if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec))
return LLDB_INVALID_PROCESS_ID;
darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
if (!darwin_debug_file_spec.Exists())
return LLDB_INVALID_PROCESS_ID;
char launcher_path[PATH_MAX];
darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
command_file.Printf("\"%s\" ", launcher_path);
command_file.Printf("--unix-socket=%s ", unix_socket_name.c_str());
if (arch_spec && arch_spec->IsValid())
{
command_file.Printf("--arch=%s ", arch_spec->GetArchitectureName());
}
if (disable_aslr)
{
command_file.PutCString("--disable-aslr ");
}
command_file.PutCString("-- ");
if (argv)
{
for (size_t i=0; argv[i] != NULL; ++i)
{
command_file.Printf("\"%s\" ", argv[i]);
}
}
command_file.PutCString("\necho Process exited with status $?\n");
command_file.GetFile().Close();
if (::chmod (temp_file_path, S_IRWXU | S_IRWXG) != 0)
return LLDB_INVALID_PROCESS_ID;
CFCMutableDictionary cf_env_dict;
const bool can_create = true;
if (envp)
{
for (size_t i=0; envp[i] != NULL; ++i)
{
const char *env_entry = envp[i];
const char *equal_pos = strchr(env_entry, '=');
if (equal_pos)
{
std::string env_key (env_entry, equal_pos);
std::string env_val (equal_pos + 1);
CFCString cf_env_key (env_key.c_str(), kCFStringEncodingUTF8);
CFCString cf_env_val (env_val.c_str(), kCFStringEncodingUTF8);
cf_env_dict.AddValue (cf_env_key.get(), cf_env_val.get(), can_create);
}
}
}
LSApplicationParameters app_params;
::memset (&app_params, 0, sizeof (app_params));
app_params.flags = kLSLaunchDontAddToRecents | kLSLaunchAsync;
app_params.argv = NULL;
app_params.environment = (CFDictionaryRef)cf_env_dict.get();
CFCReleaser<CFURLRef> command_file_url (::CFURLCreateFromFileSystemRepresentation (NULL,
(const UInt8 *)temp_file_path,
strlen(temp_file_path),
false));
CFCMutableArray urls;
// Terminal.app will open the ".command" file we have created
// and run our process inside it which will wait at the entry point
// for us to attach.
urls.AppendValue(command_file_url.get());
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
Error lldb_error;
// Sleep and wait a bit for debugserver to start to listen...
char connect_url[128];
::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str());
// Spawn a new thread to accept incoming connection on the connect_url
// so we can grab the pid from the inferior
lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name.c_str(),
AcceptPIDFromInferior,
connect_url,
&lldb_error);
ProcessSerialNumber psn;
error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params, &psn, 1);
if (error == noErr)
{
thread_result_t accept_thread_result = NULL;
if (Host::ThreadJoin (accept_thread, &accept_thread_result, &lldb_error))
{
if (accept_thread_result)
{
pid = (intptr_t)accept_thread_result;
// Wait for process to be stopped the the entry point by watching
// for the process status to be set to SSTOP which indicates it it
// SIGSTOP'ed at the entry point
WaitForProcessToSIGSTOP (pid, 5);
}
}
}
else
{
Host::ThreadCancel (accept_thread, &lldb_error);
}
return pid;
}
//static lldb::pid_t
//LaunchInNewTerminalWithCommandFile
//(
// const char **argv,
// const char **envp,
// const char *working_dir,
// const ArchSpec *arch_spec,
// bool stop_at_entry,
// bool disable_aslr
//)
//{
// if (!argv || !argv[0])
// return LLDB_INVALID_PROCESS_ID;
//
// OSStatus error = 0;
//
// FileSpec program (argv[0], false);
//
//
// std::string unix_socket_name;
//
// char temp_file_path[PATH_MAX];
// const char *tmpdir = ::getenv ("TMPDIR");
// if (tmpdir == NULL)
// tmpdir = "/tmp/";
// ::snprintf (temp_file_path, sizeof(temp_file_path), "%s%s-XXXXXX", tmpdir, program.GetFilename().AsCString());
//
// if (::mktemp (temp_file_path) == NULL)
// return LLDB_INVALID_PROCESS_ID;
//
// unix_socket_name.assign (temp_file_path);
//
// ::strlcat (temp_file_path, ".command", sizeof (temp_file_path));
//
// StreamFile command_file;
// command_file.GetFile().Open (temp_file_path,
// File::eOpenOptionWrite | File::eOpenOptionCanCreate,
// File::ePermissionsDefault);
//
// if (!command_file.GetFile().IsValid())
// return LLDB_INVALID_PROCESS_ID;
//
// FileSpec darwin_debug_file_spec;
// if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec))
// return LLDB_INVALID_PROCESS_ID;
// darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
//
// if (!darwin_debug_file_spec.Exists())
// return LLDB_INVALID_PROCESS_ID;
//
// char launcher_path[PATH_MAX];
// darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
// command_file.Printf("\"%s\" ", launcher_path);
//
// command_file.Printf("--unix-socket=%s ", unix_socket_name.c_str());
//
// if (arch_spec && arch_spec->IsValid())
// {
// command_file.Printf("--arch=%s ", arch_spec->GetArchitectureName());
// }
//
// if (disable_aslr)
// {
// command_file.PutCString("--disable-aslr ");
// }
//
// command_file.PutCString("-- ");
//
// if (argv)
// {
// for (size_t i=0; argv[i] != NULL; ++i)
// {
// command_file.Printf("\"%s\" ", argv[i]);
// }
// }
// command_file.PutCString("\necho Process exited with status $?\n");
// command_file.GetFile().Close();
// if (::chmod (temp_file_path, S_IRWXU | S_IRWXG) != 0)
// return LLDB_INVALID_PROCESS_ID;
//
// CFCMutableDictionary cf_env_dict;
//
// const bool can_create = true;
// if (envp)
// {
// for (size_t i=0; envp[i] != NULL; ++i)
// {
// const char *env_entry = envp[i];
// const char *equal_pos = strchr(env_entry, '=');
// if (equal_pos)
// {
// std::string env_key (env_entry, equal_pos);
// std::string env_val (equal_pos + 1);
// CFCString cf_env_key (env_key.c_str(), kCFStringEncodingUTF8);
// CFCString cf_env_val (env_val.c_str(), kCFStringEncodingUTF8);
// cf_env_dict.AddValue (cf_env_key.get(), cf_env_val.get(), can_create);
// }
// }
// }
//
// LSApplicationParameters app_params;
// ::memset (&app_params, 0, sizeof (app_params));
// app_params.flags = kLSLaunchDontAddToRecents | kLSLaunchAsync;
// app_params.argv = NULL;
// app_params.environment = (CFDictionaryRef)cf_env_dict.get();
//
// CFCReleaser<CFURLRef> command_file_url (::CFURLCreateFromFileSystemRepresentation (NULL,
// (const UInt8 *)temp_file_path,
// strlen(temp_file_path),
// false));
//
// CFCMutableArray urls;
//
// // Terminal.app will open the ".command" file we have created
// // and run our process inside it which will wait at the entry point
// // for us to attach.
// urls.AppendValue(command_file_url.get());
//
//
// lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
//
// Error lldb_error;
// // Sleep and wait a bit for debugserver to start to listen...
// char connect_url[128];
// ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str());
//
// // Spawn a new thread to accept incoming connection on the connect_url
// // so we can grab the pid from the inferior
// lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name.c_str(),
// AcceptPIDFromInferior,
// connect_url,
// &lldb_error);
//
// ProcessSerialNumber psn;
// error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params, &psn, 1);
// if (error == noErr)
// {
// thread_result_t accept_thread_result = NULL;
// if (Host::ThreadJoin (accept_thread, &accept_thread_result, &lldb_error))
// {
// if (accept_thread_result)
// {
// pid = (intptr_t)accept_thread_result;
//
// // Wait for process to be stopped the the entry point by watching
// // for the process status to be set to SSTOP which indicates it it
// // SIGSTOP'ed at the entry point
// WaitForProcessToSIGSTOP (pid, 5);
// }
// }
// }
// else
// {
// Host::ThreadCancel (accept_thread, &lldb_error);
// }
//
// return pid;
//}
const char *applscript_in_new_tty =
"tell application \"Terminal\"\n"
@ -953,34 +959,35 @@ Host::GetOSVersion
CFCReleaser<CFPropertyListRef> property_list;
CFCReleaser<CFStringRef> error_string;
CFCReleaser<CFDataRef> resource_data;
Boolean status;
SInt32 error_code;
// Read the XML file.
status = CFURLCreateDataAndPropertiesFromResource (kCFAllocatorDefault,
plist_url.get(),
resource_data.ptr_address(),
NULL,
NULL,
&error_code);
// Reconstitute the dictionary using the XML data.
property_list = CFPropertyListCreateFromXMLData (kCFAllocatorDefault,
resource_data.get(),
kCFPropertyListImmutable,
error_string.ptr_address());
if (CFGetTypeID(property_list.get()) == CFDictionaryGetTypeID())
if (CFURLCreateDataAndPropertiesFromResource (kCFAllocatorDefault,
plist_url.get(),
resource_data.ptr_address(),
NULL,
NULL,
&error_code))
{
CFDictionaryRef property_dict = (CFDictionaryRef) property_list.get();
CFStringRef product_version_key = CFSTR("ProductVersion");
CFPropertyListRef product_version_value;
product_version_value = CFDictionaryGetValue(property_dict, product_version_key);
if (product_version_value && CFGetTypeID(product_version_value) == CFStringGetTypeID())
// Reconstitute the dictionary using the XML data.
property_list = CFPropertyListCreateFromXMLData (kCFAllocatorDefault,
resource_data.get(),
kCFPropertyListImmutable,
error_string.ptr_address());
if (CFGetTypeID(property_list.get()) == CFDictionaryGetTypeID())
{
CFStringRef product_version_cfstr = (CFStringRef) product_version_value;
product_version_str = CFStringGetCStringPtr(product_version_cfstr, kCFStringEncodingUTF8);
if (product_version_str == NULL) {
if (CFStringGetCString(product_version_cfstr, buffer, 256, kCFStringEncodingUTF8))
product_version_str = buffer;
CFDictionaryRef property_dict = (CFDictionaryRef) property_list.get();
CFStringRef product_version_key = CFSTR("ProductVersion");
CFPropertyListRef product_version_value;
product_version_value = CFDictionaryGetValue(property_dict, product_version_key);
if (product_version_value && CFGetTypeID(product_version_value) == CFStringGetTypeID())
{
CFStringRef product_version_cfstr = (CFStringRef) product_version_value;
product_version_str = CFStringGetCStringPtr(product_version_cfstr, kCFStringEncodingUTF8);
if (product_version_str == NULL) {
if (CFStringGetCString(product_version_cfstr, buffer, 256, kCFStringEncodingUTF8))
product_version_str = buffer;
}
}
}
}
@ -1067,7 +1074,6 @@ GetMacOSXProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
{
DataExtractor data (arg_data, arg_data_size, lldb::endian::InlHostByteOrder(), sizeof(void *));
uint32_t offset = 0;
uint32_t start_offset;
uint32_t argc = data.GetU32 (&offset);
const char *cstr;
@ -1093,7 +1099,6 @@ GetMacOSXProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
Args &proc_args = process_info.GetArguments();
for (int i=0; i<argc; ++i)
{
start_offset = offset;
cstr = data.GetCStr(&offset);
if (cstr)
proc_args.AppendArgument(cstr);
@ -1825,7 +1830,7 @@ Host::StartMonitoringChildProcess (Host::MonitorChildProcessCallback callback,
if (callback)
cancel = callback (callback_baton, pid, exited, signal, exit_status);
if (exited)
if (exited || cancel)
{
::dispatch_source_cancel(source);
}

View File

@ -2537,7 +2537,6 @@ CommandInterpreter::OutputHelpText (Stream &strm,
text_strm.Printf ("%-*s %s %s", max_word_len, word_text, separator, help_text);
const uint32_t max_columns = m_debugger.GetTerminalWidth();
bool first_line = true;
size_t len = text_strm.GetSize();
const char *text = text_strm.GetData();
@ -2548,7 +2547,6 @@ CommandInterpreter::OutputHelpText (Stream &strm,
{
if ((text[i] == ' ' && ::strchr((text+i+1), ' ') && chars_left < ::strchr((text+i+1), ' ')-(text+i)) || text[i] == '\n')
{
first_line = false;
chars_left = max_columns - indent_size;
strm.EOL();
strm.Indent();

View File

@ -208,7 +208,6 @@ DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule (
if (!module_sp)
{
bool uuid_is_valid = uuid.IsValid();
if (uuid_is_valid)
{
ModuleList &target_images = target.GetImages();

View File

@ -564,7 +564,7 @@ EmulateInstructionARM::EmulatePOP (const uint32_t opcode, const ARMEncoding enco
// In ARMv5T and above, this is an interworking branch.
if (!LoadWritePC(context, data))
return false;
addr += addr_byte_size;
//addr += addr_byte_size;
}
context.type = EmulateInstruction::eContextAdjustStackPointer;
@ -1295,13 +1295,12 @@ EmulateInstructionARM::EmulateADDSPImm (const uint32_t opcode, const ARMEncoding
return false;
uint32_t imm32; // the immediate operand
uint32_t d;
bool setflags;
//bool setflags = false; // Add this back if/when support eEncodingT3 eEncodingA1
switch (encoding)
{
case eEncodingT1:
// d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:'00', 32);
d = Bits32 (opcode, 10, 8);
setflags = false;
imm32 = (Bits32 (opcode, 7, 0) << 2);
break;
@ -1309,7 +1308,6 @@ EmulateInstructionARM::EmulateADDSPImm (const uint32_t opcode, const ARMEncoding
case eEncodingT2:
// d = 13; setflags = FALSE; imm32 = ZeroExtend(imm7:'00', 32);
d = 13;
setflags = false;
imm32 = ThumbImm7Scaled(opcode); // imm32 = ZeroExtend(imm7:'00', 32)
break;
@ -1335,6 +1333,15 @@ EmulateInstructionARM::EmulateADDSPImm (const uint32_t opcode, const ARMEncoding
{
if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + d, addr))
return false;
// Add this back if/when support eEncodingT3 eEncodingA1
//if (setflags)
//{
// APSR.N = result<31>;
// APSR.Z = IsZeroBit(result);
// APSR.C = carry;
// APSR.V = overflow;
//}
}
}
return true;
@ -5395,6 +5402,7 @@ EmulateInstructionARM::EmulateADR (const uint32_t opcode, const ARMEncoding enco
case eEncodingT1:
Rd = Bits32(opcode, 10, 8);
imm32 = ThumbImm8Scaled(opcode); // imm32 = ZeroExtend(imm8:'00', 32)
add = true;
break;
case eEncodingT2:
case eEncodingT3:
@ -11505,6 +11513,10 @@ EmulateInstructionARM::EmulateVLD1Single (const uint32_t opcode, const ARMEncodi
else
alignment = 4;
}
else
{
return false;
}
// d = UInt(D:Vd); n = UInt(Rn); m = UInt(Rm);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
@ -11841,6 +11853,10 @@ EmulateInstructionARM::EmulateVST1Single (const uint32_t opcode, ARMEncoding enc
else
alignment = 4;
}
else
{
return false;
}
// d = UInt(D:Vd); n = UInt(Rn); m = UInt(Rm);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);

View File

@ -877,14 +877,11 @@ ObjectFileELF::ParseDynamicSymbols()
DataExtractor dynsym_data;
if (ReadSectionData(dynsym, dynsym_data))
{
const unsigned section_size = dynsym_data.GetByteSize();
unsigned offset = 0;
unsigned cursor = 0;
while (cursor < section_size)
{
offset = cursor;
if (!symbol.Parse(dynsym_data, &cursor))
break;

View File

@ -2933,13 +2933,8 @@ struct lldb_copy_dyld_cache_local_symbols_entry
func_start_entry->data = true;
addr_t symbol_file_addr = func_start_entry->addr;
uint32_t symbol_flags = 0;
if (is_arm)
{
if (symbol_file_addr & 1)
symbol_flags = MACHO_NLIST_ARM_SYMBOL_IS_THUMB;
symbol_file_addr &= 0xfffffffffffffffeull;
}
const FunctionStarts::Entry *next_func_start_entry = function_starts.FindNextEntry (func_start_entry);
const addr_t section_end_file_addr = section_file_addr + symbol_section->GetByteSize();

View File

@ -99,6 +99,7 @@ PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
{
case llvm::Triple::Apple:
create = true;
break;
case llvm::Triple::UnknownArch:
create = !arch->TripleVendorWasSpecified();

View File

@ -25,10 +25,10 @@ static inline uint32_t Align(uint32_t val, uint32_t alignment)
static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5, ARM_ShifterType &shift_t)
{
switch (type) {
switch (type)
{
default:
//assert(0 && "Invalid shift type");
return UINT32_MAX;
case 0:
shift_t = SRType_LSL;
return imm5;
@ -50,6 +50,9 @@ static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5,
return imm5;
}
}
shift_t = SRType_Invalid;
return UINT32_MAX;
}
// A8.6.35 CMP (register) -- Encoding T3
@ -322,6 +325,7 @@ static inline uint32_t ThumbExpandImm_C(uint32_t opcode, uint32_t carry_in, uint
if (bits(imm12, 11, 10) == 0)
{
switch (bits(imm12, 9, 8)) {
default: // Keep static analyzer happy with a default case
case 0:
imm32 = abcdefgh;
break;

View File

@ -184,7 +184,7 @@ RegisterContextLLDB::InitializeZerothFrame()
UnwindPlan::RowSP active_row;
int cfa_offset = 0;
int row_register_kind;
int row_register_kind = -1;
if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
{
active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset);
@ -507,7 +507,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
UnwindPlan::RowSP active_row;
int cfa_offset = 0;
int row_register_kind;
int row_register_kind = -1;
// Try to get by with just the fast UnwindPlan if possible - the full UnwindPlan may be expensive to get
// (e.g. if we have to parse the entire eh_frame section of an ObjectFile for the first time.)
@ -670,8 +670,8 @@ RegisterContextLLDB::GetFastUnwindPlanForFrame ()
const char *has_fast = "";
if (m_fast_unwind_plan_sp)
has_fast = ", and has a fast UnwindPlan";
log->Printf("%*sFrame %u frame has a fast UnwindPlan",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
log->Printf("%*sFrame %u frame%s",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, has_fast);
}
m_frame_type = eNormalFrame;
return unwind_plan_sp;

View File

@ -1824,13 +1824,13 @@ GDBRemoteCommunicationClient::LaunchGDBserverAndGetPort ()
std::string name;
std::string value;
uint16_t port = 0;
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
//lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
while (response.GetNameColonValue(name, value))
{
if (name.size() == 4 && name.compare("port") == 0)
port = Args::StringToUInt32(value.c_str(), 0, 0);
if (name.size() == 3 && name.compare("pid") == 0)
pid = Args::StringToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0);
// if (name.size() == 3 && name.compare("pid") == 0)
// pid = Args::StringToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0);
}
return port;
}

View File

@ -229,8 +229,7 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
m_register_info.Clear();
uint32_t reg_offset = 0;
uint32_t reg_num = 0;
StringExtractorGDBRemote::ResponseType response_type;
for (response_type = StringExtractorGDBRemote::eResponse;
for (StringExtractorGDBRemote::ResponseType response_type = StringExtractorGDBRemote::eResponse;
response_type == StringExtractorGDBRemote::eResponse;
++reg_num)
{
@ -376,7 +375,6 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
}
else
{
response_type = StringExtractorGDBRemote::eError;
break;
}
}
@ -1271,7 +1269,6 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
uint32_t exc_type = 0;
std::vector<addr_t> exc_data;
addr_t thread_dispatch_qaddr = LLDB_INVALID_ADDRESS;
uint32_t exc_data_count = 0;
ThreadSP thread_sp;
while (stop_packet.GetNameColonValue(name, value))
@ -1281,11 +1278,6 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
// exception type in big endian hex
exc_type = Args::StringToUInt32 (value.c_str(), 0, 16);
}
else if (name.compare("mecount") == 0)
{
// exception count in big endian hex
exc_data_count = Args::StringToUInt32 (value.c_str(), 0, 16);
}
else if (name.compare("medata") == 0)
{
// exception data in big endian hex

View File

@ -618,9 +618,8 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
DWARFDebugInfoEntry::Attributes attributes;
const char *name = NULL;
const char *mangled_cstr = NULL;
bool is_variable = false;
bool is_declaration = false;
bool is_artificial = false;
//bool is_artificial = false;
bool has_address = false;
bool has_location = false;
bool is_global_or_static_variable = false;
@ -629,8 +628,6 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes);
if (num_attributes > 0)
{
is_variable = tag == DW_TAG_variable;
for (uint32_t i=0; i<num_attributes; ++i)
{
dw_attr_t attr = attributes.AttributeAtIndex(i);
@ -647,10 +644,10 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
is_declaration = form_value.Unsigned() != 0;
break;
case DW_AT_artificial:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
is_artificial = form_value.Unsigned() != 0;
break;
// case DW_AT_artificial:
// if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
// is_artificial = form_value.Unsigned() != 0;
// break;
case DW_AT_MIPS_linkage_name:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
@ -798,7 +795,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
// as our name. If it starts with '_', then it is ok, else compare
// the string to make sure it isn't the same and we don't end up
// with duplicate entries
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (name && ::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (mangled_cstr, true);
func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());

View File

@ -105,7 +105,6 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
const char *name = NULL;
const char *mangled = NULL;
bool add_die = false;
bool is_variable = false;
const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes);
if (num_attributes > 0)
{
@ -113,8 +112,6 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
dw_tag_t tag = die->Tag();
is_variable = tag == DW_TAG_variable;
for (i=0; i<num_attributes; ++i)
{
dw_attr_t attr = attributes.AttributeAtIndex(i);

View File

@ -186,83 +186,83 @@ DWARFFormValue::SkipValue(const DataExtractor& debug_info_data, uint32_t* offset
bool
DWARFFormValue::SkipValue(dw_form_t form, const DataExtractor& debug_info_data, uint32_t* offset_ptr, const DWARFCompileUnit* cu)
{
bool indirect = false;
do
switch (form)
{
indirect = false;
switch (form)
// Blocks if inlined data that have a length field and the data bytes
// inlined in the .debug_info
case DW_FORM_exprloc:
case DW_FORM_block: { dw_uleb128_t size = debug_info_data.GetULEB128(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block1: { dw_uleb128_t size = debug_info_data.GetU8(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block2: { dw_uleb128_t size = debug_info_data.GetU16(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block4: { dw_uleb128_t size = debug_info_data.GetU32(offset_ptr); *offset_ptr += size; } return true;
// Inlined NULL terminated C-strings
case DW_FORM_string:
debug_info_data.GetCStr(offset_ptr);
return true;
// Compile unit address sized values
case DW_FORM_addr:
case DW_FORM_ref_addr:
*offset_ptr += DWARFCompileUnit::GetAddressByteSize(cu);
return true;
// 0 bytes values (implied from DW_FORM)
case DW_FORM_flag_present:
return true;
// 1 byte values
case DW_FORM_data1:
case DW_FORM_flag:
case DW_FORM_ref1:
*offset_ptr += 1;
return true;
// 2 byte values
case DW_FORM_data2:
case DW_FORM_ref2:
*offset_ptr += 2;
return true;
// 32 bit for DWARF 32, 64 for DWARF 64
case DW_FORM_sec_offset:
*offset_ptr += 4;
return true;
// 4 byte values
case DW_FORM_strp:
case DW_FORM_data4:
case DW_FORM_ref4:
*offset_ptr += 4;
return true;
// 8 byte values
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sig8:
*offset_ptr += 8;
return true;
// signed or unsigned LEB 128 values
case DW_FORM_sdata:
case DW_FORM_udata:
case DW_FORM_ref_udata:
debug_info_data.Skip_LEB128(offset_ptr);
return true;
case DW_FORM_indirect:
{
// Blocks if inlined data that have a length field and the data bytes
// inlined in the .debug_info
case DW_FORM_exprloc:
case DW_FORM_block: { dw_uleb128_t size = debug_info_data.GetULEB128(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block1: { dw_uleb128_t size = debug_info_data.GetU8(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block2: { dw_uleb128_t size = debug_info_data.GetU16(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block4: { dw_uleb128_t size = debug_info_data.GetU32(offset_ptr); *offset_ptr += size; } return true;
// Inlined NULL terminated C-strings
case DW_FORM_string:
debug_info_data.GetCStr(offset_ptr);
return true;
// Compile unit address sized values
case DW_FORM_addr:
case DW_FORM_ref_addr:
*offset_ptr += DWARFCompileUnit::GetAddressByteSize(cu);
return true;
// 0 bytes values (implied from DW_FORM)
case DW_FORM_flag_present:
return true;
// 1 byte values
case DW_FORM_data1:
case DW_FORM_flag:
case DW_FORM_ref1:
*offset_ptr += 1;
return true;
// 2 byte values
case DW_FORM_data2:
case DW_FORM_ref2:
*offset_ptr += 2;
return true;
// 32 bit for DWARF 32, 64 for DWARF 64
case DW_FORM_sec_offset:
*offset_ptr += 4;
return true;
// 4 byte values
case DW_FORM_strp:
case DW_FORM_data4:
case DW_FORM_ref4:
*offset_ptr += 4;
return true;
// 8 byte values
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sig8:
*offset_ptr += 8;
return true;
// signed or unsigned LEB 128 values
case DW_FORM_sdata:
case DW_FORM_udata:
case DW_FORM_ref_udata:
debug_info_data.Skip_LEB128(offset_ptr);
return true;
case DW_FORM_indirect:
indirect = true;
form = debug_info_data.GetULEB128(offset_ptr);
break;
default:
return false;
dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr);
return DWARFFormValue::SkipValue (indirect_form,
debug_info_data,
offset_ptr,
cu);
}
} while (indirect);
return true;
default:
break;
}
return false;
}

View File

@ -421,16 +421,8 @@ SymbolFileDWARF::CalculateAbilities ()
return 0;
uint64_t debug_abbrev_file_size = 0;
uint64_t debug_aranges_file_size = 0;
uint64_t debug_frame_file_size = 0;
uint64_t debug_info_file_size = 0;
uint64_t debug_line_file_size = 0;
uint64_t debug_loc_file_size = 0;
uint64_t debug_macinfo_file_size = 0;
uint64_t debug_pubnames_file_size = 0;
uint64_t debug_pubtypes_file_size = 0;
uint64_t debug_ranges_file_size = 0;
uint64_t debug_str_file_size = 0;
section = section_list->FindSectionByName(GetDWARFMachOSegmentName ()).get();
@ -449,15 +441,11 @@ SymbolFileDWARF::CalculateAbilities ()
m_flags.Set (flagsGotDebugAbbrevData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugAranges, true).get();
if (section)
debug_aranges_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugArangesData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugFrame, true).get();
if (section)
debug_frame_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugFrameData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugLine, true).get();
@ -467,39 +455,27 @@ SymbolFileDWARF::CalculateAbilities ()
m_flags.Set (flagsGotDebugLineData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugLoc, true).get();
if (section)
debug_loc_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugLocData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugMacInfo, true).get();
if (section)
debug_macinfo_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugMacInfoData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubNames, true).get();
if (section)
debug_pubnames_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugPubNamesData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubTypes, true).get();
if (section)
debug_pubtypes_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugPubTypesData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugRanges, true).get();
if (section)
debug_ranges_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugRangesData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get();
if (section)
debug_str_file_size = section->GetFileSize();
else
if (!section)
m_flags.Set (flagsGotDebugStrData);
}
else
@ -1834,7 +1810,7 @@ SymbolFileDWARF::ParseChildMembers
AccessType accessibility = default_accessibility;
bool is_virtual = false;
bool is_base_of_class = true;
off_t member_offset = 0;
//off_t member_offset = 0;
uint32_t i;
for (i=0; i<num_attributes; ++i)
{
@ -1848,31 +1824,31 @@ SymbolFileDWARF::ParseChildMembers
case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break;
case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break;
case DW_AT_data_member_location:
if (form_value.BlockData())
{
Value initialValue(0);
Value memberOffset(0);
const DataExtractor& debug_info_data = get_debug_info_data();
uint32_t block_length = form_value.Unsigned();
uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
if (DWARFExpression::Evaluate (NULL,
NULL,
NULL,
NULL,
NULL,
debug_info_data,
block_offset,
block_length,
eRegisterKindDWARF,
&initialValue,
memberOffset,
NULL))
{
member_offset = memberOffset.ResolveValue(NULL, NULL).UInt();
}
}
break;
// case DW_AT_data_member_location:
// if (form_value.BlockData())
// {
// Value initialValue(0);
// Value memberOffset(0);
// const DataExtractor& debug_info_data = get_debug_info_data();
// uint32_t block_length = form_value.Unsigned();
// uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
// if (DWARFExpression::Evaluate (NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// debug_info_data,
// block_offset,
// block_length,
// eRegisterKindDWARF,
// &initialValue,
// memberOffset,
// NULL))
// {
// member_offset = memberOffset.ResolveValue(NULL, NULL).UInt();
// }
// }
// break;
case DW_AT_accessibility:
accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
@ -4011,58 +3987,12 @@ SymbolFileDWARF::ParseChildArrayInfo
const dw_tag_t tag = die->Tag();
switch (tag)
{
case DW_TAG_enumerator:
{
DWARFDebugInfoEntry::Attributes attributes;
const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
if (num_child_attributes > 0)
{
const char *name = NULL;
bool got_value = false;
int64_t enum_value = 0;
uint32_t i;
for (i=0; i<num_child_attributes; ++i)
{
const dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;
if (attributes.ExtractFormValueAtIndex(this, i, form_value))
{
switch (attr)
{
case DW_AT_const_value:
got_value = true;
enum_value = form_value.Unsigned();
break;
case DW_AT_name:
name = form_value.AsCString(&get_debug_str_data());
break;
case DW_AT_description:
default:
case DW_AT_decl_file:
case DW_AT_decl_line:
case DW_AT_decl_column:
case DW_AT_sibling:
break;
}
}
}
}
}
break;
case DW_TAG_subrange_type:
{
DWARFDebugInfoEntry::Attributes attributes;
const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
if (num_child_attributes > 0)
{
const char *name = NULL;
bool got_value = false;
uint64_t byte_size = 0;
int64_t enum_value = 0;
uint64_t num_elements = 0;
uint64_t lower_bound = 0;
uint64_t upper_bound = 0;
@ -4075,13 +4005,7 @@ SymbolFileDWARF::ParseChildArrayInfo
{
switch (attr)
{
case DW_AT_const_value:
got_value = true;
enum_value = form_value.Unsigned();
break;
case DW_AT_name:
name = form_value.AsCString(&get_debug_str_data());
break;
case DW_AT_count:
@ -4096,10 +4020,6 @@ SymbolFileDWARF::ParseChildArrayInfo
byte_stride = form_value.Unsigned();
break;
case DW_AT_byte_size:
byte_size = form_value.Unsigned();
break;
case DW_AT_lower_bound:
lower_bound = form_value.Unsigned();
break;
@ -5152,7 +5072,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
ConstString type_name_const_str;
Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
size_t byte_size = 0;
bool byte_size_valid = false;
Declaration decl;
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
@ -5206,7 +5125,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
if (type_name_cstr)
type_name_const_str.SetCString(type_name_cstr);
break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); byte_size_valid = true; break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
case DW_AT_encoding: encoding = form_value.Unsigned(); break;
case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break;
default:
@ -5328,6 +5247,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
{
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
bool byte_size_valid = false;
LanguageType class_language = eLanguageTypeUnknown;
bool is_complete_objc_class = false;
@ -5711,9 +5631,9 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
type_name_const_str.SetCString(type_name_cstr);
break;
case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); byte_size_valid = true; break;
case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
case DW_AT_accessibility: break; //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration: break; //is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_bit_stride:
@ -5781,7 +5701,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
const char *mangled = NULL;
//const char *mangled = NULL;
dw_offset_t type_die_offset = DW_INVALID_OFFSET;
bool is_variadic = false;
bool is_inline = false;
@ -5816,10 +5736,10 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
type_name_const_str.SetCString(type_name_cstr);
break;
case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break;
case DW_AT_MIPS_linkage_name: break; // mangled = form_value.AsCString(&get_debug_str_data()); break;
case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break;
case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_declaration: break; // is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_inline: is_inline = form_value.Unsigned() != 0; break;
case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break;
case DW_AT_explicit: is_explicit = form_value.Unsigned() != 0; break;
@ -6214,11 +6134,11 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
break;
case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); byte_size_valid = true; break;
case DW_AT_byte_size: break; // byte_size = form_value.Unsigned(); break;
case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break;
case DW_AT_bit_stride: bit_stride = form_value.Unsigned(); break;
case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_accessibility: break; // accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration: break; // is_forward_declaration = form_value.Unsigned() != 0; break;
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_data_location:
@ -6597,7 +6517,7 @@ SymbolFileDWARF::ParseVariableDIE
bool is_external = false;
bool is_artificial = false;
bool location_is_const_value_data = false;
AccessType accessibility = eAccessNone;
//AccessType accessibility = eAccessNone;
for (i=0; i<num_attributes; ++i)
{
@ -6644,7 +6564,7 @@ SymbolFileDWARF::ParseVariableDIE
break;
case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break;
case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_accessibility: break; //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration:
case DW_AT_description:
case DW_AT_endianity:

View File

@ -225,31 +225,37 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp)
xmlNode *value_node = key_node->next;
while (value_node && value_node->type != XML_ELEMENT_NODE)
value_node = value_node->next;
if (strcmp((const char *)value_node->name, "string") == 0)
if (value_node && value_node->name)
{
const char *node_content = (const char *)::xmlNodeGetContent(value_node);
if (node_content)
if (strcmp((const char *)value_node->name, "string") == 0)
{
strncpy(DBGBuildSourcePath, node_content, sizeof(DBGBuildSourcePath));
const char *node_content = (const char *)::xmlNodeGetContent(value_node);
if (node_content)
{
strncpy(DBGBuildSourcePath, node_content, sizeof(DBGBuildSourcePath));
}
}
key_node = value_node;
}
key_node = value_node;
}
else if (strcmp(key_name, "DBGSourcePath") == 0)
{
xmlNode *value_node = key_node->next;
while (value_node && value_node->type != XML_ELEMENT_NODE)
value_node = value_node->next;
if (strcmp((const char *)value_node->name, "string") == 0)
if (value_node && value_node->name)
{
const char *node_content = (const char *)::xmlNodeGetContent(value_node);
if (node_content)
if (strcmp((const char *)value_node->name, "string") == 0)
{
FileSpec resolved_source_path(node_content, true);
resolved_source_path.GetPath(DBGSourcePath, sizeof(DBGSourcePath));
const char *node_content = (const char *)::xmlNodeGetContent(value_node);
if (node_content)
{
FileSpec resolved_source_path(node_content, true);
resolved_source_path.GetPath(DBGSourcePath, sizeof(DBGSourcePath));
}
}
key_node = value_node;
}
key_node = value_node;
}
}
}

View File

@ -2420,7 +2420,7 @@ ClangASTContext::AddObjCClassProperty
{
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
clang_type_t property_opaque_type_to_access;
clang_type_t property_opaque_type_to_access = NULL;
if (property_opaque_type)
property_opaque_type_to_access = property_opaque_type;

View File

@ -161,7 +161,7 @@ ClangASTImporter::CompleteDecl (clang::Decl *decl)
CompleteObjCInterfaceDecl(interface_decl);
}
}
else if (ObjCProtocolDecl *protocol_decl = dyn_cast<ObjCProtocolDecl>(protocol_decl))
else if (ObjCProtocolDecl *protocol_decl = dyn_cast<ObjCProtocolDecl>(decl))
{
if (!protocol_decl->getDefinition())
protocol_decl->startDefinition();

View File

@ -398,7 +398,6 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t offset, Address startaddr, Unwi
uint32_t reg_num = 0;
int32_t op_offset = 0;
uint32_t tmp_uval32;
uint32_t code_align = cie->code_align;
int32_t data_align = cie->data_align;
@ -750,7 +749,6 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t offset, Address startaddr, Unwi
case DW_CFA_val_offset : // 0x14
case DW_CFA_val_offset_sf : // 0x15
default:
tmp_uval32 = extended_opcode;
break;
}
}

View File

@ -3179,11 +3179,11 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
// break at main.cpp:58, run and hit the breakpoints on
// multiple threads, then somehow during the stepping over
// of all breakpoints no run gets reported.
return_value = true;
// This is a transition from stop to run.
switch (m_thread_list.ShouldReportRun (event_ptr))
{
default:
case eVoteYes:
case eVoteNoOpinion:
return_value = true;
@ -4258,7 +4258,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
}
// Now wait for the process to stop again:
stop_state = lldb::eStateInvalid;
event_sp.reset();
if (log)

View File

@ -164,6 +164,7 @@ posix_spawn_for_debug
int main (int argc, char *const *argv, char *const *envp, const char **apple)
{
#if defined (DEBUG_LLDB_LAUNCHER)
const char *program_name = strrchr(apple[0], '/');
if (program_name)
@ -171,7 +172,6 @@ int main (int argc, char *const *argv, char *const *envp, const char **apple)
else
program_name = apple[0];
#if defined (DEBUG_LLDB_LAUNCHER)
printf("%s called with:\n", program_name);
for (int i=0; i<argc; ++i)
printf("argv[%u] = '%s'\n", i, argv[i]);

View File

@ -1214,9 +1214,9 @@ DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file
case '%':
{
f++; // Skip the '%' character
int min_field_width = 0;
int precision = 0;
uint32_t flags = 0;
// int min_field_width = 0;
// int precision = 0;
//uint32_t flags = 0;
uint32_t length_modifiers = 0;
uint32_t byte_size = 0;
uint32_t actual_byte_size = 0;
@ -1233,12 +1233,12 @@ DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file
// Decode any flags
switch (*f)
{
case '#': fprintf_format += *f++; flags |= alternate_form; break;
case '0': fprintf_format += *f++; flags |= zero_padding; break;
case '-': fprintf_format += *f++; flags |= negative_field_width; break;
case ' ': fprintf_format += *f++; flags |= blank_space; break;
case '+': fprintf_format += *f++; flags |= show_sign; break;
case ',': fprintf_format += *f++; flags |= show_thousands_separator;break;
case '#': fprintf_format += *f++; break; //flags |= alternate_form; break;
case '0': fprintf_format += *f++; break; //flags |= zero_padding; break;
case '-': fprintf_format += *f++; break; //flags |= negative_field_width; break;
case ' ': fprintf_format += *f++; break; //flags |= blank_space; break;
case '+': fprintf_format += *f++; break; //flags |= show_sign; break;
case ',': fprintf_format += *f++; break; //flags |= show_thousands_separator;break;
case '{':
case '[':
{
@ -1330,7 +1330,8 @@ DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file
// Check for a minimum field width
if (isdigit(*f))
{
min_field_width = strtoul(f, &end, 10);
//min_field_width = strtoul(f, &end, 10);
strtoul(f, &end, 10);
if (end > f)
{
fprintf_format.append(f, end - f);
@ -1346,7 +1347,8 @@ DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file
if (isdigit(*f))
{
fprintf_format += '.';
precision = strtoul(f, &end, 10);
//precision = strtoul(f, &end, 10);
strtoul(f, &end, 10);
if (end > f)
{
fprintf_format.append(f, end - f);
@ -1453,7 +1455,7 @@ DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file
byte_size = sizeof(char);
else if (length_modifiers & length_mod_h)
byte_size = sizeof(short);
if (length_modifiers & length_mod_ll)
else if (length_modifiers & length_mod_ll)
byte_size = sizeof(long long);
else if (length_modifiers & length_mod_l)
byte_size = sizeof(long);

View File

@ -122,7 +122,6 @@ catch_mach_exception_raise_state_identity
mach_msg_type_number_t *new_stateCnt
)
{
kern_return_t kret;
if (DNBLogCheckLogBit(LOG_EXCEPTIONS))
{
DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = 0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, 0x%llx })",
@ -135,8 +134,8 @@ catch_mach_exception_raise_state_identity
(uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
(uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
}
kret = mach_port_deallocate (mach_task_self (), task_port);
kret = mach_port_deallocate (mach_task_self (), thread_port);
mach_port_deallocate (mach_task_self (), task_port);
mach_port_deallocate (mach_task_self (), thread_port);
return KERN_FAILURE;
}
@ -229,7 +228,7 @@ MachException::Data::GetStopInfo(struct DNBThreadStopInfo *stop_info) const
if (desc < end_desc)
{
const char *sig_str = SysSignal::Name(soft_signal);
desc += snprintf(desc, end_desc - desc, " EXC_SOFT_SIGNAL( %i ( %s ))", soft_signal, sig_str ? sig_str : "unknown signal");
snprintf(desc, end_desc - desc, " EXC_SOFT_SIGNAL( %i ( %s ))", soft_signal, sig_str ? sig_str : "unknown signal");
}
}
else

View File

@ -421,8 +421,7 @@ MachProcess::DoSIGSTOP (bool clear_bps_and_wps, bool allow_running, uint32_t *th
{
DisableAllBreakpoints (true);
DisableAllWatchpoints (true);
// The static analyzer complains about this, but just leave the following line in.
clear_bps_and_wps = false;
//clear_bps_and_wps = false;
}
uint32_t thread_idx = m_thread_list.GetThreadIndexForThreadStoppedWithSignal (SIGSTOP);
if (thread_idx_ptr)
@ -1865,18 +1864,20 @@ MachProcess::ForkChildForPTraceDebugging
// If our parent is setgid, lets make sure we don't inherit those
// extra powers due to nepotism.
::setgid (getgid ());
if (::setgid (getgid ()) == 0)
{
// Let the child have its own process group. We need to execute
// this call in both the child and parent to avoid a race condition
// between the two processes.
::setpgid (0, 0); // Set the child process group to match its pid
// Let the child have its own process group. We need to execute
// this call in both the child and parent to avoid a race condition
// between the two processes.
::setpgid (0, 0); // Set the child process group to match its pid
// Sleep a bit to before the exec call
::sleep (1);
// Sleep a bit to before the exec call
::sleep (1);
// Turn this process into
::execv (path, (char * const *)argv);
// Turn this process into
::execv (path, (char * const *)argv);
}
// Exit with error code. Child process should have taken
// over in above exec call and if the exec fails it will
// exit the child process below.

View File

@ -470,9 +470,9 @@ MachThreadList::DisableHardwareBreakpoint (const DNBBreakpoint* bp) const
uint32_t
MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
{
uint32_t hw_index = INVALID_NUB_HW_INDEX;
if (wp != NULL)
{
uint32_t hw_index;
PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
const uint32_t num_threads = m_threads.size();
for (uint32_t idx = 0; idx < num_threads; ++idx)
@ -492,9 +492,8 @@ MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
// Use an arbitrary thread to signal the completion of our transaction.
if (num_threads)
m_threads[0]->HardwareWatchpointStateChanged();
return hw_index;
}
return INVALID_NUB_HW_INDEX;
return hw_index;
}
bool

View File

@ -1674,7 +1674,7 @@ set_logging (const char *p)
}
}
// Did we get a properly formatted logging bitmask?
if (*p == ';')
if (p && *p == ';')
{
// Enable DNB logging
DNBLogSetLogCallback(ASLLogCallback, NULL);
@ -2028,14 +2028,21 @@ void
register_value_in_hex_fixed_width (std::ostream& ostrm,
nub_process_t pid,
nub_thread_t tid,
const register_map_entry_t* reg)
const register_map_entry_t* reg,
const DNBRegisterValue *reg_value_ptr)
{
if (reg != NULL)
{
DNBRegisterValue val;
if (DNBThreadGetRegisterValueByID (pid, tid, reg->nub_info.set, reg->nub_info.reg, &val))
DNBRegisterValue reg_value;
if (reg_value_ptr == NULL)
{
append_hex_value (ostrm, val.value.v_uint8, reg->gdb_size, false);
if (DNBThreadGetRegisterValueByID (pid, tid, reg->nub_info.set, reg->nub_info.reg, &reg_value))
reg_value_ptr = &reg_value;
}
if (reg_value_ptr)
{
append_hex_value (ostrm, reg_value_ptr->value.v_uint8, reg->gdb_size, false);
}
else
{
@ -2063,7 +2070,8 @@ void
gdb_regnum_with_fixed_width_hex_register_value (std::ostream& ostrm,
nub_process_t pid,
nub_thread_t tid,
const register_map_entry_t* reg)
const register_map_entry_t* reg,
const DNBRegisterValue *reg_value_ptr)
{
// Output the register number as 'NN:VVVVVVVV;' where NN is a 2 bytes HEX
// gdb register number, and VVVVVVVV is the correct number of hex bytes
@ -2071,7 +2079,7 @@ gdb_regnum_with_fixed_width_hex_register_value (std::ostream& ostrm,
if (reg != NULL)
{
ostrm << RAWHEX8(reg->gdb_regnum) << ':';
register_value_in_hex_fixed_width (ostrm, pid, tid, reg);
register_value_in_hex_fixed_width (ostrm, pid, tid, reg, reg_value_ptr);
ostrm << ';';
}
}
@ -2173,15 +2181,18 @@ RNBRemote::SendStopReplyPacketForThread (nub_thread_t tid)
if (g_num_reg_entries == 0)
InitializeRegisters ();
DNBRegisterValue reg_value;
for (uint32_t reg = 0; reg < g_num_reg_entries; reg++)
if (g_reg_entries != NULL)
{
if (g_reg_entries[reg].expedite)
DNBRegisterValue reg_value;
for (uint32_t reg = 0; reg < g_num_reg_entries; reg++)
{
if (!DNBThreadGetRegisterValueByID (pid, tid, g_reg_entries[reg].nub_info.set, g_reg_entries[reg].nub_info.reg, &reg_value))
continue;
if (g_reg_entries[reg].expedite)
{
if (!DNBThreadGetRegisterValueByID (pid, tid, g_reg_entries[reg].nub_info.set, g_reg_entries[reg].nub_info.reg, &reg_value))
continue;
gdb_regnum_with_fixed_width_hex_register_value (ostrm, pid, tid, &g_reg_entries[reg]);
gdb_regnum_with_fixed_width_hex_register_value (ostrm, pid, tid, &g_reg_entries[reg], &reg_value);
}
}
}
@ -2496,7 +2507,7 @@ RNBRemote::HandlePacket_g (const char *p)
}
for (uint32_t reg = 0; reg < g_num_reg_entries; reg++)
register_value_in_hex_fixed_width (ostrm, pid, tid, &g_reg_entries[reg]);
register_value_in_hex_fixed_width (ostrm, pid, tid, &g_reg_entries[reg], NULL);
return SendPacket (ostrm.str ());
}
@ -2695,7 +2706,6 @@ RNBRemote::HandlePacket_v (const char *p)
}
else if (strstr (p, "vCont") == p)
{
rnb_err_t rnb_err = rnb_success;
typedef struct
{
nub_thread_t tid;
@ -2747,7 +2757,7 @@ RNBRemote::HandlePacket_v (const char *p)
break;
default:
rnb_err = HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Unsupported action in vCont packet");
HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Unsupported action in vCont packet");
break;
}
if (*c == ':')
@ -3194,7 +3204,7 @@ RNBRemote::HandlePacket_p (const char *p)
}
else
{
register_value_in_hex_fixed_width (ostrm, pid, tid, reg_entry);
register_value_in_hex_fixed_width (ostrm, pid, tid, reg_entry, NULL);
}
return SendPacket (ostrm.str());
}

View File

@ -1141,6 +1141,7 @@ main (int argc, char *argv[])
int listen_port = INT32_MAX;
char str[PATH_MAX];
str[0] = '\0';
if (g_lockdown_opt == 0 && g_applist_opt == 0)
{

View File

@ -722,7 +722,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
{
// Skip any options we consumed with getopt_long
argc -= optind;
argv += optind;
//argv += optind; // Commented out to keep static analyzer happy
if (argc > 0)
::fprintf (out_fh, "Warning: program arguments are ignored when attaching.\n");