9

を使用してCシンボルまたはグローバル定義を検索するとcscope、ファイル名と行番号が表示されます。arch固有のファイルにジャンプできるように、完全なファイルパスを確認したいと思います。たとえば、Linuxコードベースでのビルドのグローバル定義を検索すると、次のようになります__switch_tocscope

Global definition: __switch_to

  File         Line
0 process.c    297 struct task_struct *__switch_to(struct task_struct *prev,
1 switch_to.h   44 #define __switch_to(prev,next,last) do { \
2 process.c    202 struct task_struct *__switch_to(struct task_struct *old,
3 process.c    400 struct task_struct *__switch_to(struct task_struct *prev,
4 process_32.c 211 __switch_to(struct task_struct *prev, struct task_struct *next)
5 process.c     80 void *__switch_to(struct task_struct *from, struct task_struct *to)
6 process_32.c 248 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
7 process_64.c 272 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)

現在、ファイルprocess.cはごとに異なりますarchcscope完全なファイルパスを表示するにはどうすればよいですか?

4

1 に答える 1

8

args-pnを指定してcscopeを実行します

-pnデフォルト(1)の代わりに、最後のn個のファイルパスコンポーネントを表示します。ファイル名をまったく表示しない場合は、0を使用します。

cscope -p4を使用して実行し、__ switch_toのグローバル定義を検索すると、次のようになります。

Global definition: __switch_to

  File                           Line
0 arch/arm64/kernel/process.c    297 struct task_struct *__switch_to(struct task_struct *prev,
1 ia64/include/asm/switch_to.h    44 #define __switch_to(prev,next,last) do { \
2 arch/openrisc/kernel/process.c 202 struct task_struct *__switch_to(struct task_struct *old,
3 arch/powerpc/kernel/process.c  400 struct task_struct *__switch_to(struct task_struct *prev,
4 arch/sh/kernel/process_32.c    211 __switch_to(struct task_struct *prev, struct task_struct *next)
5 arch/um/kernel/process.c        80 void *__switch_to(struct task_struct *from, struct task_struct *to)
6 arch/x86/kernel/process_32.c   248 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
7 arch/x86/kernel/process_64.c   272 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
于 2012-12-18T08:15:28.297 に答える