--- crash-4.0-3.8-org/main.c	2006-10-21 04:46:27.000000000 +0900
+++ crash-4.0-3.8-test/main.c	2006-10-31 09:40:23.554989824 +0900
@@ -23,6 +23,7 @@
 static int is_external_command(void);
 static int is_builtin_command(void);
 static int is_input_file(void);
+static void check_xen_hyper(void);
 
 static struct option long_options[] = {
         {"memory_module", 1, 0, 0},
@@ -370,6 +371,8 @@
 		}
 		optind++;
 	}
+
+	check_xen_hyper();
 	
         if (setjmp(pc->main_loop_env))
                 clean_exit(1);
@@ -409,17 +412,26 @@
 {
         if (!(pc->flags & GDB_INIT)) {
 		gdb_session_init();
-		read_in_kernel_config(IKCFG_INIT);
-		kernel_init();
-		machdep_init(POST_GDB);
-        	vm_init();
-        	module_init();
-        	help_init();
-        	task_init();
-        	vfs_init();
-		net_init();
-		dev_init();
-		machdep_init(POST_INIT);
+ 		if (XEN_HYPER_MODE()) {
+ 			machdep_init(POST_GDB);
+ 			xen_hyper_init();
+ 			xen_hyper_pcpu_init();
+ 			xen_hyper_domain_init();
+ 			xen_hyper_vcpu_init();
+ 			xen_hyper_post_init();
+ 		} else {
+			read_in_kernel_config(IKCFG_INIT);
+			kernel_init();
+			machdep_init(POST_GDB);
+        		vm_init();
+        		module_init();
+        		help_init();
+        		task_init();
+        		vfs_init();
+			net_init();
+			dev_init();
+			machdep_init(POST_INIT);
+		}
 	} else
 		SIGACTION(SIGINT, restart, &pc->sigaction, NULL);
 
@@ -427,8 +439,13 @@
          *  Display system statistics and current context.
          */
         if (!(pc->flags & SILENT) && !(pc->flags & RUNTIME)) {
-                display_sys_stats();
-                show_context(CURRENT_CONTEXT());
+		if (XEN_HYPER_MODE()) {
+			display_xen_hyper_sys_stats();
+			show_xen_hyper_vcpu_context(XEN_HYPER_VCPU_LAST_CONTEXT());
+		} else {
+                	display_sys_stats();
+                	show_context(CURRENT_CONTEXT());
+		}
                 fprintf(fp, "\n");
         }
 
@@ -474,8 +491,13 @@
 
 	if ((ct = get_command_table_entry(args[0]))) {
                 if (ct->flags & REFRESH_TASK_TABLE) {
-                        tt->refresh_task_table();
-			sort_context_array();
+			if (XEN_HYPER_MODE()) {
+				xen_hyper_refresh_domain_context_space();
+				xen_hyper_refresh_vcpu_context_space();
+			} else {
+				tt->refresh_task_table();
+				sort_context_array();
+			}
 		}
                 if (!STREQ(pc->curcmd, pc->program_name))
                         pc->lastcmd = pc->curcmd;
@@ -522,7 +544,7 @@
         struct command_table_entry *cp;
         struct extension_table *ext;
   
-        for (cp = &base_command_table[0]; cp->name; cp++) {
+        for (cp = pc->cmd_tp; cp->name; cp++) {
                 if (STREQ(cp->name, name))
                         return cp;
         }
@@ -679,6 +701,7 @@
 	pc->redhat_debug_loc = DEFAULT_REDHAT_DEBUG_LOCATION;
 	pc->cmdgencur = 0;
 	pc->cmdgenspec = ~pc->cmdgencur;
+	pc->cmd_tp = base_command_table;
 
 	/*
 	 *  Get gdb version before initializing it since this might be one 
@@ -1185,3 +1208,18 @@
 
 	exit(status);
 }
+
+/*
+ * check this session is xen hypervisor analysis
+ */
+void
+check_xen_hyper(void)
+{
+	if (!pc->namelist || strncmp(basename(pc->namelist), "xen-syms", 8))
+		return;
+
+	pc->flags |= XEN_HYPER;
+	pc->cmd_tp = xen_hyper_command_table;
+        if (pc->flags & XENDUMP)
+		pc->readmem = read_xendump_hyper;
+}
