mrubyを使っていてsegmentation faultとか出て困ったことは無いでしょうか。こういう場合にgdbでデバッグするノウハウを書きます。gdbの使い方についてはここでは説明しません。 逆アセンブラ gdbでデバッグするならmrubyのバイトコードの逆アセンブラが必要です。標準ではcodedump関数が用意されていますが、なぜかここで説明するような使い方はできないようです。mrubyのJITで使っているものがここにありますので、コピーしてcodedump.cあたりにでも入れておいてくください。 これを使うと、変数mrbとirepが見えていれば、こんな感じでdisasm_irep関数を呼び出すことで逆アセンブルできます。見えていない場合、gdbのupコマンドで呼び出し元を辿っていて見えるところがあればそこで実行可能です。disasm_irepは値を返さないのでcallを使う方がよさ
2016-08-05 My Ruby process has stopped doing any work, what’s wrong? This is an uncommon but occasional problem for many people, especially with large applications using lots of native extensions. Step 1 - Thread backtraces A Sidekiq process will print out the backtrace of every thread when you send it the TTIN signal. kill -TTIN <pid> Side note: YMMV for other types of Ruby processes: resque, uni
Your Ruby code smells. And it’s okay -- mine does, too! Maybe it has some long methods with too many parameters, a few classes that try to do too much, an uncommunicative name here or there. No codebase is perfect, but it’s worthwhile to be aware of its deficiencies and refactorings that could improve the state of things -- so let’s look at a few example code smells, potential ways to fix them and
Perl での print debug の方法の紹介がブーム(?)だったので、自分がよく行ってる Ruby での debug 方法7つについて書いてみます。 p ご存じの人も多い Kernel#p メソッド。これを使うとオブジェクトの内容を見やすい形で出力してくれます。 >> p ({:foobar => :baz}) {:foobar=>:baz}Object#inspect を使うと、p で出力するときと同じ文字列を String として取得できます。 >> puts ({:foobar => :baz}).inspect {:foobar=>:baz}初心者の頃この p での出力を使う方法がわからなくて困った記憶が…。 pp pp というライブラリを使うと、p より、より見やすい形式で出力してくれます。たとえば >> a = Array.new(10) { {:foobar => :
In math, a unary operation is an operation with a single input. In Ruby, a unary operator is an operator which only takes a single ‘argument’ in the form of a receiver. For example, the – on -5 or ! on !true. In contrast, a binary operator, such as in 2 + 3, deals with two arguments. Here, 2 and 3 (which become one receiver and one argument in a method call to +). Ruby only has a handful of unary
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く