* [PATCH 1/4] Fix regression with debug via SIGUSR2
@ 2010-06-04 10:16 Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 2/4] Add debug_string and debug_enabled vars Gustavo F. Padovan
2010-06-04 11:34 ` [PATCH 1/4] Fix regression with debug via SIGUSR2 Johan Hedberg
0 siblings, 2 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-06-04 10:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
The new dynamic debug feature was not using the SIGUSR2 signal so this was
causing bluetoothd to crash when one tries to toogle debug via SIGUSR2.
This patch brings back such compatibility.
---
src/log.c | 31 +++++++++++++++++++++++++++++--
src/log.h | 1 +
src/main.c | 8 ++++++++
3 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/log.c b/src/log.c
index 29e2d7d..4ef178a 100644
--- a/src/log.c
+++ b/src/log.c
@@ -95,9 +95,8 @@ static gboolean is_enabled(struct btd_debug_desc *desc)
return 0;
}
-void __btd_log_init(const char *debug, int detach)
+static void turn_debug_on(const char *debug)
{
- int option = LOG_NDELAY | LOG_PID;
struct btd_debug_desc *desc;
const char *name = NULL, *file = NULL;
@@ -116,6 +115,34 @@ void __btd_log_init(const char *debug, int detach)
if (is_enabled(desc))
desc->flags |= BTD_DEBUG_FLAG_PRINT;
}
+}
+
+static void turn_debug_off()
+{
+ struct btd_debug_desc *desc;
+
+ for (desc = __start___debug; desc < __stop___debug; desc++) {
+ if (is_enabled(desc))
+ desc->flags &= ~BTD_DEBUG_FLAG_PRINT;
+ }
+
+ g_strfreev(enabled);
+ enabled = NULL;
+}
+
+void __btd_toogle_debug()
+{
+ if (enabled == NULL)
+ turn_debug_on("*");
+ else
+ turn_debug_off();
+}
+
+void __btd_log_init(const char *debug, int detach)
+{
+ int option = LOG_NDELAY | LOG_PID;
+
+ turn_debug_on(debug);
if (!detach)
option |= LOG_PERROR;
diff --git a/src/log.h b/src/log.h
index 9af51e7..8c1b937 100644
--- a/src/log.h
+++ b/src/log.h
@@ -30,6 +30,7 @@ void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
void __btd_log_init(const char *debug, int detach);
void __btd_log_cleanup(void);
+void __btd_toogle_debug();
struct btd_debug_desc {
const char *name;
diff --git a/src/main.c b/src/main.c
index 3118a34..d6559b5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,6 +288,11 @@ static void sig_term(int sig)
g_main_loop_quit(event_loop);
}
+static void sig_debug(int sig)
+{
+ __btd_toogle_debug();
+}
+
static gchar *option_debug = NULL;
static gboolean option_detach = TRUE;
static gboolean option_udev = FALSE;
@@ -406,6 +411,9 @@ int main(int argc, char *argv[])
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
+ sa.sa_handler = sig_debug;
+ sigaction(SIGUSR2, &sa, NULL);
+
sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] Add debug_string and debug_enabled vars
2010-06-04 10:16 [PATCH 1/4] Fix regression with debug via SIGUSR2 Gustavo F. Padovan
@ 2010-06-04 10:16 ` Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 3/4] log: Remove vinfo function Gustavo F. Padovan
2010-06-04 11:34 ` [PATCH 1/4] Fix regression with debug via SIGUSR2 Johan Hedberg
1 sibling, 1 reply; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-06-04 10:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
Both will be very useful when we add Debug property to DBus.
---
src/log.c | 10 ++++++++++
src/log.h | 5 ++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/src/log.c b/src/log.c
index 4ef178a..9248c4d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -75,6 +75,9 @@ extern struct btd_debug_desc __start___debug[];
extern struct btd_debug_desc __stop___debug[];
static gchar **enabled = NULL;
+static const char *debug_string = NULL;
+
+int debug_enabled = FALSE;
static gboolean is_enabled(struct btd_debug_desc *desc)
{
@@ -100,9 +103,12 @@ static void turn_debug_on(const char *debug)
struct btd_debug_desc *desc;
const char *name = NULL, *file = NULL;
+
if (debug != NULL)
enabled = g_strsplit_set(debug, ":, ", 0);
+ debug_enabled = TRUE;
+
for (desc = __start___debug; desc < __stop___debug; desc++) {
if (file != NULL || name != NULL) {
if (g_strcmp0(desc->file, file) == 0) {
@@ -121,6 +127,8 @@ static void turn_debug_off()
{
struct btd_debug_desc *desc;
+ debug_enabled = FALSE;
+
for (desc = __start___debug; desc < __stop___debug; desc++) {
if (is_enabled(desc))
desc->flags &= ~BTD_DEBUG_FLAG_PRINT;
@@ -142,6 +150,8 @@ void __btd_log_init(const char *debug, int detach)
{
int option = LOG_NDELAY | LOG_PID;
+ debug_string = debug;
+
turn_debug_on(debug);
if (!detach)
diff --git a/src/log.h b/src/log.h
index 8c1b937..235430e 100644
--- a/src/log.h
+++ b/src/log.h
@@ -24,6 +24,8 @@
#ifndef __LOGGING_H
#define __LOGGING_H
+extern int debug_enabled;
+
void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -53,7 +55,8 @@ struct btd_debug_desc {
__attribute__((used, section("__debug"), aligned(8))) = { \
.file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
}; \
- if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
+ if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT \
+ && debug_enabled) \
debug("%s:%s() " fmt, \
__FILE__, __FUNCTION__ , ## arg); \
} while (0)
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] log: Remove vinfo function
2010-06-04 10:16 ` [PATCH 2/4] Add debug_string and debug_enabled vars Gustavo F. Padovan
@ 2010-06-04 10:16 ` Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 4/4] Adjust define name to the name of the file Gustavo F. Padovan
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-06-04 10:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
It was used only once.
---
src/log.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/src/log.c b/src/log.c
index 9248c4d..f113fa6 100644
--- a/src/log.c
+++ b/src/log.c
@@ -33,18 +33,13 @@
#include "log.h"
-static inline void vinfo(const char *format, va_list ap)
-{
- vsyslog(LOG_INFO, format, ap);
-}
-
void info(const char *format, ...)
{
va_list ap;
va_start(ap, format);
- vinfo(format, ap);
+ vsyslog(LOG_INFO, format, ap);
va_end(ap);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] Adjust define name to the name of the file
2010-06-04 10:16 ` [PATCH 3/4] log: Remove vinfo function Gustavo F. Padovan
@ 2010-06-04 10:16 ` Gustavo F. Padovan
2010-06-04 10:59 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-06-04 10:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
---
src/log.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/log.h b/src/log.h
index 235430e..7a5942c 100644
--- a/src/log.h
+++ b/src/log.h
@@ -21,8 +21,8 @@
*
*/
-#ifndef __LOGGING_H
-#define __LOGGING_H
+#ifndef __LOG_H
+#define __LOG_H
extern int debug_enabled;
@@ -61,4 +61,4 @@ struct btd_debug_desc {
__FILE__, __FUNCTION__ , ## arg); \
} while (0)
-#endif /* __LOGGING_H */
+#endif /* __LOG_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] Adjust define name to the name of the file
2010-06-04 10:16 ` [PATCH 4/4] Adjust define name to the name of the file Gustavo F. Padovan
@ 2010-06-04 10:59 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2010-06-04 10:59 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Gustavo,
On Fri, Jun 4, 2010 at 1:16 PM, Gustavo F. Padovan <gustavo@padovan.org> wrote:
> ---
> src/log.h | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/log.h b/src/log.h
> index 235430e..7a5942c 100644
> --- a/src/log.h
> +++ b/src/log.h
> @@ -21,8 +21,8 @@
> *
> */
>
> -#ifndef __LOGGING_H
> -#define __LOGGING_H
> +#ifndef __LOG_H
> +#define __LOG_H
>
> extern int debug_enabled;
>
> @@ -61,4 +61,4 @@ struct btd_debug_desc {
> __FILE__, __FUNCTION__ , ## arg); \
> } while (0)
>
> -#endif /* __LOGGING_H */
> +#endif /* __LOG_H */
I remember Marcel being against this since it hides real dependency circle.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] Fix regression with debug via SIGUSR2
2010-06-04 10:16 [PATCH 1/4] Fix regression with debug via SIGUSR2 Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 2/4] Add debug_string and debug_enabled vars Gustavo F. Padovan
@ 2010-06-04 11:34 ` Johan Hedberg
1 sibling, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2010-06-04 11:34 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Gustavo,
On Fri, Jun 04, 2010, Gustavo F. Padovan wrote:
> +static void turn_debug_on(const char *debug)
Please call this simply debug_on()
> +static void turn_debug_off()
same here (debug_off)
> +void __btd_toogle_debug()
It's called toggle and not toogle :)
> + if (enabled == NULL)
> + turn_debug_on("*");
I suppose this should restore the previous value and not hard-code "*"?
Johan
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] Fix regression with debug via SIGUSR2
@ 2010-06-05 2:23 Gustavo F. Padovan
0 siblings, 0 replies; 7+ messages in thread
From: Gustavo F. Padovan @ 2010-06-05 2:23 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
The new dynamic debug feature was not using the SIGUSR2 signal so this was
causing bluetoothd to crash when one tries to toggle debug via SIGUSR2.
This patch brings back such compatibility.
---
src/log.c | 31 +++++++++++++++++++++++++++++--
src/log.h | 1 +
src/main.c | 8 ++++++++
3 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/log.c b/src/log.c
index 29e2d7d..1c0f0b9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -95,9 +95,8 @@ static gboolean is_enabled(struct btd_debug_desc *desc)
return 0;
}
-void __btd_log_init(const char *debug, int detach)
+static void debug_on(const char *debug)
{
- int option = LOG_NDELAY | LOG_PID;
struct btd_debug_desc *desc;
const char *name = NULL, *file = NULL;
@@ -116,6 +115,34 @@ void __btd_log_init(const char *debug, int detach)
if (is_enabled(desc))
desc->flags |= BTD_DEBUG_FLAG_PRINT;
}
+}
+
+static void debug_off()
+{
+ struct btd_debug_desc *desc;
+
+ for (desc = __start___debug; desc < __stop___debug; desc++) {
+ if (is_enabled(desc))
+ desc->flags &= ~BTD_DEBUG_FLAG_PRINT;
+ }
+
+ g_strfreev(enabled);
+ enabled = NULL;
+}
+
+void __btd_toggle_debug()
+{
+ if (enabled == NULL)
+ debug_on("*");
+ else
+ debug_off();
+}
+
+void __btd_log_init(const char *debug, int detach)
+{
+ int option = LOG_NDELAY | LOG_PID;
+
+ debug_on(debug);
if (!detach)
option |= LOG_PERROR;
diff --git a/src/log.h b/src/log.h
index 9af51e7..a1530da 100644
--- a/src/log.h
+++ b/src/log.h
@@ -30,6 +30,7 @@ void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
void __btd_log_init(const char *debug, int detach);
void __btd_log_cleanup(void);
+void __btd_toggle_debug();
struct btd_debug_desc {
const char *name;
diff --git a/src/main.c b/src/main.c
index 3118a34..ba18523 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,6 +288,11 @@ static void sig_term(int sig)
g_main_loop_quit(event_loop);
}
+static void sig_debug(int sig)
+{
+ __btd_toggle_debug();
+}
+
static gchar *option_debug = NULL;
static gboolean option_detach = TRUE;
static gboolean option_udev = FALSE;
@@ -406,6 +411,9 @@ int main(int argc, char *argv[])
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
+ sa.sa_handler = sig_debug;
+ sigaction(SIGUSR2, &sa, NULL);
+
sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-06-05 2:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-04 10:16 [PATCH 1/4] Fix regression with debug via SIGUSR2 Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 2/4] Add debug_string and debug_enabled vars Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 3/4] log: Remove vinfo function Gustavo F. Padovan
2010-06-04 10:16 ` [PATCH 4/4] Adjust define name to the name of the file Gustavo F. Padovan
2010-06-04 10:59 ` Luiz Augusto von Dentz
2010-06-04 11:34 ` [PATCH 1/4] Fix regression with debug via SIGUSR2 Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2010-06-05 2:23 Gustavo F. Padovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).