Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2923 → Rev 2924

/branches/tracing/kernel/arch/mips32/src/exception.c
107,6 → 107,12
 
static void breakpoint_exception(int n, istate_t *istate)
{
if (istate_from_uspace(istate)) {
/* userspace breakpoint */
udebug_breakpoint_event(0);
return;
}
 
#ifdef CONFIG_DEBUG
debugger_bpoint(istate);
#else
/branches/tracing/uspace/app/debug/include/arch
File deleted
\ No newline at end of file
Property changes:
Deleted: svn:special
-*
\ No newline at end of property
/branches/tracing/uspace/app/debug/main.c
243,11 → 243,9
abort_debug = true;
break;
case UDEBUG_EVENT_BREAKPOINT:
printf("breakpoint reached\n");
arch_event_breakpoint(thash);
break;
case UDEBUG_EVENT_TRAP:
printf("trap event\n");
arch_event_trap(thash);
break;
default:
312,7 → 310,7
while ((i = getchar()) != 'c')
putchar(i);
 
taskid = 14;
taskid = 13;
rc = task_connect(taskid);
if (rc < 0) {
printf("Failed to connect to task %d\n", taskid);
/branches/tracing/uspace/app/debug/Makefile
59,7 → 59,7
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend include/arch
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend
/branches/tracing/uspace/app/debug/arch/mips32/include/types.h
0,0 → 1,47
/*
* 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 TYPES_H_
#define TYPES_H_
 
#include <sys/types.h>
 
typedef struct {
uint32_t back;
} breakpoint_arch_t;
 
#endif
 
/** @}
*/
/branches/tracing/uspace/app/debug/arch/mips32/Makefile.inc
0,0 → 1,29
#
# 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.
#
 
ARCH_SOURCES := arch/$(ARCH)/src/mips32.c
/branches/tracing/uspace/app/debug/arch/mips32/src/mips32.c
0,0 → 1,132
/*
* 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 <sys/types.h>
#include <udebug.h>
#include <kernel/arch/context_offset.h>
 
#include "../../../main.h"
#include "../../../include/arch.h"
 
#define OPCODE_BREAK 0x0000000d
 
void arch_breakpoint_add(uintptr_t addr)
{
uint32_t brkp;
int rc;
breakpoint_t *brk;
int i;
 
brk = NULL;
for (i = 0; i < MAX_BRKPTS; i++)
if (brk_list[i].set == 0) {
brk = brk_list+i;
break;
}
 
if (!brk) {
printf("too many breakpoints\n");
return;
}
 
rc = udebug_mem_read(app_phone, &brk->arch.back, addr, sizeof(&brk->arch.back));
printf("udebug_mem_read() -> %d\n", rc);
brkp = OPCODE_BREAK;
rc = udebug_mem_write(app_phone, &brkp, addr, sizeof(brkp));
// for (i=0; i<256; i++) rc = udebug_mem_write(app_phone, &brkp, addr+4*i, sizeof(brkp));
printf("udebug_mem_write() -> %d\n", rc);
 
brk->addr = addr;
brk->set = 1;
}
 
static unsigned buffer[1024];
static breakpoint_t *lifted_brkpt;
 
void arch_event_breakpoint(thash_t thread_hash)
{
int rc;
uint32_t epc;
int brk_addr;
uint32_t brkp;
 
brkp = OPCODE_BREAK;
 
rc = udebug_regs_read(app_phone, thread_hash, buffer);
printf("udebug_regs_read -> %d\n", rc);
epc = buffer[EOFFSET_EPC/sizeof(unsigned)];
printf("EPC was 0x%08x\n", epc);
brk_addr = epc;
 
int bi;
for (bi = 0; bi < MAX_BRKPTS; bi++) {
if (brk_list[bi].set && brk_list[bi].addr == brk_addr)
break;
}
if (bi < MAX_BRKPTS) {
printf("breakpoint %d hit\n", bi);
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);
rc = udebug_mem_write(app_phone, &brkp, brk_addr+4, 4);
lifted_brkpt = &brk_list[bi];
return;
}
 
for (bi = 0; bi < MAX_BRKPTS; bi++) {
if (brk_list[bi].set && brk_list[bi].addr + 4 == brk_addr)
break;
}
if (bi < MAX_BRKPTS) {
printf("restoring breakpoint %d\n", bi);
rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4);
rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr-4, 4);
rc = udebug_mem_write(app_phone, &brkp, brk_addr-4, 4);
lifted_brkpt = NULL;
return;
}
 
printf("unrecognized breakpoint at 0x%x\n", brk_addr);
}
 
void arch_event_trap(thash_t thread_hash)
{
/* Unused */
(void)thread_hash;
}
 
/** @}
*/
/branches/tracing/uspace/app/debug/arch/ia32/src/ia32.c
87,7 → 87,10
if (brk_list[bi].set && brk_list[bi].addr == brk_addr)
break;
}
 
if (bi < MAX_BRKPTS) {
printf("breakpoint %d hit\n", bi);
 
buffer[ISTATE_OFF_EIP] = brk_addr;
buffer[ISTATE_OFF_EFLAGS] |= 0x0100; /* trap flag */
printf("setting EIP to 0x%08x\n", buffer[ISTATE_OFF_EIP]);
105,6 → 108,8
unsigned char brkinstr[1];
int rc;
 
printf("trap event\n");
 
breakpoint_t *lb = lifted_brkpt;
brkinstr[0] = OPCODE_INT3;
rc = udebug_mem_write(app_phone, brkinstr, lb->addr, 1);