Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created January 6, 2017 01:44
Show Gist options
  • Select an option

  • Save wanabe/649543c5dcee3bb3982b1efff254f6b0 to your computer and use it in GitHub Desktop.

Select an option

Save wanabe/649543c5dcee3bb3982b1efff254f6b0 to your computer and use it in GitHub Desktop.
$ make miniruby && ln -fs $PWD/miniruby /tmp/miniruby && printf "b compile.c:$(sed -n "/int orig_sp = sp;/=" ../compile.c)\nr\ncall dump_disasm_list(FIRST_ELEMENT(anchor))\nq"|gdb -x - --args /tmp/miniruby g.rb
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O0 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wno-maybe-uninitialized -std=gnu99
XCFLAGS = -fstack-protector -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE
CPPFLAGS = -I. -I.ext/include/x86_64-linux -I../include -I.. -I../enc/unicode/9.0.0
DLDFLAGS = -Wl,--compress-debug-sections=zlib -fstack-protector -pie
SOLIBS =
gcc (Ubuntu 6.3.0-2ubuntu1) 6.3.0 20161229
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
generating known_errors.inc
known_errors.inc unchanged
GNU gdb (Ubuntu 7.12-0ubuntu3) 7.12
Copyright (C) 2016 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/miniruby...done.
-: No such file or directory.
(gdb) Breakpoint 1 at 0x573cd: file ../compile.c, line 1803.
(gdb) Starting program: /tmp/miniruby g.rb
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7ff4700 (LWP 30402)]
Thread 1 "miniruby" hit Breakpoint 1, iseq_set_sequence (iseq=0x555555a92e28, anchor=0x7fffffffc910)
at ../compile.c:1803
1803 int orig_sp = sp;
(gdb) -- raw disasm--------
0000 trace 1 ( 1)
0002 jump <L001> ( 1)
<L004>
0004 putnil ( 1)
<L005>
0005 pop ( 1)
<L001>
0006 trace 1 ( 2)
<L006>
0008 putnil ( 2)
<L007>
0009 pop ( 2)
0010 nop ( 2)
<L008>
0011 pop ( 2)
0012 trace 1 ( 7)
<L009>
adjust: [label: 1]
0014 putnil ( 7)
0015 leave ( 7)
adjust: [label: 9]
0016 jump <L001> ( 1)
adjust: [label: 4]
0018 putnil ( 1)
<L002>
0019 leave ( 7)
---------------------
(gdb) A debugging session is active.
Inferior 1 [process 30398] will be killed.
Quit anyway? (y or n) [answered Y; input not from terminal]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment