mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-24 06:03:59 +08:00
rtemstoolkit/elf,files: Catch exceptions in destructors.
Catch exceptions in destructures and print a message to avoid an unhandled exception happening in an exception stack unwind.
This commit is contained in:
@@ -256,10 +256,12 @@ namespace rld
|
||||
image::~image ()
|
||||
{
|
||||
if (references_)
|
||||
std::cerr << "rtl:file:image: references when destructing";
|
||||
std::cerr << "rtl:file:image: references when destructing" << std::endl;
|
||||
|
||||
if (fd_ >= 0)
|
||||
{
|
||||
::close (fd_);
|
||||
fd_= -1;
|
||||
if (writable && remove)
|
||||
{
|
||||
if (rld::verbose () >= RLD_VERBOSE_INFO)
|
||||
@@ -268,6 +270,22 @@ namespace rld
|
||||
::unlink (name_.path ().c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
elf_.end ();
|
||||
}
|
||||
catch (rld::error re)
|
||||
{
|
||||
std::cerr << "error: rld::files::image:::~image: "
|
||||
<< re.where << ": " << re.what
|
||||
<< std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "error: rld::files::image:::~image: unhandled exception"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -537,8 +555,22 @@ namespace rld
|
||||
|
||||
archive::~archive ()
|
||||
{
|
||||
end ();
|
||||
close ();
|
||||
try
|
||||
{
|
||||
end ();
|
||||
close ();
|
||||
}
|
||||
catch (rld::error re)
|
||||
{
|
||||
std::cerr << "error: rld::files::archive::~archive: "
|
||||
<< re.where << ": " << re.what
|
||||
<< std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "error: rld::files::archive::~archive: unhandled exception"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -960,8 +992,22 @@ namespace rld
|
||||
|
||||
object::~object ()
|
||||
{
|
||||
end ();
|
||||
close ();
|
||||
try
|
||||
{
|
||||
end ();
|
||||
close ();
|
||||
}
|
||||
catch (rld::error re)
|
||||
{
|
||||
std::cerr << "error: rld::files::object::~object: "
|
||||
<< re.where << ": " << re.what
|
||||
<< std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "error: rld::files::object::~object: unhandled exception"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1318,7 +1364,21 @@ namespace rld
|
||||
|
||||
cache::~cache ()
|
||||
{
|
||||
close ();
|
||||
try
|
||||
{
|
||||
close ();
|
||||
}
|
||||
catch (rld::error re)
|
||||
{
|
||||
std::cerr << "error: rld::files:cache::~cache: "
|
||||
<< re.where << ": " << re.what
|
||||
<< std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "error: rld::files::cache::~cache: unhandled exception"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user