Comments (58)
趙唯安 在家
from sp110b.
李思慧 在 家
from sp110b.
王冠文 在 家
from sp110b.
蘇郁晴 在家
from sp110b.
徐伯元 在家
from sp110b.
周佳蒨 在家
from sp110b.
張芷榕 在家
from sp110b.
魏仲彥 在家
from sp110b.
楊堤筑 在家
from sp110b.
呂嘉融 在家
from sp110b.
吳俊億 在家
from sp110b.
林孫全 在家
from sp110b.
蔡宗霖 在家
from sp110b.
吳昆儒 在家
from sp110b.
施威帆 在家
from sp110b.
張博翔 在家
from sp110b.
邱麟翔 在家
from sp110b.
鄭宇岑 在家
from sp110b.
李維晏 在家
from sp110b.
張昀翰 在家
from sp110b.
張繼光 在家
from sp110b.
蘇彥華 在家
from sp110b.
王昱凱 在家
from sp110b.
李安博 在家
from sp110b.
王證傑 在家
from sp110b.
姜呈諭 在家
from sp110b.
張喜朵 在家
from sp110b.
蘇乾羽 在家
from sp110b.
黃紹安 在家
from sp110b.
李韋德 在家
from sp110b.
張嘉芸 在家
from sp110b.
潘其恩 在家
from sp110b.
張貽婷 在家
from sp110b.
胡禎恩 在家
from sp110b.
陳威宇 在家
from sp110b.
張展睿 在家
from sp110b.
林庭光 在家
from sp110b.
鄭智陽 在家
from sp110b.
趙唯安在家
from sp110b.
林成也 在家
from sp110b.
陳玟卉 在家
from sp110b.
陳文吉 在家
from sp110b.
林宥呈 在 家
from sp110b.
邵南翔 在家
from sp110b.
何文旺 在家
from sp110b.
林鈺翔 在家
from sp110b.
李翊慈 在家
from sp110b.
王澤瑋 在家
from sp110b.
羅彥翔 在家
from sp110b.
劉彥廷 在 家
from sp110b.
吳鑛山 在家
from sp110b.
葉峻豪 在家
from sp110b.
$ objdump -d sum.o
sum.o: file format pe-x86-64
Disassembly of section .text:
0000000000000000 <sum>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 83 ec 10 sub $0x10,%rsp
8: 89 4d 10 mov %ecx,0x10(%rbp)
b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
12: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
19: eb 0a jmp 25 <sum+0x25>
1b: 8b 45 f8 mov -0x8(%rbp),%eax
1e: 01 45 fc add %eax,-0x4(%rbp)
21: 83 45 f8 01 addl $0x1,-0x8(%rbp)
25: 8b 45 f8 mov -0x8(%rbp),%eax
28: 3b 45 10 cmp 0x10(%rbp),%eax
2b: 7e ee jle 1b <sum+0x1b>
2d: 8b 45 fc mov -0x4(%rbp),%eax
30: 48 83 c4 10 add $0x10,%rsp
34: 5d pop %rbp
35: c3 retq
0000000000000036 <main>:
36: 55 push %rbp
37: 48 89 e5 mov %rsp,%rbp
3a: 48 83 ec 30 sub $0x30,%rsp
3e: e8 00 00 00 00 callq 43 <main+0xd>
43: b9 0a 00 00 00 mov $0xa,%ecx
48: e8 b3 ff ff ff callq 0 <sum>
4d: 89 45 fc mov %eax,-0x4(%rbp)
50: 8b 45 fc mov -0x4(%rbp),%eax
53: 89 c2 mov %eax,%edx
55: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 5c <main+0x26>
5c: e8 00 00 00 00 callq 61 <main+0x2b>
61: b8 00 00 00 00 mov $0x0,%eax
66: 48 83 c4 30 add $0x30,%rsp
6a: 5d pop %rbp
6b: c3 retq
6c: 90 nop
6d: 90 nop
6e: 90 nop
6f: 90 nop
from sp110b.
蔡宜潔 在家
from sp110b.
黃劭騏 在家
from sp110b.
$ gcc -g fact.c -o fact
E320-teacher@DESKTOP-6F7H4R9 MINGW64 /d/ccc/sp/01-gcc/06-gdb/fact (master)
$ gdb fact.exe
GNU gdb (GDB) 8.1
Copyright (C) 2018 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-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
---Type <return> to continue, or q <return> to quit---
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from fact.exe...done.
(gdb) r
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact.exe
[New Thread 6728.0xdc0]
[New Thread 6728.0x1d40]
factorial(5)=120
[Thread 6728.0x1d40 exited with code 0]
[Inferior 1 (process 6728) exited normally]
(gdb) break main
Breakpoint 1 at 0x401597: file fact.c, line 12.
(gdb) r
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact.exe
[New Thread 6272.0x3218]
[New Thread 6272.0x1eac]
Thread 1 hit Breakpoint 1, main () at fact.c:12
12 printf("factorial(5)=%d\n", factorial(5));
(gdb) n
factorial(5)=120
13 }
(gdb) n
0x00000000004013c7 in __tmainCRTStartup ()
(gdb) n
Single stepping until exit from function __tmainCRTStartup,
which has no line number information.
[Thread 6272.0x1eac exited with code 0]
[Inferior 1 (process 6272) exited normally]
(gdb)
The program is not being run.
(gdb) r
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact.exe
[New Thread 7872.0xc74]
[New Thread 7872.0x37dc]
Thread 1 hit Breakpoint 1, main () at fact.c:12
12 printf("factorial(5)=%d\n", factorial(5));
(gdb) s
factorial (n=5) at fact.c:4
4 int r = 1;
(gdb) n
5 for (int i=2; i<=n; i++) {
(gdb) n
6 r = r*i;
(gdb) n
5 for (int i=2; i<=n; i++) {
(gdb) n
6 r = r*i;
(gdb) n
5 for (int i=2; i<=n; i++) {
(gdb) n
6 r = r*i;
(gdb) p i
$1 = 4
(gdb) p r
$2 = 6
(gdb) n
5 for (int i=2; i<=n; i++) {
(gdb) p r
$3 = 24
(gdb) c
Continuing.
factorial(5)=120
[Thread 7872.0x37dc exited with code 0]
[Inferior 1 (process 7872) exited normally]
from sp110b.
E320-teacher@DESKTOP-6F7H4R9 MINGW64 /d/ccc/sp/01-gcc/06-gdb/fact (master)
$ gcc -g fact_bug.c -o fact_bug
E320-teacher@DESKTOP-6F7H4R9 MINGW64 /d/ccc/sp/01-gcc/06-gdb/fact (master)
$ gdb fact_bug.exe
GNU gdb (GDB) 8.1
Copyright (C) 2018 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-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
---Type <return> to continue, or q <return> to quit---
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from fact_bug.exe...done.
(gdb) r
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact_bug.exe
[New Thread 6164.0x29b0]
[New Thread 6164.0x84c]
factorial(5)=0
[Thread 6164.0x84c exited with code 0]
[Inferior 1 (process 6164) exited normally]
(gdb) break factorial
Breakpoint 1 at 0x40155b: file fact_bug.c, line 5.
(gdb) r
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact_bug.exe
[New Thread 13504.0x718]
[New Thread 13504.0x3490]
Thread 1 hit Breakpoint 1, factorial (n=5) at fact_bug.c:5
5 for (int i=2; i<=n; i++) {
(gdb) p r
$1 = 0
(gdb) p i
$2 = 0
(gdb) n
6 r = r*i;
(gdb) p i
$3 = 2
(gdb) p r
$4 = 0
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: D:\ccc\sp\01-gcc\06-gdb\fact\fact_bug.exe
[New Thread 1568.0x15f8]
[New Thread 1568.0x2548]
Thread 1 hit Breakpoint 1, factorial (n=5) at fact_bug.c:5
5 for (int i=2; i<=n; i++) {
(gdb) p r=1
$5 = 1
(gdb) p r
$6 = 1
(gdb) c
Continuing.
factorial(5)=120
[Thread 1568.0x2548 exited with code 0]
[Inferior 1 (process 1568) exited normally]
from sp110b.
張詠翔 在家
from sp110b.
Related Issues (20)
- 系統程式 第 2 週 -- 簽到討論區 HOT 52
- 系統程式 第 3 週 -- 簽到討論區 HOT 50
- 系統程式 第 4 週 -- 簽到討論區 HOT 47
- 習題 1 : 請為編譯器加上 do ... while 語法的程式碼 HOT 43
- 系統程式 第 5 週 -- 簽到討論區 HOT 45
- 習題 2 : 請為 c6 編譯器加上 do ... while 語法的程式碼 HOT 42
- 系統程式 第 6 週 -- 簽到討論區 HOT 43
- 習題 3 : 請用 jit 的方法直接執行一個函數的機器碼 HOT 27
- 系統程式 第 7 週 -- 簽到討論區 HOT 43
- 系統程式 第 9 週 -- 簽到討論區 HOT 42
- 系統程式 第 10 週 -- 簽到討論區 HOT 38
- 系統程式 第 11 週 -- 簽到討論區 HOT 43
- 系統程式 第 12 週 -- 簽到討論區 HOT 39
- 系統程式 第 13 週 -- 簽到討論區 HOT 36
- 系統程式 第 14 週 -- 簽到討論區 HOT 37
- 系統程式 第 15 週 -- 簽到討論區 HOT 44
- 系統程式 第 16 週 -- 簽到討論區 HOT 14
- 系統程式 第 16 週 -- 簽到討論區 HOT 33
- 系統程式 第 17 週 -- 簽到討論區 HOT 38
- 系統程式 第 18 週 -- 簽到討論區 HOT 34
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sp110b.