/branches/tracing/uspace/app/debug/cmd.c |
---|
44,6 → 44,7 |
#include "cmd.h" |
static void cmd_break(int argc, char *argv[]); |
void cmd_go(int argc, char *argv[]); |
void cmd_help(int argc, char *argv[]); |
static void cmd_read(int argc, char *argv[]); |
static void cmd_quit(int argc, char *argv[]); |
52,6 → 53,7 |
cmd_desc_t cmd_table[] = { |
{ 1, "break", cmd_break }, |
{ 0, "go", cmd_go }, |
{ 0, "help", cmd_help }, |
{ 2, "read", cmd_read }, |
{ 0, "quit", cmd_quit }, |
69,6 → 71,11 |
arch_breakpoint_add(addr); |
} |
void cmd_go(int argc, char *argv[]) |
{ |
fcv_broadcast(&go_cv); |
} |
void cmd_help(int argc, char *argv[]) |
{ |
int i; |
/branches/tracing/uspace/app/debug/main.c |
---|
45,6 → 45,7 |
#include "cmd.h" |
#include "include/arch.h" |
#include "fib_synch.h" |
#include "main.h" |
void thread_debug_start(unsigned thread_hash); |
71,6 → 72,8 |
breakpoint_t brk_list[MAX_BRKPTS]; |
int lifted_brkpt; |
fcv_t go_cv; |
void read_line(char *buffer, int n) |
{ |
char c; |
161,6 → 164,13 |
(*cmd_table[idx_found].proc)(cmd_argc, cmd_argv); |
} |
/* |
* Called by a fibril (from arch code) when a breakpoint is hit. |
*/ |
void breakpoint_hit(void) |
{ |
fcv_wait(&go_cv); |
} |
int task_connect(int taskid) |
{ |
269,16 → 279,16 |
while (!abort_debug) { |
printf("go\n"); |
printf("[t%d] go...\n", thread_id); |
/* Run thread until an event occurs */ |
rc = udebug_go(app_phone, thread_hash, |
&ev_type, &val0, &val1); |
printf("[t%d] stopped\n", thread_id); |
if (ev_type == UDEBUG_EVENT_FINISHED) { |
printf("thread %u debugging finished\n", thread_id); |
break; |
} |
if (rc >= 0) debug_event(thread_hash, ev_type, val0); |
} |
310,7 → 320,7 |
while ((i = getchar()) != 'c') |
putchar(i); |
taskid = 13; |
taskid = 14; |
rc = task_connect(taskid); |
if (rc < 0) { |
printf("Failed to connect to task %d\n", taskid); |
353,6 → 363,8 |
{ |
next_thread_id = 1; |
paused = 0; |
fcv_init(&go_cv); |
} |
int main(void) |
/branches/tracing/uspace/app/debug/fib_synch.c |
---|
0,0 → 1,94 |
/* |
* Copyright (c) 2008 Jiri Svoboda |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup debug |
* @{ |
*/ |
/** @file |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <fibril.h> |
#include <async.h> |
#include <futex.h> |
#include "fib_synch.h" |
void fcv_init(fcv_t *fcv) |
{ |
int i; |
for (i = 0; i < MAX_FIB; i++) { |
fcv->waiting[i] = 0; |
} |
} |
void fcv_wait(fcv_t *fcv) |
{ |
fid_t fid; |
int i; |
futex_down(&async_futex); |
fid = fibril_get_id(); |
for (i = 0; i < MAX_FIB; i++) { |
if (fcv->waiting[i] == 0) { |
fcv->waiting[i] = fid; |
fibril_switch(FIBRIL_TO_MANAGER); |
futex_up(&async_futex); |
return; |
} |
} |
futex_up(&async_futex); |
printf("fcv_failed: too many waiting fibrils\n"); |
exit(1); |
} |
void fcv_broadcast(fcv_t *fcv) |
{ |
int i; |
futex_down(&async_futex); |
for (i = 0; i < MAX_FIB; i++) { |
if (fcv->waiting[i] != 0) { |
fibril_add_ready(fcv->waiting[i]); |
fcv->waiting[i] = 0; |
} |
} |
futex_up(&async_futex); |
} |
/** @} |
*/ |
/branches/tracing/uspace/app/debug/main.h |
---|
36,6 → 36,7 |
#define MAIN_H_ |
#include "include/arch/types.h" |
#include "fib_synch.h" |
typedef struct { |
int set; |
47,7 → 48,11 |
extern breakpoint_t brk_list[MAX_BRKPTS]; |
extern int app_phone; |
extern fcv_t go_cv; |
void breakpoint_hit(void); |
#endif |
/** @} |
/branches/tracing/uspace/app/debug/fib_synch.h |
---|
0,0 → 1,53 |
/* |
* Copyright (c) 2008 Jiri Svoboda |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup debug |
* @{ |
*/ |
/** @file |
*/ |
#ifndef FIB_SYNCH_H_ |
#define FIB_SYNCH_H_ |
#include <fibril.h> |
#define MAX_FIB 32 |
typedef struct { |
fid_t waiting[MAX_FIB]; |
} fcv_t; |
void fcv_init(fcv_t *fcv); |
void fcv_wait(fcv_t *fcv); |
void fcv_broadcast(fcv_t *fcv); |
#endif |
/** @} |
*/ |
/branches/tracing/uspace/app/debug/Makefile |
---|
44,6 → 44,7 |
OUTPUT = debug |
GENERIC_SOURCES = cmd.c \ |
fib_synch.c \ |
main.c |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) |
60,6 → 61,7 |
clean: |
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend include/arch |
find . -name '*.o' -follow -exec rm \{\} \; |
depend: |
$(CC) $(DEFS) $(CFLAGS) -M $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend |
/branches/tracing/uspace/app/debug/arch/mips32/src/mips32.c |
---|
98,6 → 98,8 |
} |
if (bi < MAX_BRKPTS) { |
printf("breakpoint %d hit\n", bi); |
breakpoint_hit(); |
rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4); |
printf("udebug_mem_write(phone, 0x%x, 0x%02x, 1) -> %d\n", brk_addr, brk_list[bi].arch.back, rc); |
rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr+4, 4); |
/branches/tracing/uspace/app/debug/arch/ia32/src/ia32.c |
---|
90,6 → 90,7 |
if (bi < MAX_BRKPTS) { |
printf("breakpoint %d hit\n", bi); |
breakpoint_hit(); |
buffer[ISTATE_OFF_EIP] = brk_addr; |
buffer[ISTATE_OFF_EFLAGS] |= 0x0100; /* trap flag */ |