[PATCH] debug: add option to log to tracing

Jouni Malinen j
Sat Mar 31 04:02:30 PDT 2012


On Mon, Mar 12, 2012 at 02:43:50PM +0100, Johannes Berg wrote:
> Add the option (-T) to wpa_supplicant to log
> all debug messages into the kernel tracing,
> allowing to aggregate kernel debugging with
> wpa_supplicant debugging and recording all
> with trace-cmd.
> 
> Since tracing is has relatively low overhead
> and can be filtered afterwards, record all
> messages regardless of log level. However,
> it will honour the -K option and not record
> key material by default.

Thanks! Applied.

> diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
> @@ -106,6 +118,72 @@ static int syslog_priority(int level)
> +int wpa_debug_open_linux_tracing(void)

> +	line = strtok_r(buf, "\n", &tmp1);
> +	if (line) do {
> +		char *tmp2, *tmp_path, *fstype;
> +
> +		/* "<dev> <mountpoint> <fs type> ..." */
> +		strtok_r(line, " ", &tmp2);

gcc was not happy about this construction for some reason.. It seemed to
think that line could be NULL here and warned about tmp2 not having been
initialized.

> +	} while ((line = strtok_r(NULL, "\n", &tmp1)));

I converted this somewhat strange if-do-while loop into a simpler while
loop which is apparently easier for gcc (and me, too, for that matter)
to understand.

> @@ -281,6 +388,29 @@ static void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
> +	if (wpa_debug_tracing_file != NULL) {
> +		size_t orig_len = len;
> +
> +		fprintf(wpa_debug_tracing_file,
> +			WPAS_TRACE_PFX "%s - hexdump_ascii(len=%lu):",
> +			level, title, (unsigned long) len);
> +		if (buf == NULL) {
> +			fprintf(wpa_debug_tracing_file, " [NULL]\n");
> +		} else if (!show) {
> +			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
> +		} else {
> +			/* can do ascii processing in userspace */
> +			for (i = 0; i < len; i++)
> +				fprintf(wpa_debug_tracing_file,
> +					" %02x", buf[i]);
> +		}
> +		fflush(wpa_debug_tracing_file);
> +
> +		len = orig_len;
> +	}

I can't see where the len variable would be changed here, so I dropped
the orig_len save-and-restore.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list