[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] How to get debug output
Pretty trivial change, IMHO...
--- a/opal/event/libevent/log-internal.h Wed Oct 13 07:34:24 2010 -0500
+++ b/opal/event/libevent/log-internal.h Thu Oct 14 09:00:04 2010 -0600
@@ -29,6 +29,8 @@
#include <event2/util.h>
+#include <stdbool.h>
+
#ifdef __GNUC__
#define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b)))
#define EV_NORETURN __attribute__((noreturn))
@@ -48,7 +50,7 @@
void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2);
void _event_debugx(const char *fmt, ...) EV_CHECK_FMT(1,2);
-#ifdef USE_DEBUG
+#ifndef _EVENT_DISABLE_DEBUG_MODE
#define event_debug(x) _event_debugx x
#else
#define event_debug(x) do {;} while (0)
@@ -56,4 +58,6 @@
#undef EV_CHECK_FMT
+extern bool event_enable_debug_output;
+
#endif
--- a/opal/event/libevent/log.c Wed Oct 13 07:34:24 2010 -0500
+++ b/opal/event/libevent/log.c Thu Oct 14 09:00:04 2010 -0600
@@ -63,6 +63,8 @@
static event_fatal_cb fatal_fn = NULL;
+bool event_enable_debug_output = false;
+
void
event_set_fatal_callback(event_fatal_cb cb)
{
@@ -161,6 +163,10 @@
{
va_list ap;
+ if (!event_enable_debug_output) {
+ return;
+ }
+
va_start(ap, fmt);
_warn_helper(_EVENT_LOG_DEBUG, NULL, fmt, ap);
va_end(ap);
I then created OMPI API to set the debug output flag - imagine you would need to do something similar in libevent itself.
HTH
Ralph
On Oct 12, 2010, at 9:53 AM, Nick Mathewson wrote:
> On Tue, Oct 12, 2010 at 11:50 AM, Ralph Castain <rhc@xxxxxxxxxxxx> wrote:
>>
>> On Oct 12, 2010, at 8:59 AM, Nick Mathewson wrote:
>>
>>> On Tue, Oct 12, 2010 at 10:55 AM, Ralph Castain <rhc@xxxxxxxxxxxx> wrote:
>>>> Hi folks
>>>>
>>>> I apologize for the ignorance - I'm sure this is something simple that I'm overlooking.
>>>>
>>>> I built libevent 2.0.7rc with the default configuration, so I did -not- specify --disable-debug. It is my understanding that the debug code is therefore built. I have confirmed that this is the case.
>>>>
>>>> I then have my code call event_enable_debug_mode prior to calling event_init. However, I never get any debug output sent to my screen, even though I confirmed that I am calling event_assign, event_add, and other libevent functions.
>>>>
>>>> Any suggestions on what I'm doing wrong?
>>>> Ralph
>>>
>>> There are two debugging features here: event debugging mode, and the
>>> verbose debug logs you're talking about. Debug mode is a feature for
>>> debugging your program; it turns on checks for incorrect uses of
>>> events. To get debugging output sent to stdout, rebuild with
>>> "-DUSE_DEBUG" in the CPPFLAGS.
>>
>> Ouch - ick. It comes out all the time now.
>>
>> I gather that you only have a compile-time flag to toggle this output? I was hoping for a run-time option. Otherwise, we have to rebuild the system every time we want to debug something, which is an annoyance.
>
> I'm afraid there isn't a run-time option for this. If somebody wants
> to submit a patch to write one, and you can do it efficiently, I'd be
> glad to take it in the 2.1 series.
>
> For now, could you build two copies of libevent -- one with debugging
> logs and one without -- and use LD_PRELOAD (or another appropriate
> linker option, depending on your platform) to switch in the debugging
> one when you want to use it? It's not beautiful, but it should work
> out okay for most applications.
>
> --
> Nick
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users in the body.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.