Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2914 → Rev 2915

/branches/tracing/uspace/app/debug/cmd.c
36,11 → 36,15
#include <stdlib.h>
#include <string.h>
#include <bool.h>
#include <udebug.h>
#include <sys/types.h>
 
#include "main.h"
#include "cmd.h"
 
static void cmd_break(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[]);
 
volatile bool quit = false;
48,6 → 52,7
cmd_desc_t cmd_table[] = {
{ 1, "break", cmd_break },
{ 0, "help", cmd_help },
{ 2, "read", cmd_read },
{ 0, "quit", cmd_quit },
{ -1, NULL, NULL }
};
55,11 → 60,16
static void cmd_break(int argc, char *argv[])
{
uintptr_t addr;
char brkp[1];
int rc;
 
(void)argc;
addr = strtoul(argv[1], NULL, 0);
 
printf("You requested a breakpoint at 0x%x\n", addr);
brkp[0] = 0xcc;
rc = udebug_mem_write(app_phone, brkp, addr, 1);
printf("udebug_mem_write() -> %d\n", rc);
}
 
void cmd_help(int argc, char *argv[])
74,6 → 84,53
}
}
 
#define BYTES_PER_LINE 16
 
static void cmd_read(int argc, char *argv[])
{
uintptr_t addr;
size_t length;
uint8_t buf[BYTES_PER_LINE];
int to_read, i;
int rc;
 
(void)argc;
addr = strtoul(argv[1], NULL, 0);
length = strtoul(argv[2], NULL, 0);
 
while (length > 0) {
to_read = length < BYTES_PER_LINE ? length : BYTES_PER_LINE;
 
rc = udebug_mem_read(app_phone, buf, addr, to_read);
if (rc < 0) {
printf("error %d\n", rc);
return;
}
 
printf("0x%x:", addr);
for (i = 0; i < to_read; ++i) {
printf(" %02x", buf[i]);
}
for (i = to_read; i < BYTES_PER_LINE; ++i) {
printf(" ");
}
 
putchar ('\t');
 
for (i = 0; i < to_read; ++i) {
if (buf[i] >= 32 && buf[i] < 127)
putchar(buf[i]);
else
putchar('.');
}
printf("\n");
 
addr += to_read;
length -= to_read;
}
}
 
 
static void cmd_quit(int argc, char *argv[])
{
(void)argc; (void)argv;
/branches/tracing/uspace/app/debug/main.c
44,6 → 44,7
#include <string.h>
 
#include "cmd.h"
#include "main.h"
 
void thread_debug_start(unsigned thread_hash);
 
/branches/tracing/uspace/app/debug/main.h
0,0 → 1,43
/*
* 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 MAIN_H_
#define MAIN_H_
 
extern int app_phone;
 
#endif
 
/** @}
*/