test.c 파일을 심심해서 프로파일링과 디버깅 정보를 조합하여 출력하도록 해보았다.
(나중에 어셈블리 분석도 해볼겸!)
아래의 내용중 파란색 내용은 디버깅에서 추가되는 내용
빨간색 내용은 프로파일링에서 추가되는 내용이다.
vimdiff 를 이용해서 비교해본 결과는 아래와 같다.
- 프로파일링 없이 디버깅 정보의 유무
- 디버깅 정보 없이 프로파일링 유무
(나중에 어셈블리 분석도 해볼겸!)
$ cat test.c
#include "unistd.h" int main(int argc, char **argv) { int a = 0; int b = 0; printf("%d %d\n",a,b); a++; b++; printf("%d %d\n",a,b); } |
아래의 내용중 파란색 내용은 디버깅에서 추가되는 내용
빨간색 내용은 프로파일링에서 추가되는 내용이다.
$ gcc -S test.c
$ cat test.s
.file "test.c" .section .rodata .LC0: .string "%d %d\n" .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp movl $0, 28(%esp) movl $0, 24(%esp) movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf addl $1, 28(%esp) addl $1, 24(%esp) movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf leave ret .size main, .-main .ident "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1" .section .note.GNU-stack,"",@progbits |
$ gcc -S -pg test.c
$ cat test.s
.file "test.c" .section .rodata .LC0: .string "%d %d\n" .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call mcount movl $0, 28(%esp) movl $0, 24(%esp) movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf addl $1, 28(%esp) addl $1, 24(%esp) movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf leave ret .size main, .-main .ident "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1" .section .note.GNU-stack,"",@progbits |
$ gcc -S -g test.c
$ cat test.s
.file "test.c" .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .section .debug_info,"",@progbits .Ldebug_info0: .section .debug_line,"",@progbits .Ldebug_line0: .text .Ltext0: .cfi_sections .debug_frame .section .rodata .LC0: .string "%d %d\n" .text .globl main .type main, @function main: .LFB0: .file 1 "test.c" .loc 1 4 0 .cfi_startproc pushl %ebp .LCFI0: .cfi_def_cfa_offset 8 movl %esp, %ebp .cfi_offset 5, -8 .LCFI1: .cfi_def_cfa_register 5 andl $-16, %esp subl $32, %esp .loc 1 5 0 movl $0, 28(%esp) .loc 1 6 0 movl $0, 24(%esp) .loc 1 8 0 movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf .loc 1 9 0 addl $1, 28(%esp) addl $1, 24(%esp) .loc 1 10 0 movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf .loc 1 11 0 leave ret .cfi_endproc .LFE0: .size main, .-main .Letext0: .section .debug_loc,"",@progbits .Ldebug_loc0: .LLST0: .long .LFB0-.Ltext0 .long .LCFI0-.Ltext0 .value 0x2 .byte 0x74 .sleb128 4 .long .LCFI0-.Ltext0 .long .LCFI1-.Ltext0 .value 0x2 .byte 0x74 .sleb128 8 .long .LCFI1-.Ltext0 .long .LFE0-.Ltext0 .value 0x2 .byte 0x75 .sleb128 8 .long 0x0 .long 0x0 .section .debug_info .long 0xd0 .value 0x2 .long .Ldebug_abbrev0 .byte 0x4 .uleb128 0x1 .long .LASF12 .byte 0x1 .long .LASF13 .long .LASF14 .long .Ltext0 .long .Letext0 .long .Ldebug_line0 .uleb128 0x2 .byte 0x1 .byte 0x8 .long .LASF0 .uleb128 0x2 .byte 0x2 .byte 0x7 .long .LASF1 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF2 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF3 .uleb128 0x2 .byte 0x1 .byte 0x6 .long .LASF4 .uleb128 0x2 .byte 0x2 .byte 0x5 .long .LASF5 .uleb128 0x3 .byte 0x4 .byte 0x5 .string "int" .uleb128 0x2 .byte 0x8 .byte 0x5 .long .LASF6 .uleb128 0x2 .byte 0x8 .byte 0x7 .long .LASF7 .uleb128 0x2 .byte 0x4 .byte 0x5 .long .LASF8 .uleb128 0x4 .byte 0x4 .byte 0x7 .uleb128 0x5 .byte 0x4 .long 0x74 .uleb128 0x2 .byte 0x1 .byte 0x6 .long .LASF9 .uleb128 0x6 .byte 0x1 .long .LASF15 .byte 0x1 .byte 0x3 .byte 0x1 .long 0x4f .long .LFB0 .long .LFE0 .long .LLST0 .long 0xcd .uleb128 0x7 .long .LASF10 .byte 0x1 .byte 0x3 .long 0x4f .byte 0x2 .byte 0x91 .sleb128 0 .uleb128 0x7 .long .LASF11 .byte 0x1 .byte 0x3 .long 0xcd .byte 0x2 .byte 0x91 .sleb128 4 .uleb128 0x8 .string "a" .byte 0x1 .byte 0x5 .long 0x4f .byte 0x2 .byte 0x74 .sleb128 28 .uleb128 0x8 .string "b" .byte 0x1 .byte 0x6 .long 0x4f .byte 0x2 .byte 0x74 .sleb128 24 .byte 0x0 .uleb128 0x5 .byte 0x4 .long 0x6e .byte 0x0 .section .debug_abbrev .uleb128 0x1 .uleb128 0x11 .byte 0x1 .uleb128 0x25 .uleb128 0xe .uleb128 0x13 .uleb128 0xb .uleb128 0x3 .uleb128 0xe .uleb128 0x1b .uleb128 0xe .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x1 .uleb128 0x10 .uleb128 0x6 .byte 0x0 .byte 0x0 .uleb128 0x2 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0xe .byte 0x0 .byte 0x0 .uleb128 0x3 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0x8 .byte 0x0 .byte 0x0 .uleb128 0x4 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .byte 0x0 .byte 0x0 .uleb128 0x5 .uleb128 0xf .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .byte 0x0 .byte 0x0 .uleb128 0x6 .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0xc .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0xc .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x1 .uleb128 0x40 .uleb128 0x6 .uleb128 0x1 .uleb128 0x13 .byte 0x0 .byte 0x0 .uleb128 0x7 .uleb128 0x5 .byte 0x0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0xa .byte 0x0 .byte 0x0 .uleb128 0x8 .uleb128 0x34 .byte 0x0 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0xa .byte 0x0 .byte 0x0 .byte 0x0 .section .debug_pubnames,"",@progbits .long 0x17 .value 0x2 .long .Ldebug_info0 .long 0xd4 .long 0x7b .string "main" .long 0x0 .section .debug_aranges,"",@progbits .long 0x1c .value 0x2 .long .Ldebug_info0 .byte 0x4 .byte 0x0 .value 0x0 .value 0x0 .long .Ltext0 .long .Letext0-.Ltext0 .long 0x0 .long 0x0 .section .debug_str,"MS",@progbits,1 .LASF6: .string "long long int" .LASF2: .string "unsigned int" .LASF14: .string "/home/pubuntu/src" .LASF15: .string "main" .LASF3: .string "long unsigned int" .LASF7: .string "long long unsigned int" .LASF12: .string "GNU C 4.4.1" .LASF0: .string "unsigned char" .LASF9: .string "char" .LASF13: .string "test.c" .LASF8: .string "long int" .LASF10: .string "argc" .LASF1: .string "short unsigned int" .LASF4: .string "signed char" .LASF11: .string "argv" .LASF5: .string "short int" .ident "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1" .section .note.GNU-stack,"",@progbit |
$ gcc -S -g -pg test.c
$ cat test.s
.file "test.c" .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .section .debug_info,"",@progbits .Ldebug_info0: .section .debug_line,"",@progbits .Ldebug_line0: .text .Ltext0: .cfi_sections .debug_frame .section .rodata .LC0: .string "%d %d\n" .text .globl main .type main, @function main: .LFB0: .file 1 "test.c" .loc 1 4 0 .cfi_startproc pushl %ebp .LCFI0: .cfi_def_cfa_offset 8 movl %esp, %ebp .cfi_offset 5, -8 .LCFI1: .cfi_def_cfa_register 5 andl $-16, %esp subl $32, %esp call mcount .loc 1 5 0 movl $0, 28(%esp) .loc 1 6 0 movl $0, 24(%esp) .loc 1 8 0 movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf .loc 1 9 0 addl $1, 28(%esp) addl $1, 24(%esp) .loc 1 10 0 movl 24(%esp), %eax movl %eax, 8(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf .loc 1 11 0 leave ret .cfi_endproc .LFE0: .size main, .-main .Letext0: .section .debug_loc,"",@progbits .Ldebug_loc0: .LLST0: .long .LFB0-.Ltext0 .long .LCFI0-.Ltext0 .value 0x2 .byte 0x74 .sleb128 4 .long .LCFI0-.Ltext0 .long .LCFI1-.Ltext0 .value 0x2 .byte 0x74 .sleb128 8 .long .LCFI1-.Ltext0 .long .LFE0-.Ltext0 .value 0x2 .byte 0x75 .sleb128 8 .long 0x0 .long 0x0 .section .debug_info .long 0xd0 .value 0x2 .long .Ldebug_abbrev0 .byte 0x4 .uleb128 0x1 .long .LASF12 .byte 0x1 .long .LASF13 .long .LASF14 .long .Ltext0 .long .Letext0 .long .Ldebug_line0 .uleb128 0x2 .byte 0x1 .byte 0x8 .long .LASF0 .uleb128 0x2 .byte 0x2 .byte 0x7 .long .LASF1 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF2 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF3 .uleb128 0x2 .byte 0x1 .byte 0x6 .long .LASF4 .uleb128 0x2 .byte 0x2 .byte 0x5 .long .LASF5 .uleb128 0x3 .byte 0x4 .byte 0x5 .string "int" .uleb128 0x2 .byte 0x8 .byte 0x5 .long .LASF6 .uleb128 0x2 .byte 0x8 .byte 0x7 .long .LASF7 .uleb128 0x2 .byte 0x4 .byte 0x5 .long .LASF8 .uleb128 0x4 .byte 0x4 .byte 0x7 .uleb128 0x5 .byte 0x4 .long 0x74 .uleb128 0x2 .byte 0x1 .byte 0x6 .long .LASF9 .uleb128 0x6 .byte 0x1 .long .LASF15 .byte 0x1 .byte 0x3 .byte 0x1 .long 0x4f .long .LFB0 .long .LFE0 .long .LLST0 .long 0xcd .uleb128 0x7 .long .LASF10 .byte 0x1 .byte 0x3 .long 0x4f .byte 0x2 .byte 0x91 .sleb128 0 .uleb128 0x7 .long .LASF11 .byte 0x1 .byte 0x3 .long 0xcd .byte 0x2 .byte 0x91 .sleb128 4 .uleb128 0x8 .string "a" .byte 0x1 .byte 0x5 .long 0x4f .byte 0x2 .byte 0x74 .sleb128 28 .uleb128 0x8 .string "b" .byte 0x1 .byte 0x6 .long 0x4f .byte 0x2 .byte 0x74 .sleb128 24 .byte 0x0 .uleb128 0x5 .byte 0x4 .long 0x6e .byte 0x0 .section .debug_abbrev .uleb128 0x1 .uleb128 0x11 .byte 0x1 .uleb128 0x25 .uleb128 0xe .uleb128 0x13 .uleb128 0xb .uleb128 0x3 .uleb128 0xe .uleb128 0x1b .uleb128 0xe .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x1 .uleb128 0x10 .uleb128 0x6 .byte 0x0 .byte 0x0 .uleb128 0x2 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0xe .byte 0x0 .byte 0x0 .uleb128 0x3 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0x8 .byte 0x0 .byte 0x0 .uleb128 0x4 .uleb128 0x24 .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .byte 0x0 .byte 0x0 .uleb128 0x5 .uleb128 0xf .byte 0x0 .uleb128 0xb .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .byte 0x0 .byte 0x0 .uleb128 0x6 .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0xc .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0xc .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x1 .uleb128 0x40 .uleb128 0x6 .uleb128 0x1 .uleb128 0x13 .byte 0x0 .byte 0x0 .uleb128 0x7 .uleb128 0x5 .byte 0x0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0xa .byte 0x0 .byte 0x0 .uleb128 0x8 .uleb128 0x34 .byte 0x0 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0xa .byte 0x0 .byte 0x0 .byte 0x0 .section .debug_pubnames,"",@progbits .long 0x17 .value 0x2 .long .Ldebug_info0 .long 0xd4 .long 0x7b .string "main" .long 0x0 .section .debug_aranges,"",@progbits .long 0x1c .value 0x2 .long .Ldebug_info0 .byte 0x4 .byte 0x0 .value 0x0 .value 0x0 .long .Ltext0 .long .Letext0-.Ltext0 .long 0x0 .long 0x0 .section .debug_str,"MS",@progbits,1 .LASF6: .string "long long int" .LASF2: .string "unsigned int" .LASF14: .string "/home/pubuntu/src" .LASF15: .string "main" .LASF3: .string "long unsigned int" .LASF7: .string "long long unsigned int" .LASF12: .string "GNU C 4.4.1" .LASF0: .string "unsigned char" .LASF9: .string "char" .LASF13: .string "test.c" .LASF8: .string "long int" .LASF10: .string "argc" .LASF1: .string "short unsigned int" .LASF4: .string "signed char" .LASF11: .string "argv" .LASF5: .string "short int" .ident "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1" .section .note.GNU-stack,"",@progbit |
vimdiff 를 이용해서 비교해본 결과는 아래와 같다.
- 프로파일링 없이 디버깅 정보의 유무
- 디버깅 정보 없이 프로파일링 유무
'Linux' 카테고리의 다른 글
쉘스크립트의 stdout / stderr 리다이렉션(redirection c) (0) | 2010.07.07 |
---|---|
bash 쉘 스크립트 에서 파일이 존재하지 않을 경우 (0) | 2010.06.24 |
ulimit (1/3) (0) | 2010.06.03 |
putenv (3) (2) | 2010.06.03 |
복수개의 파일을 strip 시키기 (0) | 2010.06.01 |
Posted by 구차니