udev: move DEVICE_TRACE() to udev-trace.h

It is only used by udevd, and not necessary in src/shared.
This commit is contained in:
Yu Watanabe
2023-07-18 23:10:32 +09:00
parent 2f7862cc57
commit 1c3edc2ee3
5 changed files with 38 additions and 32 deletions

View File

@@ -1,11 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#if HAVE_SYS_SDT_H
#define SDT_USE_VARIADIC
#include <sys/sdt.h>
#endif
#include "sd-device.h"
#include "time-util.h"
@@ -55,30 +50,3 @@ bool devpath_conflict(const char *a, const char *b);
int udev_queue_is_empty(void);
bool udev_available(void);
#if HAVE_SYS_SDT_H
/* Each trace point can have different number of additional arguments. Note that when the macro is used only
* additional arguments are listed in the macro invocation!
*
* Default arguments for each trace point are as follows:
* - arg0 - action
* - arg1 - sysname
* - arg2 - syspath
* - arg3 - subsystem
*/
#define DEVICE_TRACE_POINT(name, dev, ...) \
do { \
PROTECT_ERRNO; \
const char *_n = NULL, *_p = NULL, *_s = NULL; \
sd_device *_d = (dev); \
sd_device_action_t _a = _SD_DEVICE_ACTION_INVALID; \
(void) sd_device_get_action(_d, &_a); \
(void) sd_device_get_sysname(_d, &_n); \
(void) sd_device_get_syspath(_d, &_p); \
(void) sd_device_get_subsystem(_d, &_s); \
STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
} while (false);
#else
#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
#endif

View File

@@ -31,6 +31,7 @@
#include "udev-builtin.h"
#include "udev-event.h"
#include "udev-node.h"
#include "udev-trace.h"
#include "udev-util.h"
#include "udev-watch.h"
#include "user-util.h"

View File

@@ -32,6 +32,7 @@
#include "udev-event.h"
#include "udev-node.h"
#include "udev-rules.h"
#include "udev-trace.h"
#include "udev-util.h"
#include "user-util.h"
#include "virt.h"

35
src/udev/udev-trace.h Normal file
View File

@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#if HAVE_SYS_SDT_H
#define SDT_USE_VARIADIC
#include <sys/sdt.h>
#include "device-private.h"
#include "device-util.h"
#include "errno-util.h"
/* Each trace point can have different number of additional arguments. Note that when the macro is used only
* additional arguments are listed in the macro invocation!
*
* Default arguments for each trace point are as follows:
* - arg0 - action
* - arg1 - sysname
* - arg2 - syspath
* - arg3 - subsystem
*/
#define DEVICE_TRACE_POINT(name, dev, ...) \
do { \
PROTECT_ERRNO; \
const char *_n = NULL, *_p = NULL, *_s = NULL; \
sd_device *_d = (dev); \
sd_device_action_t _a = _SD_DEVICE_ACTION_INVALID; \
(void) sd_device_get_action(_d, &_a); \
(void) sd_device_get_sysname(_d, &_n); \
(void) sd_device_get_syspath(_d, &_p); \
(void) sd_device_get_subsystem(_d, &_s); \
STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
} while (false);
#else
#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
#endif

View File

@@ -69,6 +69,7 @@
#include "udev-ctrl.h"
#include "udev-event.h"
#include "udev-node.h"
#include "udev-trace.h"
#include "udev-util.h"
#include "udev-watch.h"
#include "user-util.h"