validate: Use gst_debug_get_stack_trace instead of our implementation

And remove now useless config.h.meson file
This commit is contained in:
Thibault Saunier 2016-11-08 18:06:19 -03:00
parent 5452672e89
commit 17586b80b1
6 changed files with 6 additions and 214 deletions

View file

@ -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

View 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)

View 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 =

View file

@ -25,13 +25,6 @@
# 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;
}

View 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

View 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')