summaryrefslogtreecommitdiff
path: root/vm_dump.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-11 08:09:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-11 08:09:48 +0000
commit05e73548645fecf95494fee4f75f7f7713bf870c (patch)
tree47c99271a1ae978a998b66874595cbed94f5e50d /vm_dump.c
parent0d746627af624e1fca683b726ee2de86127fa16c (diff)
* vm_dump.c (HAVE_BACKTRACE): fallback to 0.
* vm_dump.c (rb_vm_bugreport): show "Other runtime information" header only when available. * vm_dump.c (rb_vm_bugreport): get rid of modifying the content of VM directly. * vm_dump.c (rb_vm_bugreport): check if vm is non-null. Pointed out by Ikegami Daisuke <ikegami.da@gmail.com>. Thank you. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 5fd9354..1e59919 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -593,6 +593,9 @@ bugreport_backtrace(void *arg, VALUE file, int line, VALUE method)
#if defined(__FreeBSD__) && defined(__OPTIMIZE__)
#undef HAVE_BACKTRACE
#endif
+#ifndef HAVE_BACKTRACE
+#define HAVE_BACKTRACE 0
+#endif
#if HAVE_BACKTRACE
# include <execinfo.h>
#elif defined(_WIN32)
@@ -774,7 +777,15 @@ dump_thread(void *arg)
void
rb_vm_bugreport(void)
{
- rb_vm_t *vm = GET_VM();
+#ifdef __linux__
+# define PROC_MAPS_NAME "/proc/self/maps"
+#endif
+#ifdef PROC_MAPS_NAME
+ enum {other_runtime_info = 1};
+#else
+ enum {other_runtime_info = 0};
+#endif
+ const rb_vm_t *const vm = GET_VM();
if (vm) {
int i = 0;
SDR();
@@ -823,22 +834,29 @@ rb_vm_bugreport(void)
fprintf(stderr, "\n");
#endif /* HAVE_BACKTRACE */
- fprintf(stderr, "-- Other runtime information "
- "-----------------------------------------------\n\n");
- {
+ if (other_runtime_info || vm) {
+ fprintf(stderr, "-- Other runtime information "
+ "-----------------------------------------------\n\n");
+ }
+ if (vm) {
int i;
+ VALUE name;
- fprintf(stderr, "* Loaded script: %s\n", StringValueCStr(vm->progname));
+ name = vm->progname;
+ fprintf(stderr, "* Loaded script: %s\n", StringValueCStr(name));
fprintf(stderr, "\n");
fprintf(stderr, "* Loaded features:\n\n");
for (i=0; i<RARRAY_LEN(vm->loaded_features); i++) {
- fprintf(stderr, " %4d %s\n", i, StringValueCStr(RARRAY_PTR(vm->loaded_features)[i]));
+ name = RARRAY_PTR(vm->loaded_features)[i];
+ fprintf(stderr, " %4d %s\n", i, StringValueCStr(name));
}
fprintf(stderr, "\n");
+ }
-#if __linux__
+ {
+#ifdef PROC_MAPS_NAME
{
- FILE *fp = fopen("/proc/self/maps", "r");
+ FILE *fp = fopen(PROC_MAPS_NAME, "r");
if (fp) {
fprintf(stderr, "* Process memory map:\n\n");