* [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 20:53 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 02/19] xenctx: clean up usage output Don Slutz
` (17 subsequent siblings)
18 siblings, 1 reply; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: George Dunlap, Ian Jackson, Ian Campbell, Jan Beulich,
Stefano Stabellini
From: Ian Campbell <ian.campbell@citrix.com>
These should all be unsigned long long to match various variables used
in the
code, same as x86_64.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 7275a00..47712ab 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -57,8 +57,8 @@ typedef uint64_t guest_word_t;
#elif defined(__aarch64__)
#define NO_TRANSLATION
typedef uint64_t guest_word_t;
-#define FMT_32B_WORD "%08lx"
-#define FMT_64B_WORD "%016lx"
+#define FMT_32B_WORD "%08llx"
+#define FMT_64B_WORD "%016llx"
#endif
struct symbol {
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64.
2014-04-03 19:06 ` [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64 Don Slutz
@ 2014-04-03 20:53 ` Don Slutz
2014-04-04 8:46 ` Ian Campbell
0 siblings, 1 reply; 22+ messages in thread
From: Don Slutz @ 2014-04-03 20:53 UTC (permalink / raw)
To: Don Slutz, xen-devel
Cc: George Dunlap, Ian Jackson, Ian Campbell, Jan Beulich,
Stefano Stabellini
On 04/03/14 15:06, Don Slutz wrote:
> From: Ian Campbell <ian.campbell@citrix.com>
>
> These should all be unsigned long long to match various variables used
> in the
> code, same as x86_64.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
I think I can add:
Reviewed-by: Don Slutz <dslutz@verizon.com>
And it I may also have forgotten to add:
Signed-off-by: Don Slutz <dslutz@verizon.com>
-Don Slutz
> ---
> tools/xentrace/xenctx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
> index 7275a00..47712ab 100644
> --- a/tools/xentrace/xenctx.c
> +++ b/tools/xentrace/xenctx.c
> @@ -57,8 +57,8 @@ typedef uint64_t guest_word_t;
> #elif defined(__aarch64__)
> #define NO_TRANSLATION
> typedef uint64_t guest_word_t;
> -#define FMT_32B_WORD "%08lx"
> -#define FMT_64B_WORD "%016lx"
> +#define FMT_32B_WORD "%08llx"
> +#define FMT_64B_WORD "%016llx"
> #endif
>
> struct symbol {
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64.
2014-04-03 20:53 ` Don Slutz
@ 2014-04-04 8:46 ` Ian Campbell
0 siblings, 0 replies; 22+ messages in thread
From: Ian Campbell @ 2014-04-04 8:46 UTC (permalink / raw)
To: Don Slutz
Cc: George Dunlap, Stefano Stabellini, Ian Jackson, Jan Beulich,
xen-devel
On Thu, 2014-04-03 at 16:53 -0400, Don Slutz wrote:
> On 04/03/14 15:06, Don Slutz wrote:
> > From: Ian Campbell <ian.campbell@citrix.com>
> >
> > These should all be unsigned long long to match various variables used
> > in the
> > code, same as x86_64.
> >
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
>
> I think I can add:
>
> Reviewed-by: Don Slutz <dslutz@verizon.com>
>
> And it I may also have forgotten to add:
>
> Signed-off-by: Don Slutz <dslutz@verizon.com>
I think S-o-b is something of a super-set of reviewed by, so I just
added that one. S-o-b is correct when you are forwarding a patch from
someone else, either via DCO (b) or (c), in this case (c) since you
didn't modify the patch.
Anyway, this seems to build on both classes of ARM so I've committed the
entire thing. Thanks!
Ian.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v10 02/19] xenctx: clean up usage output
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
2014-04-03 19:06 ` [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64 Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 03/19] xenctx: Clean up stack trace when hypercall_page not in symbol table Don Slutz
` (16 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
Fix usage formatting to be all the same.
Fix usage display of default --kernel-start for 64 bit.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 47712ab..889f788 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -823,15 +823,16 @@ static void usage(void)
printf("options:\n");
printf(" -f, --frame-pointers\n");
- printf(" assume the kernel was compiled with\n");
- printf(" frame pointers.\n");
+ printf(" assume the kernel was compiled with\n");
+ printf(" frame pointers.\n");
printf(" -s SYMTAB, --symbol-table=SYMTAB\n");
- printf(" read symbol table from SYMTAB.\n");
- printf(" -S --stack-trace print a complete stack trace.\n");
- printf(" -k, --kernel-start\n");
- printf(" set user/kernel split. (default 0xc0000000)\n");
- printf(" -a --all display more registers\n");
- printf(" -C --all-vcpus print info for all vcpus\n");
+ printf(" read symbol table from SYMTAB.\n");
+ printf(" -S, --stack-trace print a complete stack trace.\n");
+ printf(" -k KADDR, --kernel-start=KADDR\n");
+ printf(" set user/kernel split. (default 0x"FMT_32B_WORD")\n",
+ kernel_start);
+ printf(" -a, --all display more registers\n");
+ printf(" -C, --all-vcpus print info for all vcpus\n");
}
int main(int argc, char **argv)
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 03/19] xenctx: Clean up stack trace when hypercall_page not in symbol table
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
2014-04-03 19:06 ` [PATCH v10 01/19] xenctx: Correct FMT_??B_WORD for arm64 Don Slutz
2014-04-03 19:06 ` [PATCH v10 02/19] xenctx: clean up usage output Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 04/19] xenctx: Add -n (--display-stack-pages) option to output larger stack Don Slutz
` (15 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Jan Beulich
From: Don Slutz <Don@CloudSwitch.com>
Before:
Call Trace:
[<ffffffff8006b2b0>] default_idle+0x29 <--
[<ffffffff80048d19>] cpu_idle+0x95
[<ffffffff803e7801>] start_kernel+0x220
[<0000000000000000>] startup_64+0x80000000
[<ffffffff803e722f>] x86_64_start_kernel+0x22f
[<0000000000000000>] startup_64+0x80000000
[<0000000000000000>] startup_64+0x80000000
[<0000000000000000>] startup_64+0x80000000
[<0000000000000000>] startup_64+0x80000000
After:
Call Trace:
[<ffffffff8006b2b0>] default_idle+0x29 <--
[<ffffffff80048d19>] cpu_idle+0x95
[<ffffffff803e7801>] start_kernel+0x220
[<ffffffff803e722f>] x86_64_start_kernel+0x22f
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
---
tools/xentrace/xenctx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 889f788..134cf55 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -85,8 +85,9 @@ static int is_kernel_text(guest_word_t addr)
if (addr >= kernel_stext &&
addr <= kernel_etext)
return 1;
- if (addr >= kernel_hypercallpage &&
- addr <= kernel_hypercallpage + 4096)
+ if ( kernel_hypercallpage &&
+ (addr >= kernel_hypercallpage &&
+ addr <= kernel_hypercallpage + 4096) )
return 1;
if (addr >= kernel_sinittext &&
addr <= kernel_einittext)
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 04/19] xenctx: Add -n (--display-stack-pages) option to output larger stack
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (2 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 03/19] xenctx: Clean up stack trace when hypercall_page not in symbol table Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 05/19] xenctx: Add command line options -b (--bytes-per-line) and -l (--lines) Don Slutz
` (14 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
Important: This is the stack size (also known as stack limit) to
display, not the configured stack size.
Note: use with caution (easy to get garbage).
Below is a pictures of a downwards growing configured 3 page stack,
and where the SP currently is. Each box is a page.
+ pages -n 1 -n 2 -n 3
End of Memory
+------------------+
| |
| |
| |
| |
| |
+------------------+
...
+------------------+
| |
| |
| |
| |
MAX+3 | |
+------------------+ *
| | |
| | |
| | |
| | |
MAX+2 | | |
+------------------+ * |
| | | |
| | | |
| | | |
| | | |
MAX+1 | | | |
+------------------+ * | |
| | | | |
SP --> | | * * *
| |
| |
MAX | |
+------------------+
...
+------------------+
| |
| |
| |
| |
0 | |
+------------------+
Display using "-n 3" since the used stack pages is 3.
At a different time, the SP may be in the 1st page and so "-n 3"
will display garbage.
For example:
$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 1
...
Call Trace:
[<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310: [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330: [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338: [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370: [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0: [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0: [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410: [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450: [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0: [<ffffffff814fd363>] printk+0x41
$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 2
...
Call Trace:
[<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310: [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330: [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338: [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370: [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0: [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0: [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410: [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450: [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0: [<ffffffff814fd363>] printk+0x41
$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 3
...
Call Trace:
[<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310: [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330: [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338: [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370: [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0: [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0: [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410: [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450: [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0: [<ffffffff814fd363>] printk+0x41
ffff880032bb3f20: [<ffffffff8100204c>] do_one_initcall+0x3c
ffff880032bb3f50: [<ffffffff810b0eb1>] sys_init_module+0xe1
ffff880032bb3f80: [<ffffffff8100b0f2>] system_call_fastpath+0x16
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 134cf55..b740f1e 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -35,11 +35,14 @@ static struct xenctx {
int frame_ptrs;
int stack_trace;
int disp_all;
+ int nr_stack_pages;
int all_vcpus;
int self_paused;
xc_dominfo_t dominfo;
} xenctx;
+#define DEFAULT_NR_STACK_PAGES 1
+
#if defined (__i386__) || defined (__x86_64__)
typedef unsigned long long guest_word_t;
#define FMT_32B_WORD "%08llx"
@@ -663,7 +666,8 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
int i;
stack_limit = ((stack_pointer(ctx) + XC_PAGE_SIZE)
- & ~((guest_word_t) XC_PAGE_SIZE - 1));
+ & ~((guest_word_t) XC_PAGE_SIZE - 1))
+ + (xenctx.nr_stack_pages - 1) * XC_PAGE_SIZE;
printf("\n");
printf("Stack:\n");
for (i=1; i<5 && stack < stack_limit; i++) {
@@ -834,18 +838,24 @@ static void usage(void)
kernel_start);
printf(" -a, --all display more registers\n");
printf(" -C, --all-vcpus print info for all vcpus\n");
+ printf(" -n PAGES, --display-stack-pages=PAGES\n");
+ printf(" Display N pages from the stack pointer. (default %d)\n",
+ DEFAULT_NR_STACK_PAGES);
+ printf(" Changes stack limit. Note: use with caution (easy\n");
+ printf(" to get garbage).\n");
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SC";
+ static const char *sopts = "fs:hak:SCn:";
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
{"frame-pointers", 0, NULL, 'f'},
{"kernel-start", 1, NULL, 'k'},
+ {"display-stack-pages", 0, NULL, 'n'},
{"all", 0, NULL, 'a'},
{"all-vcpus", 0, NULL, 'C'},
{"help", 0, NULL, 'h'},
@@ -855,6 +865,8 @@ int main(int argc, char **argv)
int vcpu = 0;
+ xenctx.nr_stack_pages = DEFAULT_NR_STACK_PAGES;
+
while ((ch = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch(ch) {
case 'f':
@@ -869,6 +881,16 @@ int main(int argc, char **argv)
case 'a':
xenctx.disp_all = 1;
break;
+ case 'n':
+ xenctx.nr_stack_pages = strtol(optarg, NULL, 0);
+ if ( xenctx.nr_stack_pages < 1)
+ {
+ fprintf(stderr,
+ "%s: Unsupported value(%d) for --display-stack-pages '%s'. Needs to be >= 1\n",
+ argv[0], xenctx.nr_stack_pages, optarg);
+ exit(-1);
+ }
+ break;
case 'C':
xenctx.all_vcpus = 1;
break;
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 05/19] xenctx: Add command line options -b (--bytes-per-line) and -l (--lines)
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (3 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 04/19] xenctx: Add -n (--display-stack-pages) option to output larger stack Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 06/19] xenctx: Add command line option -D (--decode-as-ascii) Don Slutz
` (13 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
-b <bytes>, --bytes-per-line <bytes>
change the number of bytes per line output for Stack.
(default 32) Note: rounded to native size (4 or 8 bytes).
This option allows you to change the width of the output line. When
used with the -D option and/or -t, the output can be adjusted with
this to less then 80 columns.
-l <lines>, --lines <lines>
change the number of lines output for Stack. (default 5)
Can be specified as MAX. Note: Fewer lines will be output
if stack limit reached.
The default value show a reasonable amount of the raw stack. The -S
option will output all of it one line at a time. This can be used
to select something in the middle.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 79 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 67 insertions(+), 12 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index b740f1e..1433056 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <inttypes.h>
#include <getopt.h>
+#include <limits.h>
#include "xenctrl.h"
#include <xen/foreign/x86_32.h>
@@ -36,12 +37,16 @@ static struct xenctx {
int stack_trace;
int disp_all;
int nr_stack_pages;
+ int bytes_per_line;
+ int lines;
int all_vcpus;
int self_paused;
xc_dominfo_t dominfo;
} xenctx;
#define DEFAULT_NR_STACK_PAGES 1
+#define DEFAULT_BYTES_PER_LINE 32
+#define DEFAULT_LINES 5
#if defined (__i386__) || defined (__x86_64__)
typedef unsigned long long guest_word_t;
@@ -64,6 +69,8 @@ typedef uint64_t guest_word_t;
#define FMT_64B_WORD "%016llx"
#endif
+#define MAX_BYTES_PER_LINE 128
+
struct symbol {
guest_word_t address;
char *name;
@@ -665,24 +672,33 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
guest_word_t *p;
int i;
+ if ( width )
+ xenctx.bytes_per_line =
+ ((xenctx.bytes_per_line + width - 1) / width) * width;
stack_limit = ((stack_pointer(ctx) + XC_PAGE_SIZE)
& ~((guest_word_t) XC_PAGE_SIZE - 1))
+ (xenctx.nr_stack_pages - 1) * XC_PAGE_SIZE;
printf("\n");
- printf("Stack:\n");
- for (i=1; i<5 && stack < stack_limit; i++) {
- while(stack < stack_limit && stack < stack_pointer(ctx) + i*32) {
- p = map_page(ctx, vcpu, stack);
- if (!p)
- return -1;
- word = read_stack_word(p, width);
- printf(" ");
- print_stack_word(word, width);
- stack += width;
+ if ( xenctx.lines )
+ {
+ printf("Stack:\n");
+ for (i = 1; i < xenctx.lines + 1 && stack < stack_limit; i++)
+ {
+ while ( stack < stack_limit &&
+ stack < stack_pointer(ctx) + i * xenctx.bytes_per_line )
+ {
+ p = map_page(ctx, vcpu, stack);
+ if ( !p )
+ return -1;
+ word = read_stack_word(p, width);
+ printf(" ");
+ print_stack_word(word, width);
+ stack += width;
+ }
+ printf("\n");
}
printf("\n");
}
- printf("\n");
if(xenctx.stack_trace)
printf("Stack Trace:\n");
@@ -843,19 +859,30 @@ static void usage(void)
DEFAULT_NR_STACK_PAGES);
printf(" Changes stack limit. Note: use with caution (easy\n");
printf(" to get garbage).\n");
+ printf(" -b <bytes>, --bytes-per-line <bytes>\n");
+ printf(" change the number of bytes per line output for Stack.\n");
+ printf(" (default %d) Note: rounded to native size (4 or 8 bytes).\n",
+ DEFAULT_BYTES_PER_LINE);
+ printf(" -l <lines>, --lines <lines>\n");
+ printf(" change the number of lines output for Stack. (default %d)\n",
+ DEFAULT_LINES);
+ printf(" Can be specified as MAX. Note: Fewer lines will be output\n");
+ printf(" if stack limit reached.\n");
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SCn:";
+ static const char *sopts = "fs:hak:SCn:b:l:";
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
{"frame-pointers", 0, NULL, 'f'},
{"kernel-start", 1, NULL, 'k'},
{"display-stack-pages", 0, NULL, 'n'},
+ {"bytes-per-line", 1, NULL, 'b'},
+ {"lines", 1, NULL, 'l'},
{"all", 0, NULL, 'a'},
{"all-vcpus", 0, NULL, 'C'},
{"help", 0, NULL, 'h'},
@@ -865,6 +892,8 @@ int main(int argc, char **argv)
int vcpu = 0;
+ xenctx.bytes_per_line = DEFAULT_BYTES_PER_LINE;
+ xenctx.lines = DEFAULT_LINES;
xenctx.nr_stack_pages = DEFAULT_NR_STACK_PAGES;
while ((ch = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
@@ -891,6 +920,32 @@ int main(int argc, char **argv)
exit(-1);
}
break;
+ case 'b':
+ xenctx.bytes_per_line = strtol(optarg, NULL, 0);
+ if ( xenctx.bytes_per_line < 4 ||
+ xenctx.bytes_per_line > MAX_BYTES_PER_LINE )
+ {
+ fprintf(stderr,
+ "%s: Unsupported value for --bytes-per-line '%s'. Needs to be 4 <= %d <= %d\n",
+ argv[0], optarg, xenctx.bytes_per_line,
+ MAX_BYTES_PER_LINE);
+ exit(-1);
+ }
+ break;
+ case 'l':
+ if ( !strcmp(optarg, "all") || !strcmp(optarg, "ALL") ||
+ !strcmp(optarg, "max") || !strcmp(optarg, "MAX") )
+ xenctx.lines = INT_MAX - 1;
+ else
+ xenctx.lines = strtol(optarg, NULL, 0);
+ if ( xenctx.lines < 0 || xenctx.lines == INT_MAX)
+ {
+ fprintf(stderr,
+ "%s: Unsupported value(%d) for --lines '%s'. Needs to be >= 0, < %d\n",
+ argv[0], xenctx.lines, optarg, INT_MAX);
+ exit(-1);
+ }
+ break;
case 'C':
xenctx.all_vcpus = 1;
break;
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 06/19] xenctx: Add command line option -D (--decode-as-ascii)
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (4 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 05/19] xenctx: Add command line options -b (--bytes-per-line) and -l (--lines) Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 07/19] xenctx: Add command line option -t (--tag-stack-dump) Don Slutz
` (12 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
If specified, output ascii version of stack also.
This is not the default because the result exceeds 80 characters per line.
Here is an example:
Stack:
ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800 .......... ......x>......h......
0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c ........ .C...../r>.............
00000000ffffffff 0000000000000000 0000000000000000 0000000000200000 .......................... .....
0000000000000000 0000000000000000 ................
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 1433056..82cf6b0 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -39,6 +39,7 @@ static struct xenctx {
int nr_stack_pages;
int bytes_per_line;
int lines;
+ int decode_as_ascii;
int all_vcpus;
int self_paused;
xc_dominfo_t dominfo;
@@ -670,6 +671,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
guest_word_t frame;
guest_word_t word;
guest_word_t *p;
+ guest_word_t ascii[MAX_BYTES_PER_LINE/4];
int i;
if ( width )
@@ -684,6 +686,9 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
printf("Stack:\n");
for (i = 1; i < xenctx.lines + 1 && stack < stack_limit; i++)
{
+ int j = 0;
+ int k;
+
while ( stack < stack_limit &&
stack < stack_pointer(ctx) + i * xenctx.bytes_per_line )
{
@@ -691,10 +696,36 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
if ( !p )
return -1;
word = read_stack_word(p, width);
+ if ( xenctx.decode_as_ascii )
+ ascii[j++] = word;
printf(" ");
print_stack_word(word, width);
stack += width;
}
+ if ( xenctx.decode_as_ascii )
+ {
+ /*
+ * Line up ascii output if less than bytes_per_line
+ * were printed.
+ */
+ for (k = j; k < xenctx.bytes_per_line / width; k++)
+ printf(" %*s", width * 2, "");
+ printf(" ");
+ for (k = 0; k < j; k++)
+ {
+ int l;
+ unsigned char *bytep = (unsigned char *)&ascii[k];
+
+ for (l = 0; l < width; l++)
+ {
+ if (isprint(*bytep))
+ printf("%c", *bytep);
+ else
+ printf(".");
+ bytep++;
+ }
+ }
+ }
printf("\n");
}
printf("\n");
@@ -868,19 +899,22 @@ static void usage(void)
DEFAULT_LINES);
printf(" Can be specified as MAX. Note: Fewer lines will be output\n");
printf(" if stack limit reached.\n");
+ printf(" -D, --decode-as-ascii\n");
+ printf(" add a decode of Stack dump as ascii.\n");
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SCn:b:l:";
+ static const char *sopts = "fs:hak:SCn:b:l:D";
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
{"frame-pointers", 0, NULL, 'f'},
{"kernel-start", 1, NULL, 'k'},
{"display-stack-pages", 0, NULL, 'n'},
+ {"decode-as-ascii", 0, NULL, 'D'},
{"bytes-per-line", 1, NULL, 'b'},
{"lines", 1, NULL, 'l'},
{"all", 0, NULL, 'a'},
@@ -920,6 +954,9 @@ int main(int argc, char **argv)
exit(-1);
}
break;
+ case 'D':
+ xenctx.decode_as_ascii = 1;
+ break;
case 'b':
xenctx.bytes_per_line = strtol(optarg, NULL, 0);
if ( xenctx.bytes_per_line < 4 ||
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 07/19] xenctx: Add command line option -t (--tag-stack-dump)
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (5 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 06/19] xenctx: Add command line option -D (--decode-as-ascii) Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 08/19] xenctx: Change print_symbol to do the space before Don Slutz
` (11 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
If specified, add stack address to dump.
This is not the default because the result exceeds 80 characters per line.
Here is an example:
Stack:
ffffffff803ddf90: ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800
ffffffff803ddfb0: 0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c
ffffffff803ddfd0: 00000000ffffffff 0000000000000000 0000000000000000 0000000000200000
ffffffff803ddff0: 0000000000000000 0000000000000000
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 82cf6b0..145c990 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -40,6 +40,7 @@ static struct xenctx {
int bytes_per_line;
int lines;
int decode_as_ascii;
+ int tag_stack_dump;
int all_vcpus;
int self_paused;
xc_dominfo_t dominfo;
@@ -689,6 +690,11 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
int j = 0;
int k;
+ if ( xenctx.tag_stack_dump )
+ {
+ print_stack_word(stack, width);
+ printf(":");
+ }
while ( stack < stack_limit &&
stack < stack_pointer(ctx) + i * xenctx.bytes_per_line )
{
@@ -901,13 +907,15 @@ static void usage(void)
printf(" if stack limit reached.\n");
printf(" -D, --decode-as-ascii\n");
printf(" add a decode of Stack dump as ascii.\n");
+ printf(" -t, --tag-stack-dump\n");
+ printf(" add address on each line of Stack dump.\n");
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SCn:b:l:D";
+ static const char *sopts = "fs:hak:SCn:b:l:Dt";
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
@@ -915,6 +923,7 @@ int main(int argc, char **argv)
{"kernel-start", 1, NULL, 'k'},
{"display-stack-pages", 0, NULL, 'n'},
{"decode-as-ascii", 0, NULL, 'D'},
+ {"tag-stack-dump", 0, NULL, 't'},
{"bytes-per-line", 1, NULL, 'b'},
{"lines", 1, NULL, 'l'},
{"all", 0, NULL, 'a'},
@@ -957,6 +966,9 @@ int main(int argc, char **argv)
case 'D':
xenctx.decode_as_ascii = 1;
break;
+ case 't':
+ xenctx.tag_stack_dump = 1;
+ break;
case 'b':
xenctx.bytes_per_line = strtol(optarg, NULL, 0);
if ( xenctx.bytes_per_line < 4 ||
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 08/19] xenctx: Change print_symbol to do the space before.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (6 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 07/19] xenctx: Add command line option -t (--tag-stack-dump) Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:06 ` [PATCH v10 09/19] xenctx: More info on failed to map page Don Slutz
` (10 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Jan Beulich
From: Don Slutz <Don@CloudSwitch.com>
This stops the output of an extra space at the end of the line.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
---
tools/xentrace/xenctx.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 145c990..eb30577 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -171,9 +171,9 @@ static void print_symbol(guest_word_t addr)
return;
if (addr==s->address)
- printf("%s ", s->name);
+ printf(" %s", s->name);
else
- printf("%s+%#x ", s->name, (unsigned int)(addr - s->address));
+ printf(" %s+%#x", s->name, (unsigned int)(addr - s->address));
}
static void read_symbol_table(const char *symtab)
@@ -312,7 +312,7 @@ static void print_ctx_32(vcpu_guest_context_x86_32_t *ctx)
{
struct cpu_user_regs_x86_32 *regs = &ctx->user_regs;
- printf("cs:eip: %04x:%08x ", regs->cs, regs->eip);
+ printf("cs:eip: %04x:%08x", regs->cs, regs->eip);
print_symbol(regs->eip);
print_flags(regs->eflags);
printf("ss:esp: %04x:%08x\n", regs->ss, regs->esp);
@@ -341,7 +341,7 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx)
{
struct cpu_user_regs_x86_64 *regs = &ctx->user_regs;
- printf("cs:eip: %04x:%08x ", regs->cs, (uint32_t)regs->eip);
+ printf("cs:eip: %04x:%08x", regs->cs, (uint32_t)regs->eip);
print_symbol((uint32_t)regs->eip);
print_flags((uint32_t)regs->eflags);
printf("ss:esp: %04x:%08x\n", regs->ss, (uint32_t)regs->esp);
@@ -370,7 +370,7 @@ static void print_ctx_64(vcpu_guest_context_x86_64_t *ctx)
{
struct cpu_user_regs_x86_64 *regs = &ctx->user_regs;
- printf("rip: %016"PRIx64" ", regs->rip);
+ printf("rip: %016"PRIx64, regs->rip);
print_symbol(regs->rip);
print_flags(regs->rflags);
printf("rsp: %016"PRIx64"\n", regs->rsp);
@@ -468,7 +468,7 @@ static void print_ctx_32(vcpu_guest_context_t *ctx)
{
vcpu_guest_core_regs_t *regs = &ctx->user_regs;
- printf("PC: %08"PRIx32" ", regs->pc32);
+ printf("PC: %08"PRIx32, regs->pc32);
print_symbol(regs->pc32);
printf("\n");
printf("CPSR: %08"PRIx32"\n", regs->cpsr);
@@ -520,7 +520,7 @@ static void print_ctx_64(vcpu_guest_context_t *ctx)
{
vcpu_guest_core_regs_t *regs = &ctx->user_regs;
- printf("PC: %016"PRIx64" ", regs->pc64);
+ printf("PC: %016"PRIx64, regs->pc64);
print_symbol(regs->pc64);
printf("\n");
@@ -743,7 +743,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
printf("Call Trace:\n");
printf("%c [<", xenctx.stack_trace ? '*' : ' ');
print_stack_word(instr_pointer(ctx), width);
- printf(">] ");
+ printf(">]");
print_symbol(instr_pointer(ctx));
printf(" <--\n");
@@ -783,7 +783,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
word = read_stack_word(p, width);
printf("%c [<", xenctx.stack_trace ? '|' : ' ');
print_stack_word(word, width);
- printf(">] ");
+ printf(">]");
print_symbol(word);
printf("\n");
stack += width;
@@ -799,7 +799,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
if (is_kernel_text(word)) {
printf(" [<");
print_stack_word(word, width);
- printf(">] ");
+ printf(">]");
print_symbol(word);
printf("\n");
} else if (xenctx.stack_trace) {
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 09/19] xenctx: More info on failed to map page.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (7 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 08/19] xenctx: Change print_symbol to do the space before Don Slutz
@ 2014-04-03 19:06 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 10/19] xenctx: Add output of stack address to Call and Stack Trace Don Slutz
` (9 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:06 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Jan Beulich
From: Don Slutz <Don@CloudSwitch.com>
Also output an extra new line since we may be in the middle of output.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
---
tools/xentrace/xenctx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index eb30577..4bb5507 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -618,7 +618,7 @@ static void *map_page(vcpu_guest_context_any_t *ctx, int vcpu, guest_word_t virt
mapped = xc_map_foreign_range(xenctx.xc_handle, xenctx.domid, XC_PAGE_SIZE, PROT_READ, mfn);
if (mapped == NULL) {
- fprintf(stderr, "failed to map page.\n");
+ fprintf(stderr, "\nfailed to map page for "FMT_32B_WORD".\n", virt);
return NULL;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 10/19] xenctx: Add output of stack address to Call and Stack Trace.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (8 preceding siblings ...)
2014-04-03 19:06 ` [PATCH v10 09/19] xenctx: More info on failed to map page Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 11/19] xenctx: Add -m (--memory) <maddr> option to dump memory at maddr Don Slutz
` (8 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
Here is an example:
Call Trace:
[<ffffffff8006b2b0>] default_idle+0x29 <--
ffffffff803ddf90: [<ffffffff80048d19>] cpu_idle+0x95
ffffffff803ddfa0: [<ffffffff803e7801>] start_kernel+0x220
ffffffff803ddfc0: [<ffffffff803e722f>] x86_64_start_kernel+0x22f
and
Stack Trace:
* [<ffffffff8006b2b0>] default_idle+0x29 <--
ffffffff803ddf90: [<ffffffff80048d19>] cpu_idle+0x95
ffffffff803ddf98: 0000000000200800
ffffffff803ddfa0: [<ffffffff803e7801>] start_kernel+0x220
ffffffff803ddfa8: 0000000000086800
ffffffff803ddfb0: 0000000000000000
ffffffff803ddfb8: ffffffff80430720
ffffffff803ddfc0: [<ffffffff803e722f>] x86_64_start_kernel+0x22f
ffffffff803ddfc8: 80008e000010019c
ffffffff803ddfd0: 00000000ffffffff
ffffffff803ddfd8: 0000000000000000
ffffffff803ddfe0: 0000000000000000
ffffffff803ddfe8: 0000000000200000
ffffffff803ddff0: 0000000000000000
ffffffff803ddff8: 0000000000000000
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 4bb5507..cefbb8b 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -665,6 +665,12 @@ static int print_code(vcpu_guest_context_any_t *ctx, int vcpu)
return 0;
}
+static void print_stack_addr(guest_word_t addr, int width)
+{
+ print_stack_word(addr, width);
+ printf(": ");
+}
+
static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
{
guest_word_t stack = stack_pointer(ctx);
@@ -741,7 +747,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
printf("Stack Trace:\n");
else
printf("Call Trace:\n");
- printf("%c [<", xenctx.stack_trace ? '*' : ' ');
+ printf("%*s %c [<", width*2, "", xenctx.stack_trace ? '*' : ' ');
print_stack_word(instr_pointer(ctx), width);
printf(">]");
@@ -756,9 +762,10 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
p = map_page(ctx, vcpu, stack);
if (!p)
return -1;
+ print_stack_addr(stack, width);
printf("| ");
print_stack_word(read_stack_word(p, width), width);
- printf(" \n");
+ printf("\n");
stack += width;
}
} else {
@@ -770,6 +777,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
return -1;
frame = read_stack_word(p, width);
if (xenctx.stack_trace) {
+ print_stack_addr(stack, width);
printf("|-- ");
print_stack_word(read_stack_word(p, width), width);
printf("\n");
@@ -781,6 +789,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
if (!p)
return -1;
word = read_stack_word(p, width);
+ print_stack_addr(stack, width);
printf("%c [<", xenctx.stack_trace ? '|' : ' ');
print_stack_word(word, width);
printf(">]");
@@ -797,12 +806,14 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
return -1;
word = read_stack_word(p, width);
if (is_kernel_text(word)) {
+ print_stack_addr(stack, width);
printf(" [<");
print_stack_word(word, width);
printf(">]");
print_symbol(word);
printf("\n");
} else if (xenctx.stack_trace) {
+ print_stack_addr(stack, width);
printf(" ");
print_stack_word(word, width);
printf("\n");
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 11/19] xenctx: Add -m (--memory) <maddr> option to dump memory at maddr.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (9 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 10/19] xenctx: Add output of stack address to Call and Stack Trace Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 12/19] xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified Don Slutz
` (7 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
Currently not supported on ARM.
New routine read_mem_word() will correctly read a word that crosses
a page boundary. It will not fault if the 2nd page can not be
mapped.
Moved xenctx because guest_word_t is not defined where it was.
Here is an example:
Memory (address ffffffff803ddf90):
ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800
0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c
00000000ffffffff 0000000000000000 0000000000000000 0000000000200000
0000000000000000 0000000000000000 0000000000000000 00cf9b000000ffff
00af9b000000ffff 00cf93000000ffff 00cffb000000ffff 00cff3000000ffff
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v10:
Drop #endif before print_stack_word (and #ifndef after).
tools/xentrace/xenctx.c | 240 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 170 insertions(+), 70 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index cefbb8b..9aa55e2 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -30,22 +30,6 @@
#include <xen/foreign/x86_64.h>
#include <xen/hvm/save.h>
-static struct xenctx {
- xc_interface *xc_handle;
- int domid;
- int frame_ptrs;
- int stack_trace;
- int disp_all;
- int nr_stack_pages;
- int bytes_per_line;
- int lines;
- int decode_as_ascii;
- int tag_stack_dump;
- int all_vcpus;
- int self_paused;
- xc_dominfo_t dominfo;
-} xenctx;
-
#define DEFAULT_NR_STACK_PAGES 1
#define DEFAULT_BYTES_PER_LINE 32
#define DEFAULT_LINES 5
@@ -73,6 +57,27 @@ typedef uint64_t guest_word_t;
#define MAX_BYTES_PER_LINE 128
+static struct xenctx {
+ xc_interface *xc_handle;
+ int domid;
+ int frame_ptrs;
+ int stack_trace;
+ int disp_all;
+ int nr_stack_pages;
+ int bytes_per_line;
+ int lines;
+ int decode_as_ascii;
+ int tag_stack_dump;
+ int tag_call_trace;
+ int all_vcpus;
+#ifndef NO_TRANSLATION
+ guest_word_t mem_addr;
+ int do_memory;
+#endif
+ int self_paused;
+ xc_dominfo_t dominfo;
+} xenctx;
+
struct symbol {
guest_word_t address;
char *name;
@@ -634,6 +639,44 @@ static guest_word_t read_stack_word(guest_word_t *src, int width)
return word;
}
+static guest_word_t read_mem_word(vcpu_guest_context_any_t *ctx, int vcpu,
+ guest_word_t virt, int width)
+{
+ if ( (virt & 7) == 0 )
+ {
+ guest_word_t *p = map_page(ctx, vcpu, virt);
+
+ if ( p )
+ return read_stack_word(p, width);
+ else
+ return -1;
+ }
+ else
+ {
+ guest_word_t word = 0;
+ char *src, *dst;
+ int i;
+
+ /* Little-endian only */
+ dst = (char *)&word;
+ for (i = 0; i < width; i++)
+ {
+ src = map_page(ctx, vcpu, virt + i);
+ if ( src )
+ *dst++ = *src;
+ else
+ {
+ guest_word_t missing = -1LL;
+
+ /* Return all ones for missing memory */
+ memcpy(dst, &missing, width - i);
+ return word;
+ }
+ }
+ return word;
+ }
+}
+
static void print_stack_word(guest_word_t word, int width)
{
if (width == 4)
@@ -642,6 +685,77 @@ static void print_stack_word(guest_word_t word, int width)
printf(FMT_64B_WORD, word);
}
+static int print_lines(vcpu_guest_context_any_t *ctx, int vcpu, int width,
+ guest_word_t mem_addr, guest_word_t mem_limit)
+{
+ guest_word_t mem_start = mem_addr;
+ guest_word_t word;
+ guest_word_t ascii[MAX_BYTES_PER_LINE/4];
+ int i;
+
+ for (i = 1; i < xenctx.lines + 1 && mem_addr < mem_limit; i++)
+ {
+ int j = 0;
+ int k;
+
+ if ( xenctx.tag_stack_dump )
+ {
+ print_stack_word(mem_addr, width);
+ printf(":");
+ }
+ while ( mem_addr < mem_limit &&
+ mem_addr < mem_start + i * xenctx.bytes_per_line )
+ {
+ void *p = map_page(ctx, vcpu, mem_addr);
+ if ( !p )
+ return -1;
+ word = read_mem_word(ctx, vcpu, mem_addr, width);
+ if ( xenctx.decode_as_ascii )
+ ascii[j++] = word;
+ printf(" ");
+ print_stack_word(word, width);
+ mem_addr += width;
+ }
+ if ( xenctx.decode_as_ascii )
+ {
+ /*
+ * Line up ascii output if less than bytes_per_line
+ * were printed.
+ */
+ for (k = j; k < xenctx.bytes_per_line / width; k++)
+ printf(" %*s", width * 2, "");
+ printf(" ");
+ for (k = 0; k < j; k++)
+ {
+ int l;
+ unsigned char *bytep = (unsigned char *)&ascii[k];
+
+ for (l = 0; l < width; l++)
+ {
+ if (isprint(*bytep))
+ printf("%c", *bytep);
+ else
+ printf(".");
+ bytep++;
+ }
+ }
+ }
+ printf("\n");
+ }
+ printf("\n");
+ return 0;
+}
+
+static void print_mem(vcpu_guest_context_any_t *ctx, int vcpu, int width,
+ guest_word_t mem_addr)
+{
+ printf("Memory (address ");
+ print_stack_word(mem_addr, width);
+ printf("):\n");
+ print_lines(ctx, vcpu, width, mem_addr,
+ mem_addr + xenctx.lines * xenctx.bytes_per_line);
+}
+
static int print_code(vcpu_guest_context_any_t *ctx, int vcpu)
{
guest_word_t instr;
@@ -678,8 +792,6 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
guest_word_t frame;
guest_word_t word;
guest_word_t *p;
- guest_word_t ascii[MAX_BYTES_PER_LINE/4];
- int i;
if ( width )
xenctx.bytes_per_line =
@@ -691,56 +803,8 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
if ( xenctx.lines )
{
printf("Stack:\n");
- for (i = 1; i < xenctx.lines + 1 && stack < stack_limit; i++)
- {
- int j = 0;
- int k;
-
- if ( xenctx.tag_stack_dump )
- {
- print_stack_word(stack, width);
- printf(":");
- }
- while ( stack < stack_limit &&
- stack < stack_pointer(ctx) + i * xenctx.bytes_per_line )
- {
- p = map_page(ctx, vcpu, stack);
- if ( !p )
- return -1;
- word = read_stack_word(p, width);
- if ( xenctx.decode_as_ascii )
- ascii[j++] = word;
- printf(" ");
- print_stack_word(word, width);
- stack += width;
- }
- if ( xenctx.decode_as_ascii )
- {
- /*
- * Line up ascii output if less than bytes_per_line
- * were printed.
- */
- for (k = j; k < xenctx.bytes_per_line / width; k++)
- printf(" %*s", width * 2, "");
- printf(" ");
- for (k = 0; k < j; k++)
- {
- int l;
- unsigned char *bytep = (unsigned char *)&ascii[k];
-
- for (l = 0; l < width; l++)
- {
- if (isprint(*bytep))
- printf("%c", *bytep);
- else
- printf(".");
- bytep++;
- }
- }
- }
- printf("\n");
- }
- printf("\n");
+ if ( print_lines(ctx, vcpu, width, stack, stack_limit) )
+ return -1;
}
if(xenctx.stack_trace)
@@ -861,6 +925,13 @@ static void dump_ctx(int vcpu)
}
#endif
+#ifndef NO_TRANSLATION
+ if ( xenctx.do_memory )
+ {
+ print_mem(&ctx, vcpu, guest_word_size, xenctx.mem_addr);
+ return;
+ }
+#endif
print_ctx(&ctx);
#ifndef NO_TRANSLATION
if (print_code(&ctx, vcpu))
@@ -920,13 +991,21 @@ static void usage(void)
printf(" add a decode of Stack dump as ascii.\n");
printf(" -t, --tag-stack-dump\n");
printf(" add address on each line of Stack dump.\n");
+#ifndef NO_TRANSLATION
+ printf(" -m maddr, --memory=maddr\n");
+ printf(" dump memory at maddr.\n");
+#endif
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SCn:b:l:Dt";
+ static const char *sopts = "fs:hak:SCn:b:l:Dt"
+#ifndef NO_TRANSLATION
+ "m:"
+#endif
+ ;
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
@@ -935,6 +1014,9 @@ int main(int argc, char **argv)
{"display-stack-pages", 0, NULL, 'n'},
{"decode-as-ascii", 0, NULL, 'D'},
{"tag-stack-dump", 0, NULL, 't'},
+#ifndef NO_TRANSLATION
+ {"memory", 1, NULL, 'm'},
+#endif
{"bytes-per-line", 1, NULL, 'b'},
{"lines", 1, NULL, 'l'},
{"all", 0, NULL, 'a'},
@@ -945,6 +1027,7 @@ int main(int argc, char **argv)
const char *symbol_table = NULL;
int vcpu = 0;
+ int do_default = 1;
xenctx.bytes_per_line = DEFAULT_BYTES_PER_LINE;
xenctx.lines = DEFAULT_LINES;
@@ -1008,10 +1091,18 @@ int main(int argc, char **argv)
break;
case 'C':
xenctx.all_vcpus = 1;
+ do_default = 0;
break;
case 'k':
kernel_start = strtoull(optarg, NULL, 0);
break;
+#ifndef NO_TRANSLATION
+ case 'm':
+ xenctx.mem_addr = strtoull(optarg, NULL, 0);
+ xenctx.do_memory = 1;
+ do_default = 0;
+ break;
+#endif
case 'h':
usage();
exit(-1);
@@ -1061,9 +1152,18 @@ int main(int argc, char **argv)
xenctx.self_paused = 1;
}
+#ifndef NO_TRANSLATION
+ if ( xenctx.do_memory )
+ {
+ dump_ctx(vcpu);
+ if (xenctx.all_vcpus)
+ printf("\n");
+ }
+ xenctx.do_memory = 0;
+#endif
if (xenctx.all_vcpus)
dump_all_vcpus();
- else
+ if ( do_default )
dump_ctx(vcpu);
if (xenctx.self_paused) {
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 12/19] xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (10 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 11/19] xenctx: Add -m (--memory) <maddr> option to dump memory at maddr Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 13/19] xenctx: Add -d (--dump-as-stack) <daddr> option to dump memory at daddr as a stack Don Slutz
` (6 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
To do this correctly the program name must be remembered since argv
is adjusted at the end of option parsing.
Switch all uses of argv[0] to prog.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 9aa55e2..aa0c9d1 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -1001,6 +1001,7 @@ int main(int argc, char **argv)
{
int ch;
int ret;
+ const char *prog = argv[0];
static const char *sopts = "fs:hak:SCn:b:l:Dt"
#ifndef NO_TRANSLATION
"m:"
@@ -1053,7 +1054,7 @@ int main(int argc, char **argv)
{
fprintf(stderr,
"%s: Unsupported value(%d) for --display-stack-pages '%s'. Needs to be >= 1\n",
- argv[0], xenctx.nr_stack_pages, optarg);
+ prog, xenctx.nr_stack_pages, optarg);
exit(-1);
}
break;
@@ -1070,7 +1071,7 @@ int main(int argc, char **argv)
{
fprintf(stderr,
"%s: Unsupported value for --bytes-per-line '%s'. Needs to be 4 <= %d <= %d\n",
- argv[0], optarg, xenctx.bytes_per_line,
+ prog, optarg, xenctx.bytes_per_line,
MAX_BYTES_PER_LINE);
exit(-1);
}
@@ -1085,7 +1086,7 @@ int main(int argc, char **argv)
{
fprintf(stderr,
"%s: Unsupported value(%d) for --lines '%s'. Needs to be >= 0, < %d\n",
- argv[0], xenctx.lines, optarg, INT_MAX);
+ prog, xenctx.lines, optarg, INT_MAX);
exit(-1);
}
break;
@@ -1107,7 +1108,7 @@ int main(int argc, char **argv)
usage();
exit(-1);
case '?':
- fprintf(stderr, "%s --help for more options\n", argv[0]);
+ fprintf(stderr, "%s --help for more options\n", prog);
exit(-1);
}
}
@@ -1125,8 +1126,17 @@ int main(int argc, char **argv)
exit(-1);
}
- if (argc == 2)
+ if ( argc == 2 )
+ {
+ if ( xenctx.all_vcpus )
+ {
+ fprintf(stderr,
+ "%s: both --all-vcpus and [VCPU] is not supported\n",
+ prog);
+ exit(-1);
+ }
vcpu = atoi(argv[1]);
+ }
if (symbol_table)
read_symbol_table(symbol_table);
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 13/19] xenctx: Add -d (--dump-as-stack) <daddr> option to dump memory at daddr as a stack.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (11 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 12/19] xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 14/19] xenctx: change is_kernel_text() into kernel_addr() Don Slutz
` (5 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Don Slutz,
Ian Jackson, Don Slutz, Jan Beulich
Also switch from read_stack_word to read_mem_word since the provided
address may not be aligned.
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 66 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 16 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index aa0c9d1..3773b34 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -72,7 +72,9 @@ static struct xenctx {
int all_vcpus;
#ifndef NO_TRANSLATION
guest_word_t mem_addr;
+ guest_word_t stk_addr;
int do_memory;
+ int do_stack;
#endif
int self_paused;
xc_dominfo_t dominfo;
@@ -773,9 +775,7 @@ static int print_code(vcpu_guest_context_any_t *ctx, int vcpu)
else
printf("%02x ", *c);
}
- printf("\n");
-
- printf("\n");
+ printf("\n\n\n");
return 0;
}
@@ -785,9 +785,10 @@ static void print_stack_addr(guest_word_t addr, int width)
printf(": ");
}
-static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
+static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
+ guest_word_t stk_addr_start)
{
- guest_word_t stack = stack_pointer(ctx);
+ guest_word_t stack = stk_addr_start;
guest_word_t stack_limit;
guest_word_t frame;
guest_word_t word;
@@ -799,7 +800,6 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
stack_limit = ((stack_pointer(ctx) + XC_PAGE_SIZE)
& ~((guest_word_t) XC_PAGE_SIZE - 1))
+ (xenctx.nr_stack_pages - 1) * XC_PAGE_SIZE;
- printf("\n");
if ( xenctx.lines )
{
printf("Stack:\n");
@@ -811,12 +811,15 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
printf("Stack Trace:\n");
else
printf("Call Trace:\n");
- printf("%*s %c [<", width*2, "", xenctx.stack_trace ? '*' : ' ');
- print_stack_word(instr_pointer(ctx), width);
- printf(">]");
+ if ( !xenctx.do_stack )
+ {
+ printf("%*s %c [<", width*2, "", xenctx.stack_trace ? '*' : ' ');
+ print_stack_word(instr_pointer(ctx), width);
+ printf(">]");
- print_symbol(instr_pointer(ctx));
- printf(" <--\n");
+ print_symbol(instr_pointer(ctx));
+ printf(" <--\n");
+ }
if (xenctx.frame_ptrs) {
stack = stack_pointer(ctx);
frame = frame_pointer(ctx);
@@ -863,12 +866,12 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
}
}
} else {
- stack = stack_pointer(ctx);
+ stack = stk_addr_start;
while(stack < stack_limit) {
p = map_page(ctx, vcpu, stack);
if (!p)
return -1;
- word = read_stack_word(p, width);
+ word = read_mem_word(ctx, vcpu, stack, width);
if (is_kernel_text(word)) {
print_stack_addr(stack, width);
printf(" [<");
@@ -931,13 +934,19 @@ static void dump_ctx(int vcpu)
print_mem(&ctx, vcpu, guest_word_size, xenctx.mem_addr);
return;
}
+ if ( xenctx.do_stack )
+ {
+ print_stack(&ctx, vcpu, guest_word_size, xenctx.stk_addr);
+ return;
+ }
#endif
print_ctx(&ctx);
#ifndef NO_TRANSLATION
if (print_code(&ctx, vcpu))
return;
if (is_kernel_text(instr_pointer(&ctx)))
- if (print_stack(&ctx, vcpu, guest_word_size))
+ if ( print_stack(&ctx, vcpu, guest_word_size,
+ stack_pointer(&ctx)) )
return;
#endif
}
@@ -994,6 +1003,8 @@ static void usage(void)
#ifndef NO_TRANSLATION
printf(" -m maddr, --memory=maddr\n");
printf(" dump memory at maddr.\n");
+ printf(" -d daddr, --dump-as-stack=daddr\n");
+ printf(" dump memory as a stack at daddr.\n");
#endif
}
@@ -1004,7 +1015,7 @@ int main(int argc, char **argv)
const char *prog = argv[0];
static const char *sopts = "fs:hak:SCn:b:l:Dt"
#ifndef NO_TRANSLATION
- "m:"
+ "m:d:"
#endif
;
static const struct option lopts[] = {
@@ -1017,6 +1028,7 @@ int main(int argc, char **argv)
{"tag-stack-dump", 0, NULL, 't'},
#ifndef NO_TRANSLATION
{"memory", 1, NULL, 'm'},
+ {"dump-as-stack", 1, NULL, 'd'},
#endif
{"bytes-per-line", 1, NULL, 'b'},
{"lines", 1, NULL, 'l'},
@@ -1103,6 +1115,11 @@ int main(int argc, char **argv)
xenctx.do_memory = 1;
do_default = 0;
break;
+ case 'd':
+ xenctx.stk_addr = strtoull(optarg, NULL, 0);
+ xenctx.do_stack = 1;
+ do_default = 0;
+ break;
#endif
case 'h':
usage();
@@ -1120,6 +1137,16 @@ int main(int argc, char **argv)
exit(-1);
}
+#ifndef NO_TRANSLATION
+ if ( xenctx.frame_ptrs && xenctx.do_stack )
+ {
+ fprintf(stderr,
+ "%s: both --frame-pointers and --dump-as-stack is not supported\n",
+ prog);
+ exit(-1);
+ }
+#endif
+
xenctx.domid = atoi(argv[0]);
if (xenctx.domid==0) {
fprintf(stderr, "cannot trace dom0\n");
@@ -1166,10 +1193,17 @@ int main(int argc, char **argv)
if ( xenctx.do_memory )
{
dump_ctx(vcpu);
- if (xenctx.all_vcpus)
+ if ( xenctx.do_stack || xenctx.all_vcpus )
printf("\n");
}
xenctx.do_memory = 0;
+ if ( xenctx.do_stack )
+ {
+ dump_ctx(vcpu);
+ if ( xenctx.all_vcpus )
+ printf("\n");
+ }
+ xenctx.do_stack = 0;
#endif
if (xenctx.all_vcpus)
dump_all_vcpus();
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 14/19] xenctx: change is_kernel_text() into kernel_addr().
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (12 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 13/19] xenctx: Add -d (--dump-as-stack) <daddr> option to dump memory at daddr as a stack Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 15/19] xenctx: Add conversion of more registers to symbols Don Slutz
` (4 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
A new enum has been added to allow the caller to determine if this
kernel address is a text or data address. This is currenlty not
used, but will be in the next patch.
Add both _end and __bss_stop as kernel_end.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 75 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 56 insertions(+), 19 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 3773b34..6f6c3a3 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -34,6 +34,15 @@
#define DEFAULT_BYTES_PER_LINE 32
#define DEFAULT_LINES 5
+/* Note: the order of these matter.
+ * NOT_KERNEL_ADDR must be < both KERNEL_DATA_ADDR and KERNEL_TEXT_ADDR.
+ * KERNEL_DATA_ADDR must be < KERNEL_TEXT_ADDR. */
+typedef enum type_of_addr_ {
+ NOT_KERNEL_ADDR,
+ KERNEL_DATA_ADDR,
+ KERNEL_TEXT_ADDR,
+} type_of_addr;
+
#if defined (__i386__) || defined (__x86_64__)
typedef unsigned long long guest_word_t;
#define FMT_32B_WORD "%08llx"
@@ -76,6 +85,7 @@ static struct xenctx {
int do_memory;
int do_stack;
#endif
+ int kernel_start_set;
int self_paused;
xc_dominfo_t dominfo;
} xenctx;
@@ -87,31 +97,52 @@ struct symbol {
} *symbol_table = NULL;
guest_word_t kernel_stext, kernel_etext, kernel_sinittext, kernel_einittext, kernel_hypercallpage;
+guest_word_t kernel_text;
#if defined (__i386__) || defined (__arm__)
unsigned long long kernel_start = 0xc0000000;
+unsigned long long kernel_end = 0xffffffffULL;
#elif defined (__x86_64__)
unsigned long long kernel_start = 0xffffffff80000000UL;
+unsigned long long kernel_end = 0xffffffffffffffffUL;
#elif defined (__aarch64__)
unsigned long long kernel_start = 0xffffff8000000000UL;
+unsigned long long kernel_end = 0xffffffffffffffffULL;
#endif
-static int is_kernel_text(guest_word_t addr)
+static type_of_addr kernel_addr(guest_word_t addr)
{
- if (symbol_table == NULL)
- return (addr > kernel_start);
+ if ( symbol_table == NULL )
+ {
+ if ( addr > kernel_start )
+ return KERNEL_TEXT_ADDR;
+ else
+ return NOT_KERNEL_ADDR;
+ }
if (addr >= kernel_stext &&
addr <= kernel_etext)
- return 1;
+ return KERNEL_TEXT_ADDR;
if ( kernel_hypercallpage &&
(addr >= kernel_hypercallpage &&
addr <= kernel_hypercallpage + 4096) )
- return 1;
+ return KERNEL_TEXT_ADDR;
if (addr >= kernel_sinittext &&
addr <= kernel_einittext)
- return 1;
- return 0;
+ return KERNEL_TEXT_ADDR;
+ if ( xenctx.kernel_start_set )
+ {
+ if ( addr > kernel_start )
+ return KERNEL_TEXT_ADDR;
+ } else {
+ if ( addr >= kernel_text &&
+ addr <= kernel_end )
+ return KERNEL_DATA_ADDR;
+ if ( addr >= kernel_start &&
+ addr <= kernel_end )
+ return KERNEL_TEXT_ADDR;
+ }
+ return NOT_KERNEL_ADDR;
}
#if 0
@@ -165,11 +196,11 @@ static struct symbol *lookup_symbol(guest_word_t address)
return s->next && s->next->address <= address ? s->next : s;
}
-static void print_symbol(guest_word_t addr)
+static void print_symbol(guest_word_t addr, type_of_addr type)
{
struct symbol *s;
- if (!is_kernel_text(addr))
+ if ( kernel_addr(addr) < type )
return;
s = lookup_symbol(addr);
@@ -249,6 +280,10 @@ static void read_symbol_table(const char *symtab)
kernel_stext = address;
else if (strcmp(p, "_etext") == 0)
kernel_etext = address;
+ else if ( strcmp(p, "_text") == 0 )
+ kernel_text = address;
+ else if ( strcmp(p, "_end") == 0 || strcmp(p, "__bss_stop") == 0 )
+ kernel_end = address;
else if (strcmp(p, "_sinittext") == 0)
kernel_sinittext = address;
else if (strcmp(p, "_einittext") == 0)
@@ -320,7 +355,7 @@ static void print_ctx_32(vcpu_guest_context_x86_32_t *ctx)
struct cpu_user_regs_x86_32 *regs = &ctx->user_regs;
printf("cs:eip: %04x:%08x", regs->cs, regs->eip);
- print_symbol(regs->eip);
+ print_symbol(regs->eip, KERNEL_TEXT_ADDR);
print_flags(regs->eflags);
printf("ss:esp: %04x:%08x\n", regs->ss, regs->esp);
@@ -349,7 +384,7 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx)
struct cpu_user_regs_x86_64 *regs = &ctx->user_regs;
printf("cs:eip: %04x:%08x", regs->cs, (uint32_t)regs->eip);
- print_symbol((uint32_t)regs->eip);
+ print_symbol((uint32_t)regs->eip, KERNEL_TEXT_ADDR);
print_flags((uint32_t)regs->eflags);
printf("ss:esp: %04x:%08x\n", regs->ss, (uint32_t)regs->esp);
@@ -378,7 +413,7 @@ static void print_ctx_64(vcpu_guest_context_x86_64_t *ctx)
struct cpu_user_regs_x86_64 *regs = &ctx->user_regs;
printf("rip: %016"PRIx64, regs->rip);
- print_symbol(regs->rip);
+ print_symbol(regs->rip, KERNEL_TEXT_ADDR);
print_flags(regs->rflags);
printf("rsp: %016"PRIx64"\n", regs->rsp);
@@ -476,7 +511,7 @@ static void print_ctx_32(vcpu_guest_context_t *ctx)
vcpu_guest_core_regs_t *regs = &ctx->user_regs;
printf("PC: %08"PRIx32, regs->pc32);
- print_symbol(regs->pc32);
+ print_symbol(regs->pc32, KERNEL_TEXT_ADDR);
printf("\n");
printf("CPSR: %08"PRIx32"\n", regs->cpsr);
printf("USR: SP:%08"PRIx32" LR:%08"PRIx32"\n",
@@ -528,7 +563,7 @@ static void print_ctx_64(vcpu_guest_context_t *ctx)
vcpu_guest_core_regs_t *regs = &ctx->user_regs;
printf("PC: %016"PRIx64, regs->pc64);
- print_symbol(regs->pc64);
+ print_symbol(regs->pc64, KERNEL_TEXT_ADDR);
printf("\n");
printf("LR: %016"PRIx64"\n", regs->x30);
@@ -817,7 +852,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
print_stack_word(instr_pointer(ctx), width);
printf(">]");
- print_symbol(instr_pointer(ctx));
+ print_symbol(instr_pointer(ctx), KERNEL_TEXT_ADDR);
printf(" <--\n");
}
if (xenctx.frame_ptrs) {
@@ -860,7 +895,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
printf("%c [<", xenctx.stack_trace ? '|' : ' ');
print_stack_word(word, width);
printf(">]");
- print_symbol(word);
+ print_symbol(word, KERNEL_TEXT_ADDR);
printf("\n");
stack += width;
}
@@ -872,12 +907,13 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
if (!p)
return -1;
word = read_mem_word(ctx, vcpu, stack, width);
- if (is_kernel_text(word)) {
+ if ( kernel_addr(word) >= KERNEL_TEXT_ADDR )
+ {
print_stack_addr(stack, width);
printf(" [<");
print_stack_word(word, width);
printf(">]");
- print_symbol(word);
+ print_symbol(word, KERNEL_TEXT_ADDR);
printf("\n");
} else if (xenctx.stack_trace) {
print_stack_addr(stack, width);
@@ -944,7 +980,7 @@ static void dump_ctx(int vcpu)
#ifndef NO_TRANSLATION
if (print_code(&ctx, vcpu))
return;
- if (is_kernel_text(instr_pointer(&ctx)))
+ if ( kernel_addr(instr_pointer(&ctx)) >= KERNEL_TEXT_ADDR )
if ( print_stack(&ctx, vcpu, guest_word_size,
stack_pointer(&ctx)) )
return;
@@ -1108,6 +1144,7 @@ int main(int argc, char **argv)
break;
case 'k':
kernel_start = strtoull(optarg, NULL, 0);
+ xenctx.kernel_start_set = 1;
break;
#ifndef NO_TRANSLATION
case 'm':
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 15/19] xenctx: Add conversion of more registers to symbols
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (13 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 14/19] xenctx: change is_kernel_text() into kernel_addr() Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 16/19] xenctx: Add output of vcpu value and state for --all-vcpus Don Slutz
` (3 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
For example can change:
gs: 0000 @ ffffffff803ac000/0000000000000000
to
gs: 0000 @ ffffffff803ac000/0000000000000000 boot_cpu_pda/
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 47 +++++++++++++++++++++++++++++++++++------------
1 file changed, 35 insertions(+), 12 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 6f6c3a3..59b2f1a 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -44,6 +44,8 @@ typedef enum type_of_addr_ {
} type_of_addr;
#if defined (__i386__) || defined (__x86_64__)
+static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) };
+static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) };
typedef unsigned long long guest_word_t;
#define FMT_32B_WORD "%08llx"
#define FMT_64B_WORD "%016llx"
@@ -336,17 +338,29 @@ static void print_flags(uint64_t flags)
printf("\n");
}
-static void print_special(void *regs, const char *name, unsigned int mask, int width)
+static void print_special(void *regs, const char *name, unsigned int mask,
+ const uint64_t reg_is_addr_mask[], int width)
{
unsigned int i;
printf("\n");
for (i = 0; mask; mask >>= 1, ++i)
if (mask & 1) {
- if (width == 4)
- printf("%s%u: %08"PRIx32"\n", name, i, ((uint32_t *) regs)[i]);
+ if ( width == 4 )
+ {
+ printf("%s%u: %08"PRIx32, name, i, ((uint32_t *) regs)[i]);
+ if ( reg_is_addr_mask[i] )
+ print_symbol(reg_is_addr_mask[i] & ((uint32_t *) regs)[i],
+ KERNEL_DATA_ADDR);
+ }
else
- printf("%s%u: %08"PRIx64"\n", name, i, ((uint64_t *) regs)[i]);
+ {
+ printf("%s%u: %016"PRIx64, name, i, ((uint64_t *) regs)[i]);
+ if ( reg_is_addr_mask[i] )
+ print_symbol(reg_is_addr_mask[i] & ((uint64_t *) regs)[i],
+ KERNEL_DATA_ADDR);
+ }
+ printf("\n");
}
}
@@ -374,8 +388,8 @@ static void print_ctx_32(vcpu_guest_context_x86_32_t *ctx)
printf(" gs: %04x\n", regs->gs);
if (xenctx.disp_all) {
- print_special(ctx->ctrlreg, "cr", 0x1d, 4);
- print_special(ctx->debugreg, "dr", 0xcf, 4);
+ print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4);
+ print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4);
}
}
@@ -403,8 +417,8 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx)
printf(" gs: %04x\n", regs->gs);
if (xenctx.disp_all) {
- print_special(ctx->ctrlreg, "cr", 0x1d, 4);
- print_special(ctx->debugreg, "dr", 0xcf, 4);
+ print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4);
+ print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4);
}
}
@@ -442,13 +456,22 @@ static void print_ctx_64(vcpu_guest_context_x86_64_t *ctx)
printf(" ds: %04x\t", regs->ds);
printf(" es: %04x\n", regs->es);
- printf(" fs: %04x @ %016"PRIx64"\n", regs->fs, ctx->fs_base);
- printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64"\n", regs->gs,
+ printf(" fs: %04x @ %016"PRIx64, regs->fs, ctx->fs_base);
+ print_symbol(ctx->fs_base, KERNEL_DATA_ADDR);
+ printf("\n");
+ printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64, regs->gs,
ctx->gs_base_kernel, ctx->gs_base_user);
+ if ( symbol_table )
+ {
+ print_symbol(ctx->gs_base_kernel, KERNEL_DATA_ADDR);
+ printf("/");
+ print_symbol(ctx->gs_base_user, KERNEL_DATA_ADDR);
+ }
+ printf("\n");
if (xenctx.disp_all) {
- print_special(ctx->ctrlreg, "cr", 0x1d, 8);
- print_special(ctx->debugreg, "dr", 0xcf, 8);
+ print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 8);
+ print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 8);
}
}
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 16/19] xenctx: Add output of vcpu value and state for --all-vcpus
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (14 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 15/19] xenctx: Add conversion of more registers to symbols Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 17/19] xenctx: Fix handling of !guest_protected_mode Don Slutz
` (2 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
This makes it easier to know which vcpu the registers belong to and
when not all vcpus are online, which vcpu it is.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 59b2f1a..fa300b5 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -1019,7 +1019,13 @@ static void dump_all_vcpus(void)
if ( xc_vcpu_getinfo(xenctx.xc_handle, xenctx.domid, vcpu, &vinfo) )
continue;
if ( vinfo.online )
+ {
+ printf("vcpu%d:\n", vcpu);
dump_ctx(vcpu);
+ printf("\n");
+ }
+ else
+ printf("vcpu%d offline\n\n", vcpu);
}
}
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 17/19] xenctx: Fix handling of !guest_protected_mode
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (15 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 16/19] xenctx: Add output of vcpu value and state for --all-vcpus Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 18/19] xenctx: Add 16 bit output Don Slutz
2014-04-03 19:07 ` [PATCH v10 19/19] xenctx: Fix print_ctx_32on64's print_special call Don Slutz
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
Start with adding the code to the 64 bit path that the 32 bit path
has.
Next disable the "Stack Trace" or "Call Trace".
Finally allow stack dump.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index fa300b5..3804bd3 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -498,8 +498,13 @@ static guest_word_t instr_pointer(vcpu_guest_context_any_t *ctx)
r += ctx->x32.user_regs.cs << NONPROT_MODE_SEGMENT_SHIFT;
}
else
+ {
r = ctx->x64.user_regs.rip;
+ if ( !guest_protected_mode )
+ r += ctx->x64.user_regs.cs << NONPROT_MODE_SEGMENT_SHIFT;
+ }
+
return r;
}
@@ -514,8 +519,13 @@ static guest_word_t stack_pointer(vcpu_guest_context_any_t *ctx)
r += ctx->x32.user_regs.ss << NONPROT_MODE_SEGMENT_SHIFT;
}
else
+ {
r = ctx->x64.user_regs.rsp;
+ if ( !guest_protected_mode )
+ r += ctx->x64.user_regs.ss << NONPROT_MODE_SEGMENT_SHIFT;
+ }
+
return r;
}
@@ -865,6 +875,9 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
return -1;
}
+ if ( !guest_protected_mode )
+ return 0;
+
if(xenctx.stack_trace)
printf("Stack Trace:\n");
else
@@ -1003,7 +1016,8 @@ static void dump_ctx(int vcpu)
#ifndef NO_TRANSLATION
if (print_code(&ctx, vcpu))
return;
- if ( kernel_addr(instr_pointer(&ctx)) >= KERNEL_TEXT_ADDR )
+ if ( !guest_protected_mode ||
+ kernel_addr(instr_pointer(&ctx)) >= KERNEL_TEXT_ADDR )
if ( print_stack(&ctx, vcpu, guest_word_size,
stack_pointer(&ctx)) )
return;
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 18/19] xenctx: Add 16 bit output
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (16 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 17/19] xenctx: Fix handling of !guest_protected_mode Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
2014-04-03 19:07 ` [PATCH v10 19/19] xenctx: Fix print_ctx_32on64's print_special call Don Slutz
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
This output happens on !guest_protected_mode. The cpu is in 16 bit
mode in this case.
For example:
$ xenctx 4
cs:eip: f000:0000d61b
flags: 00000002 nz
ss:esp: 0000:00001fee
eax: 0000ffc2 ebx: 00000049 ecx: 00000049 edx: ffffffff
esi: 00000000 edi: 00000010 ebp: 00001ff0
ds: e000 es: 0040 fs: 0000 gs: 0000
Code (instr addr 000fd61b)
04 67 66 8b 70 08 67 66 8b 68 0c 67 66 8b 58 10 67 66 8b 50 14 <67> 66 8b 48 18 67 8e 40 02 67 ff
Stack:
8e30 0000 0246 812f 0000 0206 80e7 0080 0080
$ xenctx 4 -d 0x00001fee -m 0x00001fee -l 1
Memory (address 1fee):
8e30 0000 0246 812f 0000 0206 80e7 0080 0080 c2c2 c2c2 c2c2 c2c2 c2c2 c2c2 c2c2
Stack:
8e30 0000 0246 812f 0000 0206 80e7 0080 0080
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v10: Added FMT_16B_WORD to ARM cases.
tools/xentrace/xenctx.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 3804bd3..6655990 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -47,6 +47,7 @@ typedef enum type_of_addr_ {
static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) };
static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) };
typedef unsigned long long guest_word_t;
+#define FMT_16B_WORD "%04llx"
#define FMT_32B_WORD "%08llx"
#define FMT_64B_WORD "%016llx"
/* Word-length of the guest's own data structures */
@@ -57,11 +58,13 @@ int guest_protected_mode = 1;
#elif defined(__arm__)
#define NO_TRANSLATION
typedef uint64_t guest_word_t;
+#define FMT_16B_WORD "%04llx"
#define FMT_32B_WORD "%08llx"
#define FMT_64B_WORD "%016llx"
#elif defined(__aarch64__)
#define NO_TRANSLATION
typedef uint64_t guest_word_t;
+#define FMT_16B_WORD "%04llx"
#define FMT_32B_WORD "%08llx"
#define FMT_64B_WORD "%016llx"
#endif
@@ -479,7 +482,7 @@ static void print_ctx(vcpu_guest_context_any_t *ctx)
{
if (ctxt_word_size == 4)
print_ctx_32(&ctx->x32);
- else if (guest_word_size == 4)
+ else if (guest_word_size != 8)
print_ctx_32on64(&ctx->x64);
else
print_ctx_64(&ctx->x64);
@@ -749,7 +752,9 @@ static guest_word_t read_mem_word(vcpu_guest_context_any_t *ctx, int vcpu,
static void print_stack_word(guest_word_t word, int width)
{
- if (width == 4)
+ if (width == 2)
+ printf(FMT_16B_WORD, word);
+ else if (width == 4)
printf(FMT_32B_WORD, word);
else
printf(FMT_64B_WORD, word);
@@ -984,8 +989,9 @@ static void dump_ctx(int vcpu)
perror("xc_domain_hvm_getcontext_partial");
return;
}
- guest_word_size = (cpuctx.msr_efer & 0x400) ? 8 : 4;
guest_protected_mode = (cpuctx.cr0 & CR0_PE);
+ guest_word_size = (cpuctx.msr_efer & 0x400) ? 8 :
+ guest_protected_mode ? 4 : 2;
/* HVM guest context records are always host-sized */
if (xc_version(xenctx.xc_handle, XENVER_capabilities, &xen_caps) != 0) {
perror("xc_version");
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v10 19/19] xenctx: Fix print_ctx_32on64's print_special call.
2014-04-03 19:06 [PATCH v10 00/19] xenctx: Many changes Don Slutz
` (17 preceding siblings ...)
2014-04-03 19:07 ` [PATCH v10 18/19] xenctx: Add 16 bit output Don Slutz
@ 2014-04-03 19:07 ` Don Slutz
18 siblings, 0 replies; 22+ messages in thread
From: Don Slutz @ 2014-04-03 19:07 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Stefano Stabellini, George Dunlap, Ian Jackson,
Don Slutz, Jan Beulich
print_special() uses the width argument to both select output format
and array size. So by passing 4 it expects an array of uint32_t.
But an array of uint64_t is passed.
So copy and mask the registers to 32 bits.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/xentrace/xenctx.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 6655990..82bd789 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -420,8 +420,15 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx)
printf(" gs: %04x\n", regs->gs);
if (xenctx.disp_all) {
- print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4);
- print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4);
+ uint32_t tmp_regs[8];
+ int i;
+
+ for (i = 0; i < 5; i++)
+ tmp_regs[i] = ctx->ctrlreg[i];
+ print_special(tmp_regs, "cr", 0x1d, cr_reg_mask, 4);
+ for (i = 0; i < 8; i++)
+ tmp_regs[i] = ctx->debugreg[i];
+ print_special(tmp_regs, "dr", 0xcf, dr_reg_mask, 4);
}
}
--
1.8.4
^ permalink raw reply related [flat|nested] 22+ messages in thread