mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Page:
Machine Instructions Trace with GDB
Pages
Assumptions JA
Assumptions
C99 Usage Guidelines
CI Servers
CI用Savings Planの購入
Committer How To JA
Committer How To
Developer How To JA
Developer How To
Developers Meeting
Donation
General Maintenance Policy
Git Migration FAQ JA
Home
How To Backport
How To Contribute
How To Maintain RubyCI Servers
How To Manage Redmine
How To Release JA
How To Report JA
How To Report
How To Request Backport
How To Request Features
Machine Instructions Trace with GDB
Node Position Memo JA
Refinements Spec
Release Engineering 2.1
Release Engineering 2.2
Release Engineering 2.3
Release Engineering 2.4
Release Engineering 2.5
Release Engineering 2.6
Release Engineering 2.7
Release Engineering 3.0
Release Engineering 3.1
Release Engineering 3.2
Release Engineering
Ruby 1.8 Branch Policy JA
Ruby 1.8 Branch Policy
Ruby 1.8 Release Plan JA
Ruby 1.8 Release Plan
Security
Server Resources
Versioning Policy
No results
1
Machine Instructions Trace with GDB
Jemma Issroff edited this page 2023-05-30 13:29:29 -04:00
MachineInstructionsTraceWithGDB
new gdb function trace_machine_instructions
Usage:
$ gdb -x .gdbinit ... # run gdb with .gdbinit
(gdb) b foo # set breakpoint to function `foo'
(gdb) run # execute debuggee program
... # and stop at break point
(gdb) trace_machine_instructions
... # continue program and show each instructions
... # all output will be saved on 'gdb.txt'
Example:
$ gdb -x ../clean-trunk/.gdbinit --args ./miniruby ../clean-trunk/benchmark/bm_app_fib.rb
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ko1/build/ruby/clean-build/miniruby...done.
(gdb)
(gdb) b vm_exec
Breakpoint 1 at 0x81c4c00: file ../clean-trunk/vm.c, line 1116.
(gdb) run
Starting program: /home/ko1/build/ruby/clean-build/miniruby ../clean-trunk/benchmark/bm_app_fib.rb
[Thread debugging using libthread_db enabled]
[New Thread 0xb7c80b70 (LWP 7878)]
Breakpoint 1, vm_exec (th=0x8264b88) at ../clean-trunk/vm.c:1116
1116 {
(gdb) continue
Continuing.
Breakpoint 1, vm_exec (th=0x8264b88) at ../clean-trunk/vm.c:1116
1116 {
(gdb) (gdb) trace_machine_instructions
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c00 <vm_exec> and ends at 0x81c4c01 <vm_exec+1>.
1122 TH_PUSH_TAG(th);
1: x/i $pc
0x81c4c01 <vm_exec+1>: mov %eax,%edx
Line 1122 of "../clean-trunk/vm.c" starts at address 0x81c4c01 <vm_exec+1> and ends at 0x81c4c03 <vm_exec+3>.
1116 {
1: x/i $pc
0x81c4c03 <vm_exec+3>: mov %esp,%ebp
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c03 <vm_exec+3> and ends at 0x81c4c19 <vm_exec+25>.
0x081c4c05 1116 {
1: x/i $pc
0x81c4c05 <vm_exec+5>: push %edi
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c03 <vm_exec+3> and ends at 0x81c4c19 <vm_exec+25>.
0x081c4c06 1116 {
1: x/i $pc
0x81c4c06 <vm_exec+6>: push %esi
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c03 <vm_exec+3> and ends at 0x81c4c19 <vm_exec+25>.
0x081c4c07 1116 {
1: x/i $pc
0x81c4c07 <vm_exec+7>: push %ebx
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c03 <vm_exec+3> and ends at 0x81c4c19 <vm_exec+25>.
0x081c4c08 1116 {
1: x/i $pc
0x81c4c08 <vm_exec+8>: sub $0x15c,%esp
Line 1116 of "../clean-trunk/vm.c" starts at address 0x81c4c03 <vm_exec+3> and ends at 0x81c4c19 <vm_exec+25>.
0x081c4c0e 1116 {
...
(gdb) quit
You can see all outputs in `gdb.txt'.
pretty log
The attached script gdb-logparse.rb ' make slim log from
gdb.txt'
Example output:
vm_exec+1 mov %eax,%edx ../clean-trunk/vm.c:1122
vm_exec+3 mov %esp,%ebp ../clean-trunk/vm.c:1116
vm_exec+5 push %edi ../clean-trunk/vm.c:1116
vm_exec+6 push %esi ../clean-trunk/vm.c:1116
vm_exec+7 push %ebx ../clean-trunk/vm.c:1116
vm_exec+8 sub $0x15c,%esp ../clean-trunk/vm.c:1116
vm_exec+14 call 0x805c3c0 <__i686.get_pc_thunk.bx> ../clean-trunk/vm.c:1116
__i686.get_pc_thunk.bx mov (%esp),%ebx
__i686.get_pc_thunk.bx+3 ret
vm_exec+19 add $0x8dd1d,%ebx ../clean-trunk/vm.c:1116
vm_exec+25 mov %eax,-0xcc(%ebp) ../clean-trunk/vm.c:1116
...
Policies
Development
For developers
- Developer How To, Developer How To JA
- How To Contribute
- How To Report, How To Report JA
- How To Request Backport
- How To Request Features
- Developers Meeting
For committers
- Committer How To, Committer How To JA
- Git Migration FAQ JA
- How To Backport
- How To Manage Redmine
- How To Release JA
- How To Maintain RubyCI Servers