Commit graph

9 commits

Author SHA1 Message Date
Leandro Ribeiro 23491cd931 weston-log: destroy subscriptions with destruction of subscribers
The subscription is directly related to both the log scope and
the subscriber. It makes no sense to destroy one of them and
keep the subscriptions living.

We only had code to destroy subscription with
the destruction of log scopes. Add code to destroy
subscriptions with destruction of subscribers.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-02-10 10:53:50 +00:00
Leandro Ribeiro 1ded661aac weston-log: merge functions that destroy different types of subscribers
Log subscriber API is not type-safe. File and flight recorder
subscribers are created with functions that return
weston_log_subscriber objects. But there's a problem: to destroy
these objects you have to call the right function for each type
of subscriber, and a user calling the wrong destroy function
wouldn't get a warning.

Merge functions that destroy different types of subscribers, making
the log subscriber API type-safe.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-02-10 10:53:50 +00:00
Leandro Ribeiro 8c02ea1069 weston-log: rename weston_log_subscriber::destroy to destroy_subscription
weston_log_subscriber has a member named destroy. There are
other structs (weston_output, for instance) that have this
member, and by convention it is a pointer to a function
that destroys the struct.

In weston_log_subscriber it is being used to destroy
subscriptions of the debug protocol, and not the subscriber,
so this name is misleading. Rename it to destroy_subscription.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-02-10 10:53:50 +00:00
Pekka Paalanen 8fc4b59bfd weston-log-flight-rec: allow re-running a compositor
weston_primary_flight_recorder_ring_buffer needs to be cleared on destruction
of the subscriber it was assigned from so that a compositor and be re-executed
in-process (static variables do not get re-initialized automatically).

This will be used by the test harness when it will execute wet_main() multiple
times in the same process. Otherwise it would hit the assert in
weston_log_subscriber_create_flight_rec().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-05 11:13:51 +00:00
Marius Vlad d2dbcd3d7e weston-log-flight-rec: Fix useless comparison when displaying the
contents of the flight recorder

The overlap variable is sufficient to determine from where to start
displaying the contents of the ring buffer. Also redundant to verify
if the position in the buffer went over the maximum size.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-25 20:29:49 +00:00
Marius Vlad 0ba0b8e86f weston-log-flight-rec: Don't allow more than one flight recorder to be
created

Having a (single) global variable which others depend on it implies
having a single flight recorder present. Until we have a reason to
support multiple flight recorders limit the amount to a maximum of one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-25 20:29:49 +00:00
Marius Vlad b1f5f8076a weston-log-flight-rec: Add a global variable to access the ring buffer
With it add also a function which can be used in an assert()-like
situation to display the contents of the ring buffer. Within gdb
this call also be called if the program is loaded/still loaded into
memory.

The global variable will be used in a later patch to be accessed from a
python gdb script.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-25 20:29:49 +00:00
Pekka Paalanen c232f8d934 Unify the include style of shared/ headers
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.

This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.

This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with

	#include "libweston/dbus.h"

or even

	#include <libweston/dbus.h>

IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.

The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 16:04:48 +03:00
Marius Vlad 9c3804f8d5 weston-log-flight-rec: Introduce flight recorder stream
Like a black box in an airplane, the flight recorder can be used to
accumulate data and, when needed, to display its contents.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00