This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

try-catch-throw blocks in dwarf_edit/output


Hi,

Another one of these c++ constructs that make me go ehe? questions...
Just wondering why there are these try-catch-throw constructs in
dwarf_edit and dwarf_output. They do some cleanups, but there isn't any
"recatcher" for the failures, so effectively all they do is hide the
root cause when something goes wrong. But I might be missing something.
To help my own debugging I have removed them on my branch.

Cheers,

Mark
commit c651d9058ba1066dc05a059fda6d1d456dc932a4
Author: Mark Wielaard <mjw@redhat.com>
Date:   Tue Feb 1 11:10:09 2011 +0100

    Remove unused try-catch-throw blocks.
    
    There isn't any "recatcher" of these throws, so the only thing the
    cleanup does is hide the original exception in case of error, making
    debugging the root cause harder.

diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit
index e7ed54e..854c276 100644
--- a/libdw/c++/dwarf_edit
+++ b/libdw/c++/dwarf_edit
@@ -164,22 +164,11 @@ namespace elfutils
       template<typename die_type, typename arg_type>
       inline void set (const die_type &die, arg_type &arg)
       {
-	try
-	  {
-	    _m_tag = die.tag ();
-	    attributes_type t_attrs (die.attributes (), arg);
-	    _m_attributes.swap (t_attrs);
-	    children_type t_children (die.children (), arg);
-	    _m_children.swap (t_children);
-	  }
-	catch (...)
-	  {
-	    // Never leave a partially-formed DIE.
-	    _m_tag = -1;
-	    _m_attributes.clear ();
-	    _m_children.clear ();
-	    throw;
-	  };
+	_m_tag = die.tag ();
+	attributes_type t_attrs (die.attributes (), arg);
+	_m_attributes.swap (t_attrs);
+	children_type t_children (die.children (), arg);
+	_m_children.swap (t_children);
       }
 
     public:
diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output
index 04ace96..8b14c6c 100644
--- a/libdw/c++/dwarf_output
+++ b/libdw/c++/dwarf_output
@@ -1875,21 +1875,13 @@ namespace elfutils
 	assert (_m_in->_m_pending == NULL);
 	_m_in->_m_pending = _m_out;
 
-	try
-	  {
-	    // This calls add_reference for each pending reference.
-	    _m_out->_m_attributes.set (in.attributes (), *this);
+	// This calls add_reference for each pending reference.
+	_m_out->_m_attributes.set (in.attributes (), *this);
 
-	    for (input_die_ptr i = in.children ().begin ();
-		 i != in.children ().end ();
-		 ++i)
-	      add_child (*i);
-	  }
-	catch (...)
-	  {
-	    _m_in->_m_pending = NULL;
-	    throw;
-	  }
+	for (input_die_ptr i = in.children ().begin ();
+	     i != in.children ().end ();
+	     ++i)
+	  add_child (*i);
 
 	_m_out = NULL;
 	_m_in->defined_self (_m_copier);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]