1*567c7b10SIngo Weinhold /* 2*567c7b10SIngo Weinhold * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3*567c7b10SIngo Weinhold * Distributed under the terms of the MIT License. 4*567c7b10SIngo Weinhold */ 5*567c7b10SIngo Weinhold 6*567c7b10SIngo Weinhold 7*567c7b10SIngo Weinhold #include <stdio.h> 8*567c7b10SIngo Weinhold #include <string.h> 9*567c7b10SIngo Weinhold 10*567c7b10SIngo Weinhold 11*567c7b10SIngo Weinhold #include <syscalls.h> 12*567c7b10SIngo Weinhold 13*567c7b10SIngo Weinhold 14*567c7b10SIngo Weinhold extern const char* __progname; 15*567c7b10SIngo Weinhold 16*567c7b10SIngo Weinhold static const char* const kUsage = 17*567c7b10SIngo Weinhold "Usage: %s [ <message> ]\n" 18*567c7b10SIngo Weinhold "Enters the kernel debugger with the optional message.\n"; 19*567c7b10SIngo Weinhold 20*567c7b10SIngo Weinhold 21*567c7b10SIngo Weinhold int main(int argc,const char * const * argv)22*567c7b10SIngo Weinholdmain(int argc, const char* const* argv) 23*567c7b10SIngo Weinhold { 24*567c7b10SIngo Weinhold const char* message = "User command requested kernel debugger."; 25*567c7b10SIngo Weinhold 26*567c7b10SIngo Weinhold if (argc > 1) { 27*567c7b10SIngo Weinhold if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { 28*567c7b10SIngo Weinhold printf(kUsage, __progname); 29*567c7b10SIngo Weinhold return 0; 30*567c7b10SIngo Weinhold } 31*567c7b10SIngo Weinhold 32*567c7b10SIngo Weinhold message = argv[1]; 33*567c7b10SIngo Weinhold } 34*567c7b10SIngo Weinhold 35*567c7b10SIngo Weinhold status_t error = _kern_kernel_debugger(message); 36*567c7b10SIngo Weinhold if (error != B_OK) { 37*567c7b10SIngo Weinhold fprintf(stderr, "Error: Entering the kernel debugger failed: %s\n", 38*567c7b10SIngo Weinhold strerror(error)); 39*567c7b10SIngo Weinhold return 1; 40*567c7b10SIngo Weinhold } 41*567c7b10SIngo Weinhold 42*567c7b10SIngo Weinhold return 0; 43*567c7b10SIngo Weinhold } 44