POSIX signal 小整理

做 SOC 軟體的人常常會收到 bug 的 log, 其中一個常見的類型就是 signal XXX, code YYY, fault address ZZZ. 例如:

Fatal signal 11 (SIGSEGV), code 2, fault addr 0x12345678 in tid 12345 (MyTask)

這個 log 是標準 C library 裡面的 signal.h 所定義的 [1].  參考 ref [2], 裡面有較完整的 code No. 說明, 而 ref [3] 有完整的 POSIX signal 定義和歷史沿革; Ref [4] 是把 Unix signal 做成一張表.

取常用的部分, 重新整理如下. 這些都是 core error, 所以會終止程序, 並且產生 core dump.

Signal

No.

Code

No.

Reason

SIGILL

4

ILL_ILLOPC

1

Illegal opcode.

ILL_ILLOPN

2

Illegal operand.

ILL_ILLADR

3

Illegal addressing mode.

ILL_ILLTRP

4

Illegal trap.

ILL_PRVOPC

5

Privileged opcode.

ILL_PRVREG

6

Privileged register.

ILL_COPROC

7

Coprocessor error.

ILL_BADSTK

8

Internal stack error.

SIGFPE

8

FPE_INTDIV

1

Integer divide by zero.

FPE_INTOVF

2

Integer overflow.

FPE_FLTDIV

3

Floating-point divide by zero.

FPE_FLTOVF

4

Floating-point overflow.

FPE_FLTUND

5

Floating-point underflow.

FPE_FLTRES

6

Floating-point inexact result.

FPE_FLTINV

7

Invalid floating-point operation.

FPE_FLTSUB

8

Subscript out of range.

SIGSEGV

11

SEGV_MAPERR

1

Address not mapped to object.

SEGV_ACCERR

2

Invalid permissions for mapped object.

SIGBUS

10

BUS_ADRALN

1

Invalid address alignment.

BUS_ADRERR

2

Nonexistent physical address.

BUS_OBJERR

3

Object-specific hardware error.

SIGTRAP

5

TRAP_BRKPT

1

Process breakpoint.

TRAP_TRACE

2

Process trace trap.

[REF]

  1. https://zh.wikipedia.org/wiki/Signal.h
  2. http://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html
  3. http://man7.org/linux/man-pages/man7/signal.7.html
  4. http://people.cs.pitt.edu/~alanjawi/cs449/code/shell/UnixSignals.htm

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s

%d 位部落客按了讚: