Ptrace 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/module/Ptrace.h ADDED
@@ -0,0 +1,51 @@
1
+ /* Ptrace.h
2
+ * Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
3
+ * Written by TG Community Developers <community@thoughtgang.org>
4
+ * Released under the GNU Public License, version 3.
5
+ * See http://www.gnu.org/licenses/gpl.txt for details.
6
+ */
7
+
8
+ #ifndef PTRACE_RUBY_EXTENSION_H
9
+ #define PTRACE_RUBY_EXTENSION_H
10
+
11
+ #define SZ_PTRACE_TRACEME "traceme"
12
+ #define SZ_PTRACE_PEEKTEXT "peektext"
13
+ #define SZ_PTRACE_PEEKDATA "peekdata"
14
+ #define SZ_PTRACE_PEEKUSR "peekusr"
15
+ #define SZ_PTRACE_POKETEXT "poketext"
16
+ #define SZ_PTRACE_POKEDATA "pokedata"
17
+ #define SZ_PTRACE_POKEUSR "pokeusr"
18
+ #define SZ_PTRACE_GETREGS "getregs"
19
+ #define SZ_PTRACE_GETFPREGS "getfpregs"
20
+ #define SZ_PTRACE_GETFPXREGS "getfpxregs"
21
+ #define SZ_PTRACE_SETREGS "setregs"
22
+ #define SZ_PTRACE_SETFPREGS "setfpregs"
23
+ #define SZ_PTRACE_SETFPXREGS "setfpxregs"
24
+ #define SZ_PTRACE_CONT "cont"
25
+ #define SZ_PTRACE_SYSCALL "syscall"
26
+ #define SZ_PTRACE_SINGLESTEP "singlestep"
27
+ #define SZ_PTRACE_KILL "kill"
28
+ #define SZ_PTRACE_ATTACH "attach"
29
+ #define SZ_PTRACE_DETACH "detach"
30
+ #define SZ_PTRACE_GETSIGINFO "getsiginfo"
31
+ #define SZ_PTRACE_SETSIGINFO "setsiginfo"
32
+ #define SZ_PTRACE_SETOPTIONS "setoptions"
33
+ #define SZ_PTRACE_GETEVENTMSG "geteventmsg"
34
+ #define SZ_PTRACE_SYSEMU "sysemu"
35
+ #define SZ_PTRACE_SYSEMU_SINGLESTEP "sysemu_singlestep"
36
+
37
+ /* module and class names */
38
+ #define PTRACE_MODULE_NAME "Ptrace"
39
+ #define PTRACE_ERROR_CLASS_NAME "PtraceError"
40
+ #define DEBUGGER_CLASS_NAME "Debugger"
41
+
42
+ void Init_Ptrace_ext();
43
+
44
+ #endif
45
+ #define SZ_PTRACE_O_TRACESYSGOOD "trace_sys_good"
46
+ #define SZ_PTRACE_O_TRACEFORK "trace_fork"
47
+ #define SZ_PTRACE_O_TRACEVFORK "trace_vfork"
48
+ #define SZ_PTRACE_O_TRACEVFORKDONE "trace_vfork_done"
49
+ #define SZ_PTRACE_O_TRACECLONE "trace_clone"
50
+ #define SZ_PTRACE_O_TRACEEXEC "trace_exec"
51
+ #define SZ_PTRACE_O_TRACEEXIT "trace_exit"
data/module/extconf.rb ADDED
@@ -0,0 +1,11 @@
1
+ #!/usrbin/ruby1.9
2
+
3
+ require 'mkmf'
4
+
5
+ if RUBY_VERSION =~ /1.8/ then
6
+ $CPPFLAGS += " -DRUBY_18"
7
+ elsif RUBY_VERSION =~ /1.9/ then
8
+ $CPPFLAGS += " -DRUBY_19"
9
+ end
10
+
11
+ create_makefile('Ptrace_ext')
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+ # :title: Ptrace
3
+ =begin rdoc
4
+ =Ptrace
5
+ <i>Copyright 2011 Thoughtgang <http://www.thoughtgang.org></i>
6
+
7
+ = Ptrace wrapper.
8
+
9
+ All of the original ptrace data structures and constants can be found in
10
+ <b>ptrace.h</b>, available on Linux installations at
11
+ <b>/usr/include/sys/ptrace.h</b>.
12
+
13
+ == Summary
14
+ A wrapper for the ptrace debugging facility.
15
+
16
+ == Example
17
+ require 'Ptrace_ext'
18
+
19
+ == Disclaimer
20
+
21
+ == Contact
22
+ Support:: community@thoughtgang.org
23
+ Project:: http://rubyforge.org/projects/opdis/
24
+ =end
25
+
26
+
27
+ =begin rdoc
28
+ Ptrace support.
29
+ =end
30
+ module Ptrace
31
+
32
+ =begin rdoc
33
+ A ptrace debugger. Note that this class is not instantiated; it is simply
34
+ a wrapper for the ptrace system call that performs translation of objects
35
+ between Ruby and C.
36
+ =end
37
+ class Debugger
38
+
39
+ =begin rdoc
40
+ Return a Hash mapping command symbols (e.g. :singlestep) to ptrace command
41
+ numbers. This serves as a list of all ptrace commands supported by the OS.
42
+ =end
43
+ def self.commands
44
+ end
45
+
46
+ =begin rdoc
47
+ Send a ptrace command number to the specified PID. The addr argument can be
48
+ nil. This is a wrapper for the ptrace system call.
49
+ =end
50
+ def self.send_cmd(cmd, pid, addr)
51
+ end
52
+
53
+ =begin rdoc
54
+ Send a ptrace command number to the specified PID, using addr and data as
55
+ the address and data arguments. This is a wrapper for the ptrace system call.
56
+ =end
57
+ def self.send_data(cmd, pid, addr, data)
58
+ end
59
+
60
+ =begin rdoc
61
+ Read a word from memory at the specified address in the specified process. The
62
+ cms is expected to be one of PT_READ_I, PT_READ_D, or PT_READ_U.
63
+ =end
64
+ def self.peek(cmd, pid, addr)
65
+ end
66
+
67
+ =begin rdoc
68
+ Write a word to memory at the specified address in the specified process. The
69
+ cms is expected to be one of PT_WRITE_I, PT_WRITE_D, or PT_WRITE_U.
70
+ =end
71
+ def self.poke(cmd, pid, addr, word)
72
+ end
73
+
74
+ =begin rdoc
75
+ Read the general (CPU) registers for the specified process. This returns a Hash
76
+ mapping register name to value.
77
+ =end
78
+ def self.regs(pid)
79
+ end
80
+
81
+ =begin rdoc
82
+ Write the general (CPU) registers for the specified process. The Hash must be
83
+ a complete set of registers as returned by Debugger.regs; missing registers
84
+ will be set to 0.
85
+ =end
86
+ def self.regs=(pid, hash)
87
+ end
88
+
89
+ =begin rdoc
90
+ Read the FPU registers for the specified process. This returns a Hash
91
+ mapping register name to value.
92
+ =end
93
+ def self.fpregs(pid)
94
+ end
95
+
96
+ =begin rdoc
97
+ Write the FPU registers for the specified process. The Hash must be
98
+ a complete set of registers as returned by Debugger.fpregs; missing registers
99
+ will be set to 0.
100
+ =end
101
+ def self.fpregs=(pid, hash)
102
+ end
103
+
104
+ =begin rdoc
105
+ =end
106
+ def self.signal(pid)
107
+ end
108
+
109
+ =begin rdoc
110
+ =end
111
+ def self.signal=(pid, hash)
112
+ end
113
+
114
+ =begin rdoc
115
+ =end
116
+ def self.event_msg(pid)
117
+ end
118
+ end
119
+
120
+ end
@@ -0,0 +1,17 @@
1
+ /* ruby_compat.c
2
+ * Copyright 2010 Thoughtgang <http://www.thoughtgang.org>
3
+ * Written by TG Community Developers <community@thoughtgang.org>
4
+ * Released under the GNU Public License, version 3.
5
+ * See http://www.gnu.org/licenses/gpl.txt for details.
6
+ */
7
+
8
+ #ifndef RUBY_19
9
+
10
+ #include <ruby.h>
11
+
12
+ VALUE Bfd_rb_hash_lookup2( VALUE hash, VALUE key, VALUE def ) {
13
+ VALUE v = rb_hash_lookup(hash, key);
14
+ return (v == Qnil) ? def : v;
15
+ }
16
+
17
+ #endif
@@ -0,0 +1,28 @@
1
+ /* ruby_compat.h
2
+ * Macros to make ruby1.8 look like ruby1.9.
3
+ * Copyright 2010 Thoughtgang <http://www.thoughtgang.org>
4
+ * Written by TG Community Developers <community@thoughtgang.org>
5
+ * Released under the GNU Public License, version 3.
6
+ * See http://www.gnu.org/licenses/gpl.txt for details.
7
+ */
8
+
9
+ #ifndef RUBY_COMPAT_H
10
+ #define RUBY_COMPAT_H
11
+
12
+ #ifdef RUBY_18
13
+ #include <stdarg.h>
14
+ #define rb_str_new_cstr(arg) rb_str_new2(arg)
15
+
16
+ VALUE Bfd_rb_hash_lookup2(VALUE, VALUE, VALUE);
17
+ #define rb_hash_lookup2( a1, a2, a3 ) Bfd_rb_hash_lookup2(a1, a2, a3)
18
+
19
+ #if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
20
+ # define SIZET2NUM(v) ULL2NUM(v)
21
+ #elif SIZEOF_SIZE_T == SIZEOF_LONG
22
+ # define SIZET2NUM(v) ULONG2NUM(v)
23
+ #else
24
+ # define SIZET2NUM(v) UINT2NUM(v)
25
+ #endif
26
+
27
+ #endif
28
+ #endif