summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2016-07-22 14:56:58 +0200
committerDodji Seketeli <dodji@redhat.com>2016-07-26 20:04:23 +0200
commit5a24ffcd6154564c7d51b5391f4a09e664c2f837 (patch)
tree8c6a2fa2768877d6aac4762f237074bbca92dea3
parentPrepare support for symbol visibility control (diff)
downloadlibabigail-5a24ffcd6154564c7d51b5391f4a09e664c2f837.tar.gz
libabigail-5a24ffcd6154564c7d51b5391f4a09e664c2f837.tar.bz2
libabigail-5a24ffcd6154564c7d51b5391f4a09e664c2f837.tar.xz
Add ABG_ASSERT_NOT_REACHED macro
Adding this macro to abort at places where the execution flow shouldn't take us to. Using this is more explicit (self-documented) than using abort. This patch replaces the use of abort() in abg-dwarf-reader.cc. * include/abg-tools-utils.h (ABG_ASSERT_NOT_REACHED): New macro. * src/abg-dwarf-reader.cc (stt_to_elf_symbol_type) (stb_to_elf_symbol_binding, get_elf_class_size_in_bytes) (build_ir_node_from_die): Use the new ABG_ASSERT_NOT_REACHED macro in lieu of just calling abort(). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--include/abg-tools-utils.h13
-rw-r--r--src/abg-dwarf-reader.cc17
2 files changed, 19 insertions, 11 deletions
diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h
index e62dda06..39caae6c 100644
--- a/include/abg-tools-utils.h
+++ b/include/abg-tools-utils.h
@@ -210,6 +210,17 @@ std::tr1::shared_ptr<char>
210make_path_absolute(const char*p); 210make_path_absolute(const char*p);
211 211
212extern const char* PRIVATE_TYPES_SUPPR_SPEC_NAME; 212extern const char* PRIVATE_TYPES_SUPPR_SPEC_NAME;
213
214}// end namespace tools_utils 213}// end namespace tools_utils
214
215/// A macro that expands to aborting the program when executed.
216///
217/// Before aborting, the macro emits informatin about the source
218/// location where it was expanded.
219#define ABG_ASSERT_NOT_REACHED \
220 do { \
221 std::cerr << "in " << __FUNCTION__ \
222 << " at: " << __FILE__ << ":" << __LINE__ \
223 << ": execution should not have reached this point!\n"; \
224 abort(); \
225 } while (false)
215}//end namespace abigail 226}//end namespace abigail
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 008c4253..8e7b36fd 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -296,7 +296,7 @@ stt_to_elf_symbol_type(unsigned char stt)
296 default: 296 default:
297 // An unknown value that probably ought to be supported? Let's 297 // An unknown value that probably ought to be supported? Let's
298 // abort right here rather than yielding garbage. 298 // abort right here rather than yielding garbage.
299 abort(); 299 ABG_ASSERT_NOT_REACHED;
300 } 300 }
301 301
302 return t; 302 return t;
@@ -330,7 +330,7 @@ stb_to_elf_symbol_binding(unsigned char stb)
330 b = elf_symbol::GNU_UNIQUE_BINDING; 330 b = elf_symbol::GNU_UNIQUE_BINDING;
331 break; 331 break;
332 default: 332 default:
333 abort(); 333 ABG_ASSERT_NOT_REACHED;
334 } 334 }
335 335
336 return b; 336 return b;
@@ -1381,7 +1381,7 @@ get_elf_class_size_in_bytes(Elf* elf_handle)
1381 result = 8; 1381 result = 8;
1382 break; 1382 break;
1383 default: 1383 default:
1384 abort(); 1384 ABG_ASSERT_NOT_REACHED;
1385 } 1385 }
1386 1386
1387 return result; 1387 return result;
@@ -9185,8 +9185,7 @@ build_ir_node_from_die(read_context& ctxt,
9185 break; 9185 break;
9186 case DW_TAG_subrange_type: 9186 case DW_TAG_subrange_type:
9187 /* we shouldn't get here as this part is handled by build_array_type */ 9187 /* we shouldn't get here as this part is handled by build_array_type */
9188 abort(); 9188 ABG_ASSERT_NOT_REACHED;
9189 break;
9190 case DW_TAG_thrown_type: 9189 case DW_TAG_thrown_type:
9191 break; 9190 break;
9192 case DW_TAG_interface_type: 9191 case DW_TAG_interface_type:
@@ -9201,8 +9200,7 @@ build_ir_node_from_die(read_context& ctxt,
9201 case DW_TAG_compile_unit: 9200 case DW_TAG_compile_unit:
9202 // We shouldn't reach this point b/c this should be handled by 9201 // We shouldn't reach this point b/c this should be handled by
9203 // build_translation_unit. 9202 // build_translation_unit.
9204 abort(); 9203 ABG_ASSERT_NOT_REACHED;
9205 break;
9206 9204
9207 case DW_TAG_namespace: 9205 case DW_TAG_namespace:
9208 case DW_TAG_module: 9206 case DW_TAG_module:
@@ -9374,8 +9372,7 @@ build_ir_node_from_die(read_context& ctxt,
9374 case DW_TAG_formal_parameter: 9372 case DW_TAG_formal_parameter:
9375 // We should not read this case as it should have been dealt 9373 // We should not read this case as it should have been dealt
9376 // with by build_function_decl above. 9374 // with by build_function_decl above.
9377 abort(); 9375 ABG_ASSERT_NOT_REACHED;
9378 break;
9379 9376
9380 case DW_TAG_constant: 9377 case DW_TAG_constant:
9381 break; 9378 break;
@@ -9387,7 +9384,7 @@ build_ir_node_from_die(read_context& ctxt,
9387 // For now, the DIEs under these are read lazily when they are 9384 // For now, the DIEs under these are read lazily when they are
9388 // referenced by a public decl DIE that is under a 9385 // referenced by a public decl DIE that is under a
9389 // DW_TAG_compile_unit, so we shouldn't get here. 9386 // DW_TAG_compile_unit, so we shouldn't get here.
9390 abort(); 9387 ABG_ASSERT_NOT_REACHED;
9391 9388
9392 // Other declaration we don't really intend to support yet. 9389 // Other declaration we don't really intend to support yet.
9393 case DW_TAG_dwarf_procedure: 9390 case DW_TAG_dwarf_procedure: