* src/vm/jit/x86_64/codegen.c: Changed the code generator to produce
[cacao.git] / src / native / jvmti / dbg.c
1 /* src/native/jvmti/dbg.c - jvmti os/architecture support
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Martin Platter
28
29    Changes: 
30
31
32    $Id: cacao.c,v 3.165 2006/01/03 23:44:38 twisti Exp $
33
34 */
35
36 /* at the moment linux/i386 is the only plattform available */
37 #if defined(__LINUX__)  && defined (__I386__)
38
39 #include "dbg.h"
40 #include <sys/ptrace.h>
41 #include <linux/user.h>
42
43 #include <stdio.h>
44
45 void* getip(pid_t pid) {
46     struct user_regs_struct regs;
47
48     GETREGS(pid,regs);
49     return (void*)regs.eip;
50 }
51
52 void setip(pid_t pid, void* ip) {
53     struct user_regs_struct regs;
54
55     GETREGS(pid,regs);
56     regs.eip=(long)ip; 
57     ptrace(PTRACE_SETREGS, pid, 0, &regs); 
58 }
59
60 void setbrk(pid_t pid, void* addr, long* orig) {
61     long ins;
62
63         *orig = GETMEM(pid,addr);
64
65         ins = (*orig & ~0x000000FF) | TRAPINS; 
66
67         fprintf (stderr,"pid %d set brk at %p orig: %X new: %X\n",pid,addr,*orig,ins);
68         if (ptrace(PTRACE_POKEDATA, pid, (caddr_t) addr, ins)==-1) 
69                 perror("setbrk error ");
70 }
71
72 #endif
73
74 /*
75  * These are local overrides for various environment variables in Emacs.
76  * Please do not remove this and leave it at the end of the file, where
77  * Emacs will automagically detect them.
78  * ---------------------------------------------------------------------
79  * Local variables:
80  * mode: c
81  * indent-tabs-mode: t
82  * c-basic-offset: 4
83  * tab-width: 4
84  * End:
85  */