~ubuntu-branches/ubuntu/saucy/radare/saucy

« back to all changes in this revision

Viewing changes to src/dbg/regs.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Reichel
  • Date: 2009-05-22 19:01:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090522190100-qqp4aja112976t5v
Tags: 20090522-1
* new hg checkout
 - added 'cX' command to compare like 'cc' does but using two side hexdiff dump format
 - specify pointer & data size in pm with %<size>
 - add graph.weight
 - fix 'c' command (missing radare_read(0))
 - added /P search command that searchs for proximity in bytelevel distance
 - added more 'ag' and 'gu' commands to readline autocompletion.
 - fix build of debugger for non-linux systems
 - fixed code analysis at startup
 - more work in graphs (graph.split)
 - fixups in x86 code analysis

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007, 2008
 
2
 * Copyright (C) 2007, 2008, 2009
3
3
 *       pancake <youterm.com>
4
4
 *
5
5
 * radare is part of the radare project
37
37
#include "debug.h"
38
38
 
39
39
extern struct regs_off roff[];
 
40
int regio_enabled = 0;
 
41
u64 regio_addr = 0;
 
42
 
 
43
/* reg io mode */
 
44
int debug_reg_read_at(int pid, u8 *data, int length, u64 addr)
 
45
{
 
46
        regs_t regs;
 
47
        int i, regsz = sizeof(regs_t);
 
48
        u8 *ptr = &regs;
 
49
        debug_getregs(pid, &regs);
 
50
        if (addr<regio_addr)
 
51
                return -1;
 
52
        if (addr>regsz+regio_addr)
 
53
                return -1;
 
54
        for(i=0;i<length;i++) {
 
55
                if (addr+i>regsz+regio_addr)
 
56
                        data[i] = 0xff;
 
57
                else data[i] = ptr[i];
 
58
        }
 
59
        return length;
 
60
}
 
61
 
 
62
int debug_reg_write_at(int pid, const u8 *data, int length, u64 addr)
 
63
{
 
64
        regs_t regs;
 
65
        int i, regsz = sizeof(regs_t);
 
66
        u8 *ptr = &regs;
 
67
        debug_getregs(pid, &regs);
 
68
        if (addr>regsz+regio_addr)
 
69
                return -1;
 
70
        for(i=0;i<length;i++) {
 
71
                if (addr+i<regsz+regio_addr)
 
72
                        ptr[addr-regio_addr+i] = data[i];
 
73
        }
 
74
        debug_setregs(pid, &regs);
 
75
        return length;
 
76
}
 
77
/* ----------- */
40
78
 
41
79
u64 debug_get_regoff(regs_t *regs, int off)
42
80
{
129
167
                eprintf(":regs No program loaded.\n");
130
168
                return 1;
131
169
        }
132
 
 
133
170
        return arch_print_registers(rad, "line");
134
171
}
135
172
 
139
176
                eprintf(":regs No program loaded.\n");
140
177
                return 1;
141
178
        }
142
 
 
143
179
        return arch_print_registers(rad, "orig");
144
180
}
145
181