Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2903 → Rev 2904

/branches/tracing/uspace/app/sctrace/sctrace.c
51,7 → 51,6
#include "syscalls.h"
#include "ipcp.h"
#include "errors.h"
#include "debug_api.h"
 
#define THBUF_SIZE 64
unsigned thread_hash_buf[THBUF_SIZE];
79,13 → 78,13
phoneid = rc;
if (rc < 0) return rc;
 
printf("debug_begin()... ");
rc = debug_begin(phoneid);
printf("udebug_begin()... ");
rc = udebug_begin(phoneid);
printf("-> %d\n", rc);
if (rc < 0) return rc;
 
printf("debug_set_evmask(0x%x)... ", UDEBUG_EM_ALL);
rc = debug_set_evmask(phoneid, UDEBUG_EM_ALL);
printf("udebug_set_evmask(0x%x)... ", UDEBUG_EM_ALL);
rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL);
printf("-> %d\n", rc);
if (rc < 0) return rc;
 
101,7 → 100,7
 
 
printf("send IPC_M_DEBUG_THREAD_READ message\n");
rc = debug_thread_read(phoneid, (unsigned)thread_hash_buf,
rc = udebug_thread_read(phoneid, (unsigned)thread_hash_buf,
THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
printf("-> %d\n", rc);
if (rc < 0) return rc;
185,7 → 184,7
return;
 
memset(&call, 0, sizeof(call));
rc = debug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args));
rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args));
 
if (rc >= 0) {
ipcp_call_out(sc_args[0], &call, sc_rc);
210,9 → 209,9
 
// printf("memset\n");
memset(&reply, 0, sizeof(reply));
// printf("debug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n",
// printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n",
// phoneid, &reply.args, sc_args[5], sizeof(reply.args));
rc = debug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args));
rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args));
// printf("dmr->%d\n", rc);
if (rc < 0) return;
 
226,12 → 225,12
int rc;
 
memset(&question, 0, sizeof(question));
rc = debug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
printf("dmr->%d\n", rc);
if (rc < 0) return;
 
memset(&reply, 0, sizeof(reply));
rc = debug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
printf("dmr->%d\n", rc);
if (rc < 0) return;
 
246,8 → 245,8
if (sc_rc == 0) return 0;
 
memset(&call, 0, sizeof(call));
rc = debug_mem_read(phoneid, &call, sc_args[0], sizeof(call));
// printf("debug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n",
rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call));
// printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n",
// phoneid, (int)&call, sc_args[0], sizeof(call), rc);
 
if (rc >= 0) {
262,7 → 261,7
int rc;
 
/* Read syscall arguments */
rc = debug_args_read(phoneid, thread_hash, sc_args);
rc = udebug_args_read(phoneid, thread_hash, sc_args);
 
async_serialize_start();
 
288,7 → 287,7
int rc;
 
/* Read syscall arguments */
rc = debug_args_read(phoneid, thread_hash, sc_args);
rc = udebug_args_read(phoneid, thread_hash, sc_args);
 
async_serialize_start();
 
351,7 → 350,7
while (!abort_trace) {
 
/* Run thread until an event occurs */
rc = debug_go(phoneid, thread_hash,
rc = udebug_go(phoneid, thread_hash,
&ev_type, &val0, &val1);
 
// printf("rc = %d, ev_type=%d\n", rc, ev_type);
450,7 → 449,7
if (c == 'q') break;
if (c == 'p') {
paused = 1;
rc = debug_stop(phoneid, thash);
rc = udebug_stop(phoneid, thash);
printf("stop -> %d\n", rc);
}
if (c == 'r') {
460,7 → 459,7
 
printf("terminate debugging session...\n");
abort_trace = 1;
debug_end(phoneid);
udebug_end(phoneid);
ipc_hangup(phoneid);
 
ipcp_cleanup();
/branches/tracing/uspace/app/sctrace/Makefile
46,8 → 46,7
ipcp.c \
ipc_desc.c \
proto.c \
errors.c \
debug_api.c
errors.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
/branches/tracing/uspace/lib/libc/include/udebug.h
37,6 → 37,17
 
#include <kernel/udebug/udebug.h>
 
int udebug_begin(unsigned phoneid);
int udebug_end(unsigned phoneid);
int udebug_set_evmask(unsigned phoneid, udebug_evmask_t mask);
int udebug_thread_read(unsigned phoneid, void *buffer, unsigned n,
unsigned *copied, unsigned *needed);
int udebug_mem_read(unsigned phoneid, void *buffer, unsigned addr, unsigned n);
int udebug_args_read(unsigned phoneid, unsigned tid, unsigned *buffer);
int udebug_go(unsigned phoneid, unsigned tid, unsigned *ev_type,
unsigned *sc_id, unsigned *sc_rc);
int udebug_stop(unsigned phoneid, unsigned tid);
 
#endif
 
/** @}
/branches/tracing/uspace/lib/libc/generic/udebug.c
0,0 → 1,91
/*
* 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 libc
* @{
*/
/** @file
*/
 
#include <udebug.h>
#include <syscall.h>
#include <ipc/ipc.h>
#include <async.h>
 
int udebug_begin(unsigned phoneid)
{
return async_req_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_BEGIN);
}
 
int udebug_end(unsigned phoneid)
{
return async_req_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_END);
}
 
int udebug_set_evmask(unsigned phoneid, udebug_evmask_t mask)
{
return async_req_2_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_SET_EVMASK,
mask);
}
 
int udebug_thread_read(unsigned phoneid, void *buffer, unsigned n,
unsigned *copied, unsigned *needed)
{
unsigned dest_addr;
 
return async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_THREAD_READ,
(sysarg_t)buffer, n, &dest_addr, copied, needed);
}
 
int udebug_mem_read(unsigned phoneid, void *buffer, unsigned addr, unsigned n)
{
return async_req_4_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_MEM_READ,
(sysarg_t)buffer, addr, n);
}
 
int udebug_args_read(unsigned phoneid, unsigned tid, unsigned *buffer)
{
return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
tid, (sysarg_t)buffer);
}
 
int udebug_go(unsigned phoneid, unsigned tid, unsigned *ev_type,
unsigned *sc_id, unsigned *sc_rc)
{
return async_req_2_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_GO,
tid, (sysarg_t)ev_type, (sysarg_t)sc_id, (sysarg_t)sc_rc);
}
 
int udebug_stop(unsigned phoneid, unsigned tid)
{
return async_req_2_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_STOP,
tid);
}
 
/** @}
*/
/branches/tracing/uspace/lib/libc/Makefile
74,6 → 74,7
generic/err.c \
generic/stdlib.c \
generic/mman.c \
generic/udebug.c \
generic/vfs/vfs.c \
generic/vfs/canonify.c