From: George Dunlap Subject: [PATCH 09 of 12] xenalyze: Sort cr3 enumerated values by start time Date: Mon, 28 Nov 2011 16:18:06 +0000 Message-ID: <46c366d71c74a60173a5.1322497086@elijah> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Add a new sort method to sort by start time, rather than by total time, and make it the default. Really should make it command-line switchable, but I'll leave that improvement until later. Signed-off-by: George Dunlap diff -r 3c6da152c844 -r 46c366d71c74 xenalyze.c --- a/xenalyze.c Mon Nov 28 16:16:23 2011 +0000 +++ b/xenalyze.c Mon Nov 28 16:16:23 2011 +0000 @@ -4144,7 +4144,7 @@ void cr3_dump_list(struct cr3_value_stru struct cr3_value_struct **qsort_array; int i, N=0; - int cr3_compare(const void *_a, const void *_b) { + int cr3_compare_total(const void *_a, const void *_b) { struct cr3_value_struct *a=*(typeof(&a))_a; struct cr3_value_struct *b=*(typeof(&a))_b; @@ -4161,6 +4161,18 @@ void cr3_dump_list(struct cr3_value_stru return -1; } + int cr3_compare_start(const void *_a, const void *_b) { + struct cr3_value_struct *a=*(typeof(&a))_a; + struct cr3_value_struct *b=*(typeof(&a))_b; + + if(a->first_time > b->first_time) + return 1; + else if(b->first_time == a->first_time) + return 0; + else + return -1; + } + if(!head) return; @@ -4180,7 +4192,7 @@ void cr3_dump_list(struct cr3_value_stru /* Sort the array by time */ qsort(qsort_array, N, sizeof(struct eip_list_struct *), - cr3_compare); + cr3_compare_start); /* WARNING: don't use N after this point unless you copy this variable */ #if 0