aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/unix/etp-commands.in
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-10-02 16:00:36 +0200
committerSverker Eriksson <[email protected]>2014-10-02 16:00:36 +0200
commit8aa3475bba30fed67c1d886fc4bb5910a196db6c (patch)
tree0200d51c83fb036e5629601fba0812ccbc4d5f43 /erts/etc/unix/etp-commands.in
parentedd24536805528c0701d8cf8b0cacac51e5abb09 (diff)
parentf175f46b74efc2419fab09cfe4c09d741bcebf67 (diff)
downloadotp-8aa3475bba30fed67c1d886fc4bb5910a196db6c.tar.gz
otp-8aa3475bba30fed67c1d886fc4bb5910a196db6c.tar.bz2
otp-8aa3475bba30fed67c1d886fc4bb5910a196db6c.zip
Merge branch 'sverk/etp-address-to-beam-opcode' into maint
* sverk/etp-address-to-beam-opcode: erts: Add gdb command etp-address-to-beam-opcode
Diffstat (limited to 'erts/etc/unix/etp-commands.in')
-rw-r--r--erts/etc/unix/etp-commands.in33
1 files changed, 33 insertions, 0 deletions
diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in
index bf6eb00314..e22771c582 100644
--- a/erts/etc/unix/etp-commands.in
+++ b/erts/etc/unix/etp-commands.in
@@ -3552,6 +3552,39 @@ document etp-carrier-blocks
%---------------------------------------------------------------------------
end
+define etp-address-to-beam-opcode
+ set $etp_i = 0
+ set $etp_min_diff = ((UWord)1 << (sizeof(UWord)*8 - 1))
+ set $etp_min_opcode = -1
+ set $etp_addr = (UWord) ($arg0)
+
+ while $etp_i < num_instructions && $etp_min_diff > 0
+ if ($etp_addr - (UWord)beam_ops[$etp_i]) < $etp_min_diff
+ set $etp_min_diff = $etp_addr - (UWord)beam_ops[$etp_i]
+ set $etp_min_opcode = $etp_i
+ end
+ set $etp_i = $etp_i + 1
+ end
+ if $etp_min_diff == 0
+ printf "Address %p is start of '%s'\n", $etp_addr, opc[$etp_min_opcode].name
+ else
+ if $etp_min_opcode >= 0
+ printf "Address is %ld bytes into opcode '%s' at %p\n", $etp_min_diff, opc[$etp_min_opcode].name, beam_ops[$etp_min_opcode]
+ else
+ printf "Invalid opcode address\n"
+ end
+ end
+end
+
+document etp-address-to-beam-opcode
+%---------------------------------------------------------------------------
+% Get beam opcode from a native instruction address (within process_main())
+% Arg: Instructon pointer value
+%
+% Does not work with NO_JUMP_TABLE
+%---------------------------------------------------------------------------
+end
+
############################################################################
# Toolbox parameter handling