validate: Use gst_debug_get_stack_trace instead of our implementation
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 8 Nov 2016 21:06:19 +0000 (18:06 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Wed, 9 Nov 2016 13:55:40 +0000 (10:55 -0300)
And remove now useless config.h.meson file

validate/config.h.meson [deleted file]
validate/configure.ac
validate/gst/validate/Makefile.am
validate/gst/validate/gst-validate-report.c
validate/gst/validate/meson.build
validate/meson.build

diff --git a/validate/config.h.meson b/validate/config.h.meson
deleted file mode 100644 (file)
index 26c3d9a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* GStreamer API Version */
-#mesondefine GST_API_VERSION
-
-/* data dir */
-#mesondefine GST_DATADIR
-
-/* Define to the full name of this package. */
-#mesondefine PACKAGE_NAME
-
-/* directory where plugins are located */
-#mesondefine VALIDATEPLUGINDIR
-#mesondefine HAVE_UNWIND
-#mesondefine HAVE_BACKTRACE
-#mesondefine HAVE_DW
-#mesondefine GST_LICENSE
-#mesondefine VERSION
-#mesondefine PACKAGE
-#mesondefine PACKAGE_VERSION
-#mesondefine GST_PACKAGE_NAME
-#mesondefine GST_PACKAGE_ORIGIN
index 7b309867b11ea540e5a2306338d2d69fcb127608..abd68198997976013a02e7014256043f8620a002 100644 (file)
@@ -205,26 +205,6 @@ PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0)
 AC_SUBST(JSON_GLIB_LIBS)
 AC_SUBST(JSON_GLIB_CFLAGS)
 
-dnl libunwind is optionally used to generate backtraces
-PKG_CHECK_MODULES(UNWIND, libunwind, HAVE_UNWIND=yes, HAVE_UNWIND=no)
-if test "x$HAVE_UNWIND" = "xyes"; then
-  AC_DEFINE(HAVE_UNWIND, 1, [libunwind available])
-fi
-
-dnl libdw is optionally used to add source lines and numbers to backtraces
-PKG_CHECK_MODULES(DW, libdw, HAVE_DW=yes, HAVE_DW=no)
-if test "x$HAVE_DW" = "xyes"; then
-  AC_DEFINE(HAVE_DW, 1, [libdw available])
-fi
-
-dnl Check for backtrace() from libc
-AC_CHECK_FUNC(backtrace, [
-  AC_CHECK_HEADERS([execinfo.h], [
-    AC_DEFINE(HAVE_BACKTRACE,1,[Have backtrace])
-  ], [], [])
-])
-
-
 dnl checks for gstreamer
 
 AG_GST_CHECK_GST_CHECK($GST_API_VERSION, [$GST_REQ], no)
index 04e4784e112d6625e16f93d6b68b919b5d27b4f7..a87ed78a44e26f190a1f371c3550645622be0df3 100644 (file)
@@ -51,15 +51,13 @@ libgstvalidate_@GST_API_VERSION@_la_SOURCES = $(source_c)
 libgstvalidate_@GST_API_VERSION@include_HEADERS = $(source_h)
 libgstvalidate_@GST_API_VERSION@_la_CFLAGS = $(GST_ALL_CFLAGS)\
        $(JSON_GLIB_CFLAGS) $(GIO_CFLAGS) $(GST_PBUTILS_CFLAGS) \
-       $(DW_CFLAGS) \
        -DGST_USE_UNSTABLE_API
 libgstvalidate_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) \
        $(GST_LT_LDFLAGS) $(GIO_LDFLAGS) $(GST_PBUTILS_LDFAGS)
 libgstvalidate_@GST_API_VERSION@_la_LIBADD = \
        $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
        $(GST_ALL_LIBS) $(GIO_LIBS) $(GST_PBUTILS_LIBS) \
-       $(JSON_GLIB_LIBS) $(GLIB_LIBS) $(LIBM) $(UNWIND_LIBS) \
-       $(DW_LIBS)
+       $(JSON_GLIB_LIBS) $(GLIB_LIBS) $(LIBM)
 
 libgstvalidate_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/validate
 
@@ -68,7 +66,6 @@ plugin_LTLIBRARIES = libgstvalidateplugin-@GST_API_VERSION@.la
 libgstvalidateplugin_@GST_API_VERSION@_la_SOURCES = $(source_c)
 libgstvalidateplugin_@GST_API_VERSION@_la_CFLAGS = $(GST_ALL_CFLAGS)\
        $(JSON_GLIB_CFLAGS) $(GIO_CFLAGS) $(GST_PBUTILS_CFLAGS) \
-       $(DW_CFLAGS) \
        -DGST_USE_UNSTABLE_API \
        -D__GST_VALIDATE_PLUGIN
 libgstvalidateplugin_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) \
@@ -76,8 +73,7 @@ libgstvalidateplugin_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL
 libgstvalidateplugin_@GST_API_VERSION@_la_LIBADD = \
        $(JSON_GLIB_CFLAGS) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
        $(GST_ALL_LIBS) $(GIO_LIBS) $(GST_PBUTILS_LIBS) \
-       $(JSON_GLIB_LIBS) $(GLIB_LIBS) $(LIBM) $(UNWIND_LIBS) \
-       $(DW_LIBS)
+       $(JSON_GLIB_LIBS) $(GLIB_LIBS) $(LIBM)
 
 CLEANFILES =
 
index dac0ca4d1bfd3a5be33e3922c89abf3cccb3f03f..835c2a5afd035b2f53395ee5faf1d3eb63bc5e1c 100644 (file)
 #  include "config.h"
 #endif
 
-#ifdef HAVE_UNWIND
-/* No need for remote debugging so turn on the 'local only' optimizations in
- * libunwind */
-#define UNW_LOCAL_ONLY
-#include <libunwind.h>
-#endif /* HAVE_UNWIND */
-
 
 #include <stdio.h>              /* fprintf */
 #include <glib/gstdio.h>
@@ -58,141 +51,6 @@ GOutputStream *server_ostream = NULL;
 
 GType _gst_validate_report_type = 0;
 
-#ifdef HAVE_UNWIND
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <assert.h>
-
-#ifdef HAVE_DW
-#include <elfutils/libdwfl.h>
-#include <libunwind.h>
-static void
-append_debug_info (GString * trace, const void *ip)
-{
-
-  char *debuginfo_path = NULL;
-  Dwarf_Addr addr;
-  Dwfl_Module *module;
-  const char *function_name;
-  Dwfl_Line *line;
-
-  Dwfl_Callbacks callbacks = {
-    .find_elf = dwfl_linux_proc_find_elf,
-    .find_debuginfo = dwfl_standard_find_debuginfo,
-    .debuginfo_path = &debuginfo_path,
-  };
-
-  Dwfl *dwfl = dwfl_begin (&callbacks);
-
-  assert (dwfl != NULL);
-
-  assert (dwfl_linux_proc_report (dwfl, getpid ()) == 0);
-  assert (dwfl_report_end (dwfl, NULL, NULL) == 0);
-
-  addr = (uintptr_t) ip;
-
-  module = dwfl_addrmodule (dwfl, addr);
-
-  function_name = dwfl_module_addrname (module, addr);
-
-  g_string_append_printf (trace, "%s(", function_name ? function_name : "??");
-
-  line = dwfl_getsrc (dwfl, addr);
-  if (line != NULL) {
-    int nline;
-    Dwarf_Addr addr;
-    const char *filename = dwfl_lineinfo (line, &addr,
-        &nline, NULL, NULL, NULL);
-    g_string_append_printf (trace, "%s:%d", strrchr (filename, '/') + 1, nline);
-  } else {
-    const gchar *eflfile = NULL;
-
-    dwfl_module_info (module, NULL, NULL, NULL, NULL, NULL, &eflfile, NULL);
-    g_string_append_printf (trace, "%s:%p", eflfile ? eflfile : "??", ip);
-  }
-}
-#endif
-
-static gchar *
-generate_unwind_trace (void)
-{
-  unw_context_t uc;
-  unw_cursor_t cursor;
-  GString *trace = g_string_new (NULL);
-
-  unw_getcontext (&uc);
-  unw_init_local (&cursor, &uc);
-
-  while (unw_step (&cursor) > 0) {
-#ifdef HAVE_DW
-    unw_word_t ip;
-
-    unw_get_reg (&cursor, UNW_REG_IP, &ip);
-    append_debug_info (trace, (void *) (ip - 4));
-    g_string_append (trace, ")\n");
-#else
-    char name[32];
-
-    unw_word_t offset;
-    unw_get_proc_name (&cursor, name, sizeof (name), &offset);
-    g_string_append_printf (trace, "%s (0x%lx)\n", name, (long) offset);
-#endif
-  }
-
-  return g_string_free (trace, FALSE);
-}
-
-#endif /* HAVE_UNWIND */
-
-#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
-#define BT_BUF_SIZE 100
-static gchar *
-generate_backtrace_trace (void)
-{
-  int j, nptrs;
-  void *buffer[BT_BUF_SIZE];
-  char **strings;
-  GString *trace;
-
-  trace = g_string_new (NULL);
-  nptrs = backtrace (buffer, BT_BUF_SIZE);
-
-  strings = backtrace_symbols (buffer, nptrs);
-
-  if (!strings)
-    return NULL;
-
-  for (j = 0; j < nptrs; j++)
-    g_string_append_printf (trace, "%s\n", strings[j]);
-
-  return g_string_free (trace, FALSE);
-}
-#endif /* HAVE_BACKTRACE */
-
-static gchar *
-generate_trace (void)
-{
-  gchar *trace = NULL;
-
-#ifdef HAVE_UNWIND
-  trace = generate_unwind_trace ();
-  if (trace)
-    return trace;
-#endif /* HAVE_UNWIND */
-
-#ifdef HAVE_BACKTRACE
-  trace = generate_backtrace_trace ();
-#endif /* HAVE_BACKTRACE */
-
-
-  return trace;
-}
-
 static JsonNode *
 gst_validate_report_serialize (GstValidateReport * report)
 {
@@ -841,7 +699,7 @@ gst_validate_report_new (GstValidateIssue * issue,
       issue_type_details == GST_VALIDATE_SHOW_ALL ||
       gst_validate_report_check_abort (report) ||
       report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL)
-    report->trace = generate_trace ();
+    report->trace = gst_debug_get_stack_trace ();
 
   return report;
 }
index 976922ba64fc461a86ee17df716c63b7e01e1710..7bd283a58420e46750528281d4691bacc0302f39 100644 (file)
@@ -46,8 +46,7 @@ gstvalidate = shared_library('gstvalidate-1.0',
     install: true,
     c_args : [gst_c_args] + ['-D_GNU_SOURCE'],
     dependencies : [gst_dep, glib_dep, gio_dep, gmodule_dep,
-                    gst_pbutils_dep, mathlib, json_dep,
-                    unwind_dep, dw_dep])
+                    gst_pbutils_dep, mathlib, json_dep])
 
 gstvalidate = shared_library('gstvalidateplugin',
     sources: gstvalidate_sources,
@@ -56,8 +55,7 @@ gstvalidate = shared_library('gstvalidateplugin',
     c_args : [gst_c_args] + ['-D__GST_VALIDATE_PLUGIN', '-D_GNU_SOURCE'],
     install_dir : '@0@/gstreamer-1.0'.format(get_option('libdir')),
     dependencies : [gst_dep, glib_dep, gio_dep, gmodule_dep,
-                    gst_pbutils_dep, mathlib, json_dep, unwind_dep,
-                    dw_dep])
+                    gst_pbutils_dep, mathlib, json_dep])
 
 validate_gen_sources = []
 if build_gir
index 96a17d75125bd79ae6aa6ad391ca7c54e7a4137a..e6bdc559b682b11b08769967976913543266f4bc 100644 (file)
@@ -2,24 +2,6 @@ inc_dirs = include_directories('.')
 
 cdata = configuration_data()
 
-unwind_dep = dependency('libunwind', required : false)
-dw_dep = dependency('libdw', required: false)
-if unwind_dep.found()
-  cdata.set('HAVE_UNWIND', 1)
-  if dw_dep.found()
-    cdata.set('HAVE_DW', 1)
-  else
-    message('Support for backtraces is partial only.')
-  endif
-else
-  if cc.has_function('backtrace')
-    cdata.set('HAVE_BACKTRACE', 1)
-  else
-      message('NO backtraces support.')
-  endif
-endif
-
-
 cdata.set('GST_LICENSE', '"LGPL"')
 cdata.set('VERSION', '"@0@"'.format(gst_version))
 cdata.set('PACKAGE', '"gst-validate"')
@@ -30,9 +12,7 @@ cdata.set('VALIDATEPLUGINDIR', '"@0@/@1@/gstreamer-1.0/validate"'.format(get_opt
 cdata.set('GST_DATADIR', '"@0@/@1@"'.format(prefix, get_option('datadir')))
 cdata.set('PACKAGE_NAME', '"GStreamer Validate"')
 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
-configure_file(input : 'config.h.meson',
-  output : 'config.h',
-  configuration : cdata)
+configure_file(output : 'config.h', configuration : cdata)
 
 subdir('data')
 subdir('gst')