aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/core/fsm.h64
-rw-r--r--include/osmocom/core/logging.h36
-rw-r--r--include/osmocom/core/tdef.h4
3 files changed, 79 insertions, 25 deletions
diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 77ebe7c1..9ff58731 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -202,6 +202,34 @@ void osmo_fsm_set_dealloc_ctx(void *ctx);
#define OSMO_T_FMT "%c%u"
#define OSMO_T_FMT_ARGS(T) ((T) >= 0 ? 'T' : 'X'), ((T) >= 0 ? T : -T)
+/* FSM Tracing Macros */
+#define TRACEPFSMENTSRC(fi, file, line, func, fmt, args...) \
+ TRACEPSRC((fi)->fsm->log_subsys, TRACEOP_ENTFUN, \
+ file, line, func, \
+ "fsminst=%p name=%s id=%s state=%s%s" fmt, fi, \
+ (fi)->fsm->name, (fi)->id, \
+ osmo_fsm_state_name((fi)->fsm, (fi)->state), \
+ fmt[0] ? " " : "", ## args)
+#define TRACEPFSMEXTSRC(fi, file, line, func, fmt, args...) \
+ TRACEPSRC((fi)->fsm->log_subsys, TRACEOP_EXTFUN, \
+ file, line, func, fmt, ##args)
+#define TRACEPFSMATTRSRC(fi, file, line, func, fmt, args...) \
+ TRACEPSRC((fi)->fsm->log_subsys, TRACEOP_ATTR, \
+ file, line, func, fmt, ##args)
+
+#define TRACEPFSMENT(fi, fmt, args...) \
+ TRACEP((fi)->fsm->log_subsys, TRACEOP_ENTFUN, \
+ "fsminst=%p name=%s id=%s state=%s%s" fmt, fi, \
+ (fi)->fsm->name, (fi)->id, \
+ osmo_fsm_state_name((fi)->fsm, (fi)->state), \
+ fmt[0] ? " " : "", ## args)
+
+#define TRACEPFSMEXT(fi, fmt, args...) \
+ TRACEP((fi)->fsm->log_subsys, TRACEOP_EXTFUN, fmt, ##args)
+
+#define TRACEPFSMATTR(fi, fmt, args...) \
+ TRACEP((fi)->fsm->log_subsys, TRACEOP_ATTR, fmt, ##args)
+
int osmo_fsm_register(struct osmo_fsm *fsm);
void osmo_fsm_unregister(struct osmo_fsm *fsm);
struct osmo_fsm *osmo_fsm_find_by_name(const char *name);
@@ -240,17 +268,17 @@ static inline const char *osmo_fsm_inst_state_name(struct osmo_fsm_inst *fi)
*/
#define osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T) \
_osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state,
unsigned long timeout_secs, int T,
- const char *file, int line);
+ const char *file, int line, const char *func);
#define osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T) \
_osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_state_chg_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
unsigned long timeout_ms, int T,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! perform a state change while keeping the current timer running.
*
@@ -263,9 +291,9 @@ int _osmo_fsm_inst_state_chg_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
*/
#define osmo_fsm_inst_state_chg_keep_timer(fi, new_state) \
_osmo_fsm_inst_state_chg_keep_timer(fi, new_state, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_state,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! perform a state change while keeping the current timer if running, or starting a timer otherwise.
*
@@ -277,17 +305,17 @@ int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_s
*/
#define osmo_fsm_inst_state_chg_keep_or_start_timer(fi, new_state, timeout_secs, T) \
_osmo_fsm_inst_state_chg_keep_or_start_timer(fi, new_state, timeout_secs, T, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_state_chg_keep_or_start_timer(struct osmo_fsm_inst *fi, uint32_t new_state,
unsigned long timeout_secs, int T,
- const char *file, int line);
+ const char *file, int line, const char *func);
#define osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T) \
_osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
unsigned long timeout_ms, int T,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! dispatch an event to an osmocom finite state machine instance
@@ -297,9 +325,9 @@ int _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(struct osmo_fsm_inst *fi, ui
* purposes. See there for documentation.
*/
#define osmo_fsm_inst_dispatch(fi, event, data) \
- _osmo_fsm_inst_dispatch(fi, event, data, __FILE__, __LINE__)
+ _osmo_fsm_inst_dispatch(fi, event, data, __FILE__, __LINE__, __func__)
int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! Terminate FSM instance with given cause
*
@@ -308,10 +336,10 @@ int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data
* See there for documentation.
*/
#define osmo_fsm_inst_term(fi, cause, data) \
- _osmo_fsm_inst_term(fi, cause, data, __FILE__, __LINE__)
+ _osmo_fsm_inst_term(fi, cause, data, __FILE__, __LINE__, __func__)
void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi,
enum osmo_fsm_term_cause cause, void *data,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! Terminate all child FSM instances of an FSM instance.
*
@@ -320,11 +348,11 @@ void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi,
* purposes. See there for documentation.
*/
#define osmo_fsm_inst_term_children(fi, cause, data) \
- _osmo_fsm_inst_term_children(fi, cause, data, __FILE__, __LINE__)
+ _osmo_fsm_inst_term_children(fi, cause, data, __FILE__, __LINE__, __func__)
void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi,
enum osmo_fsm_term_cause cause,
void *data,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! dispatch an event to all children of an osmocom finite state machine instance
*
@@ -333,8 +361,8 @@ void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi,
* purposes. See there for documentation.
*/
#define osmo_fsm_inst_broadcast_children(fi, cause, data) \
- _osmo_fsm_inst_broadcast_children(fi, cause, data, __FILE__, __LINE__)
+ _osmo_fsm_inst_broadcast_children(fi, cause, data, __FILE__, __LINE__, __func__)
void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi, uint32_t event,
- void *data, const char *file, int line);
+ void *data, const char *file, int line, const char *func);
/*! @} */
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index c7f89dea..d27c4a3c 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -50,10 +50,7 @@ void logp(int subsys, const char *file, int line, int cont, const char *format,
* \param[in] args variable argument list
*/
#define LOGPC(ss, level, fmt, args...) \
- do { \
- if (log_check_level(ss, level)) \
- logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \
- } while(0)
+ LOGPSRCC(ss, level, NULL, 0, 1, fmt, ##args)
/*! Log through the Osmocom logging framework with explicit source.
* If caller_file is passed as NULL, __FILE__ and __LINE__ are used
@@ -85,6 +82,7 @@ void logp(int subsys, const char *file, int line, int cont, const char *format,
*/
#define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) \
do { \
+ TRACEPEVTSRC(ss, level, caller_file, caller_line, __func__, fmt, ##args); \
if (log_check_level(ss, level)) {\
if (caller_file) \
logp2(ss, level, caller_file, caller_line, cont, fmt, ##args); \
@@ -93,6 +91,33 @@ void logp(int subsys, const char *file, int line, int cont, const char *format,
}\
} while(0)
+#define TRACEOP_ENTFUN "ENTER"
+#define TRACEOP_EXTFUN "EXIT"
+#define TRACEOP_ATTR "ATTR"
+#define TRACEOP_EVT "EVT"
+
+#define TRACEP(ss, oper, fmt, args...) \
+ TRACEPSRC(ss, oper, NULL, 0, (const char *)NULL, fmt, ##args)
+#define TRACEPSRC(ss, oper, caller_file, caller_line, caller_func, fmt, args...) \
+ do { \
+ if (log_check_level(DLTRACE, LOGL_DEBUG)) {\
+ if (caller_file) \
+ logp2(DLTRACE, LOGL_DEBUG, caller_file, caller_line, 0, "[" oper " func=%s ss=%02x]%s" fmt, caller_func, ss, fmt[0]?" ":"", ##args); \
+ else \
+ logp2(DLTRACE, LOGL_DEBUG, __FILE__, __LINE__, 0, "[" oper " func=%s ss=%02x]%s" fmt, __func__, ss, fmt[0]?" ":"", ##args); \
+ }\
+ } while(0)
+
+#define TRACEPENTFUN(ss, fmt, args...) \
+ TRACEP(ss, TRACEOP_ENTFUN, fmt, ##args)
+#define TRACEPEXTFUN(ss, fmt, args...) \
+ TRACEP(ss, TRACEOP_EXTFUN, fmt, ##args)
+#define TRACEPATTR(ss, fmt, args...) \
+ TRACEP(ss, TRACEOP_ATTR, fmt, ##args)
+#define TRACEPEVTSRC(ss, level, caller_file, caller_line, caller_func, fmt, args...) \
+ TRACEPSRC(ss, TRACEOP_EVT, caller_file, caller_line, caller_func, "level=%02x " fmt, level, ##args)
+
+
/*! different log levels */
#define LOGL_DEBUG 1 /*!< debugging information */
#define LOGL_INFO 3 /*!< general information */
@@ -122,7 +147,8 @@ void logp(int subsys, const char *file, int line, int cont, const char *format,
#define DLRSPRO -19 /*!< Osmocom Remote SIM Protocol */
#define DLNS -20 /*!< Osmocom NS layer */
#define DLBSSGP -21 /*!< Osmocom BSSGP layer */
-#define OSMO_NUM_DLIB 21 /*!< Number of logging sub-systems in libraries */
+#define DLTRACE -22 /*!< Osmocom Tracing messages (intended for GSMTAP logging) */
+#define OSMO_NUM_DLIB 22 /*!< Number of logging sub-systems in libraries */
/* Colors that can be used in log_info_cat.color */
#define OSMO_LOGCOLOR_NORMAL NULL
diff --git a/include/osmocom/core/tdef.h b/include/osmocom/core/tdef.h
index 627ba3f9..a589d436 100644
--- a/include/osmocom/core/tdef.h
+++ b/include/osmocom/core/tdef.h
@@ -159,11 +159,11 @@ const struct osmo_tdef_state_timeout *osmo_tdef_get_state_timeout(uint32_t state
*/
#define osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, default_timeout) \
_osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, default_timeout, \
- __FILE__, __LINE__)
+ __FILE__, __LINE__, __func__)
int _osmo_tdef_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t state,
const struct osmo_tdef_state_timeout *timeouts_array,
const struct osmo_tdef *tdefs, unsigned long default_timeout,
- const char *file, int line);
+ const char *file, int line, const char *func);
/*! Manage timer definitions in named groups.
* This should be defined as an array with the final element kept fully zero-initialized,