X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Fwinnt%2Fwinnt-debug.c;h=2e50facfe4b0365d329122bf4b6004a94faca03d;hb=2a6045403fbd46bb6501df907f0321f5401924ba;hp=9e94f845905ccf0dabc9f43bb8b78269f5f011ad;hpb=e1b3d71a27c166bebd26ab33f7299c41bd75dab5;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/winnt/winnt-debug.c b/libcfs/libcfs/winnt/winnt-debug.c index 9e94f84..2e50fac 100644 --- a/libcfs/libcfs/winnt/winnt-debug.c +++ b/libcfs/libcfs/winnt/winnt-debug.c @@ -1,67 +1,88 @@ -/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=4:tabstop=4: +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (c) 2004 Cluster File Systems, Inc. + * GPL HEADER START * - * This file is part of Lustre, http://www.lustre.org. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Lustre is free software; you can redistribute it and/or modify it under - * the terms of version 2 of the GNU General Public License as published by - * the Free Software Foundation. Lustre is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. You should have received a - * copy of the GNU General Public License along with Lustre; if not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ # define DEBUG_SUBSYSTEM S_LNET -#include #include #include "tracefile.h" -void lnet_debug_dumpstack(cfs_task_t *tsk) -{ +void libcfs_debug_dumpstack(cfs_task_t *tsk) +{ return; } -cfs_task_t *lnet_current(void) -{ - return cfs_current(); -} - -int lnet_arch_debug_init(unsigned long bufsize) +void libcfs_run_debug_log_upcall(char *file) { - return 0; } -int lnet_arch_debug_cleanup(void) +cfs_task_t *libcfs_current(void) { - return 0; + return cfs_current(); } -void lnet_run_lbug_upcall(char *file, const char *fn, const int line) +void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line) { } -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { libcfs_catastrophe = 1; CEMERG("LBUG: pid: %u thread: %#x\n", - (unsigned)cfs_curproc_pid(), (unsigned)PsGetCurrentThread()); - // portals_debug_dumplog(); - // portals_run_lbug_upcall(file, func, line); + cfs_curproc_pid(), PsGetCurrentThread()); + cfs_enter_debugger(); + libcfs_debug_dumplog(); + libcfs_run_lbug_upcall(file, func, line); +} + +void cfs_enter_debugger(void) +{ +# if _X86_ + __asm int 3; +# else + KdBreakPoint(); +# endif } -#if TDI_LIBCFS_DBG +#if DBG /* * Definitions */ -LONG KsDebugLevel = 0x5; +LONG KsDebugLevel = 1; /* @@ -1037,21 +1058,66 @@ KsPrintf( ... ) { - va_list ap; + LARGE_INTEGER tick; + va_list ap; va_start(ap, DebugMessage); - - if (DebugPrintLevel <= KsDebugLevel) - { + if (DebugPrintLevel <= KsDebugLevel) { CHAR buffer[0x200]; - + KeQueryTickCount(&tick); vsprintf(buffer, DebugMessage, ap); - - KdPrint(("TID:%8.8x: %s", PsGetCurrentThread(), buffer)); + KdPrint(("%8.8X cpu:%d:%d tid:%p %s", + tick.LowPart, + KeGetCurrentProcessorNumber(), + KeGetCurrentIrql(), + PsGetCurrentThread(), buffer)); } - va_end(ap); } // KsPrint() #endif + + +void libcfs_panic(char *msg) +{ + DbgPrint("%s", msg); + cfs_enter_debugger(); +} + +/* BUGCHECK callback record */ +static int libcfs_bugcheck_inited = 0; +KBUGCHECK_CALLBACK_RECORD libcfs_bugcheck_record; + +void +libcfs_bugcheck_callback( + IN PVOID Buffer, + IN ULONG Length + ) +{ + cfs_enter_debugger(); +} + + +void libcfs_register_panic_notifier(void) +{ + if (libcfs_bugcheck_inited) { + return; + } + + KeInitializeCallbackRecord(&libcfs_bugcheck_record); + KeRegisterBugCheckCallback(&libcfs_bugcheck_record, + libcfs_bugcheck_callback, + &libcfs_bugcheck_record, + sizeof(KBUGCHECK_CALLBACK_RECORD), + "Lustre"); +} + +void libcfs_unregister_panic_notifier(void) +{ + if (!libcfs_bugcheck_inited) { + return; + } + + KeDeregisterBugCheckCallback(&libcfs_bugcheck_record); +}