- Make opal_output_stream_t be a real opal_object_t so that it can use
a constructor, like the rest of the code base - Convert usage in the tree to use the constructor to zero out an instance of opal_output_stream_t - Still need to re-enable output files This commit was SVN r7253.
Этот коммит содержится в:
родитель
8ec6721f24
Коммит
4aa75fa739
@ -63,19 +63,7 @@ mca_btl_portals_component_t mca_btl_portals_component = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static opal_output_stream_t portals_output_stream = {
|
static opal_output_stream_t portals_output_stream;
|
||||||
true, /* is debugging */
|
|
||||||
0, /* verbose level */
|
|
||||||
0, /* want syslog */
|
|
||||||
0, /* syslog priority */
|
|
||||||
NULL, /* syslog ident */
|
|
||||||
NULL, /* prefix */
|
|
||||||
true, /* want stdout */
|
|
||||||
false, /* want stderr */
|
|
||||||
false, /* want file */
|
|
||||||
false, /* file append */
|
|
||||||
"btl-portals" /* file suffix */
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mca_btl_portals_component_open(void)
|
mca_btl_portals_component_open(void)
|
||||||
@ -88,6 +76,10 @@ mca_btl_portals_component_open(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* start up debugging output */
|
/* start up debugging output */
|
||||||
|
OBJ_CONSTRUCT(&portals_output_stream, opal_output_stream_t);
|
||||||
|
portals_output_stream.lds_is_debugging = true;
|
||||||
|
portals_output_stream.lds_want_stdout = true;
|
||||||
|
portals_output_stream.lds_file_suffix = "btl-portals";
|
||||||
mca_base_param_reg_int(&mca_btl_portals_component.super.btl_version,
|
mca_base_param_reg_int(&mca_btl_portals_component.super.btl_version,
|
||||||
"debug_level",
|
"debug_level",
|
||||||
"Debugging verbosity (0 - 100)",
|
"Debugging verbosity (0 - 100)",
|
||||||
|
@ -61,7 +61,8 @@ mca_ptl_portals_component_t mca_ptl_portals_component = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static opal_output_stream_t portals_output_stream = {
|
static opal_output_stream_t portals_output_stream;
|
||||||
|
{
|
||||||
true, /* is debugging */
|
true, /* is debugging */
|
||||||
0, /* verbose level */
|
0, /* verbose level */
|
||||||
0, /* want syslog */
|
0, /* want syslog */
|
||||||
@ -121,6 +122,11 @@ mca_ptl_portals_component_open(void)
|
|||||||
OBJ_CONSTRUCT(&mca_ptl_portals_component.portals_lock,
|
OBJ_CONSTRUCT(&mca_ptl_portals_component.portals_lock,
|
||||||
opal_mutex_t);
|
opal_mutex_t);
|
||||||
|
|
||||||
|
OBJ_CONSTRUCT(&portals_output_stream, opal_output_stream_t);
|
||||||
|
portals_output_stream.lds_is_debugging = true;
|
||||||
|
portals_output_stream.lds_want_stdout = true;
|
||||||
|
portals_output_stream.lds_file_suffix = "ptl-portals";
|
||||||
|
|
||||||
/* register portals module parameters */
|
/* register portals module parameters */
|
||||||
#if PTL_PORTALS_UTCP
|
#if PTL_PORTALS_UTCP
|
||||||
mca_ptl_portals_component.portals_ifname =
|
mca_ptl_portals_component.portals_ifname =
|
||||||
@ -203,7 +209,7 @@ mca_ptl_portals_component_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != portals_output_stream.lds_prefix) {
|
if (NULL != portals_output_stream.lds_prefix) {
|
||||||
free(portals_output_stream.lds_prefix);
|
portals_output_stream.lds_prefix = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
opal_output_close(mca_ptl_portals_component.portals_output);
|
opal_output_close(mca_ptl_portals_component.portals_output);
|
||||||
|
@ -112,19 +112,12 @@ static void set_defaults(opal_output_stream_t *lds)
|
|||||||
{
|
{
|
||||||
/* Load up defaults */
|
/* Load up defaults */
|
||||||
|
|
||||||
lds->lds_is_debugging = false;
|
OBJ_CONSTRUCT(lds, opal_output_stream_t);
|
||||||
lds->lds_verbose_level = 0;
|
|
||||||
lds->lds_want_syslog = false;
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
lds->lds_syslog_priority = LOG_INFO;
|
lds->lds_syslog_priority = LOG_INFO;
|
||||||
#endif
|
#endif
|
||||||
lds->lds_syslog_ident = "ompi";
|
lds->lds_syslog_ident = "ompi";
|
||||||
lds->lds_want_stdout = false;
|
|
||||||
lds->lds_want_stderr = true;
|
lds->lds_want_stderr = true;
|
||||||
lds->lds_want_file = false;
|
|
||||||
lds->lds_want_file_append = false;
|
|
||||||
lds->lds_file_suffix = NULL;
|
|
||||||
lds->lds_file_suffix = "mca.txt";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,8 +130,9 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
|
|||||||
char *ptr, *next;
|
char *ptr, *next;
|
||||||
bool have_output = false;
|
bool have_output = false;
|
||||||
|
|
||||||
if (NULL == e)
|
if (NULL == e) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
edup = strdup(e);
|
edup = strdup(e);
|
||||||
ptr = edup;
|
ptr = edup;
|
||||||
|
@ -49,28 +49,19 @@ int opal_malloc_output = -1;
|
|||||||
/*
|
/*
|
||||||
* Private variables
|
* Private variables
|
||||||
*/
|
*/
|
||||||
static opal_output_stream_t malloc_stream = {
|
static opal_output_stream_t malloc_stream;
|
||||||
/* debugging */
|
|
||||||
true,
|
|
||||||
/* verbose level */
|
|
||||||
5,
|
|
||||||
/* syslog */
|
|
||||||
false, 0, NULL,
|
|
||||||
/* prefix */
|
|
||||||
"malloc_debug: ",
|
|
||||||
/* stdout */
|
|
||||||
false,
|
|
||||||
/* stderr */
|
|
||||||
true,
|
|
||||||
/* file */
|
|
||||||
false, false, NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the malloc debug interface
|
* Initialize the malloc debug interface
|
||||||
*/
|
*/
|
||||||
void opal_malloc_init(void)
|
void opal_malloc_init(void)
|
||||||
{
|
{
|
||||||
|
OBJ_CONSTRUCT(&malloc_stream, opal_output_stream_t);
|
||||||
|
malloc_stream.lds_is_debugging = true;
|
||||||
|
malloc_stream.lds_verbose_level = 5;
|
||||||
|
malloc_stream.lds_prefix = "malloc debug: ";
|
||||||
|
malloc_stream.lds_want_stderr = true;
|
||||||
opal_malloc_output = opal_output_open(&malloc_stream);
|
opal_malloc_output = opal_output_open(&malloc_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +74,7 @@ void opal_malloc_finalize(void)
|
|||||||
if (-1 != opal_malloc_output) {
|
if (-1 != opal_malloc_output) {
|
||||||
opal_output_close(opal_malloc_output);
|
opal_output_close(opal_malloc_output);
|
||||||
opal_malloc_output = -1;
|
opal_malloc_output = -1;
|
||||||
|
OBJ_DESTRUCT(&malloc_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,25 +40,13 @@
|
|||||||
* Private data
|
* Private data
|
||||||
*/
|
*/
|
||||||
static int verbose_stream = -1;
|
static int verbose_stream = -1;
|
||||||
static opal_output_stream_t verbose = {
|
static opal_output_stream_t verbose;
|
||||||
/* debugging */
|
|
||||||
false,
|
|
||||||
/* verbose level */
|
|
||||||
0,
|
|
||||||
/* syslog */
|
|
||||||
false, 0, NULL, NULL,
|
|
||||||
/* stdout */
|
|
||||||
false,
|
|
||||||
/* stderr */
|
|
||||||
true,
|
|
||||||
/* file */
|
|
||||||
false, false, NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private functions
|
* Private functions
|
||||||
*/
|
*/
|
||||||
|
static void construct(opal_object_t *stream);
|
||||||
static int do_open(int output_id, opal_output_stream_t * lds);
|
static int do_open(int output_id, opal_output_stream_t * lds);
|
||||||
static int open_file(int i);
|
static int open_file(int i);
|
||||||
static void free_descriptor(int output_id);
|
static void free_descriptor(int output_id);
|
||||||
@ -111,6 +99,8 @@ static opal_mutex_t mutex;
|
|||||||
static bool syslog_opened = false;
|
static bool syslog_opened = false;
|
||||||
|
|
||||||
|
|
||||||
|
OBJ_CLASS_INSTANCE(opal_output_stream_t, opal_object_t, construct, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the output stream infrastructure
|
* Setup the output stream infrastructure
|
||||||
*/
|
*/
|
||||||
@ -122,6 +112,9 @@ bool opal_output_init(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OBJ_CONSTRUCT(&verbose, opal_output_stream_t);
|
||||||
|
verbose.lds_want_stderr = true;
|
||||||
|
|
||||||
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
|
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
|
||||||
info[i].ldi_used = false;
|
info[i].ldi_used = false;
|
||||||
info[i].ldi_enabled = false;
|
info[i].ldi_enabled = false;
|
||||||
@ -238,7 +231,7 @@ void opal_output_close(int output_id)
|
|||||||
/* Setup */
|
/* Setup */
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
opal_output_init();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it's valid, used, enabled, and has an open file descriptor,
|
/* If it's valid, used, enabled, and has an open file descriptor,
|
||||||
@ -273,6 +266,7 @@ void opal_output_close(int output_id)
|
|||||||
temp_str = NULL;
|
temp_str = NULL;
|
||||||
temp_str_len = 0;
|
temp_str_len = 0;
|
||||||
}
|
}
|
||||||
|
OBJ_DESTRUCT(&verbose);
|
||||||
OPAL_THREAD_UNLOCK(&mutex);
|
OPAL_THREAD_UNLOCK(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +322,25 @@ void opal_output_finalize(void)
|
|||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
static void construct(opal_object_t *obj)
|
||||||
|
{
|
||||||
|
opal_output_stream_t *stream = (opal_output_stream_t*) obj;
|
||||||
|
|
||||||
|
stream->lds_is_debugging = false;
|
||||||
|
stream->lds_verbose_level = 0;
|
||||||
|
stream->lds_want_syslog = false;
|
||||||
|
stream->lds_syslog_priority = 0;
|
||||||
|
stream->lds_syslog_ident = NULL;
|
||||||
|
stream->lds_prefix = NULL;
|
||||||
|
stream->lds_want_stdout = false;
|
||||||
|
stream->lds_want_file = false;
|
||||||
|
stream->lds_want_file_append = false;
|
||||||
|
stream->lds_file_suffix = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Back-end of open() and reopen(). Necessary to have it as a
|
* Back-end of open() and reopen(). Necessary to have it as a
|
||||||
* back-end function so that we can do the thread locking properly
|
* back-end function so that we can do the thread locking properly
|
||||||
|
@ -63,6 +63,8 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "opal/class/opal_object.h"
|
||||||
|
|
||||||
#if defined(c_plusplus) || defined(__cplusplus)
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -80,10 +82,11 @@ extern "C" {
|
|||||||
* Note that all strings in this struct are cached on the stream by
|
* Note that all strings in this struct are cached on the stream by
|
||||||
* value; there is no need to keep them allocated after the return
|
* value; there is no need to keep them allocated after the return
|
||||||
* from opal_output_open().
|
* from opal_output_open().
|
||||||
*
|
|
||||||
* @see output.h
|
|
||||||
*/
|
*/
|
||||||
struct opal_output_stream_t {
|
struct opal_output_stream_t {
|
||||||
|
/** Class parent */
|
||||||
|
opal_object_t super;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the output of the stream is
|
* Indicates whether the output of the stream is
|
||||||
* debugging/developer-only output or not.
|
* debugging/developer-only output or not.
|
||||||
@ -197,8 +200,19 @@ struct opal_output_stream_t {
|
|||||||
char *lds_file_suffix;
|
char *lds_file_suffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct opal_output_stream_t opal_output_stream_t;
|
/**
|
||||||
|
* Convenience typedef
|
||||||
|
*/
|
||||||
|
typedef struct opal_output_stream_t opal_output_stream_t;
|
||||||
|
/**
|
||||||
|
* Declare the class of this type. Note that the constructor for
|
||||||
|
* this class is for convenience only -- it is \em not necessary
|
||||||
|
* to be invoked. If the constructor it used, it sets all values
|
||||||
|
* in the struct to be false / 0 (i.e., turning off all output).
|
||||||
|
* The intended usage is to invoke the constructor and then enable
|
||||||
|
* the output fields that you want.
|
||||||
|
*/
|
||||||
|
OBJ_CLASS_DECLARATION(opal_output_stream_t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the output stream system and opens a default
|
* Initializes the output stream system and opens a default
|
||||||
|
@ -22,12 +22,18 @@
|
|||||||
|
|
||||||
int opal_trace_handle;
|
int opal_trace_handle;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local state
|
||||||
|
*/
|
||||||
|
static opal_output_stream_t tracer;
|
||||||
|
|
||||||
|
|
||||||
void opal_trace_init(void)
|
void opal_trace_init(void)
|
||||||
{
|
{
|
||||||
#if OPAL_ENABLE_TRACE
|
#if OPAL_ENABLE_TRACE
|
||||||
opal_output_stream_t tracer;
|
|
||||||
|
|
||||||
/* get a file setup for opal_output to use for the trace */
|
/* get a file setup for opal_output to use for the trace */
|
||||||
|
OBJ_CONSTRUCT(&tracer, opal_output_stream_t);
|
||||||
tracer.lds_file_suffix = "trace";
|
tracer.lds_file_suffix = "trace";
|
||||||
tracer.lds_want_file = true;
|
tracer.lds_want_file = true;
|
||||||
|
|
||||||
@ -39,5 +45,6 @@ void opal_trace_finalize(void)
|
|||||||
{
|
{
|
||||||
#if OPAL_ENABLE_TRACE
|
#if OPAL_ENABLE_TRACE
|
||||||
opal_output_close(opal_trace_handle);
|
opal_output_close(opal_trace_handle);
|
||||||
|
OBJ_DESTRUCT(&tracer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user