Skip to content

[lldb] Don't crash when attaching to pid and no binaries found #100287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lldb/source/Commands/CommandObjectProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,25 +369,23 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach {

// Okay, we're done. Last step is to warn if the executable module has
// changed:
char new_path[PATH_MAX];
ModuleSP new_exec_module_sp(target->GetExecutableModule());
if (!old_exec_module_sp) {
// We might not have a module if we attached to a raw pid...
if (new_exec_module_sp) {
new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
result.AppendMessageWithFormat("Executable module set to \"%s\".\n",
new_path);
result.AppendMessageWithFormat(
"Executable binary set to \"%s\".\n",
new_exec_module_sp->GetFileSpec().GetPath().c_str());
}
} else if (!new_exec_module_sp) {
result.AppendWarningWithFormat("No executable binary.");
} else if (old_exec_module_sp->GetFileSpec() !=
new_exec_module_sp->GetFileSpec()) {
char old_path[PATH_MAX];

old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX);
new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);

result.AppendWarningWithFormat(
"Executable module changed from \"%s\" to \"%s\".\n", old_path,
new_path);
"Executable binary changed from \"%s\" to \"%s\".\n",
old_exec_module_sp->GetFileSpec().GetPath().c_str(),
new_exec_module_sp->GetFileSpec().GetPath().c_str());
}

if (!old_arch_spec.IsValid()) {
Expand Down
Loading