public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 4/9] log: use console puts to output trace before LOG init
Date: Fri, 27 Nov 2020 10:01:52 -0500	[thread overview]
Message-ID: <07e2863f-aa2a-e995-1958-9bae28006a46@gmail.com> (raw)
In-Reply-To: <20201127112000.v2.4.I01167328d604e359d69c0d241754caeec1f65ebe@changeid>

On 11/27/20 5:20 AM, Patrick Delaunay wrote:
> Use the console puts functions to output the traces before
> the log initialization (when CONFIG_LOG is not activated).
> 
> This patch allows to display the first U-Boot traces
> (with macro debug) when CONFIG_DEBUG_UART is activated
> and not only drop them.
> 
> For example for traces in board_f.c requested by the macro debug,
> when LOG_DEBUG is defined and CONFIG_LOG is activated.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
> Changes in v2:
> - replace printascii by console puts, remove test on CONFIG_DEBUG_UART
> 
>   common/log.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/common/log.c b/common/log.c
> index 212789d6b3..a4ed7d79f8 100644
> --- a/common/log.c
> +++ b/common/log.c
> @@ -246,6 +246,15 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
>   
>   	if (!(gd->flags & GD_FLG_LOG_READY)) {
>   		gd->log_drop_count++;
> +
> +		/* display dropped traces with console puts and DEBUG_UART */
> +		if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug) {
> +			va_start(args, fmt);
> +			vsnprintf(buf, sizeof(buf), fmt, args);
> +			puts(buf);
> +			va_end(args);
> +		}
> +
>   		return -ENOSYS;
>   	}
>   	va_start(args, fmt);
> 

Couldn't this be done like

  	va_start(args, fmt);
  	vsnprintf(buf, sizeof(buf), fmt, args);
  	va_end(args);
  	rec.msg = buf;
	if (!gd || !(gd->flags & GD_FLG_LOG_READY)) {
		if (gd)
			gd->log_drop_count++;
		if (rec.level < CONFIG_LOG_DEFAULT_LEVEL ||
		    rec.force_debug)
			puts(buf);
		return -ENOSYS;
	}

I don't see the optimization of not doing the vsnprintf() coming up very
often. Also, shouldn't this return 0 instead of ENOSYS if something is
actually printed?

--Sean

  reply	other threads:[~2020-11-27 15:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 10:20 [PATCH v2 0/9] log: don't build the trace buffer when log is not ready Patrick Delaunay
2020-11-27 10:20 ` [PATCH v2 1/9] test: add LOGL_FORCE_DEBUG flags support in log tests Patrick Delaunay
2020-11-27 14:53   ` Sean Anderson
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 2/9] log: don't build the trace buffer when log is not ready Patrick Delaunay
2020-11-27 14:50   ` Sean Anderson
2020-11-30 20:12     ` Simon Glass
2020-12-02  8:37     ` Patrick DELAUNAY
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 3/9] test: log: add test for dropped messages Patrick Delaunay
2020-11-30 20:11   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 4/9] log: use console puts to output trace before LOG init Patrick Delaunay
2020-11-27 15:01   ` Sean Anderson [this message]
2020-12-02  9:15     ` Patrick DELAUNAY
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 5/9] test: add test for dropped trace before log_init Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 6/9] console: remove duplicated test on gd value Patrick Delaunay
2020-11-27 15:05   ` Sean Anderson
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 7/9] console: allow to record console output before ready Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2020-12-02  9:55     ` [Uboot-stm32] " Patrick DELAUNAY
2020-12-02 21:46       ` Simon Glass
2021-01-16 16:22   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 8/9] test: log: add test for console output of dropped messages Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:22   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 9/9] log: call vsnprintf only when it is needed to emit trace Patrick Delaunay
2021-01-16 16:22   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07e2863f-aa2a-e995-1958-9bae28006a46@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox