[ovs-dev] [PATCH] backtrace: add LOG_BACKTRACE()

Ben Pfaff blp at nicira.com
Fri Mar 14 20:33:54 UTC 2014


On Thu, Mar 13, 2014 at 06:17:14PM -0700, Andy Zhou wrote:
> LOG_BACKTRACE() logs the back trace into the log file. I find it
> to be helpful when debugging unit tests. "backtrace.h" documents
> the usage. It is not being called directly in the code, but rather as
> a handy tool available when needed.
> 
> Signed-off-by: Andy Zhou <azhou at nicira.com>

This looks useful.

I think that LOG_BACKTRACE and log_backtrace() could be defined more
along the existing pattern with the *_at() functions like
poll_fd_wait() and poll_fd_wait_at(), so that we'd have something more
like this:

    void log_backtrace_at(const char *where);
    #define log_backtrace() log_backtrace_at(SOURCE_LOCATOR)

I think that log_backtrace() could internally grab the backtrace.  I
mean, it isn't strictly necessary to do it in the caller, you just get
an extra entry at the top and that isn't normally a big deal.

Do you think it's worthwhile to allow the backtrace user to specify a
message to include?



More information about the dev mailing list