debuggers.hg

view xen/common/trace.c @ 3705:4294cfa9fad3

bitkeeper revision 1.1159.212.95 (4204aa0ee0re5Xx1zWrJ9ejxzgRs3w)

Various cleanups. Remove PDB pending simpler GDB stub and/or NetBSD debugger.
Force emacs mode to appropriate tabbing in various files.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Sat Feb 05 11:12:14 2005 +0000 (2005-02-05)
parents f913da82d617
children 88957a238191
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
2 /******************************************************************************
3 * common/trace.c
4 *
5 * Xen Trace Buffer
6 *
7 * Copyright (C) 2004 by Intel Research Cambridge
8 *
9 * Author: Mark Williamson, mark.a.williamson@intel.com
10 * Date: January 2004
11 *
12 * The trace buffer code is designed to allow debugging traces of Xen to be
13 * generated on UP / SMP machines. Each trace entry is timestamped so that
14 * it's possible to reconstruct a chronological record of trace events.
15 *
16 * See also include/xen/trace.h and the dom0 op in
17 * include/public/dom0_ops.h
18 */
20 #include <xen/config.h>
21 #include <asm/types.h>
22 #include <asm/io.h>
23 #include <xen/lib.h>
24 #include <xen/sched.h>
25 #include <xen/slab.h>
26 #include <xen/smp.h>
27 #include <xen/trace.h>
28 #include <xen/errno.h>
29 #include <xen/init.h>
30 #include <asm/atomic.h>
31 #include <public/dom0_ops.h>
33 /* opt_tbuf_size: trace buffer size (in pages) */
34 static unsigned int opt_tbuf_size = 10;
35 integer_param("tbuf_size", opt_tbuf_size);
37 /* Pointers to the meta-data objects for all system trace buffers */
38 struct t_buf *t_bufs[NR_CPUS];
40 /* a flag recording whether initialisation has been done */
41 int tb_init_done = 0;
43 /**
44 * init_trace_bufs - performs initialisation of the per-cpu trace buffers.
45 *
46 * This function is called at start of day in order to initialise the per-cpu
47 * trace buffers. The trace buffers are then available for debugging use, via
48 * the %TRACE_xD macros exported in <xen/trace.h>.
49 */
50 void init_trace_bufs(void)
51 {
52 int i, order;
53 unsigned long nr_pages;
54 char *rawbuf;
55 struct t_buf *buf;
57 if ( opt_tbuf_size == 0 )
58 {
59 printk("Xen trace buffers: disabled\n");
60 return;
61 }
63 nr_pages = smp_num_cpus * opt_tbuf_size;
64 order = get_order(nr_pages * PAGE_SIZE);
66 if ( (rawbuf = (char *)alloc_xenheap_pages(order)) == NULL )
67 {
68 printk("Xen trace buffers: memory allocation failed\n");
69 return;
70 }
72 /* Share pages so that xentrace can map them. */
74 for ( i = 0; i < nr_pages; i++ )
75 SHARE_PFN_WITH_DOMAIN(virt_to_page(rawbuf+(i*PAGE_SIZE)), dom0);
77 for ( i = 0; i < smp_num_cpus; i++ )
78 {
79 buf = t_bufs[i] = (struct t_buf *)&rawbuf[i*opt_tbuf_size*PAGE_SIZE];
81 /* For use in Xen. */
82 buf->vdata = (struct t_rec *)(buf+1);
83 buf->head_ptr = buf->vdata;
85 /* For use in user space. */
86 buf->data = __pa(buf->vdata);
87 buf->head = 0;
89 /* For use in both. */
90 buf->size = (opt_tbuf_size * PAGE_SIZE - sizeof(struct t_buf))
91 / sizeof(struct t_rec);
92 }
94 printk("Xen trace buffers: initialised\n");
96 wmb(); /* above must be visible before tb_init_done flag set */
98 tb_init_done = 1;
99 }
101 /**
102 * get_tb_info - get trace buffer details
103 * @st: a pointer to a dom0_gettbufs_t to be filled out
104 *
105 * Called by the %DOM0_GETTBUFS dom0 op to fetch the machine address of the
106 * trace buffers.
107 */
108 int get_tb_info(dom0_gettbufs_t *st)
109 {
110 if ( tb_init_done )
111 {
112 st->mach_addr = __pa(t_bufs[0]);
113 st->size = opt_tbuf_size * PAGE_SIZE;
115 return 0;
116 }
117 else
118 {
119 st->mach_addr = 0;
120 st->size = 0;
121 return -ENODATA;
122 }
123 }