Subversion Repositories HelenOS

Rev

Rev 2885 | Rev 2899 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2885 Rev 2894
-
 
1
/*
-
 
2
 * Copyright (c) 2008 Jiri Svoboda
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions
-
 
7
 * are met:
-
 
8
 *
-
 
9
 * - Redistributions of source code must retain the above copyright
-
 
10
 *   notice, this list of conditions and the following disclaimer.
-
 
11
 * - Redistributions in binary form must reproduce the above copyright
-
 
12
 *   notice, this list of conditions and the following disclaimer in the
-
 
13
 *   documentation and/or other materials provided with the distribution.
-
 
14
 * - The name of the author may not be used to endorse or promote products
-
 
15
 *   derived from this software without specific prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-
 
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
27
 */
-
 
28
 
1
/** @addtogroup generic
29
/** @addtogroup generic
2
 * @{
30
 * @{
3
 */
31
 */
4
/** @file
32
/** @file
5
 */
33
 */
6
 
34
 
7
#ifndef KERN_UDEBUG_H_
35
#ifndef KERN_UDEBUG_H_
8
#define KERN_UDEBUG_H_
36
#define KERN_UDEBUG_H_
9
 
37
 
10
typedef enum { /* udebug_method_t */
38
typedef enum { /* udebug_method_t */
11
 
39
 
12
/** Start debugging the recipient.
40
/** Start debugging the recipient.
13
 * Causes all threads in the receiving task to stop. When they
41
 * Causes all threads in the receiving task to stop. When they
14
 * are all stoped, an answer with retval 0 is generated.
42
 * are all stoped, an answer with retval 0 is generated.
15
 */
43
 */
16
UDEBUG_M_BEGIN = 1,
44
UDEBUG_M_BEGIN = 1,
17
 
45
 
18
/** Finish debugging the recipient.
46
/** Finish debugging the recipient.
19
 * Answers all pending GO and GUARD messages.
47
 * Answers all pending GO and GUARD messages.
20
 */
48
 */
21
UDEBUG_M_END,
49
UDEBUG_M_END,
22
 
50
 
23
/** Make sure the debugged task is still there.
51
/** Make sure the debugged task is still there.
24
 * This message is answered when the debugged task dies
52
 * This message is answered when the debugged task dies
25
 * or the debugging session ends.
53
 * or the debugging session ends.
26
 */
54
 */
27
UDEBUG_M_GUARD,
55
UDEBUG_M_GUARD,
28
 
56
 
29
/** Run a thread until a debugging event occurs.
57
/** Run a thread until a debugging event occurs.
30
 * This message is answered when the thread stops
58
 * This message is answered when the thread stops
31
 * in a debugging event.
59
 * in a debugging event.
32
 *
60
 *
33
 * - ARG2 - id of the thread to run
61
 * - ARG2 - id of the thread to run
34
 */
62
 */
35
UDEBUG_M_GO,
63
UDEBUG_M_GO,
36
 
64
 
37
/** Stop a thread being debugged.
65
/** Stop a thread being debugged.
38
 * Creates a special STOP event in the thread, causing
66
 * Creates a special STOP event in the thread, causing
39
 * it to answer a pending GO message (if any).
67
 * it to answer a pending GO message (if any).
40
 */
68
 */
41
UDEBUG_M_STOP,
69
UDEBUG_M_STOP,
42
 
70
 
43
/** Read arguments of a syscall.
71
/** Read arguments of a syscall.
44
 *
72
 *
45
 * - ARG2 - thread identification
73
 * - ARG2 - thread identification
46
 * - ARG3 - destination address in the caller's address space
74
 * - ARG3 - destination address in the caller's address space
47
 *
75
 *
48
 */
76
 */
49
UDEBUG_M_ARGS_READ,
77
UDEBUG_M_ARGS_READ,
50
 
78
 
51
/** Read thread's userspace register state (istate_t).
79
/** Read thread's userspace register state (istate_t).
52
 *
80
 *
53
 * - ARG2 - thread identification
81
 * - ARG2 - thread identification
54
 * - ARG3 - destination address in the caller's address space
82
 * - ARG3 - destination address in the caller's address space
55
 * - ARG4 - size of receiving buffer in bytes
83
 * - ARG4 - size of receiving buffer in bytes
56
 *
84
 *
57
 * on answer, the kernel will set:
85
 * on answer, the kernel will set:
58
 *
86
 *
59
 * - ARG1 - actual size in bytes of data read
87
 * - ARG1 - actual size in bytes of data read
60
 * - ARG2 - total size in bytes of data available
88
 * - ARG2 - total size in bytes of data available
61
 *
89
 *
62
 * or, on error, retval will be
90
 * or, on error, retval will be
63
 * - ENOENT - thread does not exist
91
 * - ENOENT - thread does not exist
64
 * - EBUSY - register state not available
92
 * - EBUSY - register state not available
65
 */
93
 */
66
UDEBUG_M_REGS_READ,
94
UDEBUG_M_REGS_READ,
67
 
95
 
68
/** Write thread's userspace register state (istate_t).
96
/** Write thread's userspace register state (istate_t).
69
 *
97
 *
70
 * - ARG2 - thread identification
98
 * - ARG2 - thread identification
71
 * - ARG3 - source address in the caller's address space
99
 * - ARG3 - source address in the caller's address space
72
 * - ARG4 - size of source data in bytes
100
 * - ARG4 - size of source data in bytes
73
 *
101
 *
74
 * on answer, the kernel will set:
102
 * on answer, the kernel will set:
75
 *
103
 *
76
 * - ARG1 - actual size in bytes of data copied
104
 * - ARG1 - actual size in bytes of data copied
77
 * - ARG2 - max size in bytes that could have been copied
105
 * - ARG2 - max size in bytes that could have been copied
78
 *
106
 *
79
 * or, on error, retval will be
107
 * or, on error, retval will be
80
 * - ENOENT - thread does not exist
108
 * - ENOENT - thread does not exist
81
 * - EBUSY - register state not available
109
 * - EBUSY - register state not available
82
 */
110
 */
83
UDEBUG_M_REGS_WRITE,
111
UDEBUG_M_REGS_WRITE,
84
 
112
 
85
/** Read the list of the debugged tasks's threads.
113
/** Read the list of the debugged tasks's threads.
86
 *
114
 *
87
 * - ARG2 - destination address in the caller's address space
115
 * - ARG2 - destination address in the caller's address space
88
 * - ARG3 - size of receiving buffer in bytes
116
 * - ARG3 - size of receiving buffer in bytes
89
 *
117
 *
90
 * The kernel fills the buffer with a series of sysarg_t values
118
 * The kernel fills the buffer with a series of sysarg_t values
91
 * (thread ids). On answer, the kernel will set:
119
 * (thread ids). On answer, the kernel will set:
92
 *
120
 *
93
 * - ARG2 - number of bytes that were actually copied
121
 * - ARG2 - number of bytes that were actually copied
94
 * - ARG3 - number of bytes of the complete data
122
 * - ARG3 - number of bytes of the complete data
95
 *
123
 *
96
 */
124
 */
97
UDEBUG_M_THREAD_READ,
125
UDEBUG_M_THREAD_READ,
98
 
126
 
99
/** Read the debugged tasks's memory.
127
/** Read the debugged tasks's memory.
100
 *
128
 *
101
 * - ARG2 - destination address in the caller's address space
129
 * - ARG2 - destination address in the caller's address space
102
 * - ARG3 - source address in the recipient's address space
130
 * - ARG3 - source address in the recipient's address space
103
 * - ARG4 - size of receiving buffer in bytes
131
 * - ARG4 - size of receiving buffer in bytes
104
 *
132
 *
105
 */
133
 */
106
UDEBUG_M_MEM_READ,
134
UDEBUG_M_MEM_READ,
107
 
135
 
108
/** Write the debugged tasks's memory.
136
/** Write the debugged tasks's memory.
109
 *
137
 *
110
 * - ARG2 - source address in the caller's address space
138
 * - ARG2 - source address in the caller's address space
111
 * - ARG3 - destination address in the recipient's address space
139
 * - ARG3 - destination address in the recipient's address space
112
 * - ARG4 - size of receiving buffer in bytes
140
 * - ARG4 - size of receiving buffer in bytes
113
 *
141
 *
114
 */
142
 */
115
UDEBUG_M_MEM_WRITE
143
UDEBUG_M_MEM_WRITE
116
 
144
 
117
 
145
 
118
} udebug_method_t;
146
} udebug_method_t;
119
 
147
 
120
               
148
               
121
typedef enum {
149
typedef enum {
122
    UDEBUG_EVENT_FINISHED = 1/**< Debuging session has finished */
150
    UDEBUG_EVENT_FINISHED = 1/**< Debuging session has finished */
123
    UDEBUG_EVENT_SYSCALL,       /**< A syscall has been executed */
151
    UDEBUG_EVENT_SYSCALL,       /**< A syscall has been executed */
124
    UDEBUG_EVENT_NEW_THREAD     /**< The task created a new thread */
152
    UDEBUG_EVENT_NEW_THREAD     /**< The task created a new thread */
125
} udebug_event_t;
153
} udebug_event_t;
126
 
154
 
127
#ifdef KERNEL
155
#ifdef KERNEL
128
 
156
 
129
typedef enum {
157
typedef enum {
130
    /** Task is not being debugged */
158
    /** Task is not being debugged */
131
    UDEBUG_TS_INACTIVE,
159
    UDEBUG_TS_INACTIVE,
132
    /** BEGIN operation in progress (waiting for threads to stop) */
160
    /** BEGIN operation in progress (waiting for threads to stop) */
133
    UDEBUG_TS_BEGINNING,
161
    UDEBUG_TS_BEGINNING,
134
    /** Debugger fully connected */
162
    /** Debugger fully connected */
135
    UDEBUG_TS_ACTIVE,
163
    UDEBUG_TS_ACTIVE,
136
    /** Task is shutting down, no more debug activities allowed */
164
    /** Task is shutting down, no more debug activities allowed */
137
    UDEBUG_TS_SHUTDOWN
165
    UDEBUG_TS_SHUTDOWN
138
} udebug_task_state_t;
166
} udebug_task_state_t;
139
 
167
 
140
struct task;
168
struct task;
141
struct thread;
169
struct thread;
142
 
170
 
143
void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
171
void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
144
    unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc);
172
    unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc);
145
void udebug_new_thread_event(struct thread *t);
173
void udebug_new_thread_event(struct thread *t);
146
 
174
 
147
void udebug_stoppable_begin(void);
175
void udebug_stoppable_begin(void);
148
void udebug_stoppable_end(void);
176
void udebug_stoppable_end(void);
149
 
177
 
150
int udebug_task_cleanup(struct task *ta);
178
int udebug_task_cleanup(struct task *ta);
151
 
179
 
152
#endif
180
#endif
153
 
181
 
154
#endif
182
#endif
155
 
183
 
156
/** @}
184
/** @}
157
 */
185
 */
158
 
186