2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mac OS XでGDBのrecordが使えなかった話

Posted at

使いたかったrecord

このようなツール
http://www.halobates.de/pt-tracing-summit15.pdf

Linux 4.2 以降、GDB 7.10以降で使えるらしい
(参照: http://proc-cpuinfo.fixstars.com/2015/10/processor-trace.html)

使おうとして失敗したので、半端に記録
とても半端

recordのコマンド

詳しいマニュアルはたぶんこれ(https://sourceware.org/gdb/onlinedocs/gdb/Process-Record-and-Replay.html)
また、サブコマンドなどの原文が見たい場合はgdbを起動し以下を入力
(私は英語がものすごく苦手です、??がついているものは間違いなく原文を見た方がいいです)
help record \<method>

使い方:
record \<method>

method 内容
btrace <format> format = bts, pt

Branch Trace Storeを使うか、
Intel Processor Traceを使うか
delete レコードの実行中に、それまでのlogを削除し、新しくlogをつけはじめる
full フルレコード(機能はマニュアルページなどを参照)
function-call-history <subcommand> <+ or -> subcommand = \i, \l, \c
2つ以上を重ねて使う場合は\icなどのように記載する
\l ... ソースファイルと行番号の情報を含める
\i ... インストラクション番号の幅を指定(a〜bまで表示など)
\c ... 関数呼び出しの深さをインデントで表す
サブコマンドの後に+をつけると順方向、-をつけると逆方向に動いていく
goto <command> command = begin, start, end, n

begin, start ... 実行ログの先頭へ移動
end ... 実行ログの末尾へ移動
n ... 実行ログのn番目の命令へ移動
instruction-history <subcommand> <+ or -> subcommand = \m, \r, \f, \p
\m ... ソースの番号を記載
\r ... ??
\f ... 関数名の省略
\p ... マーカーがどこにあるかの省略??
サブコマンドの後に+をつけると順方向、-をつけると逆方向に動いていく
restore <filename> saveされた実行ログを復元
save <filename> デフォルトのファイル名は
gdb_record.(process_id)
stop recordの記録と再生を止める
そこまで記録されていたログも削除される

実際の挙動

$ gdb a.out
(gdb) break main
Breakpoint 1 at 0x100000f56: file hello.c, line 15.

(gdb) break printing2
Breakpoint 2 at 0x100000eff: file hello.c, line 4.

(gdb) start
Temporary breakpoint 3 at 0x100000f56: file hello.c, line 15.
Starting program: /Users/(usrname)/Documents/Xcode/a.out 

Breakpoint 1, main () at hello.c:15
15    printf("Hello! World\n");

(gdb) record btrace
Target does not support branch tracing.

(gdb) record btrace pt
GDB does not support Intel(R) Processor Trace.

targetの問題について

同じ現象に陥ったので以下エラー文などの引用
質問

error: Process record: the current architecture doesn't support record function.

回答

Presently, only certain target debugging environments will support reverse debugging. Those targets currently include:

Native i386-linux ('target record')
Native amd64-linux ('target record')
Several remote targets, including:
moxie-elf simulator
Simics
VMware Workstation 7.0
the SID simulator (xstormy16 architecture)
chronicle-gdbserver using valgrind
UndoDB

(引用元: http://stackoverflow.com/questions/20365117/gdb-error-process-record-the-current-architecture-doesnt-support-record-func)

自PCも調べてみた
これは...無理なのか...
ちなみにMacではhomebrewを使ってGBDのインストールを行い、証明書を発行して利用しました
macでも使えるみたいな話があったら教えてください

gdb -version
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 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-apple-darwin15.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?