Skip to content

Blog#

C Basic Types - Binary Representions

Values have a type and a binary representation.

The binary representation of a type is a model that describes the possible values for that type. It is not the same as the in-memory object representation that describes the more or less physical storage of values of a given type.

TAKEAWAY 5.49

TAKEAWAY 5.49 The same value may have different binary representations.

C语言标准与实现之整数类型

在 C 语言刚刚被设计出来的时候,一共只有两种整数类型 —— charint。C89 引入了两种新的整数类型 —— shortlong,C99 再增加一种整数类型 —— long long。

后来,随着 C 语言的进一步发展,K&R C 引入了无符号整数的概念以及 unsigned 关键字。char 既不属于标准带符号整数类型也不属于标准无符号整数类型,它属于历史遗物。

C89 引入 signed 关键字后,可显式声明 signed char,明确表达最小的标准带符号整数类型。

为什么 getchar() 返回的类型是 int,而不是 char?

GDB Enhanced Extensions

Vanilla GDB in its raw form has a rather uninformative interface and its syntax is arcane and difficult to approach. It sucks in terms of user experience and is terrible to use for reverse engineering and exploit development.

To make debugging easier and more productive, there are extensions for GDB such as GEF, pwndbg that provide a more informative view and additional commands.

GDB debug assembly

This article involves the following topics:

  1. How to disassemble source code to machine code?
  2. How to dump machine instruction along with source line?
  3. How to layout src and asm side by side in a single gdb window?

GDB Stop & Continue

5 Stopping and Continuing

在调试程序时,中断程序的运行是必须的。GDB 可以方便地暂停/继续程序的运行。

通过设置断点,可以决定程序在哪行,在什么条件下,或者在收到什么信号时暂停,以便查验程序运行的流程和状态。

程序暂停后,我们可以通过相关命令控制程序继续运行到下一个预设的中断点,在这种“暂停-继续”往复中调试验证程序设计的正确性。

GDB Invocation & Quitting

Invocation (Debugging with GDB)

This article discusses how to start GDB, and how to get out of it.

  • type gdb to start GDB.
  • Use file to change and load debugging FILE.
  • Use info/list to show info/src about the program.
  • Use the run command to start your program under GDB.
  • Use the start command to start debugging and to stop at main.
  • type quit, exit or ctrl+d to exit GDB console.