コマンドスクリプト |
|---|
| コマンドスクリプト | コンパイルモード | 備考 |
|---|---|---|
| fpdeb64.cmd | Windows 64bit モード | C:\TDM-GCC-64\bin\gdb64.exe を利用 |
| fpdeb32.cmd | Windows 32bit モード | C:\TDM-GCC-64\bin\gdb32.exe を利用 |
@ECHO OFF C:\TDM-GCC-64\bin\gdb64 %*
@ECHO OFF C:\TDM-GCC-64\bin\gdb32 %*
コマンドスクリプトでコンパイルとデバッグ |
|---|
C:\PG>CD FreePascal\Hello
C:\PG\FreePascal\Hello>fpc64deb Hello.pas
Compiling Debug Version
Free Pascal Compiler version 3.2.2 [2021/05/15] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfland others
Target OS: Win64 for x64
Compiling Hello.pas
Linking Hello.exe
14 lines compiled, 0.1 sec, 85680 bytes code,5300 bytes data
C:\PG\FreePascal\Hello>Hello
世界よ、こんにちは。
C:\PG\FreePascal\Hello>
C:\PG\FreePascal\Hello>fpdeb64 Hello.exe
GNU gdb (GDB) 10.2
Copyright (C) 2021 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 changeand redistribute it.
There is NO WARRANTY, to the extent permittedby law.
Type "show copying" and "show warranty" fordetails.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configurationdetails.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentationresources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commandsrelated to "word"...
Reading symbols from Hello.exe...
(gdb)break PASCALMAIN
Breakpoint 1 at 0x1000016ee: file Hello.pas,line 12.
(gdb)run
Starting program: C:\PG\FreePascal\Hello\Hello.exe
[New Thread 12936.0x1c3c]
[New Thread 12936.0x241c]
[New Thread 12936.0x1d0]
Thread 1 hit Breakpoint 1, main () at Hello.pas:12
12 WriteLn(Output, 'クォ。ッ')
(gdb)next
世界よ、こんにちは。
13 end.
(gdb)next
[Thread 12936.0x1c3c exited with code 0]
[Thread 12936.0x241c exited with code 0]
[Thread 12936.0x1d0 exited with code 0]
[Inferior 1 (process 12936) exited normally]
(gdb)quit
C:\PG\FreePascal\Hello>
Free Pascal のエントリポイントについて |
|---|
C:\PG>CD FreePascal\Hello
C:\PG\FreePascal\Hello>C:\FPC\3.2.2\bin\i386-win32\objdump -d Hello.o
Hello.o: file format pe-x86-64
Disassembly of section .text.n_main:
0000000000000000 <PASCALMAIN>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 8d 64 24 e0 lea -0x20(%rsp),%rsp
9: e8 00 00 00 00 call e <PASCALMAIN+0xe>
e: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 15 <PASCALMAIN+0x15>
15: 48 85 c0 test %rax,%rax
18: 74 0d je 27 <PASCALMAIN+0x27>
1a: 8b 0d 00 00 00 00 mov 0x0(%rip),%ecx # 20 <PASCALMAIN+0x20>
20: ff d0 call *%rax
22: 48 89 c2 mov %rax,%rdx
25: eb 07 jmp 2e <PASCALMAIN+0x2e>
27: 48 8d 15 08 00 00 00 lea 0x8(%rip),%rdx # 36 <PASCALMAIN+0x36>
2e: 4c 8d 05 18 00 00 00 lea 0x18(%rip),%r8 # 4d <PASCALMAIN+0x4d>
35: b9 00 00 00 00 mov $0x0,%ecx
3a: e8 00 00 00 00 call 3f <PASCALMAIN+0x3f>
3f: e8 00 00 00 00 call 44 <PASCALMAIN+0x44>
44: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 4b <PASCALMAIN+0x4b>
4b: 48 85 c0 test %rax,%rax
4e: 74 0d je 5d <PASCALMAIN+0x5d>
50: 8b 0d 00 00 00 00 mov 0x0(%rip),%ecx # 56 <PASCALMAIN+0x56>
56: ff d0 call *%rax
58: 48 89 c1 mov %rax,%rcx
5b: eb 07 jmp 64 <PASCALMAIN+0x64>
5d: 48 8d 0d 08 00 00 00 lea 0x8(%rip),%rcx # 6c <PASCALMAIN+0x6c>
64: e8 00 00 00 00 call 69 <PASCALMAIN+0x69>
69: e8 00 00 00 00 call 6e <PASCALMAIN+0x6e>
6e: e8 00 00 00 00 call 73 <PASCALMAIN+0x73>
73: 90 nop
74: 48 8d 65 00 lea 0x0(%rbp),%rsp
78: 5d pop %rbp
79: c3 ret
7a: 00 00 add %al,(%rax)
7c: 00 00 add %al,(%rax)
...
C:\PG\FreePascal\Hello>