Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

系統程式 第 1 週 -- 簽到討論區 #3

Open
ccckmit opened this issue Feb 16, 2022 · 59 comments
Open

系統程式 第 1 週 -- 簽到討論區 #3

ccckmit opened this issue Feb 16, 2022 · 59 comments

Comments

@ccckmit
Copy link
Contributor

ccckmit commented Feb 16, 2022

例如:

  1. 陳鍾誠 在 e320
  2. 史奴比 在 家
@4YCAaaa
Copy link

4YCAaaa commented Feb 16, 2022

李思慧 在 家

@Sakura01210
Copy link

王冠文 在 家

@yucing
Copy link

yucing commented Feb 16, 2022

蘇郁晴 在家

@z22756392z
Copy link

徐伯元 在家

@feliciachou
Copy link

周佳蒨 在家

@cynthia1231
Copy link

張芷榕 在家

@stereomp3
Copy link

魏仲彥 在家

@YangTiChu
Copy link

楊堤筑 在家

@jiajianong
Copy link

呂嘉融 在家

@kaifeng273
Copy link

吳俊億 在家

@Mocha777
Copy link

林孫全 在家

@Kenttsai1
Copy link

蔡宗霖 在家

@wukunru
Copy link

wukunru commented Feb 16, 2022

吳昆儒 在家

@Soober9260
Copy link

施威帆 在家

@po-hsiang666
Copy link

張博翔 在家

@QuiLinxinag
Copy link

邱麟翔 在家

@zhengyucen
Copy link

鄭宇岑 在家

@weiian000
Copy link

李維晏 在家

@patrick901218
Copy link

張昀翰 在家

@nelson023
Copy link

張繼光 在家

@404HK416
Copy link

蘇彥華 在家

@mozi5269
Copy link

王昱凱 在家

@jifkavnb0205
Copy link

李安博 在家

@stayjay
Copy link

stayjay commented Feb 16, 2022

王證傑 在家

@al2698
Copy link

al2698 commented Feb 16, 2022

姜呈諭 在家

@huahua6207
Copy link

張喜朵 在家

@qweasd049564
Copy link

蘇乾羽 在家

@shaoan901226
Copy link

黃紹安 在家

@derek120432
Copy link

李韋德 在家

@ChiaYunn
Copy link

張嘉芸 在家

@nnnnnnn1266
Copy link

潘其恩 在家

@YiTing1110
Copy link

張貽婷 在家

@Selesfia
Copy link

胡禎恩 在家

@daniel74859641
Copy link

陳威宇 在家

@ray9016
Copy link

ray9016 commented Feb 16, 2022

張展睿 在家

@Lin610313
Copy link

林庭光 在家

@OohelloworldoO
Copy link

鄭智陽 在家

@wei-annn
Copy link

趙唯安在家

@Uriel58
Copy link

Uriel58 commented Feb 16, 2022

林成也 在家

@Ellinaa
Copy link

Ellinaa commented Feb 16, 2022

陳玟卉 在家

@RyanChen-01
Copy link

陳文吉 在家

@york31390
Copy link

林宥呈 在 家

@zraiz
Copy link

zraiz commented Feb 16, 2022

邵南翔 在家

@WForU
Copy link

WForU commented Feb 16, 2022

何文旺 在家

@Vialbum
Copy link

Vialbum commented Feb 16, 2022

林鈺翔 在家

@cabdy1735
Copy link

李翊慈 在家

@nakirifumiya
Copy link

王澤瑋 在家

@Roy-Roo
Copy link

Roy-Roo commented Feb 16, 2022

羅彥翔 在家

@owen4096
Copy link

劉彥廷 在 家

@ceen123
Copy link

ceen123 commented Feb 16, 2022

吳鑛山 在家

@DE45A
Copy link

DE45A commented Feb 16, 2022

葉峻豪 在家

@ccckmit
Copy link
Contributor Author

ccckmit commented Feb 16, 2022

$ 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

@jenny126
Copy link

蔡宜潔 在家

@gakuplusq
Copy link

黃劭騏 在家

@ccckmit
Copy link
Contributor Author

ccckmit commented Feb 16, 2022

$ 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]

@ccckmit
Copy link
Contributor Author

ccckmit commented Feb 16, 2022

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]

@choco427
Copy link

choco427 commented Apr 1, 2022

張詠翔 在家

@wei-annn
Copy link

趙唯安 在家

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests