diff options
author | Sverker Eriksson <[email protected]> | 2014-09-17 17:25:37 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-09-17 17:25:37 +0200 |
commit | f175f46b74efc2419fab09cfe4c09d741bcebf67 (patch) | |
tree | 3eee8a5f451c72faf8c95f84b6637731cc9c5778 /erts/etc/unix/etp-commands.in | |
parent | 56715334380680c1466d2a9165ea2f7affc93a78 (diff) | |
download | otp-f175f46b74efc2419fab09cfe4c09d741bcebf67.tar.gz otp-f175f46b74efc2419fab09cfe4c09d741bcebf67.tar.bz2 otp-f175f46b74efc2419fab09cfe4c09d741bcebf67.zip |
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.in | 33 |
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 |