diff mbox

[kvm-unit-tests,v2,7/8] lib: dump stack on abort()

Message ID 1456967378-6367-8-git-send-email-pfeiner@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Feiner March 3, 2016, 1:09 a.m. UTC
Signed-off-by: Peter Feiner <pfeiner@google.com>
---
 lib/libcflat.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Andrew Jones March 3, 2016, 9:19 a.m. UTC | #1
Looks like you forgot to update $SUBJECT; s/abort/assert/

drew

On Wed, Mar 02, 2016 at 05:09:37PM -0800, Peter Feiner wrote:
> Signed-off-by: Peter Feiner <pfeiner@google.com>
> ---
>  lib/libcflat.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 42c94df..1798716 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -77,10 +77,12 @@ void dump_current_stack(void);
>  
>  #define assert(cond)							\
>  do {									\
> -	if (!(cond))							\
> +	if (!(cond)) {							\
>  		printf("%s:%d: assert failed: %s\n",			\
> -		       __FILE__, __LINE__, #cond),			\
> +		       __FILE__, __LINE__, #cond);			\
> +		dump_current_stack();					\
>  		abort();						\
> +	}								\
>  } while (0)
>  
>  #endif
> -- 
> 2.7.0.rc3.207.g0ac5344
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 42c94df..1798716 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -77,10 +77,12 @@  void dump_current_stack(void);
 
 #define assert(cond)							\
 do {									\
-	if (!(cond))							\
+	if (!(cond)) {							\
 		printf("%s:%d: assert failed: %s\n",			\
-		       __FILE__, __LINE__, #cond),			\
+		       __FILE__, __LINE__, #cond);			\
+		dump_current_stack();					\
 		abort();						\
+	}								\
 } while (0)
 
 #endif