aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2020-07-07 14:47:57 -0700
committerArve Hjønnevåg <arve@android.com>2020-07-30 19:27:17 -0700
commit30789f75d6000a96041844a2b00b28d53607925f (patch)
tree868cc305ff331f7e1f97e48b75b4bb4799144760 /lib
parentc0b7e5176b3aaa43c7938a16622aab7ef435b6d5 (diff)
downloadcommon-30789f75d6000a96041844a2b00b28d53607925f.tar.gz
[kernel] Add thread flag to exit thread on panic
If panic is called from a thread after thread_set_flag_exit_on_panic(thread, true) has been called for that thread. The thread will exit with ERR_FAULT as the return code instead of halting the system. This can be used to test error paths that are normally not testable, e.g. exception handling. Bug: 147698516 Change-Id: I455898d8d3b5b3ee005969893bb4cb09d4b88a48
Diffstat (limited to 'lib')
-rw-r--r--lib/debug/debug.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/debug/debug.c b/lib/debug/debug.c
index 847074d5..54a2612d 100644
--- a/lib/debug/debug.c
+++ b/lib/debug/debug.c
@@ -23,6 +23,7 @@
#include <ctype.h>
#include <debug.h>
+#include <err.h>
#include <stdlib.h>
#include <printf.h>
#include <stdio.h>
@@ -31,6 +32,7 @@
#include <platform.h>
#include <platform/debug.h>
#include <kernel/spinlock.h>
+#include <kernel/thread.h>
void spin(uint32_t usecs)
{
@@ -48,6 +50,12 @@ void spin(uint32_t usecs)
void _panic(const char *fmt, ...)
{
va_list ap;
+ struct thread *curr = get_current_thread();
+
+ if (curr && thread_get_flag_exit_on_panic(curr)) {
+ thread_exit(ERR_FAULT);
+ }
+
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);