 35a108b911
			
		
	
	
		35a108b911
		
	
	
	
	
		
			
			this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()
merging printf() and panic() statements to be done incrementally.
		
	
			
		
			
				
	
	
		
			129 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* This file contains information dump procedures. During the initialization 
 | |
|  * of the Information Service 'known' function keys are registered at the TTY
 | |
|  * server in order to receive a notification if one is pressed. Here, the 
 | |
|  * corresponding dump procedure is called.  
 | |
|  *
 | |
|  * The entry points into this file are
 | |
|  *   map_unmap_fkeys:	register or unregister function key maps with TTY
 | |
|  *   do_fkey_pressed:	handle a function key pressed notification
 | |
|  */
 | |
| 
 | |
| #include "inc.h"
 | |
| #include <minix/vm.h>
 | |
| 
 | |
| struct hook_entry {
 | |
| 	int key;
 | |
| 	void (*function)(void);
 | |
| 	char *name;
 | |
| } hooks[] = {
 | |
| 	{ F1, 	proctab_dmp, "Kernel process table" },
 | |
| 	{ F2,   memmap_dmp, "Process memory maps" },
 | |
| 	{ F3,	image_dmp, "System image" },
 | |
| 	{ F4,	privileges_dmp, "Process privileges" },
 | |
| 	{ F5,	monparams_dmp, "Boot monitor parameters" },
 | |
| 	{ F6,	irqtab_dmp, "IRQ hooks and policies" },
 | |
| 	{ F7,	kmessages_dmp, "Kernel messages" },
 | |
| 	{ F8,	vm_dmp, "VM status and process maps" },
 | |
| 	{ F10,	kenv_dmp, "Kernel parameters" },
 | |
| 	{ F11,	timing_dmp, "Timing details (if enabled)" },
 | |
| 	{ SF1,	mproc_dmp, "Process manager process table" },
 | |
| 	{ SF2,	sigaction_dmp, "Signals" },
 | |
| 	{ SF3,	fproc_dmp, "Filesystem process table" },
 | |
| 	{ SF4,	dtab_dmp, "Device/Driver mapping" },
 | |
| 	{ SF5,	mapping_dmp, "Print key mappings" },
 | |
| 	{ SF6,	rproc_dmp, "Reincarnation server process table" },
 | |
| 	{ SF8,  data_store_dmp, "Data store contents" },
 | |
| 	{ SF9,  procstack_dmp, "Processes with stack traces" },
 | |
| };
 | |
| 
 | |
| /* Define hooks for the debugging dumps. This table maps function keys
 | |
|  * onto a specific dump and provides a description for it.
 | |
|  */
 | |
| #define NHOOKS (sizeof(hooks)/sizeof(hooks[0]))
 | |
| 
 | |
| /*===========================================================================*
 | |
|  *				map_unmap_keys				     *
 | |
|  *===========================================================================*/
 | |
| PUBLIC void map_unmap_fkeys(map)
 | |
| int map;
 | |
| {
 | |
|   int fkeys, sfkeys;
 | |
|   int h, s;
 | |
| 
 | |
|   fkeys = sfkeys = 0;
 | |
| 
 | |
|   for (h = 0; h < NHOOKS; h++) {
 | |
|       if (hooks[h].key >= F1 && hooks[h].key <= F12) 
 | |
|           bit_set(fkeys, hooks[h].key - F1 + 1);
 | |
|       else if (hooks[h].key >= SF1 && hooks[h].key <= SF12)
 | |
|           bit_set(sfkeys, hooks[h].key - SF1 + 1);
 | |
|   }
 | |
| 
 | |
|   if (map) s = fkey_map(&fkeys, &sfkeys);
 | |
|   else s = fkey_unmap(&fkeys, &sfkeys);
 | |
| 
 | |
|   if (s != OK)
 | |
| 	printf("IS: warning, fkey_ctl failed: %d\n", s);
 | |
| }
 | |
| 
 | |
| /*===========================================================================*
 | |
|  *				handle_fkey				     *
 | |
|  *===========================================================================*/
 | |
| #define pressed(k) ((F1<=(k)&&(k)<=F12 && bit_isset(m->FKEY_FKEYS,((k)-F1+1)))\
 | |
|   	|| (SF1<=(k) && (k)<=SF12 && bit_isset(m->FKEY_SFKEYS, ((k)-SF1+1)))) 
 | |
| PUBLIC int do_fkey_pressed(m)
 | |
| message *m;					/* notification message */
 | |
| {
 | |
|   int s, h;
 | |
| 
 | |
|   /* The notification message does not convey any information, other
 | |
|    * than that some function keys have been pressed. Ask TTY for details.
 | |
|    */
 | |
|   m->m_type = FKEY_CONTROL;
 | |
|   m->FKEY_REQUEST = FKEY_EVENTS;
 | |
|   if (OK != (s=sendrec(TTY_PROC_NR, m)))
 | |
|       printf("IS: warning, sendrec to TTY failed: %d\n", s);
 | |
| 
 | |
|   /* Now check which keys were pressed: F1-F12, SF1-SF12. */
 | |
|   for(h=0; h < NHOOKS; h++)
 | |
|       if(pressed(hooks[h].key))
 | |
|           hooks[h].function();
 | |
| 
 | |
|   /* Don't send a reply message. */
 | |
|   return(EDONTREPLY);
 | |
| }
 | |
| 
 | |
| /*===========================================================================*
 | |
|  *				key_name				     *
 | |
|  *===========================================================================*/
 | |
| PRIVATE char *key_name(int key)
 | |
| {
 | |
| 	static char name[15];
 | |
| 
 | |
| 	if(key >= F1 && key <= F12)
 | |
| 		sprintf(name, " F%d", key - F1 + 1);
 | |
| 	else if(key >= SF1 && key <= SF12)
 | |
| 		sprintf(name, "Shift+F%d", key - SF1 + 1);
 | |
| 	else
 | |
| 		sprintf(name, "?");
 | |
| 	return name;
 | |
| }
 | |
| 
 | |
| 
 | |
| /*===========================================================================*
 | |
|  *				mapping_dmp				     *
 | |
|  *===========================================================================*/
 | |
| PUBLIC void mapping_dmp(void)
 | |
| {
 | |
|   int h;
 | |
| 
 | |
|   printf("Function key mappings for debug dumps in IS server.\n");
 | |
|   printf("        Key   Description\n");
 | |
|   printf("-------------------------------------");
 | |
|   printf("------------------------------------\n");
 | |
| 
 | |
|   for(h=0; h < NHOOKS; h++)
 | |
|       printf(" %10s.  %s\n", key_name(hooks[h].key), hooks[h].name);
 | |
|   printf("\n");
 | |
| }
 |