mirror of https://github.com/ARMmbed/mbed-os.git
Redirecting LWIP debug trace to mbed-trace
This piece of code redirects LWIP debug trace to mbed-trace if configured. This enables us to have universal traces.pull/4119/head
parent
3b44f4758d
commit
f602c936ff
|
@ -339,6 +339,11 @@ void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap)
|
||||||
if (plain == true || dlevel == TRACE_LEVEL_CMD) {
|
if (plain == true || dlevel == TRACE_LEVEL_CMD) {
|
||||||
//add trace data
|
//add trace data
|
||||||
retval = vsnprintf(ptr, bLeft, fmt, ap);
|
retval = vsnprintf(ptr, bLeft, fmt, ap);
|
||||||
|
//convenience - trim off one trailing \n. Useful if trying to directly
|
||||||
|
//connect debug layers that do expect callers to pass \n to mbed_trace.
|
||||||
|
if (retval > 0 && retval < bLeft && ptr[retval - 1] == '\n') {
|
||||||
|
ptr[--retval] = '\0';
|
||||||
|
}
|
||||||
if (dlevel == TRACE_LEVEL_CMD && m_trace.cmd_printf) {
|
if (dlevel == TRACE_LEVEL_CMD && m_trace.cmd_printf) {
|
||||||
m_trace.cmd_printf(m_trace.line);
|
m_trace.cmd_printf(m_trace.line);
|
||||||
m_trace.cmd_printf("\n");
|
m_trace.cmd_printf("\n");
|
||||||
|
@ -441,6 +446,12 @@ void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap)
|
||||||
if (retval > 0) {
|
if (retval > 0) {
|
||||||
ptr += retval;
|
ptr += retval;
|
||||||
bLeft -= retval;
|
bLeft -= retval;
|
||||||
|
//convenience - trim off one trailing \n. Useful if trying to directly
|
||||||
|
//connect debug layers that do expect callers to pass \n to mbed_trace.
|
||||||
|
if (ptr[-1] == '\n') {
|
||||||
|
*--ptr = '\0';
|
||||||
|
++bLeft;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,16 +93,28 @@
|
||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#ifdef LWIP_DEBUG
|
||||||
|
|
||||||
#include "stdio.h"
|
#if MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
|
void lwip_mbed_tracef_debug(const char *fmt, ...);
|
||||||
|
void lwip_mbed_tracef_error(const char *fmt, ...);
|
||||||
|
void lwip_mbed_tracef_warn(const char *fmt, ...);
|
||||||
|
void lwip_mbed_assert_fail(const char *msg, const char *func, const char *file, unsigned int line);
|
||||||
|
|
||||||
|
#define LWIP_PLATFORM_DIAG(vars) lwip_mbed_tracef_debug vars
|
||||||
|
#define LWIP_PLATFORM_DIAG_SEVERE(vars) lwip_mbed_tracef_error vars
|
||||||
|
#define LWIP_PLATFORM_DIAG_SERIOUS(vars) lwip_mbed_tracef_error vars
|
||||||
|
#define LWIP_PLATFORM_DIAG_WARNING(vars) lwip_mbed_tracef_warn vars
|
||||||
|
|
||||||
|
#define LWIP_PLATFORM_ASSERT(message) lwip_mbed_assert_fail(message, __func__, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
#else // MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void assert_printf(char *msg, int line, char *file);
|
void assert_printf(char *msg, int line, char *file);
|
||||||
|
|
||||||
/* Plaform specific diagnostic output */
|
/* Plaform specific diagnostic output */
|
||||||
#define LWIP_PLATFORM_DIAG(vars) printf vars
|
#define LWIP_PLATFORM_DIAG(vars) printf vars
|
||||||
#define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
|
#define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
|
||||||
#else
|
#endif // MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
#define LWIP_PLATFORM_DIAG(msg) { ; }
|
|
||||||
#define LWIP_PLATFORM_ASSERT(flag) { ; }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
|
|
|
@ -489,6 +489,42 @@ sys_thread_t sys_thread_new(const char *pcName,
|
||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#ifdef LWIP_DEBUG
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#if MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
|
#include "mbed-trace/mbed_trace.h"
|
||||||
|
|
||||||
|
void lwip_mbed_tracef_debug(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
mbed_vtracef(TRACE_LEVEL_DEBUG, "lwIP", fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lwip_mbed_tracef_warn(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
mbed_vtracef(TRACE_LEVEL_WARN, "lwIP", fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lwip_mbed_tracef_error(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
mbed_vtracef(TRACE_LEVEL_ERROR, "lwIP", fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lwip_mbed_assert_fail(const char *msg, const char *func, const char *file, unsigned int line)
|
||||||
|
{
|
||||||
|
mbed_tracef(TRACE_LEVEL_ERROR, "lwIP", "Assertion failed: %s, function %s, file %s, line %u.", msg, func, file, line);
|
||||||
|
exit(EXIT_FAILURE); // XXX how about abort? mbed_assert uses exit, so follow suit
|
||||||
|
}
|
||||||
|
#else // MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
|
|
||||||
/** \brief Displays an error message on assertion
|
/** \brief Displays an error message on assertion
|
||||||
|
|
||||||
This function will display an error message on an assertion
|
This function will display an error message on an assertion
|
||||||
|
@ -504,5 +540,6 @@ void assert_printf(char *msg, int line, char *file) {
|
||||||
else
|
else
|
||||||
error("LWIP ASSERT\n");
|
error("LWIP ASSERT\n");
|
||||||
}
|
}
|
||||||
|
#endif // MBED_CONF_LWIP_USE_MBED_TRACE
|
||||||
|
|
||||||
#endif /* LWIP_DEBUG */
|
#endif /* LWIP_DEBUG */
|
||||||
|
|
|
@ -148,6 +148,24 @@
|
||||||
#ifndef LWIP_PLATFORM_DIAG
|
#ifndef LWIP_PLATFORM_DIAG
|
||||||
#error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h"
|
#error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LWIP_PLATFORM_DIAG_SERIOUS
|
||||||
|
#define LWIP_DEBUGF(debug, message) do { \
|
||||||
|
if ( \
|
||||||
|
((debug) & LWIP_DBG_ON) && \
|
||||||
|
((debug) & LWIP_DBG_TYPES_ON) && \
|
||||||
|
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
|
||||||
|
switch ((debug) & LWIP_DBG_MASK_LEVEL) { \
|
||||||
|
case LWIP_DBG_LEVEL_SERIOUS: LWIP_PLATFORM_DIAG_SERIOUS(message); break; \
|
||||||
|
case LWIP_DBG_LEVEL_SEVERE: LWIP_PLATFORM_DIAG_SEVERE(message); break; \
|
||||||
|
case LWIP_DBG_LEVEL_WARNING: LWIP_PLATFORM_DIAG_WARNING(message); break; \
|
||||||
|
default: LWIP_PLATFORM_DIAG(message); break; \
|
||||||
|
} \
|
||||||
|
if ((debug) & LWIP_DBG_HALT) { \
|
||||||
|
while(1); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
#define LWIP_DEBUGF(debug, message) do { \
|
#define LWIP_DEBUGF(debug, message) do { \
|
||||||
if ( \
|
if ( \
|
||||||
((debug) & LWIP_DBG_ON) && \
|
((debug) & LWIP_DBG_ON) && \
|
||||||
|
@ -159,7 +177,7 @@
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
#endif
|
||||||
#else /* LWIP_DEBUG */
|
#else /* LWIP_DEBUG */
|
||||||
#define LWIP_DEBUGF(debug, message)
|
#define LWIP_DEBUGF(debug, message)
|
||||||
#endif /* LWIP_DEBUG */
|
#endif /* LWIP_DEBUG */
|
||||||
|
|
|
@ -65,7 +65,11 @@
|
||||||
#error "Either IPv4 or IPv6 must be preferred."
|
#error "Either IPv4 or IPv6 must be preferred."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define LWIP_DEBUG
|
#if defined(MBED_CONF_LWIP_DEBUG_ENABLED)
|
||||||
|
#define LWIP_DEBUG MBED_CONF_LWIP_DEBUG_ENABLED
|
||||||
|
#else
|
||||||
|
#define LWIP_DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if NO_SYS == 0
|
#if NO_SYS == 0
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
@ -85,7 +89,7 @@
|
||||||
#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200
|
#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#if LWIP_DEBUG
|
||||||
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2
|
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2
|
||||||
#else
|
#else
|
||||||
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE
|
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE
|
||||||
|
@ -98,7 +102,7 @@
|
||||||
#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512
|
#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#if LWIP_DEBUG
|
||||||
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2
|
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2
|
||||||
#else
|
#else
|
||||||
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE
|
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE
|
||||||
|
@ -227,22 +231,24 @@
|
||||||
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
||||||
#define DNS_DEBUG LWIP_DBG_OFF
|
#define DNS_DEBUG LWIP_DBG_OFF
|
||||||
#define IP6_DEBUG LWIP_DBG_OFF
|
#define IP6_DEBUG LWIP_DBG_OFF
|
||||||
|
#if MBED_CONF_LWIP_ENABLE_PPP_TRACE
|
||||||
|
#define PPP_DEBUG LWIP_DBG_ON
|
||||||
|
#else
|
||||||
#define PPP_DEBUG LWIP_DBG_OFF
|
#define PPP_DEBUG LWIP_DBG_OFF
|
||||||
|
#endif //MBED_CONF_LWIP_ENABLE_PPP_TRACE
|
||||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||||
#define UDP_LPC_EMAC LWIP_DBG_OFF
|
#define UDP_LPC_EMAC LWIP_DBG_OFF
|
||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#if LWIP_DEBUG
|
||||||
#define MEMP_OVERFLOW_CHECK 1
|
#define MEMP_OVERFLOW_CHECK 1
|
||||||
#define MEMP_SANITY_CHECK 1
|
#define MEMP_SANITY_CHECK 1
|
||||||
|
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
|
||||||
|
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
|
||||||
#else
|
#else
|
||||||
#define LWIP_NOASSERT 1
|
#define LWIP_NOASSERT 1
|
||||||
#define LWIP_STATS 0
|
#define LWIP_STATS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
|
|
||||||
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
|
|
||||||
|
|
||||||
#define LWIP_PLATFORM_BYTESWAP 1
|
#define LWIP_PLATFORM_BYTESWAP 1
|
||||||
|
|
||||||
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
|
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
|
||||||
|
@ -263,6 +269,7 @@
|
||||||
// Save RAM
|
// Save RAM
|
||||||
#define PAP_SUPPORT 0
|
#define PAP_SUPPORT 0
|
||||||
#define VJ_SUPPORT 0
|
#define VJ_SUPPORT 0
|
||||||
|
#define PRINTPKT_SUPPORT 0
|
||||||
#define PPP_LOGIT_BUFSIZE 512
|
#define PPP_LOGIT_BUFSIZE 512
|
||||||
|
|
||||||
//Hate the config hassle.
|
//Hate the config hassle.
|
||||||
|
|
|
@ -21,10 +21,22 @@
|
||||||
"help": "Enable support for Ethernet interfaces",
|
"help": "Enable support for Ethernet interfaces",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
|
"debug-enabled": {
|
||||||
|
"help": "Enable debug trace support",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
"ppp-enabled": {
|
"ppp-enabled": {
|
||||||
"help": "Enable support for PPP interfaces",
|
"help": "Enable support for PPP interfaces",
|
||||||
"value": false
|
"value": false
|
||||||
},
|
},
|
||||||
|
"use-mbed-trace": {
|
||||||
|
"help": "Use mbed trace for debug, rather than printf",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"enable-ppp-trace": {
|
||||||
|
"help": "Enable trace support for PPP interfaces",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
"socket-max": {
|
"socket-max": {
|
||||||
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM",
|
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM",
|
||||||
"value": 4
|
"value": 4
|
||||||
|
|
|
@ -71,7 +71,11 @@ static EventQueue *prepare_event_queue()
|
||||||
|
|
||||||
// Only need to queue 1 event. new blows on failure.
|
// Only need to queue 1 event. new blows on failure.
|
||||||
event_queue = new EventQueue(2 * EVENTS_EVENT_SIZE, NULL);
|
event_queue = new EventQueue(2 * EVENTS_EVENT_SIZE, NULL);
|
||||||
event_thread = new Thread(osPriorityNormal, 900);
|
#if LWIP_DEBUG
|
||||||
|
event_thread = new Thread(osPriorityNormal, 900*2);
|
||||||
|
#else
|
||||||
|
event_thread = new Thread(osPriorityNormal, 900*1);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (event_thread->start(callback(event_queue, &EventQueue::dispatch_forever)) != osOK) {
|
if (event_thread->start(callback(event_queue, &EventQueue::dispatch_forever)) != osOK) {
|
||||||
delete event_thread;
|
delete event_thread;
|
||||||
|
|
Loading…
Reference in New Issue