aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/unix/etp-commands.in
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc/unix/etp-commands.in')
-rw-r--r--erts/etc/unix/etp-commands.in478
1 files changed, 354 insertions, 124 deletions
diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in
index bb7b1a73f5..20809d61e8 100644
--- a/erts/etc/unix/etp-commands.in
+++ b/erts/etc/unix/etp-commands.in
@@ -37,7 +37,7 @@ document etp-help
% - GDB command toolbox for analyzing core dumps from the
% Erlang emulator (BEAM).
%
-% Should work for 32-bit erts-5.2/R9B, ...
+% Should work for 32-bit and 64-bit unix gdb
%
% The commands are prefixed with:
% etp: Acronym for erts-term-print
@@ -55,7 +55,8 @@ document etp-help
% Special commands for not really terms:
% etp-mfa, etp-cp, etp-disasm,
% etp-msgq, etpf-msgq,
-% etp-stacktrace, etp-stackdump, etpf-stackdump, etp-dictdump
+% etp-stacktrace, etp-stacktrace-emu, etp-stackdump, etp-stackdump-emu,
+% etpf-stackdump, etp-dictdump
% etp-process-info, etp-process-memory-info
% etp-port-info, etp-port-state, etp-port-sched-flags
% etp-heapdump, etp-offheapdump, etpf-offheapdump,
@@ -132,14 +133,14 @@ define etp-1
if (($arg0) & 0x3) == 1
# Cons pointer
if $etp_flat
- printf "<etpf-cons %#x>", ($arg0)
+ printf "<etpf-cons %p>", (($arg0)-1)
else
etp-list-1 ($arg0) ($arg1)
end
else
if (($arg0) & 0x3) == 2
if $etp_flat
- printf "<etpf-boxed %#x>", ($arg0)
+ printf "<etpf-boxed %p>", (($arg0)-2)
else
etp-boxed-1 ($arg0) ($arg1)
end
@@ -187,7 +188,7 @@ define etp-list-1
# Reentrant
#
if (($arg0) & 0x3) != 0x1
- printf "#NotCons<%#x>", ($arg0)
+ printf "#NotCons<%p>", ($arg0)
else
# Cons pointer
if $etp_chart
@@ -210,7 +211,7 @@ define etp-list-printable-1
# Returns: $etp_list_printable
#
if (($arg0) & 0x3) != 0x1
- printf "#NotCons<%#x>", ($arg0)
+ printf "#NotCons<%p>", ($arg0)
else
# Loop to check if it is a printable string
set $etp_list_p = ($arg0)
@@ -272,7 +273,7 @@ define etp-list-2
# Reentrant
#
if (($arg0) & 0x3) != 0x1
- printf "#NotCons<%#x>", ($arg0)
+ printf "#NotCons<%p>", ($arg0)
else
# Cons pointer
if ($arg1) >= $etp_max_depth
@@ -307,7 +308,7 @@ define etpf-cons
# Reentrant capable
#
if ((Eterm)($arg0) & 0x3) != 0x1
- printf "#NotCons<%#x>", ($arg0)
+ printf "#NotCons<%p>", ($arg0)
else
# Cons pointer
set $etp_flat = 1
@@ -336,13 +337,13 @@ define etp-boxed-1
# Reentrant
#
if (($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", ($arg0)
+ printf "#NotBoxed<%p>", ($arg0)
else
if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0
if $etp_chart
etp-chart-entry-1 (($arg0)&~0x3) ($arg1) 1
end
- printf "#BoxedError<%#x>", ($arg0)
+ printf "#BoxedError<%p>", ($arg0)
else
if $etp_chart
etp-chart-entry-1 (($arg0)&~0x3) ($arg1) \
@@ -390,10 +391,10 @@ define etp-boxed-immediate-1
# Non-reentrant
#
if (($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", ($arg0)
+ printf "#NotBoxed<%p>", ($arg0)
else
if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0
- printf "#BoxedError<%#x>", ($arg0)
+ printf "#BoxedError<%p>", ($arg0)
else
set $etp_boxed_immediate_p = (Eterm*)(($arg0) & ~0x3)
set $etp_boxed_immediate_h = ($etp_boxed_immediate_p[0] >> 2) & 0xF
@@ -438,12 +439,12 @@ define etp-boxed-immediate-1
while $etp_boxed_immediate_arity > 0
set $etp_boxed_immediate_p++
if $etp_boxed_immediate_arity > 1
- printf "%#x,", *$etp_boxed_immediate_p
+ printf "%p,", *$etp_boxed_immediate_p
else
- printf "%#x", *$etp_boxed_immediate_p
+ printf "%p", *$etp_boxed_immediate_p
if ($etp_boxed_immediate_h == 0xA)
set $etp_boxed_immediate_p++
- printf ":%#x", *$etp_boxed_immediate_p
+ printf ":%p", *$etp_boxed_immediate_p
end
printf ">"
end
@@ -558,7 +559,7 @@ define etp-immediate-1
# Reentrant capable
#
if (($arg0) & 0x3) != 0x3
- printf "#NotImmediate<%#x>", ($arg0)
+ printf "#NotImmediate<%p>", ($arg0)
else
if (($arg0) & 0xF) == 0x3
etp-pid-1 ($arg0)
@@ -580,7 +581,7 @@ define etp-immediate-1
if (($arg0) == $etp_nil)
printf "[]"
else
- printf "#UnknownImmediate<%#x>", ($arg0)
+ printf "#UnknownImmediate<%p>", ($arg0)
end
end
end
@@ -598,7 +599,7 @@ define etp-atom-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3f) != 0xb
- printf "#NotAtom<%#x>", ($arg0)
+ printf "#NotAtom<%p>", ($arg0)
else
set $etp_atom_1_ap = (Atom*)erts_atom_table.seg_table[(Eterm)($arg0)>>16][((Eterm)($arg0)>>6)&0x3FF]
set $etp_atom_1_i = ($etp_atom_1_ap)->len
@@ -652,7 +653,7 @@ define etp-char-1
# Non-reentrant
#
if (($arg0) < 0) || (0377 < ($arg0))
- printf "#NotChar<%#x>", ($arg0)
+ printf "#NotChar<%p>", ($arg0)
else
if ($arg0) == ($arg1)
printf "\\%c", ($arg0)
@@ -787,7 +788,7 @@ define etp-pid-1
# Internal pid
printf "<0.%u.%u>", $etp_pid_data & 0x7fff, ($etp_pid_data >> 15) & 0x1fff
else
- printf "#NotPid<%#x>", ($arg0)
+ printf "#NotPid<%p>", ($arg0)
end
end
@@ -797,11 +798,11 @@ define etp-extpid-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
set $etp_extpid_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3)
if ($etp_extpid_1_p->header & 0x3f) != 0x30
- printf "#NotExternalPid<%#x>", $etp_extpid_1_p->header
+ printf "#NotExternalPid<%p>", $etp_extpid_1_p->header
else
## External pid
set $etp_extpid_1_number = $etp_extpid_1_p->data.ui[0]&0x7fff
@@ -812,7 +813,7 @@ define etp-extpid-1
set $etp_extpid_1_node = $etp_extpid_1_np->sysname
if ($etp_extpid_1_node & 0x3f) != 0xb
# Should be an atom
- printf "#ExternalPidError<%#x>", ($arg0)
+ printf "#ExternalPidError<%p>", ($arg0)
else
if $etp_extpid_1_dep == erts_this_dist_entry
printf "<0:"
@@ -847,7 +848,7 @@ define etp-port-1
# Internal port
printf "#Port<0.%u>", $etp_port_data
else
- printf "#NotPort<%#x>", ($arg0)
+ printf "#NotPort<%p>", ($arg0)
end
end
@@ -857,11 +858,11 @@ define etp-extport-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
set $etp_extport_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3)
if ($etp_extport_1_p->header & 0x3F) != 0x34
- printf "#NotExternalPort<%#x>", $etp_extport_1->header
+ printf "#NotExternalPort<%p>", $etp_extport_1->header
else
## External port
set $etp_extport_1_number = $etp_extport_1_p->data.ui[0]&0x3ffff
@@ -871,7 +872,7 @@ define etp-extport-1
set $etp_extport_1_node = $etp_extport_1_np->sysname
if ($etp_extport_1_node & 0x3f) != 0xb
# Should be an atom
- printf "#ExternalPortError<%#x>", ($arg0)
+ printf "#ExternalPortError<%p>", ($arg0)
else
if $etp_extport_1_dep == erts_this_dist_entry
printf "#Port<0:"
@@ -893,15 +894,15 @@ define etp-bignum-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
set $etp_bignum_1_p = (Eterm*)((Eterm)($arg0) & ~0x3)
if ($etp_bignum_1_p[0] & 0x3b) != 0x08
- printf "#NotBignum<%#x>", $etp_bignum_1_p[0]
+ printf "#NotBignum<%p>", $etp_bignum_1_p[0]
else
set $etp_bignum_1_i = ($etp_bignum_1_p[0] >> 6)
if $etp_bignum_1_i < 1
- printf "#BignumError<%#x>", (Eterm)($arg0)
+ printf "#BignumError<%p>", (Eterm)($arg0)
else
if $etp_bignum_1_p[0] & 0x04
printf "-"
@@ -932,11 +933,11 @@ define etp-float-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
set $etp_float_1_p = (Eterm*)((Eterm)($arg0) & ~0x3)
if ($etp_float_1_p[0] & 0x3f) != 0x18
- printf "#NotFloat<%#x>", $etp_float_1_p[0]
+ printf "#NotFloat<%p>", $etp_float_1_p[0]
else
printf "%f", *(double*)($etp_float_1_p+1)
end
@@ -951,14 +952,14 @@ define etp-ref-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
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
+ printf "#NotRef<%p>", $etp_ref_1_p->header
else
if $etp_ref_1_p->header != etp_ref_header && $etp_ref_1_p->header != etp_magic_ref_header
- printf "#InternalRefError<%#x>", ($arg0)
+ printf "#InternalRefError<%p>", ($arg0)
else
set $etp_magic_ref = 0
set $etp_ref_1_i = 3
@@ -998,11 +999,11 @@ define etp-extref-1
# Non-reentrant
#
if ((Eterm)($arg0) & 0x3) != 0x2
- printf "#NotBoxed<%#x>", (Eterm)($arg0)
+ printf "#NotBoxed<%p>", (Eterm)($arg0)
else
set $etp_extref_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3)
if ($etp_extref_1_p->header & 0x3F) != 0x38
- printf "#NotExternalRef<%#x>", $etp_extref_1->header
+ printf "#NotExternalRef<%p>", $etp_extref_1->header
else
## External ref
set $etp_extref_1_nump = (Uint32 *) 0
@@ -1041,7 +1042,7 @@ define etp-extref-1
end
end
if $etp_extref_1_error
- printf "#ExternalRefError<%#x>", ($arg0)
+ printf "#ExternalRefError<%p>", ($arg0)
else
set $etp_extref_1_i--
while $etp_extref_1_i >= 0
@@ -1166,7 +1167,7 @@ define etp-cp-1
if *(Eterm*)($etp_cp) == beam_return_to_trace[0]
printf "#Cp<return to trace>"
else
- printf "#Cp<%#x>", $etp_cp
+ printf "#Cp<%p>", $etp_cp
end
end
end
@@ -1452,28 +1453,74 @@ end
define etp-stack-preamble
set $etp_stack_p = ($arg0)->stop
set $etp_stack_end = ($arg0)->hend
+ if ($arg0)->state.counter & 0x8000
+ printf "%%%%%% WARNING: The process is currently running, so c_p->stop will not be correct\r\n"
+ printf "%%%%%% Consider using %s-emu instead\r\n", $arg1
+ end
printf "%% Stacktrace (%u)\n", $etp_stack_end-$etp_stack_p
- etp-1 ((Eterm)($arg0)->i) 0
- printf " (I)\n"
+ if ($arg0)->i != 0
+ printf "I: "
+ etp ((Eterm)($arg0)->i)
+ end
if ($arg0)->cp != 0
- etp-1 ((Eterm)($arg0)->cp) 0
- printf " (cp)\n"
+ printf "cp:"
+ etp ((Eterm)($arg0)->cp)
end
end
+define etp-stack-preamble-emu
+ set $etp_stack_p = E
+ set $etp_stack_end = ($arg0)->hend
+ printf "%% Stacktrace (%u)\n", $etp_stack_end-$etp_stack_p
+ printf "I: "
+ etp ((BeamInstr)I)
+ if ($arg0)->cp != 0
+ printf "cp: "
+ etp ((Eterm)($arg0)->cp)
+ end
+end
+
+define etp-stacktrace-1
+ set $etp_stack_stop = (Eterm*)($arg0)
+ set $etp_stack_send = (Eterm*)($arg1)
+ set $etp_stack_cnt = 0
+ while $etp_stack_stop < $etp_stack_send
+ if ($etp_stack_stop[0] & 0x3) == 0x0
+ # Continuation pointer
+ printf "%d: ", $etp_stack_cnt
+ etp $etp_stack_stop[0]
+ end
+ set $etp_stack_stop++
+ set $etp_stack_cnt++
+ end
+end
+
+define etp-stacktrace-emu
+# Args: Process*
+#
+# Non-reentrant
+#
+ etp-stack-preamble-emu ($arg0)
+ etp-stacktrace-1 $etp_stack_p $etp_stack_end
+end
+
+document etp-stacktrace-emu
+%---------------------------------------------------------------------------
+% etp-stacktrace-emu Process*
+%
+% Take an Process* and print a stactrace for the process.
+% This macro assumes that the current frame is the process_main frame
+% and that E is not optimized out.
+%---------------------------------------------------------------------------
+end
+
define etp-stacktrace
# Args: Process*
#
# Non-reentrant
#
- etp-stack-preamble ($arg0)
- while $etp_stack_p < $etp_stack_end
- if ($etp_stack_p[0] & 0x3) == 0x0
- # Continuation pointer
- etp $etp_stack_p[0]
- end
- set $etp_stack_p++
- end
+ etp-stack-preamble ($arg0) "etp-stacktrace"
+ etp-stacktrace-1 $etp_stack_p $etp_stack_end
end
document etp-stacktrace
@@ -1486,16 +1533,48 @@ document etp-stacktrace
%---------------------------------------------------------------------------
end
+define etp-stackdump-1
+ # Args: Eterm *stop, Eterm *hend
+ #
+ # Non-reentrant
+ #
+ set $etp_stackdump_stop = (Eterm*)($arg0)
+ set $etp_stackdump_send = (Eterm*)($arg1)
+ set $etp_stackdump_cnt = 0
+ while $etp_stackdump_stop < $etp_stackdump_send
+ printf "%d: ", $etp_stackdump_cnt
+ etp $etp_stackdump_stop[0]
+ set $etp_stackdump_stop++
+ set $etp_stackdump_cnt++
+ end
+end
+
+define etp-stackdump-emu
+# Args: Process*
+#
+# Non-reentrant
+#
+ etp-stack-preamble-emu ($arg0)
+ etp-stackdump-1 $etp_stack_p $etp_stack_end
+end
+
+document etp-stacktrace-emu
+%---------------------------------------------------------------------------
+% etp-stacktrace-emu Process*
+%
+% Take an Process* and print a stactdump for the process.
+% This macro assumes that the current frame is the process_main frame
+% and that E is not optimized out.
+%---------------------------------------------------------------------------
+end
+
define etp-stackdump
# Args: Process*
#
# Non-reentrant
#
- etp-stack-preamble ($arg0)
- while $etp_stack_p < $etp_stack_end
- etp $etp_stack_p[0]
- set $etp_stack_p++
- end
+ etp-stack-preamble ($arg0) "etp-stackdump"
+ etp-stackdump-1 $etp_stack_p $etp_stack_end
end
document etp-stackdump
@@ -1741,7 +1820,7 @@ define etp-term-dump-pid
# Internal pid
printf "| <0.%04u.%03u> ", $etp_pid_data & 0x7fff, ($etp_pid_data >> 15) & 0x1fff
else
- printf "| #NotPid<%#x> ", ($arg0)
+ printf "| #NotPid<%p> ", ($arg0)
end
end
@@ -1789,7 +1868,7 @@ define etp-pix2proc
# Args: Eterm
#
set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[((int) $arg0)])
- printf "(Process *) %p\n", $proc
+ printf "(Process*)%p\n", $proc
end
define etp-pid2proc-1
@@ -1803,7 +1882,7 @@ define etp-pid2proc
# Args: Eterm
#
etp-pid2proc-1 $arg0
- printf "(Process *) %p\n", $proc
+ printf "(Process*)%p\n", $proc
end
define etp-proc-state-int
@@ -2083,12 +2162,12 @@ define etp-process-info-int
printf "\n Flags: "
etp-proc-flags $etp_proc
if $proxy_process != 0
- printf " Pointer: (Process *) %p\n", $etp_proc
+ printf " Pointer: (Process*)%p\n", $etp_proc
printf " *** PROXY process struct *** refer to: \n"
etp-pid2proc-1 $etp_proc->common.id
etp-process-info $proc
else
- if (*(((Uint32 *) &($etp_proc->state))) & 0x4) == 0
+ if (*(((Uint32 *) &($etp_proc->state))) & 0x800) == 0
if ($etp_proc->common.u.alive.reg)
printf " Registered name: "
etp-1 $etp_proc->common.u.alive.reg->name
@@ -2096,7 +2175,7 @@ define etp-process-info-int
end
end
printf " Current function: "
- if ($etp_proc->current)
+ if ($etp_proc->current && !($etp_proc->state.counter & 0x800))
etp-1 $etp_proc->current->module
printf ":"
etp-1 $etp_proc->current->function
@@ -2133,7 +2212,7 @@ define etp-process-info-int
end
printf " Parent: "
etp-1 ((Eterm)($etp_proc->parent))
- printf "\n Pointer: (Process *) %p\n", $etp_proc
+ printf "\n Pointer: (Process*)%p\n", $etp_proc
end
if ($arg1)
etp-sigqs $etp_proc
@@ -2156,6 +2235,43 @@ document etp-process-info
%---------------------------------------------------------------------------
end
+define etp-processes-free-runq-int
+ set $runq_prio = 0
+ while $runq_prio < 3
+ set $runq_proc = ($arg0)->procs.prio[$runq_prio].first
+ while $runq_proc != 0
+ if $runq_proc->state.counter & 0x400
+ printf "---\n"
+ printf " Pix: FREE -> run_queue %p\n", ($arg0)
+ etp-process-info-int $runq_proc ($arg1)
+ end
+ set $runq_proc = $runq_proc->next
+ end
+ set $runq_prio++
+ end
+end
+
+define etp-processes-free-de-int
+ set $de_ix = 0
+ set $de = ($arg0)
+ while $de
+ set $susp = $de->suspended
+ set $susp_curr = $susp
+ set $first_loop = 1
+ while $susp_curr != 0 && (($susp_curr != $susp) || $first_loop)
+ if ($susp_curr->u.pid & 0x3) == 0
+ printf "---\n"
+ printf " Pix: FREE "
+ etp $de->sysname
+ etp-process-info-int $susp_curr->u.pid ($arg2)
+ end
+ set $first_loop = 0
+ set $susp_curr = $susp_curr->next
+ end
+ set $de = $de->next
+ end
+end
+
define etp-processes-int
if (!erts_initialized)
printf "No processes, since system isn't initialized!\n"
@@ -2176,11 +2292,36 @@ define etp-processes-int
set $proc_cnt--
end
if $proc_ix == $proc_printile
- printf "--- %d%% (%d / %d) searched\n", $proc_printile / $proc_decentile * 10, $proc_ix, $proc_max_ix
+ printf "--- %d%% (%d / %d) searched, looking for %d more\n", $proc_printile / $proc_decentile * 10, $proc_ix, $proc_max_ix, $proc_cnt
set $proc_printile += $proc_decentile
end
set $proc_ix++
end
+
+ ## We should also check for any FREE processes that are running
+ ## They can be found in esdp->current_process, dep->suspendees and
+ ## runq. Running FREE processes are processes that either are yielding
+ ## when exiting or running on a dirty scheduler while having exited.
+ set $sched_ix = 0
+ while $sched_ix < erts_no_schedulers
+ set $sched_data = &erts_aligned_scheduler_data[$sched_ix].esd
+ if $sched_data->current_process != 0
+ if $sched_data->current_process.state.counter & 0x400
+ printf "---\n"
+ printf " Pix: FREE -> scheduler %d\n", $sched_ix+1
+ etp-process-info-int $sched_data->current_process ($arg0)
+ end
+ end
+ etp-processes-free-runq-int $sched_data->run_queue ($arg0)
+ set $sched_ix++
+ end
+ etp-processes-free-runq-int &erts_aligned_run_queues[erts_no_run_queues].runq ($arg0)
+ etp-processes-free-runq-int &erts_aligned_run_queues[erts_no_run_queues+1].runq ($arg0)
+ etp-processes-free-de-int erts_hidden_dist_entries erts_no_of_hidden_dist_entries ($arg0)
+ etp-processes-free-de-int erts_visible_dist_entries erts_no_of_visible_dist_entries ($arg0)
+ etp-processes-free-de-int erts_pending_dist_entries erts_no_of_pending_dist_entries ($arg0)
+ etp-processes-free-de-int erts_not_connected_dist_entries erts_no_of_not_connected_dist_entries ($arg0)
+ etp-processes-free-de-int erts_this_dist_entry 1 ($arg0)
printf "---\n",
end
end
@@ -2237,9 +2378,9 @@ define etp-process-memory-info
end
printf " "
etp-1 $etp_pmem_proc->common.id
- printf ": (Process *) %p ", $etp_pmem_proc
+ printf ": (Process*)%p ", $etp_pmem_proc
if $proxy_process != 0
- printf "(Process *) %p ", $etp_pmem_proc
+ printf "(Process*)%p ", $etp_pmem_proc
printf " *** PROXY process struct *** refer to next: \n"
etp-pid2proc-1 $etp_pmem_proc->common.id
printf " -"
@@ -2313,7 +2454,7 @@ define etp-pix2port
# Args: Eterm
#
set $port = (Port *) *((UWord *) &erts_port.r.o.tab[((int) $arg0)])
- printf "(Port *) %p\n", $port
+ printf "(Port*)%p\n", $port
end
define etp-id2port-1
@@ -2327,7 +2468,7 @@ define etp-id2port
# Args: Eterm
#
etp-id2port-1 $arg0
- printf "(Port *) %p\n", $port
+ printf "(Port*)%p\n", $port
end
define etp-port-sched-flags-int
@@ -2501,7 +2642,7 @@ define etp-port-info
printf " Connected: "
set $connected = *(((Eterm *) &(((Port *) $etp_pinfo_port)->connected)))
etp-1 $connected
- printf "\n Pointer: (Port *) %p\n", $etp_pinfo_port
+ printf "\n Pointer: (Port*)%p\n", $etp_pinfo_port
end
document etp-port-info
@@ -2851,7 +2992,7 @@ define etp-scheduler-info-internal
printf " Sleep Info Flags:"
set $ssi_flags = *((Uint32 *) &$sched_data->ssi->flags)
etp-ssi-flags $ssi_flags
- printf " Pointer: (ErtsSchedulerData *) %p\n", $sched_data
+ printf " Pointer: (ErtsSchedulerData*)%p\n", $sched_data
end
define etp-run-queue-info-internal
@@ -2884,7 +3025,7 @@ define etp-run-queue-info-internal
end
set $rq_flags = *((Uint32 *) &($runq->flags))
etp-rq-flags-int $rq_flags
- printf " Pointer: (ErtsRunQueue *) %p\n", $runq
+ printf " Pointer: (ErtsRunQueue*)%p\n", $runq
end
define etp-fds
@@ -2895,12 +3036,21 @@ define etp-fds
end
end
+document etp-fds
+%---------------------------------------------------------------------------
+% etp-fds
+%
+% Print the state of the fds currently in check_io. Only works in running systems.
+%---------------------------------------------------------------------------
+end
+
define etp-disasm-1
- set $code_ptr = ((BeamInstr*)$arg0)
- set $addr = *$code_ptr
+ set $code_ptr = ((BeamInstr*)($arg0))
+ set $addr32 = (BeamInstr)(Uint32)*$code_ptr
+ set $addr64 = (BeamInstr)(Uint64)*$code_ptr
set $i = 0
- while $i < (sizeof(opc) / sizeof(OpEntry))
- if $addr == beam_ops[$i]
+ while $i < num_instructions
+ if $addr32 == beam_ops[$i] || $addr64 == beam_ops[$i]
printf "%s %d", opc[$i].name, opc[$i].sz
set $next_i = $code_ptr + opc[$i].sz
set $i += 4999
@@ -2910,6 +3060,11 @@ define etp-disasm-1
end
define etp-disasm
+ if $argc == 1
+ set $code_end = $arg0
+ else
+ set $code_end = $arg1
+ end
etp-cp-func-info-1 $arg0
if $etp_cp_p == 0
printf "invalid argument"
@@ -2918,7 +3073,7 @@ define etp-disasm
printf ": "
etp-disasm-1 $arg0
printf "\r\n"
- while $next_i < ((BeamInstr*)$arg1)
+ while $next_i < ((BeamInstr*)$code_end)
set $prev_i = $next_i
etp-cp-func-info-1 $next_i
etp-mfa-1 $etp_cp_p $cp_cp_p_offset
@@ -2934,6 +3089,16 @@ define etp-disasm
end
end
+document etp-disasm
+%---------------------------------------------------------------------------
+% etp-fds BeamInstr* (BeamInstr*)
+%
+% Disassemble the instructions inbetween arg0 and arg1,
+% if no second argument is given only the current
+% instruction is printed.
+%---------------------------------------------------------------------------
+end
+
############################################################################
#
# Timer Wheel
@@ -2961,7 +3126,7 @@ define etp-timer-wheel
printf "\n"
while 1
printf "- Timeout pos: %ld\n", $tmr->timeout_pos
- printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr
+ printf " Pointer: (ErtsTWheelTimer*)%p\n", $tmr
set $tmr = $tmr->next
if ($tmr == $tiw->w[$ix])
loop_break
@@ -2991,7 +3156,7 @@ define etp-timer-wheel
printf "\n"
while 1
printf "- Timeout pos: %ld\n", $tmr->timeout_pos
- printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr
+ printf " Pointer: (ErtsTWheelTimer*)%p\n", $tmr
set $tmr = $tmr->next
if ($tmr == $tiw->w[$ix])
loop_break
@@ -3260,7 +3425,7 @@ define etp-offheapdump
set $etp_offheapdump_p = $etp_offheapdump_p->next
set $etp_offheapdump_i++
else
- printf "#TaggedPtr<%#x>", $etp_offheapdump_p
+ printf "#TaggedPtr<%p>", $etp_offheapdump_p
set $etp_offheapdump_p = 0
end
end
@@ -3299,12 +3464,12 @@ define etp-search-heaps
#
# Non-reentrant
#
- printf "%% Search all (<%u) process heaps for ", erts_max_processes
+ printf "%% Search all (<%u) process heaps for ", erts_proc.r.o.max
set $etp_flat = 1
etp-1 ($arg0) 0
set $etp_flat = 0
printf ":...\n"
- etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&~3))
+ etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&~(Eterm)3))
end
define etp-search-heaps-1
@@ -3312,8 +3477,8 @@ define etp-search-heaps-1
#
# Non-reentrant
#
- set $etp_search_heaps_q = erts_max_processes / 10
- set $etp_search_heaps_r = erts_max_processes % 10
+ set $etp_search_heaps_q = erts_proc.r.o.max / 10
+ set $etp_search_heaps_r = erts_proc.r.o.max % 10
set $etp_search_heaps_t = 10
set $etp_search_heaps_m = $etp_search_heaps_q
if $etp_search_heaps_r > 0
@@ -3323,7 +3488,7 @@ define etp-search-heaps-1
set $etp_search_heaps_i = 0
set $etp_search_heaps_found = 0
while $etp_search_heaps_i < erts_proc.r.o.max
- set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[$proc_ix])
+ set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[$etp_search_heaps_i])
if $proc
if ($proc->heap <= ($arg0)) && \
(($arg0) < $proc->hend)
@@ -3340,7 +3505,7 @@ define etp-search-heaps-1
while $etp_search_heaps_p && ($etp_search_heaps_cnt < $etp_max_depth)
set $etp_search_heaps_cnt++
if (&($etp_search_heaps_p->mem) <= ($arg0)) && \
- (($arg0) < &($etp_search_heaps_p->mem)+$etp_search_heaps_p->size)
+ (($arg0) < &($etp_search_heaps_p->mem)+$etp_search_heaps_p->used_size)
printf "process_tab[%d]->mbuf(%d)+%d\n", \
$etp_search_heaps_i, $etp_search_heaps_cnt, \
($arg0)-&($etp_search_heaps_p->mem)
@@ -3636,8 +3801,8 @@ define etp-overlapped-heaps
# Non-reentrant
#
printf "%% Dumping heap addresses to \"etp-commands.bin\"\n"
- set $etp_overlapped_heaps_q = erts_max_processes / 10
- set $etp_overlapped_heaps_r = erts_max_processes % 10
+ set $etp_overlapped_heaps_q = erts_proc.r.o.max / 10
+ set $etp_overlapped_heaps_r = erts_proc.r.o.max % 10
set $etp_overlapped_heaps_t = 10
set $etp_overlapped_heaps_m = $etp_overlapped_heaps_q
if $etp_overlapped_heaps_r > 0
@@ -3663,7 +3828,7 @@ define etp-overlapped-heaps
append binary value etp-commands.bin 'p'
append binary value etp-commands.bin 's'
append binary value etp-commands.bin '\0'
- while $etp_overlapped_heaps_i < erts_max_processes
+ while $etp_overlapped_heaps_i < erts_proc.r.o.max
if process_tab[$etp_overlapped_heaps_i]
append binary value etp-commands.bin \
(Eterm)$etp_overlapped_heaps_i
@@ -3804,7 +3969,7 @@ define etp-chart-entry-1
append binary value etp-commands.bin (Eterm)(($arg2)*sizeof(Eterm))
append binary value etp-commands.bin (Eterm)$etp_chart_id
append binary value etp-commands.bin (Eterm)($arg1)
-# printf "<dumped %#x %lu %lu %lu>", ($arg0)&~0x3, \
+# printf "<dumped %p %lu %lu %lu>", ($arg0)&~0x3, \
# (Eterm)(($arg2)*sizeof(Eterm)), (Eterm)$etp_chart_id, (Eterm)($arg1)
end
@@ -3828,22 +3993,79 @@ end
# ETS table debug
#
+define etp-ets-tab-status-int
+# Args:
+#
+# Non-reentrant
+ if ($arg0 & 0x1)
+ printf "priv"
+ end
+ if ($arg0 & 0x2)
+ printf "prot"
+ end
+ if ($arg0 & 0x4)
+ printf "pub"
+ end
+ if ($arg0 & 0x8)
+ printf "|del"
+ end
+ if ($arg0 & 0x10)
+ printf "|set"
+ end
+ if ($arg0 & 0x20)
+ printf "|bag"
+ end
+ if ($arg0 & 0x40)
+ printf "|dbag"
+ end
+ if ($arg0 & 0x80)
+ printf "|oset"
+ end
+ if ($arg0 & 0x100)
+ printf "|caoset"
+ end
+ if ($arg0 & 0x200)
+ printf "|flocked"
+ end
+ if ($arg0 & 0x400)
+ printf "|fread"
+ end
+ if ($arg0 & 0x800)
+ printf "|named"
+ end
+ if ($arg0 & 0x1000)
+ printf "|busy"
+ end
+end
+
define etp-ets-tables
# Args:
#
# Non-reentrant
- printf "%% Dumping < %lu ETS tables\n", (unsigned long)db_max_tabs
- while $etp_ets_tables_i < db_max_tabs
- if (meta_main_tab[$etp_ets_tables_i].u.next_free & 3) == 0
- printf "%% %d:", $etp_ets_tables_i
- etp-1 ((Eterm)(meta_main_tab[$etp_ets_tables_i].u.tb->common.id)) 0
+ set $sched_ix = 0
+ while $sched_ix < erts_no_schedulers
+ set $ets_tabs = &erts_aligned_scheduler_data[$sched_ix].esd.ets_tables
+ set $no_ets_tabs = *(unsigned long *)&($ets_tabs->count)
+ printf "\n%% %lu ETS tables created on scheduler %lu...\n\n", $no_ets_tabs, (unsigned long)$sched_ix+1
+ set $ets_tab = $ets_tabs->clist
+ set $first_ets_tab = $ets_tab
+ while $ets_tab
+ set $refn = &((ErtsMagicBinary *)$ets_tab->common->btid)->refn
+ printf "%% "
+ etp-1 $ets_tab->common.the_name 0
+ printf " #Ref<0.%u.%u.%u> ", (unsigned)$refn[2], (unsigned)$refn[1], (unsigned)$refn[0]
+ etp-1 $ets_tab->common.owner 0
printf " "
- etp-1 ((Eterm)(meta_main_tab[$etp_ets_tables_i].u.tb->common.owner)) 0
- printf "\n"
+ etp-ets-tab-status-int $ets_tab->common.status
+ printf " (DbTable*)%p\n", $ets_tab
+ if $ets_tab->common.all.next == $first_ets_tab
+ set $ets_tab = (DbTable *) 0
+ else
+ set $ets_tab = $ets_tab->common.all.next
+ end
end
- set $etp_ets_tables_i++
+ set $sched_ix++
end
- set $etp_ets_tables_i = 0
end
document etp-ets-tables
@@ -4060,14 +4282,6 @@ define etp-block-size-1
set $etp_blk_sz = ($arg0)->bhdr & ~7
else
# Allocated block
- if !$etp_MBC_ABLK_SZ_MASK
- if etp_arch_bits == 64
- set $etp_MBC_ABLK_OFFSET_SHIFT = (64 - 24)
- else
- set $etp_MBC_ABLK_OFFSET_SHIFT = (32 - 9)
- end
- set $etp_MBC_ABLK_SZ_MASK = ((UWord)1 << $etp_MBC_ABLK_OFFSET_SHIFT) - 1 - 7
- end
set $etp_blk_sz = ($arg0)->bhdr & $etp_MBC_ABLK_SZ_MASK
end
end
@@ -4082,14 +4296,7 @@ define etp-block2mbc-1
set $etp_mbc = ($arg0)->u.carrier
else
# Allocated block
- if !$etp_MBC_ABLK_OFFSET_SHIFT
- if etp_arch_bits == 64
- set $etp_MBC_ABLK_OFFSET_SHIFT = (64 - 24)
- else
- set $etp_MBC_ABLK_OFFSET_SHIFT = (32 - 9)
- end
- end
- set $etp_mbc = (Carrier_t*) ((((UWord)($arg0) >> 18) - (($arg0)->bhdr >> $etp_MBC_ABLK_OFFSET_SHIFT)) << 18)
+ set $etp_mbc = (Carrier_t*) ((((UWord)($arg0) >> 18) - ((($arg0)->bhdr & $etp_MBC_ABLK_OFFSET_MASK) >> $etp_MBC_ABLK_OFFSET_SHIFT)) << 18)
end
end
@@ -4133,7 +4340,7 @@ document etp-smp-atomic
%---------------------------------------------------------------------------
end
-define etp-carrier-blocks
+define etp-carrier-blocks-1
set $etp_crr = (Carrier_t*) $arg0
etp-smp-atomic $etp_crr->allctr $etp_alc
set $etp_alc = (Allctr_t*)($etp_alc & ~7)
@@ -4145,12 +4352,6 @@ define etp-carrier-blocks
set $etp_fblk_cnt = 0
set $etp_aborted = 0
- if $argc == 2
- set $etp_be_silent = $arg1
- else
- set $etp_be_silent = 0
- end
-
while 1
if !$etp_be_silent
etp-block $etp_blk
@@ -4173,6 +4374,12 @@ define etp-carrier-blocks
printf "ERROR: Missing PREV_FREE_BLK_HDR_FLG (2) in block at %#lx\n", $etp_blk
set $etp_error_cnt = $etp_error_cnt + 1
end
+ else
+ # Prev is ALLOCATED
+ if ($etp_blk->bhdr & 2)
+ printf "ERROR: Invalid PREV_FREE_BLK_HDR_FLG (2) set in block at %#lx\n", $etp_blk
+ set $etp_error_cnt = $etp_error_cnt + 1
+ end
end
end
if $etp_blk->bhdr & 1
@@ -4210,13 +4417,31 @@ define etp-carrier-blocks
end
end
-document etp-carrier-blocks
+define etp-carrier-print
+ set $etp_be_silent = 0
+ etp-carrier-blocks-1 $arg0
+end
+
+document etp-carrier-print
+%---------------------------------------------------------------------------
+% Print all memory blocks in carrier
+% Args: (Carrier_t*)
+%---------------------------------------------------------------------------
+end
+
+define etp-carrier-check
+ set $etp_be_silent = 1
+ etp-carrier-blocks-1 $arg0
+end
+
+document etp-carrier-check
%---------------------------------------------------------------------------
-% Check and (maybe) print all memory blocks in carrier
-% Args: (Carrier_t*) [1=be_silent]
+% Check all memory blocks in carrier
+% Args: (Carrier_t*)
%---------------------------------------------------------------------------
end
+
define etp-address-to-beam-opcode
set $etp_i = 0
set $etp_min_diff = ((UWord)1 << (sizeof(UWord)*8 - 1))
@@ -4348,9 +4573,14 @@ define etp-init
set $etp_arch64 = (sizeof(void *) == 8)
if $etp_arch64
set $etp_nil = 0xfffffffffffffffb
+ set $etp_MBC_ABLK_OFFSET_BITS = 23
else
set $etp_nil = 0xfffffffb
+ set $etp_MBC_ABLK_OFFSET_BITS = 8
end
+ set $etp_MBC_ABLK_OFFSET_SHIFT = (sizeof(UWord)*8 - 1 - $etp_MBC_ABLK_OFFSET_BITS)
+ set $etp_MBC_ABLK_OFFSET_MASK = ((((UWord)1 << $etp_MBC_ABLK_OFFSET_BITS) - 1) << $etp_MBC_ABLK_OFFSET_SHIFT)
+ set $etp_MBC_ABLK_SZ_MASK = ((UWord)1 << $etp_MBC_ABLK_OFFSET_SHIFT) - 1 - 7
set $etp_flat = 0
set $etp_chart_id = 0
set $etp_chart = 0