GithubHelp home page GithubHelp logo

Comments (58)

wei-annn avatar wei-annn commented on September 7, 2024 3

趙唯安 在家

from sp110b.

4YCAaaa avatar 4YCAaaa commented on September 7, 2024

李思慧 在 家

from sp110b.

Sakura01210 avatar Sakura01210 commented on September 7, 2024

王冠文 在 家

from sp110b.

yucing avatar yucing commented on September 7, 2024

蘇郁晴 在家

from sp110b.

z22756392z avatar z22756392z commented on September 7, 2024

徐伯元 在家

from sp110b.

feliciachou avatar feliciachou commented on September 7, 2024

周佳蒨 在家

from sp110b.

cynthia1231 avatar cynthia1231 commented on September 7, 2024

張芷榕 在家

from sp110b.

stereomp3 avatar stereomp3 commented on September 7, 2024

魏仲彥 在家

from sp110b.

YangTiChu avatar YangTiChu commented on September 7, 2024

楊堤筑 在家

from sp110b.

jiajianong avatar jiajianong commented on September 7, 2024

呂嘉融 在家

from sp110b.

kaifeng273 avatar kaifeng273 commented on September 7, 2024

吳俊億 在家

from sp110b.

Mocha777 avatar Mocha777 commented on September 7, 2024

林孫全 在家

from sp110b.

Kenttsai1 avatar Kenttsai1 commented on September 7, 2024

蔡宗霖 在家

from sp110b.

wukunru avatar wukunru commented on September 7, 2024

吳昆儒 在家

from sp110b.

Soober9260 avatar Soober9260 commented on September 7, 2024

施威帆 在家

from sp110b.

po-hsiang666 avatar po-hsiang666 commented on September 7, 2024

張博翔 在家

from sp110b.

QuiLinxinag avatar QuiLinxinag commented on September 7, 2024

邱麟翔 在家

from sp110b.

zhengyucen avatar zhengyucen commented on September 7, 2024

鄭宇岑 在家

from sp110b.

weiian000 avatar weiian000 commented on September 7, 2024

李維晏 在家

from sp110b.

patrick901218 avatar patrick901218 commented on September 7, 2024

張昀翰 在家

from sp110b.

nelson023 avatar nelson023 commented on September 7, 2024

張繼光 在家

from sp110b.

404HK416 avatar 404HK416 commented on September 7, 2024

蘇彥華 在家

from sp110b.

mozi5269 avatar mozi5269 commented on September 7, 2024

王昱凱 在家

from sp110b.

jifkavnb0205 avatar jifkavnb0205 commented on September 7, 2024

李安博 在家

from sp110b.

stayjay avatar stayjay commented on September 7, 2024

王證傑 在家

from sp110b.

al2698 avatar al2698 commented on September 7, 2024

姜呈諭 在家

from sp110b.

huahua6207 avatar huahua6207 commented on September 7, 2024

張喜朵 在家

from sp110b.

qweasd049564 avatar qweasd049564 commented on September 7, 2024

蘇乾羽 在家

from sp110b.

shaoan901226 avatar shaoan901226 commented on September 7, 2024

黃紹安 在家

from sp110b.

derek120432 avatar derek120432 commented on September 7, 2024

李韋德 在家

from sp110b.

ChiaYunn avatar ChiaYunn commented on September 7, 2024

張嘉芸 在家

from sp110b.

nnnnnnn1266 avatar nnnnnnn1266 commented on September 7, 2024

潘其恩 在家

from sp110b.

YiTing1110 avatar YiTing1110 commented on September 7, 2024

張貽婷 在家

from sp110b.

Selesfia avatar Selesfia commented on September 7, 2024

胡禎恩 在家

from sp110b.

daniel74859641 avatar daniel74859641 commented on September 7, 2024

陳威宇 在家

from sp110b.

ray9016 avatar ray9016 commented on September 7, 2024

張展睿 在家

from sp110b.

Lin610313 avatar Lin610313 commented on September 7, 2024

林庭光 在家

from sp110b.

OohelloworldoO avatar OohelloworldoO commented on September 7, 2024

鄭智陽 在家

from sp110b.

wei-annn avatar wei-annn commented on September 7, 2024

趙唯安在家

from sp110b.

Uriel58 avatar Uriel58 commented on September 7, 2024

林成也 在家

from sp110b.

Ellinaa avatar Ellinaa commented on September 7, 2024

陳玟卉 在家

from sp110b.

RyanChen-01 avatar RyanChen-01 commented on September 7, 2024

陳文吉 在家

from sp110b.

york31390 avatar york31390 commented on September 7, 2024

林宥呈 在 家

from sp110b.

zraiz avatar zraiz commented on September 7, 2024

邵南翔 在家

from sp110b.

WForU avatar WForU commented on September 7, 2024

何文旺 在家

from sp110b.

Vialbum avatar Vialbum commented on September 7, 2024

林鈺翔 在家

from sp110b.

cabdy1735 avatar cabdy1735 commented on September 7, 2024

李翊慈 在家

from sp110b.

nakirifumiya avatar nakirifumiya commented on September 7, 2024

王澤瑋 在家

from sp110b.

Roy-Roo avatar Roy-Roo commented on September 7, 2024

羅彥翔 在家

from sp110b.

owen4096 avatar owen4096 commented on September 7, 2024

劉彥廷 在 家

from sp110b.

ceen123 avatar ceen123 commented on September 7, 2024

吳鑛山 在家

from sp110b.

DE45A avatar DE45A commented on September 7, 2024

葉峻豪 在家

from sp110b.

ccckmit avatar ccckmit commented on September 7, 2024
$ 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.

jenny126 avatar jenny126 commented on September 7, 2024

蔡宜潔 在家

from sp110b.

gakuplusq avatar gakuplusq commented on September 7, 2024

黃劭騏 在家

from sp110b.

ccckmit avatar ccckmit commented on September 7, 2024
$ 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.

ccckmit avatar ccckmit commented on September 7, 2024
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.

choco427 avatar choco427 commented on September 7, 2024

張詠翔 在家

from sp110b.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.