aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/unix
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc/unix')
-rw-r--r--erts/etc/unix/Install.src2
-rw-r--r--erts/etc/unix/Makefile6
-rw-r--r--erts/etc/unix/README4
-rw-r--r--erts/etc/unix/cerl.src39
-rw-r--r--erts/etc/unix/etp-commands.in514
-rw-r--r--erts/etc/unix/run_erl.c15
-rw-r--r--erts/etc/unix/to_erl.c4
7 files changed, 486 insertions, 98 deletions
diff --git a/erts/etc/unix/Install.src b/erts/etc/unix/Install.src
index e71308edbe..e4b842877c 100644
--- a/erts/etc/unix/Install.src
+++ b/erts/etc/unix/Install.src
@@ -2,7 +2,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 1996-2016. All Rights Reserved.
+# Copyright Ericsson AB 1996-2017. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/erts/etc/unix/Makefile b/erts/etc/unix/Makefile
index 2fa9cd047b..83c64d35fd 100644
--- a/erts/etc/unix/Makefile
+++ b/erts/etc/unix/Makefile
@@ -1,7 +1,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2013-2016. All Rights Reserved.
+# Copyright Ericsson AB 2013-2017. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ include $(ERL_TOP)/make/target.mk
include $(ERL_TOP)/make/$(TARGET)/otp.mk
include ../../vsn.mk
-opt debug: etc
+opt debug lcnt: etc
.PHONY: etc
etc: etp-commands
@@ -44,4 +44,4 @@ clean:
include $(ERL_TOP)/make/otp_release_targets.mk
.PHONY: release_spec
-release_spec: etc \ No newline at end of file
+release_spec: etc
diff --git a/erts/etc/unix/README b/erts/etc/unix/README
index adc6db4300..b94f28824e 100644
--- a/erts/etc/unix/README
+++ b/erts/etc/unix/README
@@ -1,7 +1,7 @@
%CopyrightBegin%
- Copyright Ericsson AB 1996-2016. All Rights Reserved.
+ Copyright Ericsson AB 1996-2017. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ Note that the Install script will terminate if it detects problems -
you will have to correct them and re-run the script. If everything
goes well, the last printout should be:
-Erlang installation sucessfully completed
+Erlang installation successfully completed
If it isn't, something went wrong - check the printouts to find out
what it was.
diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src
index 30f2d831b5..862d6eb1d4 100644
--- a/erts/etc/unix/cerl.src
+++ b/erts/etc/unix/cerl.src
@@ -45,6 +45,8 @@
# -valgrind Run emulator compiled for valgrind
# -lcnt Run emulator compiled for lock counting
# -icount Run emulator compiled for instruction counting
+# -rr Run emulator under "rr record"
+# Can be combined with compile targets (like -debug) except valgrind.
# -nox Unset the DISPLAY variable to disable us of X Windows
#
# FIXME For GDB you can also set the break point using "-break FUNCTION".
@@ -84,6 +86,8 @@ GDBARGS=
TYPE=
debug=
run_valgrind=no
+run_rr=no
+skip_erlexec=no
# Default rootdir
ROOTDIR=%SRC_ROOTDIR%
@@ -248,6 +252,13 @@ while [ $# -gt 0 ]; do
cargs="$cargs -valgrind"
TYPE=.valgrind
run_valgrind=yes
+ skip_erlexec=yes
+ ;;
+ "-rr")
+ shift
+ cargs="$cargs -rr"
+ run_rr=yes
+ skip_erlexec=yes
;;
*)
break
@@ -269,7 +280,19 @@ PROGNAME="$PROGNAME$cargs"
EMU="$EMU$TYPE"
EMU_NAME=`$EXEC -emu_name_exit $eeargs`
-if [ $run_valgrind != yes ]; then
+if [ $skip_erlexec = yes ]; then
+ emu_xargs=`echo $xargs | sed "s|+|-|g"`
+ beam_args=`$EXEC -emu_args_exit ${1+"$@"}`
+
+ # Prepare for some argument passing voodoo:
+ # $beam_args is a list of command line arguments separated by newlines.
+ # Make "$@" represent those arguments verbatim (including spaces and quotes).
+ SAVE_IFS="$IFS"
+ IFS='
+'
+ set -- $beam_args
+ IFS="$SAVE_IFS"
+else
xargs="$xargs -pz $PRELOADED --"
fi
if [ "x$GDB" = "x" ]; then
@@ -277,7 +300,6 @@ if [ "x$GDB" = "x" ]; then
valversion=`valgrind --version`
valmajor=`echo $valversion | sed 's,[a-z]*\-\([0-9]*\).*,\1,'`
valminor=`echo $valversion | sed 's,[a-z]*\-[0-9]*.\([0-9]*\).*,\1,'`
- emu_xargs=`echo $xargs | sed "s|+|-|g"`
if [ "x$VALGRIND_LOG_XML" = "x" ]; then
valgrind_xml=
log_file_prefix="--log-file="
@@ -317,17 +339,10 @@ if [ "x$GDB" = "x" ]; then
sched_arg=
fi
- beam_args=`$EXEC -emu_args_exit ${1+"$@"}`
-
- # Time for some argument passing voodoo:
- # $beam_args is a list of command line arguments separated by newlines.
- # Make "$@" represent those arguments verbatim (including spaces and quotes).
- SAVE_IFS="$IFS"
- IFS='
-'
- set -- $beam_args
- IFS="$SAVE_IFS"
exec $taskset1 valgrind $valgrind_xml $valgrind_log $valgrind_misc_flags $BINDIR/$EMU_NAME $sched_arg $emu_xargs "$@" -pz $PRELOADED
+
+ elif [ $run_rr = yes ]; then
+ exec rr record --ignore-nested $BINDIR/$EMU_NAME $emu_xargs "$@" -pz $PRELOADED
else
exec $EXEC $eeargs $xargs ${1+"$@"}
fi
diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in
index f2babc48d2..8f70f879d5 100644
--- a/erts/etc/unix/etp-commands.in
+++ b/erts/etc/unix/etp-commands.in
@@ -1,7 +1,8 @@
+# -*- gdb-script -*-
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2005-2016. All Rights Reserved.
+# Copyright Ericsson AB 2005-2017. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -775,7 +776,7 @@ define etp-pid-1
set $etp_pid_1 = (Eterm)($arg0)
if ($etp_pid_1 & 0xF) == 0x3
if (etp_arch_bits == 64)
- if (etp_big_endian)
+ if (etp_endianness > 0)
set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 35) & 0x0fffffff)
else
set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 4) & 0x0fffffff)
@@ -835,7 +836,7 @@ define etp-port-1
set $etp_port_1 = (Eterm)($arg0)
if ($etp_port_1 & 0xF) == 0x7
if (etp_arch_bits == 64)
- if (etp_big_endian)
+ if (etp_endianness > 0)
set $etp_port_data = (unsigned) ((((Uint64) $etp_port_1) >> 36) & 0x0fffffff)
else
set $etp_port_data = (unsigned) ((((Uint64) $etp_port_1) >> 4) & 0x0fffffff)
@@ -952,30 +953,31 @@ define etp-ref-1
if ((Eterm)($arg0) & 0x3) != 0x2
printf "#NotBoxed<%#x>", (Eterm)($arg0)
else
- set $etp_ref_1_p = (RefThing *)((Eterm)($arg0) & ~0x3)
+ set $etp_ref_1_p = (ErtsORefThing *)((Eterm)($arg0) & ~0x3)
if ($etp_ref_1_p->header & 0x3b) != 0x10
printf "#NotRef<%#x>", $etp_ref_1_p->header
else
- set $etp_ref_1_nump = (Uint32 *) 0
- set $etp_ref_1_error = 0
- if ($etp_ref_1_p->header >> 6) == 0
- set $etp_ref_1_error = 1
+ if $etp_ref_1_p->header != etp_ref_header && $etp_ref_1_p->header != etp_magic_ref_header
+ printf "#InternalRefError<%#x>", ($arg0)
else
- if $etp_arch64
- set $etp_ref_1_i = (int) $etp_ref_1_p->data.ui32[0]
- if (($etp_ref_1_i + 1) > (2 * ($etp_ref_1_p->header >> 6)))
- set $etp_ref_1_error = 1
- else
- set $etp_ref_1_nump = &$etp_ref_1_p->data.ui32[1]
+ set $etp_magic_ref = 0
+ set $etp_ref_1_i = 3
+ set $etp_ref_1_error = 0
+ set $etp_ref_1_nump = (Uint32 *) 0
+ if etp_ref_header == etp_magic_ref_header
+ if $etp_ref_1_p->marker != 0xffffffff
+ set $etp_magic_ref = 1
+ end
+ else
+ if $etp_ref_1_p->header == etp_magic_ref_header
+ set $etp_magic_ref = 1
end
+ end
+ if $etp_magic_ref == 0
+ set $etp_ref_1_nump = $etp_ref_1_p->num
else
- set $etp_ref_1_i = (int) ($etp_ref_1_p->header >> 6)
- set $etp_ref_1_nump = &$etp_ref_1_p->data.ui32[0]
+ set $etp_ref_1_nump = ((ErtsMRefThing *) $etp_ref_1_p)->mb->refn
end
- end
- if $etp_ref_1_error
- printf "#InternalRefError<%#x>", ($arg0)
- else
printf "#Ref<0"
set $etp_ref_1_i--
while $etp_ref_1_i >= 0
@@ -1312,27 +1314,30 @@ document etpf-msgq
%---------------------------------------------------------------------------
end
-
+define etp-stack-preamble
+ set $etp_stack_p = ($arg0)->stop
+ set $etp_stack_end = ($arg0)->hend
+ printf "%% Stacktrace (%u)\n", $etp_stack_end-$etp_stack_p
+ etp-1 ((Eterm)($arg0)->i) 0
+ printf " (I)\n"
+ if ($arg0)->cp != 0
+ etp-1 ((Eterm)($arg0)->cp) 0
+ printf " (cp)\n"
+ end
+end
define etp-stacktrace
# Args: Process*
#
# Non-reentrant
#
- set $etp_stacktrace_p = ($arg0)->stop
- set $etp_stacktrace_end = ($arg0)->hend
- printf "%% Stacktrace (%u): ", $etp_stacktrace_end-$etp_stacktrace_p
- if ($arg0)->cp == 0x0
- printf "NULL\n"
- else
- etp ($arg0)->cp
- end
- while $etp_stacktrace_p < $etp_stacktrace_end
- if ($etp_stacktrace_p[0] & 0x3) == 0x0
+ etp-stack-preamble ($arg0)
+ while $etp_stack_p < $etp_stack_end
+ if ($etp_stack_p[0] & 0x3) == 0x0
# Continuation pointer
- etp $etp_stacktrace_p[0]
+ etp $etp_stack_p[0]
end
- set $etp_stacktrace_p++
+ set $etp_stack_p++
end
end
@@ -1351,17 +1356,10 @@ define etp-stackdump
#
# Non-reentrant
#
- set $etp_stackdump_p = ($arg0)->stop
- set $etp_stackdump_end = ($arg0)->hend
- printf "%% Stackdump (%u): ", $etp_stackdump_end-$etp_stackdump_p
- if ($arg0)->cp == 0x0
- printf "NULL\n"
- else
- etp ($arg0)->cp
- end
- while $etp_stackdump_p < $etp_stackdump_end
- etp $etp_stackdump_p[0]
- set $etp_stackdump_p++
+ etp-stack-preamble ($arg0)
+ while $etp_stack_p < $etp_stack_end
+ etp $etp_stack_p[0]
+ set $etp_stack_p++
end
end
@@ -1597,7 +1595,7 @@ define etp-term-dump-pid
set $etp_pid_1 = (Eterm)($arg0)
if ($etp_pid_1 & 0xF) == 0x3
if (etp_arch_bits == 64)
- if (etp_big_endian)
+ if (etp_endianness > 0)
set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 36) & 0x0fffffff)
else
set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 4) & 0x0fffffff)
@@ -1642,7 +1640,7 @@ define etp-pid2pix-1
# Args: Eterm
#
if (etp_arch_bits == 64)
- if (etp_big_endian)
+ if (etp_endianness > 0)
set $etp_pix = (int) (((Uint64) $arg0) & 0x0fffffff)
else
set $etp_pix = (int) ((((Uint64) $arg0) >> 32) & 0x0fffffff)
@@ -1821,6 +1819,262 @@ document etp-proc-state
% Print state of process
%---------------------------------------------------------------------------
end
+define etp-proc-state-int
+# Args: int
+#
+ if ($arg0 & 0x80000000)
+ printf "GARBAGE<0x80000000> | "
+ end
+ if ($arg0 & 0x40000000)
+ printf "dirty-running-sys | "
+ end
+ if ($arg0 & 0x20000000)
+ printf "dirty-running | "
+ end
+ if ($arg0 & 0x10000000)
+ printf "dirty-active-sys | "
+ end
+ if ($arg0 & 0x8000000)
+ printf "dirty-io-proc | "
+ end
+ if ($arg0 & 0x4000000)
+ printf "dirty-cpu-proc | "
+ end
+ if ($arg0 & 0x2000000)
+ printf "on-heap-msgq | "
+ end
+ if ($arg0 & 0x1000000)
+ printf "off-heap-msgq | "
+ end
+ if ($arg0 & 0x800000)
+ printf "delayed-sys | "
+ end
+ if ($arg0 & 0x400000)
+ printf "proxy | "
+ set $proxy_process = 1
+ else
+ set $proxy_process = 0
+ end
+ if ($arg0 & 0x200000)
+ printf "running-sys | "
+ end
+ if ($arg0 & 0x100000)
+ printf "active-sys | "
+ end
+ if ($arg0 & 0x80000)
+ printf "trapping-exit | "
+ end
+ if ($arg0 & 0x40000)
+ printf "bound | "
+ end
+ if ($arg0 & 0x20000)
+ printf "garbage-collecting | "
+ end
+ if ($arg0 & 0x10000)
+ printf "suspended | "
+ end
+ if ($arg0 & 0x8000)
+ printf "running | "
+ end
+ if ($arg0 & 0x4000)
+ printf "in-run-queue | "
+ end
+ if ($arg0 & 0x2000)
+ printf "active | "
+ end
+ if ($arg0 & 0x1000)
+ printf "pending-exit | "
+ end
+ if ($arg0 & 0x800)
+ printf "exiting | "
+ end
+ if ($arg0 & 0x400)
+ printf "free | "
+ end
+ if ($arg0 & 0x200)
+ printf "in-prq-low | "
+ end
+ if ($arg0 & 0x100)
+ printf "in-prq-normal | "
+ end
+ if ($arg0 & 0x80)
+ printf "in-prq-high | "
+ end
+ if ($arg0 & 0x40)
+ printf "in-prq-max | "
+ end
+ if ($arg0 & 0x30) == 0x0
+ printf "prq-prio-max | "
+ else
+ if ($arg0 & 0x30) == 0x10
+ printf "prq-prio-high | "
+ else
+ if ($arg0 & 0x30) == 0x20
+ printf "prq-prio-normal | "
+ else
+ printf "prq-prio-low | "
+ end
+ end
+ end
+ if ($arg0 & 0xc) == 0x0
+ printf "usr-prio-max | "
+ else
+ if ($arg0 & 0xc) == 0x4
+ printf "usr-prio-high | "
+ else
+ if ($arg0 & 0xc) == 0x8
+ printf "usr-prio-normal | "
+ else
+ printf "usr-prio-low | "
+ end
+ end
+ end
+ if ($arg0 & 0x3) == 0x0
+ printf "act-prio-max\n"
+ else
+ if ($arg0 & 0x3) == 0x1
+ printf "act-prio-high\n"
+ else
+ if ($arg0 & 0x3) == 0x2
+ printf "act-prio-normal\n"
+ else
+ printf "act-prio-low\n"
+ end
+ end
+ end
+end
+
+document etp-proc-state-int
+%---------------------------------------------------------------------------
+% etp-proc-state-int int
+%
+% Print state of process state value
+%---------------------------------------------------------------------------
+end
+
+
+define etp-proc-state
+# Args: Process*
+#
+ set $state_int = *(((Uint32 *) &(((Process *) $arg0)->state)))
+ etp-proc-state-int $state_int
+end
+
+document etp-proc-state
+%---------------------------------------------------------------------------
+% etp-proc-state Process*
+%
+% Print state of process
+%---------------------------------------------------------------------------
+end
+
+define etp-proc-flags-int
+# Args: int
+#
+ if ($arg0 & ~0x1ffffff)
+ printf "GARBAGE<%x> ", ($arg0 & ~0x1ffffff)
+ end
+ if ($arg0 & 0x1000000)
+ printf "dirty-minor-gc "
+ end
+ if ($arg0 & 0x800000)
+ printf "dirty-major-gc "
+ end
+ if ($arg0 & 0x400000)
+ printf "dirty-gc-hibernate "
+ end
+ if ($arg0 & 0x200000)
+ printf "dirty-cla "
+ end
+ if ($arg0 & 0x100000)
+ printf "delayed-del-proc "
+ end
+ if ($arg0 & 0x80000)
+ printf "hipe-mode "
+ end
+ if ($arg0 & 0x40000)
+ printf "have-blocked-nmsb "
+ end
+ if ($arg0 & 0x20000)
+ printf "shdlr-onln-wait-q "
+ end
+ if ($arg0 & 0x10000)
+ printf "delay-gc "
+ end
+ if ($arg0 & 0x8000)
+ printf "abandoned-heap-use "
+ end
+ if ($arg0 & 0x4000)
+ printf "off-heap-msgq-chng "
+ end
+ if ($arg0 & 0x2000)
+ printf "on-heap-msgq "
+ end
+ if ($arg0 & 0x1000)
+ printf "off-heap-msgq "
+ end
+ if ($arg0 & 0x800)
+ printf "disable-gc "
+ end
+ if ($arg0 & 0x400)
+ printf "force-gc "
+ end
+ if ($arg0 & 0x200)
+ printf "p2pnr-resched "
+ end
+ if ($arg0 & 0x100)
+ printf "have-blocked-msb "
+ end
+ if ($arg0 & 0x80)
+ printf "using-ddll "
+ end
+ if ($arg0 & 0x40)
+ printf "distribution "
+ end
+ if ($arg0 & 0x20)
+ printf "using-db "
+ end
+ if ($arg0 & 0x10)
+ printf "need-fullsweep "
+ end
+ if ($arg0 & 0x8)
+ printf "heap-grow "
+ end
+ if ($arg0 & 0x4)
+ printf "timo "
+ end
+ if ($arg0 & 0x2)
+ printf "inslpqueue "
+ end
+ if ($arg0 & 0x1)
+ printf "hibernate-sched "
+ end
+ printf "\n"
+end
+
+document etp-proc-flags-int
+%---------------------------------------------------------------------------
+% etp-proc-flags-int int
+%
+% Print flags of process flags value
+%---------------------------------------------------------------------------
+end
+
+
+define etp-proc-flags
+# Args: Process*
+#
+ set $flags_int = ((Process *) $arg0)->flags
+ etp-proc-flags-int $flags_int
+end
+
+document etp-proc-flags
+%---------------------------------------------------------------------------
+% etp-proc-flags Process*
+%
+% Print flags of process
+%---------------------------------------------------------------------------
+end
define etp-process-info
# Args: Process*
@@ -1830,6 +2084,8 @@ define etp-process-info
etp-1 $etp_proc->common.id
printf "\n State: "
etp-proc-state $etp_proc
+ printf "\n Flags: "
+ etp-proc-flags $etp_proc
if $proxy_process != 0
printf " Pointer: (Process *) %p\n", $etp_proc
printf " *** PROXY process struct *** refer to: \n"
@@ -1843,26 +2099,35 @@ define etp-process-info
printf "\n"
end
end
+ printf " Current function: "
if ($etp_proc->current)
- printf " Current function: "
- etp-1 $etp_proc->current[0]
+ etp-1 $etp_proc->current->module
printf ":"
- etp-1 $etp_proc->current[1]
- printf "/%d\n", $etp_proc->current[2]
+ etp-1 $etp_proc->current->function
+ printf "/%d\n", $etp_proc->current->arity
+ else
+ printf "unknown\n"
end
+ printf " CP: "
if ($etp_proc->cp)
- printf " CP: "
etp-cp-1 $etp_proc->cp
printf "\n"
+ else
+ printf "unknown\n"
end
+ printf " I: "
if ($etp_proc->i)
- printf " I: "
etp-cp-1 $etp_proc->i
printf "\n"
+ else
+ printf "unknown\n"
end
printf " Heap size: %ld\n", $etp_proc->heap_sz
+ printf " Old-heap size: "
if ($etp_proc->old_heap)
- printf " Old-heap size: %ld\n", $etp_proc->old_hend - $etp_proc->old_heap
+ printf "%ld\n", $etp_proc->old_hend - $etp_proc->old_heap
+ else
+ printf "0\n"
end
printf " Mbuf size: %ld\n", $etp_proc->mbuf_sz
if (etp_smp_compiled)
@@ -1889,13 +2154,22 @@ define etp-processes
printf "No processes, since system isn't initialized!\n"
else
set $proc_ix = 0
- while $proc_ix < erts_proc.r.o.max
- set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[$proc_ix])
- if ($proc != ((Process *) 0) && $proc != &erts_invalid_process)
+ set $proc_max_ix = erts_proc.r.o.max
+ set $proc_tab = erts_proc.r.o.tab
+ set $invalid_proc = &erts_invalid_process
+ set $proc_decentile = $proc_max_ix / 10
+ set $proc_printile = $proc_decentile
+ while $proc_ix < $proc_max_ix
+ set $proc = (Process *) *((UWord *) ($proc_tab + $proc_ix))
+ if ($proc != ((Process *) 0) && $proc != $invalid_proc)
printf "---\n"
printf " Pix: %d\n", $proc_ix
etp-process-info $proc
end
+ if $proc_ix == $proc_printile
+ printf "--- %d%% (%d / %d) searched\n", $proc_printile / $proc_decentile * 10, $proc_ix, $proc_max_ix
+ set $proc_printile += $proc_decentile
+ end
set $proc_ix++
end
printf "---\n",
@@ -2008,7 +2282,7 @@ define etp-port-id2pix-1
# Args: Eterm
#
if (etp_arch_bits == 64)
- if (etp_big_endian)
+ if (etp_endianness > 0)
set $etp_pix = (int) (((Uint64) $arg0) & 0x0fffffff)
elser
set $etp_pix = (int) ((((Uint64) $arg0) >> 32) & 0x0fffffff)
@@ -2215,15 +2489,19 @@ document etp-port-info
%---------------------------------------------------------------------------
end
-
define etp-ports
if (!erts_initialized)
printf "No ports, since system isn't initialized!\n"
else
set $port_ix = 0
- while $port_ix < erts_port.r.o.max
- set $port = (Port *) *((UWord *) &erts_port.r.o.tab[$port_ix])
- if ($port != ((Port *) 0) && $port != &erts_invalid_port)
+ set $port_max_ix = erts_port.r.o.max
+ set $port_tab = erts_port.r.o.tab
+ set $invalid_port = &erts_invalid_port
+ set $port_decentile = $port_max_ix / 10
+ set $port_printile = $port_decentile
+ while $port_ix < $port_max_ix
+ set $port = (Port *) *((UWord *) ($port_tab + $port_ix))
+ if ($port != ((Port *) 0) && $port != $invalid_port)
if (*(((Uint32 *) &(((Port *) $port)->state))) & 0x100) == 0
# I.e, not free
printf "---\n"
@@ -2231,6 +2509,10 @@ define etp-ports
etp-port-info $port
end
end
+ if $port_ix == $port_printile
+ printf "--- %d%% (%d / %d) searched\n", $port_printile / $port_decentile * 10, $port_ix, $port_max_ix
+ set $port_printile += $port_decentile
+ end
set $port_ix++
end
printf "---\n",
@@ -2351,8 +2633,20 @@ define etp-rq-flags-int
if ($arg0 & 0x4000000)
printf " protected"
end
- if ($arg0 & ~0x7ffffff)
- printf " GARBAGE(0x%x)", ($arg0 & ~0x3ffffff)
+ if ($arg0 & 0x8000000)
+ printf " exec"
+ end
+ if ($arg0 & 0x10000000)
+ printf " msb_exec"
+ end
+ if ($arg0 & 0x20000000)
+ printf " misc_op"
+ end
+ if ($arg0 & 0x40000000)
+ printf " halting"
+ end
+ if ($arg0 & ~0x7fffffff)
+ printf " GARBAGE(0x%x)", ($arg0 & ~0x7fffffff)
end
printf "\n"
end
@@ -2384,6 +2678,9 @@ define etp-ssi-flags
if ($arg0 & 0x10)
printf " suspended"
end
+ if ($arg0 & 0x20)
+ printf " msb_exec"
+ end
printf "\n"
end
@@ -2531,10 +2828,10 @@ define etp-run-queue-info-internal
else
if ($sched_type == 1)
printf "\n--- Dirty CPU Run Queue ---\n"
- set $runq = &erts_aligned_run_queues[-1].runq
+ set $runq = &erts_aligned_run_queues[erts_no_run_queues].runq
else
printf "\n--- Dirty I/O Run Queue ---\n"
- set $runq = &erts_aligned_run_queues[-2].runq
+ set $runq = &erts_aligned_run_queues[erts_no_run_queues+1].runq
end
end
printf " Length: total=%d", *((Uint32 *) &($runq->len))
@@ -2551,7 +2848,7 @@ define etp-run-queue-info-internal
set $rq_flags = *((Uint32 *) &($runq->flags))
etp-rq-flags-int $rq_flags
printf " Pointer: (ErtsRunQueue *) %p\n", $runq
-
+end
define etp-disasm-1
set $code_ptr = ((BeamInstr*)$arg0)
@@ -2592,11 +2889,86 @@ define etp-disasm
end
end
+############################################################################
+#
+# Timer Wheel
+#
+
+define etp-timer-wheel
+# Args: TimerWheel
+ if (!erts_initialized)
+ printf "System not initialized!\n"
+ else
+ set $tiw = $arg0
+ printf "Number of timers: %d\n", $tiw->nto
+ printf "Min timeout pos: %d\n", $tiw->next_timeout_pos
+ printf "\n--- Soon Wheel ---\n"
+ set $ix = $tiw->pos & etp_tw_soon_wheel_mask
+ printf "Position: %ld (%d)\n", $tiw->pos, $ix
+ printf "Min timeout position: %ld (%d)\n", $tiw->soon.min_tpos, $tiw->soon.min_tpos & etp_tw_soon_wheel_mask
+ printf "Number of timers: %d\n", $tiw->soon.nto
+ set $slots = etp_tw_soon_wheel_size
+ while $slots > 0
+ set $tmr = $tiw->w[$ix]
+ if ($tmr != (ErtsTWheelTimer *) 0x0)
+ printf "---\n"
+ printf "Slot: %d\n", $ix
+ printf "\n"
+ while 1
+ printf "- Timeout pos: %ld\n", $tmr->timeout_pos
+ printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr
+ set $tmr = $tmr->next
+ if ($tmr == $tiw->w[$ix])
+ loop_break
+ end
+ end
+ end
+ set $ix++
+ if ($ix == (etp_tw_soon_wheel_first_slot + etp_tw_soon_wheel_size))
+ set $ix = etp_tw_soon_wheel_first_slot
+ end
+ set $slots--
+ end
+ printf "\n--- Later Wheel ---\n"
+ set $ix = (($tiw->later.pos >> etp_tw_later_wheel_shift) & etp_tw_later_wheel_mask) + etp_tw_later_wheel_first_slot
+ printf "Position: %ld (%d)\n", $tiw->later.pos, $ix
+ printf "Min timeout position: %ld (%d)\n", $tiw->later.min_tpos, (($tiw->later.min_tpos >> etp_tw_later_wheel_shift) & etp_tw_later_wheel_mask) + etp_tw_later_wheel_first_slot
+ printf "Number of timers: %d\n", $tiw->later.nto
+ set $slots = etp_tw_later_wheel_size
+ set $slot_pos = $tiw->later.pos
+ while $slots > 0
+ set $tmr = $tiw->w[$ix]
+ if ($tmr != (ErtsTWheelTimer *) 0x0)
+ printf "---\n"
+ printf "Slot: %d\n", $ix
+ printf "Slot Range: [%ld, %ld]\n", $slot_pos, $slot_pos + etp_tw_later_wheel_slot_size
+ printf "Pre timeout pos: %ld\n", $slot_pos - etp_tw_later_wheel_slot_size
+ printf "\n"
+ while 1
+ printf "- Timeout pos: %ld\n", $tmr->timeout_pos
+ printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr
+ set $tmr = $tmr->next
+ if ($tmr == $tiw->w[$ix])
+ loop_break
+ end
+ end
+ end
+ set $ix++
+ if ($ix == (etp_tw_later_wheel_first_slot + etp_tw_later_wheel_size))
+ set $ix = etp_tw_later_wheel_first_slot
+ end
+ set $slot_pos = $slot_pos + etp_tw_later_wheel_slot_size
+ set $slots--
+ end
+ end
+ printf "---\n"
+end
+
document etp-disasm
%---------------------------------------------------------------------------
% etp-disasm StartI EndI
%
-% Disassemble the code inbetween StartI and EndI
+% Disassemble the code between StartI and EndI
%---------------------------------------------------------------------------
end
@@ -2628,10 +3000,14 @@ define etp-system-info
printf "Compile date: %s\n", etp_compile_date
printf "Arch: %s\n", etp_arch
printf "Endianness: "
- if (etp_big_endian)
+ if (etp_endianness > 0)
printf "Big\n"
else
- printf "Little\n"
+ if (etp_endianness < 0)
+ printf "Little\n"
+ else
+ printf "Unknown\n"
+ end
end
printf "Word size: %d-bit\n", etp_arch_bits
printf "HiPE support: "
diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c
index debd643da7..81a0036c99 100644
--- a/erts/etc/unix/run_erl.c
+++ b/erts/etc/unix/run_erl.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1996-2016. All Rights Reserved.
+ * Copyright Ericsson AB 1996-2017. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -553,7 +553,7 @@ static void pass_on(pid_t childpid)
FD_ZERO(&readfds);
FD_ZERO(&writefds);
} else {
- /* Some error occured */
+ /* Some error occurred */
ERRNO_ERR0(LOG_ERR,"Error in select.");
exit(1);
}
@@ -863,7 +863,7 @@ static int open_log(int log_num, int flags)
if (write_all(lfd, buf, strlen(buf)) < 0)
status("Error in writing to log.\n");
-#if USE_FSYNC
+#ifdef USE_FSYNC
fsync(lfd);
#endif
@@ -893,7 +893,7 @@ static void write_to_log(int* lfd, int* log_num, char* buf, int len)
status("Error in writing to log.\n");
}
-#if USE_FSYNC
+#ifdef USE_FSYNC
fsync(*lfd);
#endif
}
@@ -1343,11 +1343,8 @@ static int sf_open(const char *path, int type, mode_t mode) {
return fd;
}
static int sf_close(int fd) {
- int res = 0;
-
- do { res = close(fd); } while(fd < 0 && errno == EINTR);
-
- return res;
+ /* "close() should not be retried after an EINTR" */
+ return close(fd);
}
/* Extract any control sequences that are ment only for run_erl
* and should not be forwarded to the pty.
diff --git a/erts/etc/unix/to_erl.c b/erts/etc/unix/to_erl.c
index 0bd469727c..afff8f7e54 100644
--- a/erts/etc/unix/to_erl.c
+++ b/erts/etc/unix/to_erl.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1996-2015. All Rights Reserved.
+ * Copyright Ericsson AB 1996-2017. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -416,7 +416,7 @@ int main(int argc, char **argv)
if (len) {
#ifdef DEBUG
- if(write(1, buf, len));
+ (void)write(1, buf, len);
#endif
if (write_all(wfd, buf, len) != len) {
fprintf(stderr, "Error in writing to FIFO.\n");