diff options
author | jhb <jhb@FreeBSD.org> | 2000-11-28 23:15:44 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2000-11-28 23:15:44 +0000 |
commit | 757db0906c9bf404dabaa33245104ad2fdac48e5 (patch) | |
tree | 5a2a67ed404102a089823310f261b9aa6c51c48b /sys/amd64 | |
parent | 09e0dbdcd9bc82c9f8cf86886ceea3e8c4d460d3 (diff) | |
download | FreeBSD-src-757db0906c9bf404dabaa33245104ad2fdac48e5.zip FreeBSD-src-757db0906c9bf404dabaa33245104ad2fdac48e5.tar.gz |
Use atomic ops to close a race condition on the in_Debugger variable used
to only allow 1 CPU at a time to (non-recursively) enter the debugger.
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/db_interface.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c index a801301..a2d07cb 100644 --- a/sys/amd64/amd64/db_interface.c +++ b/sys/amd64/amd64/db_interface.c @@ -306,7 +306,7 @@ void Debugger(msg) const char *msg; { - static volatile u_char in_Debugger; + static volatile u_int in_Debugger; int flags; /* * XXX @@ -317,14 +317,13 @@ Debugger(msg) if (cons_unavail && !(boothowto & RB_GDB)) return; - if (!in_Debugger) { + if (atomic_cmpset_int(&in_Debugger, 0, 1)) { flags = save_intr(); disable_intr(); - in_Debugger = 1; db_printf("Debugger(\"%s\")\n", msg); breakpoint(); - in_Debugger = 0; restore_intr(flags); + in_Debugger = 0; } } |