質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

Q&A

解決済

2回答

2040閲覧

lldbの表示に関して

momoti_motimoti

総合スコア12

C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

0グッド

0クリップ

投稿2015/05/17 10:32

バブルソート(http://ow.ly/3xSFu5)のコードをlldbで実行したところ、
以下のような出力になりました。

下記の最後の4行の表示だと、
ソースコード上のどの行を指しているのか、ひと目でわかりません。
この表示を変えることは可能でしょうか?

/Users/localhost% gcc -g bubblesort.c /Users/localhost% lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b main Breakpoint 1: where = a.out'main, address = 0x0000000100000d34 (lldb) r Process 18477 launched: '/Users/localmost/a.out' (x86_64) Process 18477 stopped * thread #1: tid = 0x27d2e3, 0x0000000100000d34 a.out`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000d34 a.out`main a.out`main: -> 0x100000d34 <+0>: pushq %rbp 0x100000d35 <+1>: movq %rsp, %rbp 0x100000d38 <+4>: subq $0x20, %rsp 0x100000d3c <+8>: movl %edi, -0x14(%rbp)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

私の環境では、行番号が表示されます。(MacOSX 10.10.3)
gcc, lldb の version を最新にしてみては如何でしょう。(xcode も最新にしたほうが良いかもしれません)

私の環境での操作結果を以下に示します。

$ gcc -g sort.c $ lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b main Breakpoint 1: where = a.out`main + 45 at sort.c:9, address = 0x0000000100000d7d (lldb) r Process 3651 launched: '/Users/katoy/work/zzz/cpp/a.out' (x86_64) Process 3651 stopped * thread #1: tid = 0x3de7, 0x0000000100000d7d a.out`main(argc=1, argv=0x00007fff5fbff6d0) + 45 at sort.c:9, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000d7d a.out`main(argc=1, argv=0x00007fff5fbff6d0) + 45 at sort.c:9 6 7 /* program entry */ 8 int main(int argc, char **argv) { -> 9 int array[4] = {4, 1, 3, 2}; 10 printarray(&array[0], 4); 11 sort(array, 4); 12 printarray(&array[0], 4); (lldb) ^D

gcc, lldb のバージョンです。

$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.3.0 Thread model: posix $ lldb --version lldb-330.0.44

投稿2015/05/17 21:08

katoy

総合スコア22324

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

momoti_motimoti

2015/05/18 00:26

lldb のバージョンは katoyさんと同じで、 clang --versionが、katoyさんの gcc --versionと同じ内容になりました。 ``` % lldb -v lldb-330.0.44 % gcc --version gcc (Homebrew gcc 4.9.2_1) 4.9.2 Copyright (C) 2014 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. % clang --version Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.3.0 Thread model: posix ```
momoti_motimoti

2015/05/18 00:31

homebrewでgccを上書きしてしまった事が原因だったようです。 解決のご協力ありがとうございます。
guest

0

ベストアンサー

Mac ですよね? わたしの環境だと普通にソースの行などが表示されますが・・・

ためしに gcc --version するとどのように表示されるでしょうか?

または clang でビルドしてみるとかどうでしょうか?

clang -g bubblesort.c

投稿2015/05/17 17:12

ngyuki

総合スコア4514

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

momoti_motimoti

2015/05/18 00:18

ソースの行が表示されました。 ありがとうございます。
momoti_motimoti

2015/05/18 00:19

ちなみに gcc --versionはこうなりました。 ``` /Users/localmost/Documents/SoftComputing/report/5_7% gcc --version gcc (Homebrew gcc 4.9.2_1) 4.9.2 Copyright (C) 2014 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. ```
ngyuki

2015/05/18 00:25

普通ならOSXのgccの中身はclangのはずですが、homebrewで上書きしてしまったのでしょうかね・・・ もしgdbが入っているなら、gcc/gdbでも似たようにできると思います
momoti_motimoti

2015/05/18 00:33

解決できてうれしいです。 ご協力感謝します。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問