pf2 0.11.3 → 0.13.0

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/lib/pf2/serve.rb CHANGED
@@ -27,10 +27,9 @@ module Pf2
27
27
  server = WEBrick::HTTPServer.new(CONFIG)
28
28
  server.mount_proc('/profile') do |req, res|
29
29
  profile = Pf2.stop
30
- profile = JSON.parse(profile, symbolize_names: true, max_nesting: false)
31
30
  res.header['Content-Type'] = 'application/json'
32
31
  res.header['Access-Control-Allow-Origin'] = '*'
33
- res.body = JSON.generate(Pf2::Reporter::FirefoxProfiler.new((profile)).emit)
32
+ res.body = JSON.generate(Pf2::Reporter::FirefoxProfilerSer2.new(profile).emit)
34
33
  Pf2.start
35
34
  end
36
35
 
data/lib/pf2/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pf2
4
- VERSION = '0.11.3'
4
+ VERSION = '0.13.0'
5
5
  end
data/lib/pf2.rb CHANGED
@@ -15,12 +15,25 @@ module Pf2
15
15
  @@session.stop
16
16
  end
17
17
 
18
- def self.profile(&block)
18
+ # Profiles the given block of code.
19
+ #
20
+ # Example:
21
+ #
22
+ # profile = Pf2.profile(interval_ms: 42) do
23
+ # your_code_here
24
+ # end
25
+ #
26
+ def self.profile(**kwargs, &block)
19
27
  raise ArgumentError, "block required" unless block_given?
20
- start(threads: Thread.list)
28
+ start(**kwargs)
21
29
  yield
22
30
  result = stop
23
31
  @@session = nil # let GC clean up the session
24
32
  result
33
+ ensure
34
+ if defined?(@@session) && @@session != nil
35
+ stop
36
+ @@session = nil
37
+ end
25
38
  end
26
39
  end
@@ -103,7 +103,7 @@ backtrace_atomic_store_size_t (size_t *p, size_t v)
103
103
  void
104
104
  backtrace_atomic_store_int (int *p, int v)
105
105
  {
106
- size_t old;
106
+ int old;
107
107
 
108
108
  old = *p;
109
109
  while (!__sync_bool_compare_and_swap (p, old, v))
@@ -812,6 +812,7 @@ enable_darwin_at_rpath
812
812
  enable_largefile
813
813
  enable_werror
814
814
  with_system_libunwind
815
+ enable_host_pie
815
816
  enable_host_shared
816
817
  '
817
818
  ac_precious_vars='build_alias
@@ -1461,6 +1462,7 @@ Optional Features:
1461
1462
  rpaths to be added to executables
1462
1463
  --disable-largefile omit support for large files
1463
1464
  --disable-werror disable building with -Werror
1465
+ --enable-host-pie build host code as PIE
1464
1466
  --enable-host-shared build host code as shared libraries
1465
1467
 
1466
1468
  Optional Packages:
@@ -11395,7 +11397,7 @@ else
11395
11397
  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11396
11398
  lt_status=$lt_dlunknown
11397
11399
  cat > conftest.$ac_ext <<_LT_EOF
11398
- #line 11398 "configure"
11400
+ #line 11400 "configure"
11399
11401
  #include "confdefs.h"
11400
11402
 
11401
11403
  #if HAVE_DLFCN_H
@@ -11501,7 +11503,7 @@ else
11501
11503
  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11502
11504
  lt_status=$lt_dlunknown
11503
11505
  cat > conftest.$ac_ext <<_LT_EOF
11504
- #line 11504 "configure"
11506
+ #line 11506 "configure"
11505
11507
  #include "confdefs.h"
11506
11508
 
11507
11509
  #if HAVE_DLFCN_H
@@ -12190,12 +12192,18 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h
12190
12192
  fi
12191
12193
  fi
12192
12194
 
12195
+ # Enable --enable-host-pie.
12196
+ # Check whether --enable-host-pie was given.
12197
+ if test "${enable_host_pie+set}" = set; then :
12198
+ enableval=$enable_host_pie; PIC_FLAG=-fPIE
12199
+ else
12200
+ PIC_FLAG=
12201
+ fi
12202
+
12193
12203
  # Enable --enable-host-shared.
12194
12204
  # Check whether --enable-host-shared was given.
12195
12205
  if test "${enable_host_shared+set}" = set; then :
12196
12206
  enableval=$enable_host_shared; PIC_FLAG=-fPIC
12197
- else
12198
- PIC_FLAG=
12199
12207
  fi
12200
12208
 
12201
12209
 
@@ -176,11 +176,16 @@ else
176
176
  fi
177
177
  fi
178
178
 
179
+ # Enable --enable-host-pie.
180
+ AC_ARG_ENABLE(host-pie,
181
+ [AS_HELP_STRING([--enable-host-pie],
182
+ [build host code as PIE])],
183
+ [PIC_FLAG=-fPIE], [PIC_FLAG=])
179
184
  # Enable --enable-host-shared.
180
185
  AC_ARG_ENABLE(host-shared,
181
186
  [AS_HELP_STRING([--enable-host-shared],
182
187
  [build host code as shared libraries])],
183
- [PIC_FLAG=-fPIC], [PIC_FLAG=])
188
+ [PIC_FLAG=-fPIC])
184
189
  AC_SUBST(PIC_FLAG)
185
190
 
186
191
  # Test for __sync support.
@@ -160,10 +160,10 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,
160
160
  #undef EI_CLASS
161
161
  #undef EI_DATA
162
162
  #undef EI_VERSION
163
- #undef ELF_MAG0
164
- #undef ELF_MAG1
165
- #undef ELF_MAG2
166
- #undef ELF_MAG3
163
+ #undef ELFMAG0
164
+ #undef ELFMAG1
165
+ #undef ELFMAG2
166
+ #undef ELFMAG3
167
167
  #undef ELFCLASS32
168
168
  #undef ELFCLASS64
169
169
  #undef ELFDATA2LSB
@@ -47,6 +47,10 @@ POSSIBILITY OF SUCH DAMAGE. */
47
47
  #include <mach-o/dyld.h>
48
48
  #endif
49
49
 
50
+ #ifdef __hpux__
51
+ #include <dl.h>
52
+ #endif
53
+
50
54
  #ifdef HAVE_WINDOWS_H
51
55
  #ifndef WIN32_LEAN_AND_MEAN
52
56
  #define WIN32_LEAN_AND_MEAN
@@ -66,6 +70,33 @@ POSSIBILITY OF SUCH DAMAGE. */
66
70
  #define getexecname() NULL
67
71
  #endif
68
72
 
73
+ #ifdef __hpux__
74
+ static char *
75
+ hpux_get_executable_path (struct backtrace_state *state,
76
+ backtrace_error_callback error_callback, void *data)
77
+ {
78
+ struct shl_descriptor *desc;
79
+ size_t len = sizeof (struct shl_descriptor);
80
+
81
+ desc = backtrace_alloc (state, len, error_callback, data);
82
+ if (desc == NULL)
83
+ return NULL;
84
+
85
+ if (shl_get_r (0, desc) == -1)
86
+ {
87
+ backtrace_free (state, desc, len, error_callback, data);
88
+ return NULL;
89
+ }
90
+
91
+ return desc->filename;
92
+ }
93
+
94
+ #else
95
+
96
+ #define hpux_get_executable_path(state, error_callback, data) NULL
97
+
98
+ #endif
99
+
69
100
  #if !defined (HAVE_KERN_PROC_ARGS) && !defined (HAVE_KERN_PROC)
70
101
 
71
102
  #define sysctl_exec_name1(state, error_callback, data) NULL
@@ -245,7 +276,7 @@ fileline_initialize (struct backtrace_state *state,
245
276
 
246
277
  descriptor = -1;
247
278
  called_error_callback = 0;
248
- for (pass = 0; pass < 10; ++pass)
279
+ for (pass = 0; pass < 11; ++pass)
249
280
  {
250
281
  int does_not_exist;
251
282
 
@@ -285,6 +316,9 @@ fileline_initialize (struct backtrace_state *state,
285
316
  case 9:
286
317
  filename = windows_get_executable_path (buf, error_callback, data);
287
318
  break;
319
+ case 10:
320
+ filename = hpux_get_executable_path (state, error_callback, data);
321
+ break;
288
322
  default:
289
323
  abort ();
290
324
  }
@@ -3,6 +3,7 @@
3
3
  /^\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
4
4
  /^\114\001/ { if (NR == 1) { print "pecoff"; exit } }
5
5
  /^\144\206/ { if (NR == 1) { print "pecoff"; exit } }
6
+ /^\000\000\377\377/ { if (NR == 1) { print "pecoff"; exit } }
6
7
  /^\001\337/ { if (NR == 1) { print "xcoff32"; exit } }
7
8
  /^\001\367/ { if (NR == 1) { print "xcoff64"; exit } }
8
9
  /^\376\355\372\316/ { if (NR == 1) { print "macho"; exit } }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pf2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Aritomo
@@ -121,16 +121,19 @@ files:
121
121
  - LICENSE.txt
122
122
  - README.md
123
123
  - Rakefile
124
+ - THIRD_PARTY_LICENSES.txt
124
125
  - doc/development.md
125
126
  - examples/mandelbrot.rb
126
127
  - examples/mandelbrot_ractor.rb
127
128
  - exe/pf2
129
+ - ext/patches/libbacktrace/0001-Support-MACH_O_MH_BUNDLE.patch
128
130
  - ext/pf2/backtrace_state.c
129
131
  - ext/pf2/backtrace_state.h
130
132
  - ext/pf2/configuration.c
131
133
  - ext/pf2/configuration.h
132
134
  - ext/pf2/debug.h
133
135
  - ext/pf2/extconf.rb
136
+ - ext/pf2/khashl.h
134
137
  - ext/pf2/pf2.c
135
138
  - ext/pf2/pf2.h
136
139
  - ext/pf2/ringbuffer.c