Commit graph

298 commits

Author SHA1 Message Date
Tim-Philipp Müller
ee0619ec66 gstdebug: fix occasional deadlocks on windows when outputting debug logging
When outputting debug logs on Windows, some sections are protected
with a non-recursive lock. Turns out though that gst_debug_message_get()
might indirectly, via our printf format extensions, call code which
in turn would try to log something when it can't handle something. If
that happens we end up in gst_debug_log_default() again recursively and
try to again take the lock that's already taken, thus deadlocking.

Format the debug message string outside of the critical section
instead to avoid this.

https://bugzilla.gnome.org/show_bug.cgi?id=784382
2018-04-11 23:19:46 +01:00
Jan Alexander Steffens (heftig)
0b293cad89 gstinfo: fix debug levels being applied in the wrong order
Remove unneeded reapplication of patterns. Besides being
superfluous (gst_debug_reset_threshold already applies
patterns) it was also wrong and didn't stop checking patterns
after the first match (broken in 67e9d139).

Also fix up unit test which checked for the wrong order.

https://bugzilla.gnome.org/show_bug.cgi?id=794717
2018-04-05 20:01:16 +01:00
Arun Raghavan
b5028383ab gst: Fix up a bunch of GIR annotations
This is mostly on nullable return values, and some other minor ones that
I ran across.

https://bugzilla.gnome.org/show_bug.cgi?id=789319
2018-01-27 10:41:24 +00:00
Tim-Philipp Müller
3aa5ff37cd info: reset default threshold to LEVEL_DEFAULT not 0
in set_threshold_from_string().
2018-01-11 11:36:53 +00:00
Tim-Philipp Müller
9b944f7fd0 info: always check match patterns for new debug categories
Not only if a match pattern was set originally via GST_DEBUG.
Patterns might be set programmatically as well after all.
2017-12-02 12:51:17 +00:00
Tim-Philipp Müller
67e9d13950 info: fix performance issue with registering categories after gst_init()
When registering a new debug category after gst_init(), simply check
the existing patterns against that new category.

No need to iterate over all categories and recheck them all against
the existing patterns.

Also, no need to re-parse the existing pattern string set via GST_DEBUG
and add the same set of match patterns all over again to the existing
list of match patterns every time we register a new debug category.

Combined with iterating all debug categories on a change this would
make adding debug categories after gst_init() very very very slow.
2017-12-02 12:51:17 +00:00
Edward Hervey
a066522ad9 gstinfo: Use free instead of g_free
Because
2017-11-25 13:07:12 +01:00
Edward Hervey
4ac09c73f6 gstinfo: Don't leak array of strings
The array provided by backtrace_symbols needs to be freed.
2017-11-25 12:44:11 +01:00
Tim-Philipp Müller
a79503a433 info: fix build with gst debugging disabled 2017-07-29 10:28:03 +01:00
Sebastian Dröge
ad0dd860c9 debug: Add a memory ringbuffer based debug logger
This stores debug logs in memory per thread and uses up to a
configurable amount of bytes per thread for the logs. Inactive threads
are timed out after a configurable amount of time.

https://bugzilla.gnome.org/show_bug.cgi?id=785035
2017-07-28 17:27:51 +01:00
Sebastian Dröge
04676df4a8 info: Move debug output in for_each_threshold_by_entry() to TRACE level
It's otherwise appearing many, many times in logs and usually is nothing
you're interested in.
2017-04-19 17:32:17 +01:00
Thibault Saunier
94da8f5d8d info: Check libunwind return codes 2017-01-27 16:49:56 -03:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Stefan Sauer
ee52459a5e info: re-eval GST_DEBUG env var for late categories
When registering a new debug category after _debug_init(), we need to
re check the GST_DEBUG filter settings again.
In addition when parsing the filter setting, we need to already bump up
the min-debug level to not suppress debug log statments that dynamically
register a category. This happens in libraries that use a function to
register a category on first use.
2016-12-30 12:10:15 +01:00
Thibault Saunier
97b6d8fb12 gst: Fix building with msvc 2016-12-13 09:21:16 -03:00
Thibault Saunier
33616d47be info: Add a 'flags' parametter to gst_debug_get_stack_trace
This is an API break but that API has not been released yet.

We are passing a flag rather than a simple boolean as we can imagine
to implement more features in the future for example to retrieve a
stack trace for all the threads, etc..

Retrieving source file and line numbers is pretty
expensive while getting a stack trace, this new argument
allows the user to decide to retrieve a backtrace
without those infos instead which is much faster.

For example running $ GST_LEAKS_TRACER_STACK_TRACE=1 GST_DEBUG=GST_TRACER:7 \
GST_TRACERS=leaks time gst-launch-1.0 videotestsrc num-buffers=1 ! fakesink:

* With simple stack traces:

    0.04s user 0.02s system 99% cpu 0.060 total

* With full stack traces:

    0.66s user 0.23s system 96% cpu 0.926 total

https://bugzilla.gnome.org/show_bug.cgi?id=775423
2016-12-12 15:06:20 -03:00
Thibault Saunier
dbe3d2b328 info: Properly start and end dwfl sessions when getting stack traces
We were creating a new session to retrive each line of a stack trace
and we are supposed to start it once for a whole stack trace.

And pass the whole file to gst-indent.

https://bugzilla.gnome.org/show_bug.cgi?id=775365
2016-12-06 14:06:43 -03:00
Tim-Philipp Müller
66d2bae604 Add gst_print(), gst_println(), gst_printerr(), gst_printerrln()
Useful for debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=766470
2016-11-12 10:43:55 +00:00
Guillaume Desmottes
24a09d1b6d info: add GstStream and GstStreamCollection support to gst_debug_print_object()
https://bugzilla.gnome.org/show_bug.cgi?id=769220
2016-11-11 13:22:25 +00:00
Thibault Saunier
e6c8c53fbe debug: Remove the Gst only based stack trace printing implementation
We now have 2 other implementations that should work better.

https://bugzilla.gnome.org/show_bug.cgi?id=772555
2016-11-04 14:22:05 -03:00
Thibault Saunier
a8d4857555 gst: Use libunwind/libdw to generate backtraces if avalaible
Making the gst_debug_print_trace function more generally useful.

API:
  + gst_debug_get_trace

https://bugzilla.gnome.org/show_bug.cgi?id=772555
2016-11-04 14:22:05 -03:00
Stian Selnes
287645c2d7 info: Replace %p and %r in GST_DEBUG_FILE
It's useful to be able to set a name pattern for GST_DEBUG_FILE so that
the same environment variable can be used for multiple processes and
still write to different files. Especially useful if these processes
run simultaneously.

%p: Replaced with PID
%r: Replaced with random number

%p is obviously useful. %r is useful when for instance running two
processes with same PID but in different containers.

https://bugzilla.gnome.org/show_bug.cgi?id=773092
2016-11-01 20:32:46 +02:00
Tim-Philipp Müller
89f5df1782 g-i: info: allow passing NULL to gst_debug_remove_log_function()
Useful for removing the default handler from bindings.
2016-08-26 12:05:16 +01:00
Luis de Bethencourt
1bb699446a info: only open log file when adding it to the log function
This avoids the leak of opening it and then not passing it or closing it
before it goes out of scope.
2016-04-02 10:47:57 +01:00
Tim-Philipp Müller
50888062ba info: make it possible to remove default log handler before gst_init()
Make sure it's not even added then, so that we never output
anything via the default log handler then.

https://bugzilla.gnome.org/show_bug.cgi?id=751538
2016-03-26 11:40:43 +00:00
Evan Nemerson
d11e657412 docs: annotate C examples as such
https://bugzilla.gnome.org/show_bug.cgi?id=731292
2016-02-15 17:45:15 +00:00
Stefan Sauer
4859494945 tracer: add an internal ptr format for tracer serialisation
We need to apply the string wrapping that value serialisation does also in the
tracer logging, otherwise we can't parse nested structures.
2016-01-20 09:14:12 +01:00
Matthew Waters
347734e529 info: expose debugging printf functions
Other gst libraries and/or elements may want to add some debug logging to an
external debug system or implement delayed debugging for performance reasons.

Exposes the internal __gst_vasprintf as gst_info_vasprintf which has a fallback
to g_vasprintf if the debug system is disabled.

API: gst_info_vasprintf
API: gst_info_strdup_vprintf
API: gst_info_strdup_printf

https://bugzilla.gnome.org/show_bug.cgi?id=760421
2016-01-13 11:56:14 +11:00
Tim-Philipp Müller
4febebb962 info: add buffer list support to GST_PTR_FORMAT 2016-01-08 19:25:24 +00:00
Sebastian Dröge
d787105fd5 gst: Rename _priv_gst_info_start_time to _priv_gst_start_time and initialize it centrally
It's used by the debugging and tracer subsystem and in various files, make it
a central thing that is initialized independ of the existence of those
subsystems.
2016-01-07 18:41:25 +02:00
Jason Litzinger
1b881ecc26 gstinfo: fix infinite loop in gst_debug_unset_threshold_for_name()
Ensure iterator is advanced. The current list iteration code only
advances the iterator (walk) if a match is found, which results
in an infinite loop when more than one entry exists in the list.

https://bugzilla.gnome.org/show_bug.cgi?id=748321
2015-04-23 11:20:25 +01:00
Alex Ashley
abdafb0d64 protection: add GstProtectionMeta to support protected content
In order to support some types of protected streams (such as those
protected using DASH Common Encryption) some per-buffer information
needs to be passed between elements.

This commit adds a GstMeta type called GstProtectionMeta that allows
protection specific information to be added to a GstBuffer. An example
of its usage is qtdemux providing information to each output sample
that enables a downstream element to decrypt it.

This commit adds a utility function to select a supported protection
system from the installed Decryption elements found in the registry.
The gst_protection_select_system function that takes an array of
identifiers and searches the registry for a element of klass Decryptor that
supports one or more of the supplied identifiers. If multiple elements
are found, the one with the highest rank is selected.

This commit adds a unit test for the gst_protection_select_system
function that adds a fake Decryptor element to the registry and then
checks that it can correctly be selected by the utility function.

This commit adds a unit test for GstProtectionMeta that creates
GstProtectionMeta and adds & removes it from a buffer and performs some
simple reference count checks.

API: gst_buffer_add_protection_meta()
API: gst_buffer_get_protection_meta()
API: gst_protection_select_system()
API: gst_protection_meta_api_get_type()
API: gst_protection_meta_get_info()

https://bugzilla.gnome.org/show_bug.cgi?id=705991
2015-04-18 12:24:06 +01:00
Tim-Philipp Müller
bcbe8d0f01 docs: fix cross-reference to environment variables in GstInfo
https://bugzilla.gnome.org/show_bug.cgi?id=747416
2015-04-06 18:56:25 +01:00
Tim-Philipp Müller
2d92f5e6d8 info: move category level threshold check into log function dispatcher
Minor optimisation: check category log level earlier in the
log function dispatcher and not only in the default log
function.

https://bugzilla.gnome.org/show_bug.cgi?id=745213
2015-03-12 13:16:22 +00:00
Tim-Philipp Müller
bd7d1c8b61 Fix double semicolons 2015-03-10 09:24:28 +00:00
Tim-Philipp Müller
4e777233f5 info: avoid malloc/free if log object is NULL 2015-03-05 18:30:45 +00:00
Tim-Philipp Müller
5764316a8e info: move __FILE__ path shortening into default log handler
Instead of always shortening the __FILE__ path, even if the
log message is not actually printed, which might happen if
the log level is activated but the category is not, only
shorten the path if we're actually going to output it and
if it looks like it needs shortening. Log handlers had no
guarantee that they would get a name instead of a path
anyway on any architecture, so it shouldn't be a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=745213
2015-03-05 17:57:58 +00:00
Peter Urbanec
6cbe86dc58 info: shorten __FILE__ on all platforms
This is useful not only for MSVC, but also with gcc/Linux
when doing cross-compilation builds and out-of-tree builds.

https://bugzilla.gnome.org/show_bug.cgi?id=745213
2015-03-05 17:53:16 +00:00
Tim-Philipp Müller
9f58aa080a info: nicer buffer offset printing when offsets are not set
Print unset offsets as 'none' instead of humongous numbers,
for better readability.
2015-02-16 19:36:11 +00:00
Sebastian Dröge
154eefecc9 Don't compare booleans for equality to TRUE and FALSE
TRUE is 1, but every other non-zero value is also considered true. Comparing
for equality with TRUE would only consider 1 but not the others.

Also normalize booleans in a few places.
2014-12-01 09:51:37 +01:00
Tim-Philipp Müller
70d692c431 info: remove confusing warning about running under valgrind
We're not actually doing anything differently anywhere when
we detect that we're running under valgrind, so let's not
print that confusing message that makes people wonder how
they can switch it off so they can valgrind the normal
code paths. Seeing that we're not doing that nor have done
so in the last 10 years we might just as well remove the
entire check actually.
2014-09-25 18:55:03 +01:00
Stefan Sauer
a528dadb98 info: avoid global variable for log_file
Use user_data to pass the log_file handle to the logger-function.

If one wants to change the log target (e.g. GST_DEBUG_FILE), simply call
gst_debug_remove_log_function() and re-add the handler with the new log-target
using gst_debug_add_log_function ().
2014-09-17 09:47:36 +02:00
Tim-Philipp Müller
b65a7a7034 info: make printing datetimes work with GST_PTR_FORMAT 2014-06-03 23:49:26 +01:00
Wim Taymans
36d4c4c218 info: first handle all miniobjects, then GObjects
First handle all miniobjects before we attempt to dereference the first
field pointer and look at the GType. With the recent glib change to
speed up G_IS_OBJECT, this causes crashes on miniobjects otherwise.
2014-06-03 14:47:17 +02:00
Wim Taymans
460be3e124 info: GstDateTime does not have a GType as first field
GstDateTime does not have the GType as the first field so we can't use
it to detect its type.
2014-06-03 14:46:11 +02:00
Wim Taymans
e457739ac9 info: use macros to check types
Use the macros to check the type of objects instead of directly poking
at the first field.
2014-06-03 14:45:22 +02:00
Evan Nemerson
e10266e3f3 docs: convert NULL, TRUE, and FALSE to %NULL, %TRUE, and %FALSE
This should help improve documentation generated for
languages other than C.

https://bugzilla.gnome.org/show_bug.cgi?id=730961
2014-05-30 00:20:27 +01:00
Stefan Sauer
c068b225fe docs: convert the examples to use gtk-doc markup, instead of docbook
The gtk-doc markup is less intrusive and better handled when creating docs for
language bindings. The titles (where used) where not adding much.
2014-02-27 18:11:35 +01:00
Stefan Sauer
0264bbdb46 info: move some env-var checks from gst to gstinfo as well
We were doing some log related initialisation in gst.c after calling
_priv_gst_debug_init(). Just move it there for consistency.
2014-01-16 20:47:53 +01:00
Wim Taymans
42d36b9495 info: debug segment offset field as well 2014-01-08 15:04:00 +01:00