[lldb-dev] Platform code should check for null
Greg Clayton
gclayton at apple.com
Tue Nov 6 09:51:21 PST 2012
I fixed:
% svn commit source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
Sending source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
Transmitting file data .
Committed revision 167471.
I didn't see any others besides the one in TargetList.cpp:
if (error.Success() && exe_module_sp)
{
if (exe_module_sp->GetObjectFile() == NULL)
{
if (arch.IsValid())
{
error.SetErrorStringWithFormat("\"%s%s%s\" doesn't contain architecture %s",
file.GetDirectory().AsCString(),
file.GetDirectory() ? "/" : "",
file.GetFilename().AsCString(),
arch.GetArchitectureName());
}
else
{
error.SetErrorStringWithFormat("unsupported file type \"%s%s%s\"",
file.GetDirectory().AsCString(),
file.GetDirectory() ? "/" : "",
file.GetFilename().AsCString());
}
return error;
}
This already checks the module.
On Nov 6, 2012, at 5:19 AM, Carlo Kok <ck at remobjects.com> wrote:
> Platform*.ResolveExecutable has code like:
>
> error = ModuleList::GetSharedModule (module_spec,
> exe_module_sp,
> module_search_paths_ptr,
> NULL,
> NULL);
>
> if (exe_module_sp->GetObjectFile() == NULL)
> {
> exe_module_sp.reset();
> error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s",
> exe_file.GetDirectory().AsCString(""),
> exe_file.GetDirectory() ? "/" : "",
> exe_file.GetFilename().AsCString(""),
> exe_arch.GetArchitectureName());
> }
>
>
> However if for whatever reason the file doesn't load (corrupt, missing, plugin not compiled in? etc) exe_module_sp is null. IMO that check needs to check exe_module_sp too.
>
> if (exe_module_sp == NULL || exe_module_sp->GetObjectFile() == NULL)
>
> so it gives a nice error instead of a memory access error.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
More information about the lldb-dev
mailing list