Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
backtrace: kill two unused functions
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 27 Oct 2018 16:18:49 +0000 (18:18 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 27 Oct 2018 16:37:16 +0000 (18:37 +0200)
include/xbt/backtrace.hpp
src/xbt/backtrace_dummy.cpp
src/xbt/backtrace_linux.cpp
src/xbt/mmalloc/mmalloc.c

index 7801fb8..cfcd475 100644 (file)
@@ -20,18 +20,6 @@ SG_END_DECL()
 
 typedef void* xbt_backtrace_location_t;
 
-/** @brief reimplementation of glibc backtrace based directly on gcc library, without implicit malloc  */
-XBT_PUBLIC int xbt_backtrace_no_malloc(void** bt, int size);
-
-/** @brief Captures a backtrace for further use */
-XBT_PUBLIC size_t xbt_backtrace_current(xbt_backtrace_location_t* loc, size_t count);
-
-/** @brief Display a previously captured backtrace */
-XBT_PUBLIC void xbt_backtrace_display(xbt_backtrace_location_t* loc, size_t count);
-
-/** @brief Get current backtrace with libunwind */
-XBT_PUBLIC int xbt_libunwind_backtrace(void** bt, int size);
-
 namespace simgrid {
 namespace xbt {
 
@@ -61,4 +49,10 @@ XBT_PUBLIC std::vector<std::string> resolve_backtrace(xbt_backtrace_location_t c
 }
 }
 
+/** @brief Captures a backtrace for further use */
+XBT_PUBLIC size_t xbt_backtrace_current(xbt_backtrace_location_t* loc, size_t count);
+
+/** @brief Display a previously captured backtrace */
+XBT_PUBLIC void xbt_backtrace_display(xbt_backtrace_location_t* loc, size_t count);
+
 #endif
index 5f978bb..1d98b2a 100644 (file)
@@ -16,10 +16,6 @@ size_t xbt_backtrace_current(xbt_backtrace_location_t* loc, size_t count)
   return 0;
 }
 
-int xbt_backtrace_no_malloc(void **array, int size) {
-  return 0;
-}
-
 namespace simgrid {
 namespace xbt {
 
index 232e1f7..e0f687a 100644 (file)
 #include "xbt/log.h"
 #include "xbt/module.h"         /* xbt_binary_name */
 #include "src/xbt_modinter.h"       /* backtrace initialization headers */
-#if SIMGRID_HAVE_MC
-#define UNW_LOCAL_ONLY
-#include <libunwind.h>
-#endif
 /* end of "useless" inclusions */
 
-extern char **environ;          /* the environment, as specified by the opengroup */
-
-#include <unwind.h>
-struct trace_arg {
-  void** array;
-  int cnt;
-  int size;
-};
-
-static _Unwind_Reason_Code backtrace_helper(_Unwind_Context* ctx, void* a)
-{
-  trace_arg* arg = static_cast<trace_arg*>(a);
-
-  /* We are first called with address in the __backtrace function.
-     Skip it.  */
-  if (arg->cnt != -1)
-    {
-      arg->array[arg->cnt] = (void *) _Unwind_GetIP(ctx);
-
-      /* Check whether we make any progress.  */
-      if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt])
-        return _URC_END_OF_STACK;
-    }
-  if (++arg->cnt == arg->size)
-    return _URC_END_OF_STACK;
-  return _URC_NO_REASON;
-}
-
-/** @brief reimplementation of glibc backtrace based directly on gcc library, without implicit malloc
- *
- * See http://people.irisa.fr/Martin.Quinson/blog/2012/0208/system_programming_fun_in_SimGrid/
- * for the motivation behind this function
- * */
-
-int xbt_backtrace_no_malloc(void **array, int size) {
-  int i = 0;
-  for(i=0; i < size; i++)
-    array[i] = nullptr;
-
-  struct trace_arg arg;
-  arg .array = array;
-  arg.size = size;
-  arg.cnt = -1;
-
-  if (size >= 1)
-    _Unwind_Backtrace(backtrace_helper, &arg);
-
-  /* _Unwind_Backtrace on IA-64 seems to put nullptr address above
-     _start.  Fix it up here.  */
-  if (arg.cnt > 1 && arg.array[arg.cnt - 1] == nullptr)
-    --arg.cnt;
-  return arg.cnt != -1 ? arg.cnt : 0;
-}
-
 size_t xbt_backtrace_current(xbt_backtrace_location_t* loc, std::size_t count)
 {
   std::size_t used = backtrace(loc, count);
@@ -341,27 +283,3 @@ std::vector<std::string> resolve_backtrace(xbt_backtrace_location_t const* loc,
 
 }
 }
-
-#if SIMGRID_HAVE_MC
-int xbt_libunwind_backtrace(void** bt, int size){
-  for (int i = 0; i < size; i++)
-    bt[i] = nullptr;
-
-  unw_cursor_t c;
-  unw_context_t uc;
-
-  unw_getcontext (&uc);
-  unw_init_local (&c, &uc);
-
-  unw_step(&c);
-
-  int i;
-  for (i = 0; unw_step(&c) >= 0 && i < size; i++) {
-    unw_word_t ip;
-    unw_get_reg(&c, UNW_REG_IP, &ip);
-    bt[i] = (void*)(long)ip;
-  }
-
-  return i;
-}
-#endif
index 5ab476e..3050083 100644 (file)
@@ -176,10 +176,6 @@ static void mmalloc_mark_used(xbt_mheap_t mdp, size_t block, size_t nblocks, siz
   }
   mdp->heapinfo[block].busy_block.size      = nblocks;
   mdp->heapinfo[block].busy_block.busy_size = requested_size;
-  // mdp->heapinfo[block].busy_block.bt_size =
-  //     xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_block.bt, XBT_BACKTRACE_SIZE);
-  // mdp->heapinfo[block].busy_block.bt_size =
-  //     xbt_libunwind_backtrace(mdp->heapinfo[block].busy_block.bt, XBT_BACKTRACE_SIZE);
   mdp->heapstats.chunks_used++;
   mdp->heapstats.bytes_used += nblocks * BLOCKSIZE;
 }
@@ -242,8 +238,6 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size)
       /* Update our metadata about this fragment */
       candidate_info->busy_frag.frag_size[candidate_frag] = requested_size;
       candidate_info->busy_frag.ignore[candidate_frag] = 0;
-      //xbt_backtrace_no_malloc(candidate_info->busy_frag.bt[candidate_frag],XBT_BACKTRACE_SIZE);
-      //xbt_libunwind_backtrace(candidate_info->busy_frag.bt[candidate_frag],XBT_BACKTRACE_SIZE);
 
       /* Update the statistics.  */
       mdp -> heapstats.chunks_used++;
@@ -274,8 +268,6 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size)
       /* mark the fragment returned as busy */
       mdp->heapinfo[block].busy_frag.frag_size[0] = requested_size;
       mdp->heapinfo[block].busy_frag.ignore[0] = 0;
-      //xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_frag.bt[0],XBT_BACKTRACE_SIZE);
-      //xbt_libunwind_backtrace(mdp->heapinfo[block].busy_frag.bt[0],XBT_BACKTRACE_SIZE);
 
       /* update stats */
       mdp -> heapstats.chunks_free += (BLOCKSIZE >> log) - 1;