rubyrun 0.9.5-universal-darwin-8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/LICENSE +13 -0
  2. data/README +77 -0
  3. data/bin/Rakefile +11 -0
  4. data/docs/rubyrun-0.9.5.htm +5937 -0
  5. data/docs/rubyrun-0.9.5.pdf +0 -0
  6. data/docs/rubyrun-0.9.5_files/colorschememapping.xml +2 -0
  7. data/docs/rubyrun-0.9.5_files/filelist.xml +29 -0
  8. data/docs/rubyrun-0.9.5_files/header.htm +138 -0
  9. data/docs/rubyrun-0.9.5_files/image001.jpg +0 -0
  10. data/docs/rubyrun-0.9.5_files/image002.jpg +0 -0
  11. data/docs/rubyrun-0.9.5_files/image003.jpg +0 -0
  12. data/docs/rubyrun-0.9.5_files/image004.jpg +0 -0
  13. data/docs/rubyrun-0.9.5_files/image005.jpg +0 -0
  14. data/docs/rubyrun-0.9.5_files/image006.jpg +0 -0
  15. data/docs/rubyrun-0.9.5_files/image007.jpg +0 -0
  16. data/docs/rubyrun-0.9.5_files/image008.jpg +0 -0
  17. data/docs/rubyrun-0.9.5_files/image009.jpg +0 -0
  18. data/docs/rubyrun-0.9.5_files/image010.jpg +0 -0
  19. data/docs/rubyrun-0.9.5_files/image011.jpg +0 -0
  20. data/docs/rubyrun-0.9.5_files/image012.jpg +0 -0
  21. data/docs/rubyrun-0.9.5_files/image013.jpg +0 -0
  22. data/docs/rubyrun-0.9.5_files/image014.jpg +0 -0
  23. data/docs/rubyrun-0.9.5_files/image015.jpg +0 -0
  24. data/docs/rubyrun-0.9.5_files/image016.jpg +0 -0
  25. data/docs/rubyrun-0.9.5_files/image017.png +0 -0
  26. data/docs/rubyrun-0.9.5_files/image018.jpg +0 -0
  27. data/docs/rubyrun-0.9.5_files/image019.jpg +0 -0
  28. data/docs/rubyrun-0.9.5_files/image020.jpg +0 -0
  29. data/docs/rubyrun-0.9.5_files/image021.jpg +0 -0
  30. data/docs/rubyrun-0.9.5_files/image022.png +0 -0
  31. data/docs/rubyrun-0.9.5_files/themedata.thmx +0 -0
  32. data/etc/rubyrun_opts.yml +132 -0
  33. data/ext/extconf.rb +5 -0
  34. data/ext/rubyrunnative__.c +154 -0
  35. data/ext/rubyrunnative__.def +2 -0
  36. data/ext/rubyrunnative__.h +36 -0
  37. data/ext/rubyrunnative__ppc-darwin.bundle +0 -0
  38. data/ext/rubyrunnative__x86-darwin.bundle +0 -0
  39. data/ext/rubyrunnative__x86-linux.so +0 -0
  40. data/ext/rubyrunnative__x86-mswin32.so +0 -0
  41. data/lib/rubyrun/rubyrun.rb +2 -0
  42. data/lib/rubyrun/rubyrun_boot__.rb +79 -0
  43. data/lib/rubyrun/rubyrun_buffer_mgr__.rb +49 -0
  44. data/lib/rubyrun/rubyrun_commander__.rb +196 -0
  45. data/lib/rubyrun/rubyrun_dad__.rb +35 -0
  46. data/lib/rubyrun/rubyrun_globals.rb +52 -0
  47. data/lib/rubyrun/rubyrun_html__.rb +136 -0
  48. data/lib/rubyrun/rubyrun_html_writer__.rb +64 -0
  49. data/lib/rubyrun/rubyrun_initializer__.rb +313 -0
  50. data/lib/rubyrun/rubyrun_instrumentor__.rb +226 -0
  51. data/lib/rubyrun/rubyrun_monitor__.rb +238 -0
  52. data/lib/rubyrun/rubyrun_report__.rb +109 -0
  53. data/lib/rubyrun/rubyrun_rss__.rb +97 -0
  54. data/lib/rubyrun/rubyrun_tracer__.rb +79 -0
  55. data/lib/rubyrun/rubyrun_utils__.rb +101 -0
  56. data/lib/rubyrun/rubyrunnative__.bundle +0 -0
  57. metadata +115 -0
Binary file
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <a:clrMap xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
@@ -0,0 +1,29 @@
1
+ <xml xmlns:o="urn:schemas-microsoft-com:office:office">
2
+ <o:MainFile HRef="../rubyrun_ce-0.9.5.htm"/>
3
+ <o:File HRef="themedata.thmx"/>
4
+ <o:File HRef="colorschememapping.xml"/>
5
+ <o:File HRef="image001.jpg"/>
6
+ <o:File HRef="image002.jpg"/>
7
+ <o:File HRef="image003.jpg"/>
8
+ <o:File HRef="image004.jpg"/>
9
+ <o:File HRef="image005.jpg"/>
10
+ <o:File HRef="image006.jpg"/>
11
+ <o:File HRef="image007.jpg"/>
12
+ <o:File HRef="image008.jpg"/>
13
+ <o:File HRef="image009.jpg"/>
14
+ <o:File HRef="image010.jpg"/>
15
+ <o:File HRef="image011.jpg"/>
16
+ <o:File HRef="image012.jpg"/>
17
+ <o:File HRef="image013.jpg"/>
18
+ <o:File HRef="image014.jpg"/>
19
+ <o:File HRef="image015.jpg"/>
20
+ <o:File HRef="image016.jpg"/>
21
+ <o:File HRef="image017.png"/>
22
+ <o:File HRef="image018.jpg"/>
23
+ <o:File HRef="image019.jpg"/>
24
+ <o:File HRef="image020.jpg"/>
25
+ <o:File HRef="image021.jpg"/>
26
+ <o:File HRef="header.htm"/>
27
+ <o:File HRef="image022.png"/>
28
+ <o:File HRef="filelist.xml"/>
29
+ </xml>
@@ -0,0 +1,138 @@
1
+ <html xmlns:v="urn:schemas-microsoft-com:vml"
2
+ xmlns:o="urn:schemas-microsoft-com:office:office"
3
+ xmlns:w="urn:schemas-microsoft-com:office:word"
4
+ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
5
+ xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
6
+ xmlns="http://www.w3.org/TR/REC-html40">
7
+
8
+ <head>
9
+ <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
10
+ <meta name=ProgId content=Word.Document>
11
+ <meta name=Generator content="Microsoft Word 12">
12
+ <meta name=Originator content="Microsoft Word 12">
13
+ <link id=Main-File rel=Main-File href="../rubyrun_ce-0.9.5.htm">
14
+ <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
15
+ name="stockticker"/>
16
+ <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
17
+ name="place"/>
18
+ <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
19
+ name="PlaceName"/>
20
+ <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
21
+ name="PlaceType"/>
22
+ </head>
23
+
24
+ <body lang=EN-US link=blue vlink=purple>
25
+
26
+ <div style='mso-element:footnote-separator' id=fs>
27
+
28
+ <p class=MsoNormal><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
29
+
30
+ <hr align=left size=1 width="33%">
31
+
32
+ <![endif]></span></p>
33
+
34
+ </div>
35
+
36
+ <div style='mso-element:footnote-continuation-separator' id=fcs>
37
+
38
+ <p class=MsoNormal><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
39
+
40
+ <hr align=left size=1>
41
+
42
+ <![endif]></span></p>
43
+
44
+ </div>
45
+
46
+ <div style='mso-element:endnote-separator' id=es>
47
+
48
+ <p class=MsoNormal><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
49
+
50
+ <hr align=left size=1 width="33%">
51
+
52
+ <![endif]></span></p>
53
+
54
+ </div>
55
+
56
+ <div style='mso-element:endnote-continuation-separator' id=ecs>
57
+
58
+ <p class=MsoNormal><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
59
+
60
+ <hr align=left size=1>
61
+
62
+ <![endif]></span></p>
63
+
64
+ </div>
65
+
66
+ <div style='mso-element:header' id=h1>
67
+
68
+ <p class=MsoHeader align=center style='text-align:center;tab-stops:center 3.0in left 4.25in right 6.0in'><span
69
+ style='font-size:10.0pt;font-family:"Arial","sans-serif"'><span
70
+ style='mso-tab-count:1'>����������������������������������������� </span><span
71
+ style='mso-spacerun:yes'>������������ </span></span>Ruby<i style='mso-bidi-font-style:
72
+ normal'>Run</i> Community Edition<span style='font-size:10.0pt;font-family:
73
+ "Arial","sans-serif"'><span style='mso-tab-count:1'> </span><span
74
+ style='mso-spacerun:yes'>����������������������������� </span></span><b
75
+ style='mso-bidi-font-weight:normal'><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
76
+ coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
77
+ filled="f" stroked="f">
78
+ <v:stroke joinstyle="miter"/>
79
+ <v:formulas>
80
+ <v:f eqn="if lineDrawn pixelLineWidth 0"/>
81
+ <v:f eqn="sum @0 1 0"/>
82
+ <v:f eqn="sum 0 0 @1"/>
83
+ <v:f eqn="prod @2 1 2"/>
84
+ <v:f eqn="prod @3 21600 pixelWidth"/>
85
+ <v:f eqn="prod @3 21600 pixelHeight"/>
86
+ <v:f eqn="sum @0 0 1"/>
87
+ <v:f eqn="prod @6 1 2"/>
88
+ <v:f eqn="prod @7 21600 pixelWidth"/>
89
+ <v:f eqn="sum @8 21600 0"/>
90
+ <v:f eqn="prod @7 21600 pixelHeight"/>
91
+ <v:f eqn="sum @10 21600 0"/>
92
+ </v:formulas>
93
+ <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
94
+ <o:lock v:ext="edit" aspectratio="t"/>
95
+ </v:shapetype><v:shape id="_x0000_i1039" type="#_x0000_t75" style='width:114pt;
96
+ height:20.25pt'>
97
+ <v:imagedata src="image022.png" o:title="rubysophic_logo"/>
98
+ </v:shape><![endif]--></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p></o:p></span></p>
99
+
100
+ </div>
101
+
102
+ <div style='mso-element:footer' id=f1>
103
+
104
+ <p class=MsoFooter align=center style='text-align:center'><span
105
+ style='font-size:10.0pt;font-family:"Arial","sans-serif"'><span
106
+ style='mso-tab-count:1'>������������������������������������������������� </span></span>Installation
107
+ and User Guide<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><span
108
+ style='mso-tab-count:1'>��������������������������� </span></span>Page <!--[if supportFields]><span
109
+ style='mso-element:field-begin'></span><span
110
+ style='mso-spacerun:yes'>�</span>PAGE <span style='mso-element:field-separator'></span><![endif]--><span
111
+ style='mso-no-proof:yes'>32</span><!--[if supportFields]><span
112
+ style='mso-element:field-end'></span><![endif]--> of <!--[if supportFields]><span
113
+ style='mso-element:field-begin'></span><span
114
+ style='mso-spacerun:yes'>�</span>NUMPAGES <span style='mso-element:field-separator'></span><![endif]--><span
115
+ style='mso-no-proof:yes'>32</span><!--[if supportFields]><span
116
+ style='mso-element:field-end'></span><![endif]--><b style='mso-bidi-font-weight:
117
+ normal'><o:p></o:p></b></p>
118
+
119
+ </div>
120
+
121
+ <div style='mso-element:header' id=fh1>
122
+
123
+ <p class=MsoHeader style='tab-stops:center 3.0in left 310.5pt right 6.0in'><b
124
+ style='mso-bidi-font-weight:normal'><!--[if gte vml 1]><v:shape id="_x0000_i1040"
125
+ type="#_x0000_t75" style='width:110.25pt;height:20.25pt'>
126
+ <v:imagedata src="image022.png" o:title="rubysophic_logo"/>
127
+ </v:shape><![endif]--><span style='mso-tab-count:2'>������������������������������������������������������������������ </span></b><span
128
+ style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Ruby<i
129
+ style='mso-bidi-font-style:normal'>Run</i><sup>CE</sup> 0.9.5 Installation and
130
+ User Guide<o:p></o:p></span></p>
131
+
132
+ <p class=MsoHeader><o:p>&nbsp;</o:p></p>
133
+
134
+ </div>
135
+
136
+ </body>
137
+
138
+ </html>
@@ -0,0 +1,132 @@
1
+ #---------------------------------------------------------------#
2
+ # #
3
+ # (C) Copyright Rubysophic Inc. 2007-2008 #
4
+ # All rights reserved. #
5
+ # #
6
+ # Use, duplication or disclosure of the code is not permitted #
7
+ # unless licenced. #
8
+ # #
9
+ # Last Updated: 7/09/08 #
10
+ #---------------------------------------------------------------#
11
+ # #
12
+ # The master copy of this property file should have been #
13
+ # installed via the RubyRun gem install package in the #
14
+ # same directory where rubyrun.rb is. #
15
+ # #
16
+ # However, the one that is to be used at run time is the one #
17
+ # either in #
18
+ # 1) the current working directiory under which the application#
19
+ # is running, or #
20
+ # 2) in RubyRun working directory, pointed to by the #
21
+ # the environment variable RUBYRUN_WORKING_DIR (lower priority)#
22
+ # #
23
+ # ************************************************************ #
24
+ # * IN ALL HASH SPECIFICATION, A SPACE MUST BE PLACED * #
25
+ # * AFTER THE COLON AND BEFORE THE VALUES. * #
26
+ # ************************************************************ #
27
+ # #
28
+ #---------------------------------------------------------------#
29
+
30
+ # A source for application candidate classes or modules must
31
+ # be identifed for instrumentation. These classes/modules should
32
+ # be part of your application and not the Ruby or Rails libraries.
33
+ #
34
+ # APP_PATHS must be an array of directories (absolute path)
35
+ # from where ruby code is to be loaded in order to run the
36
+ # application. RubyRun will recursively expand these directories
37
+ # and open every .rb file looking for Class or Module
38
+ # statements. These Class or Module names will be noted as
39
+ # candiates for instrumentation.
40
+ APP_PATHS: []
41
+
42
+ # INCLUDE_HASH is a hash keyed on a class name with an array
43
+ # of method names as values. Class name and method name must be a
44
+ # string but names are case insensitive. This hash identifies
45
+ # class/method combination explicitly that are to be instrumented
46
+ # IN ADDITION to APP_PATHS.
47
+ # Examples:
48
+ # INCLUDE_HASH: {Class1: [method1, method2]}
49
+ # #=> method1 and method2 of Class1
50
+ # INCLUDE_HASH: {Class1: []} #=> all methods in Class1
51
+ # INCLUDE_HASH: {*: [method1]} #=> method1 of any classes
52
+ # INCLUDE_HASH: {} #=> Include nothing extra
53
+ INCLUDE_HASH: {}
54
+
55
+ # EXCLUDE_HASH is a hash keyed on a class name with an array
56
+ # of method names as values. Class name and method name must be a
57
+ # string but names are case insensitive. This hash identifies
58
+ # class/method combinations that are to be excluded from instrumented.
59
+ # Examples:
60
+ # EXCLUDE_HASH: {Class1: [method1, method2]}
61
+ # #=> method1 and method2 of Class1
62
+ # EXCLUDE_HASH: {Class1: []} #=> all methods in Class1
63
+ # EXCLUDE_HASH: {*: [method1]} #=> method1 of any classes
64
+ # EXCLUDE_HASH: {} #=> Exclude nothing
65
+ EXCLUDE_HASH: {}
66
+
67
+ # Specify one of the following to get database I/O timings and sql statements
68
+ # in method trace.
69
+ # For Mysql: { ActiveRecord::ConnectionAdapters::MysqlAdapter: [execute] }
70
+ # For Progres: { ActiveRecord::ConnectionAdapters::PostgreSQLAdapter: [execute] }
71
+ # For SQLite: { ActiveRecord::ConnectionAdapters::SQLiteAdapter: [execute] }
72
+ # For SQLite2: { ActiveRecord::ConnectionAdapters::SQLite2Adapter: [execute] }
73
+ # For Firebird: { ActiveRecord::ConnectionAdapters::FirebirdAdapter: [execute] }
74
+ # For SQLServer: { ActiveRecord::ConnectionAdapters::SQLServerAdapter: [execute] }
75
+ # For OpenBase: { ActiveRecord::ConnectionAdapters::OpenBaseAdapter: [execute] }
76
+ # For FrontBase: { ActiveRecord::ConnectionAdapters::FrontBaseAdapter: [execute] }
77
+ DB_ADAPTER_HASH: {ActiveRecord::ConnectionAdapters::MysqlAdapter: [execute]}
78
+
79
+ # Specify how tracing is to be done.
80
+ # Examples:
81
+ # TRACE_HASH: {*: []} #=> Trace all instrumented methods:
82
+ # TRACE_HASH: {} #=> Stop tracing
83
+ # TRACE_HASH: {Class1: [method1, method2], Class2: [method3, method4]}
84
+ # #=> Trace only these instrumented methods
85
+ TRACE_HASH: {}
86
+
87
+ # Only applies when TRACE_HASH is not an empty hash.
88
+ # Use DEBUG_ARGS to inspect arguments that were passed in method calls.
89
+ # This can slow down execution and affect memory
90
+ # footprint tremendously, and inspecting large argument objects can
91
+ # frequently causes "stack level too deep" error.
92
+ # Turn this on only as a last resort to debug with trace.
93
+ DEBUG_ARGS: false
94
+
95
+ # Only applies when TRACE_HASH is not an empty hash.
96
+ # Use DEBUG_OBJ to inspect objects that made the method call.
97
+ # This can slow down execution and affect memory
98
+ # footprint tremendously, and inspecting large objects can
99
+ # frequently causes "stack level too deep" error.
100
+ # Turn this on only as a last resort to debug with trace.
101
+ DEBUG_OBJ: false
102
+
103
+ # Set Dynamic Application Discovery to true if you want to log
104
+ # the name of the classes and methods that are dynamically added
105
+ # to the Ruby process.
106
+ DAD: true
107
+
108
+ # Set the report timer in second(s). Used by the report
109
+ # thread to wake up every so often to generate the performance report
110
+ # Max value allowed: 3600
111
+ # Min value allowed: 60
112
+ REPORT_TIMER: 60
113
+
114
+ # Set the max no. of RSS reports to be kept before the oldest
115
+ # report is shifted and purged.
116
+ # Max value allowed: 120
117
+ # Min value allowed: 1
118
+ REPORT_SHIFT_AGE: 60
119
+
120
+ # Select reports. The following reports are available:
121
+ # 1. perf_summary - Performance summary in RSS format
122
+ # 2. txn_log - Transaction log in CSV format
123
+ # Examples:
124
+ # OUTPUT: [perf_summary]
125
+ # OUTPUT: [perf_summary, txn_log]
126
+ OUTPUT: [perf_summary, txn_log]
127
+
128
+ # Set the location of the RSS channel and item files
129
+ # Leave this to blank results in [application directory]/public/rubyrun_rss being used
130
+ RSS_PATH:
131
+
132
+
data/ext/extconf.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+ create_makefile("rubyrunnative__")
3
+
4
+
5
+
@@ -0,0 +1,154 @@
1
+ /****************************************************************
2
+ # #
3
+ # (C) Copyright Rubysophic Inc. 2007-2008 #
4
+ # All rights reserved. #
5
+ # #
6
+ # Use, duplication or disclosure of the code is not permitted #
7
+ # unless licensed. #
8
+ # #
9
+ # Last Updated: 5/24/08 #
10
+ ****************************************************************/
11
+
12
+ /*
13
+ This piece of native code relies on the Thread Struct which is part of
14
+ eval.c in the source code directory of the Ruby install.
15
+
16
+ Other structs also exist in the directory as independent .h files but not
17
+ Thread Struct.
18
+
19
+ This means it will require separate dev work and compilation for each
20
+ platform of Ruby and release, in theory.
21
+
22
+ This piece of code follows the dev convention for writing Ruby extension.
23
+
24
+ To compile, use nmake in rubyrunnative subdirectory.
25
+ e.g. >nmake
26
+
27
+ Also, you need to imbed the manifest into the .so file afterwards as follow:
28
+ e.g. >mt.exe -manifest rubyrunnative__.so.manifest -outputresource:rubyrunnative__.so;2
29
+
30
+ Then copy rubyrunnative__.so into the directory where rubyrun.rb is loaded from.
31
+ */
32
+
33
+ #include "rubyrunnative__.h"
34
+
35
+ static VALUE RubyRunNative__;
36
+
37
+ VALUE getTopThreadStack(rb_thread_t thrObj)
38
+ {
39
+ char buf[BUFSIZ];
40
+ VALUE stack_trace;
41
+ NODE *n;
42
+ struct FRAME *frame;
43
+
44
+ /*
45
+ Input is the thread struct pointer.
46
+
47
+ The stack for each frame starts from the thread. Frame consists of the function name (last_func).
48
+
49
+ Node is pointed by each frame, which gives you the name of the file (n->nd_file) and
50
+ the line number (nd_line(n)).
51
+
52
+ For each line there may be multiple functions and dont have the granularity to list them all out.
53
+ We will only list the last one.
54
+
55
+ For the top of the stack (frame pointed to by the thread) we will list the actual function being
56
+ executed on the line #.
57
+
58
+ All the stack entries are returned to the caller as an array.
59
+
60
+ Refer to backtrace(lev) in eval.c. This serves the basis of the following code in terms of
61
+ navigating frames and nodes.
62
+
63
+ However, further testing indicates that the frames/nodes navigation is not reliable unless the
64
+ thread that is being interrogated is the ACTIVE one. It is therefore intended for this fuction
65
+ to return only the data stored in the thread struct.
66
+
67
+ Added: we dont want to kill a thread joined by the main thread, as killing it will kill the
68
+ main thread too, which does not have the begin-rescue clause and will simply terminate the
69
+ entire space with no trace.
70
+ */
71
+ frame = thrObj->frame;
72
+ n = thrObj->node;
73
+ stack_trace = rb_ary_new();
74
+
75
+ if (frame && n) {
76
+ char *funcName =
77
+ (frame->orig_func != NULL)? rb_id2name(frame->orig_func): NULL;
78
+
79
+ if(funcName == NULL)
80
+ funcName = "";
81
+
82
+ if (thrObj->join) {
83
+
84
+ snprintf(buf, BUFSIZ, "%s:%d:%s joined **%x**",
85
+ n->nd_file, nd_line(n),
86
+ funcName,
87
+ thrObj->join->thread);
88
+ /* printf("%s:%d:%s joined **%x**\n", n->nd_file, nd_line(n), rb_id2name(frame->orig_func), thrObj->join->thread); */
89
+ }
90
+ else {
91
+ snprintf(buf, BUFSIZ, "%s:%d:%s",
92
+ n->nd_file, nd_line(n),
93
+ funcName);
94
+ /* printf("%s:%d:%s\n", n->nd_file, nd_line(n), rb_id2name(frame->orig_func)); */
95
+ }
96
+ }
97
+
98
+ rb_ary_push(stack_trace, rb_str_new2(buf));
99
+ return stack_trace;
100
+ }
101
+
102
+ /*
103
+ This c routine implements RubyRunNative__.get_all_top_stacks (static method).
104
+ For each thread in the space, it calls call_stack to simulate a Ruby caller
105
+ invocation.
106
+ */
107
+
108
+ VALUE c_getAllThreadTopStacks(VALUE self)
109
+ {
110
+ VALUE all_top_stack_trace;
111
+ VALUE currThreadID;
112
+ rb_thread_t thrObj, currThreadObj;
113
+
114
+ /*
115
+ We start with the current thread, whatever it is (likely main),
116
+ and use the macro to locate its structure (rb_thread_current only
117
+ returns the thread ID)
118
+ */
119
+ currThreadID = rb_thread_current();
120
+ Data_Get_Struct(currThreadID, struct rb_thread, currThreadObj);
121
+
122
+ /*
123
+ Final result is a hash where the key is the thread ID and value
124
+ an array of stack trace entries.
125
+ */
126
+ all_top_stack_trace = rb_hash_new();
127
+
128
+ /*
129
+ Starts the loop without the dump thread itself.
130
+ Thread structs are double linked list in Ruby. We can start from any one
131
+ and chain through the rest of them.
132
+ */
133
+ thrObj = currThreadObj;
134
+
135
+ for ( ;thrObj ;thrObj = thrObj->next) {
136
+ /* printf("Ruby thread id = %x\n", thrObj->thread); */
137
+ if(thrObj != NULL) {
138
+ rb_hash_aset(all_top_stack_trace, thrObj->thread, getTopThreadStack(thrObj));
139
+ }
140
+
141
+ // If we reached the start point, break.
142
+ // Note: Threads are double linked objects
143
+
144
+ if (thrObj->next == currThreadObj) break;
145
+ }
146
+
147
+ return all_top_stack_trace;
148
+ }
149
+
150
+ void Init_rubyrunnative__()
151
+ {
152
+ RubyRunNative__ = rb_define_class("RubyRunNative__",rb_cObject);
153
+ rb_define_singleton_method(RubyRunNative__, "get_all_top_stacks", c_getAllThreadTopStacks, 0);
154
+ }
@@ -0,0 +1,2 @@
1
+ EXPORTS
2
+ Init_rubyrunnative__
@@ -0,0 +1,36 @@
1
+ /****************************************************************
2
+ # #
3
+ # (C) Copyright Rubysophic Inc. 2007-2008 #
4
+ # All rights reserved. #
5
+ # #
6
+ # Use, duplication or disclosure of the code is not permitted #
7
+ # unless licensed. #
8
+ # #
9
+ # Last Updated: 5/24/08 #
10
+ ****************************************************************/
11
+
12
+ #include "ruby.h"
13
+ #include "env.h"
14
+ #include "node.h"
15
+ #include "st.h"
16
+ #include "setjmp.h"
17
+
18
+ #define SAVE_WIN32_EXCEPTION_LIST
19
+
20
+ #if defined(__cplusplus)
21
+ extern "C" {
22
+ #endif
23
+
24
+ // Main entry method
25
+
26
+ void Init_rubyrunnative__();
27
+
28
+ static VALUE c_getAllThreadTopStacks(VALUE self);
29
+
30
+ // Helper methods
31
+ static VALUE getTopThreadStack(rb_thread_t thrObj);
32
+
33
+
34
+ #if defined(__cplusplus)
35
+ } // extern "C"
36
+ #endif
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'rubyrun_boot__'
@@ -0,0 +1,79 @@
1
+ #---------------------------------------------------------------#
2
+ # #
3
+ # (C) Copyright Rubysophic Inc. 2007-2008 #
4
+ # All rights reserved. #
5
+ # #
6
+ # Use, duplication or disclosure of the code is not permitted #
7
+ # unless licensed. #
8
+ # #
9
+ # Last Updated: 7/09/08 #
10
+ #---------------------------------------------------------------#
11
+ # #
12
+ # RubyRun bootstrap code. #
13
+ # #
14
+ # To invoke RubyRun for Rails or a Ruby script, use command #
15
+ # line option -r. #
16
+ # #
17
+ # ruby -rrubyrun script/server <webrick> #
18
+ # #
19
+ # To remove RubyRun, simply remove the -r option. #
20
+ # #
21
+ # Generally no other code change is needed to run RubyRun. #
22
+ # #
23
+ #---------------------------------------------------------------#
24
+
25
+ # BEGIN section of the code is always executed first.
26
+ # 1. Intiialize globals, requires and includes
27
+ # 2. Intitialize RubyRun runtime environment
28
+ # Note. For $rubyrun_current_buffer, 1 - primary, 2 - secondary
29
+ BEGIN {
30
+ require 'rubyrun_globals'
31
+ require 'rubyrun_instrumentor__'
32
+ require 'rubyrun_monitor__'
33
+ require 'rubyrun_initializer__'
34
+ include RubyRunGlobals
35
+ include RubyRunInitializer__
36
+ include RubyRunInstrumentor__
37
+ include RubyRunMonitor__
38
+ $rubyrun_include_hash = {}
39
+ $rubyrun_exclude_hash = {}
40
+ $rubyrun_thread_stack = {}
41
+ $rubyrun_metrics_hash = {}
42
+ $rubyrun_thread_local = {}
43
+ $rubyrun_file_date_hash = {}
44
+ $rubyrun_prime_buffer = []
45
+ $rubyrun_alt_buffer = []
46
+ $rubyrun_controller_classes = []
47
+ $rubyrun_current_buffer = 1
48
+ $rubyrun_lock = Monitor.new
49
+ init_rubyrun
50
+ }
51
+
52
+ # RubyRun uses 2 traps to get control from the interpreter
53
+ # to decide if a method should be instrumented or passed
54
+ #
55
+ # 1. When an instance method is added when a module/class is
56
+ # loaded, or dynamically created
57
+ # 2. When a module/static/singleton method is added when a
58
+ # module/class is loaded, or dynamically created
59
+ class Module
60
+ # module/class instance method trap
61
+ def method_added(id, *args)
62
+ RubyRunInstrumentor__.instrument_it?('i', self, id)
63
+ end
64
+ end
65
+
66
+ class Object
67
+ # class object/object singleton method trap
68
+ def singleton_method_added(id, *args)
69
+ RubyRunInstrumentor__.instrument_it?('s', self, id)
70
+ end
71
+ end
72
+
73
+ # 1. Instrument Thread.new method to provide a begin/rescue clause
74
+ # to catch failure for providing a stack trace
75
+ #
76
+ # 2. Start the monitor timer thread
77
+ instrument_thread_new
78
+ start_thread_monitor
79
+ puts '*** RubyRun successfully started. ***'