Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\debug\kdb\kdb_main.c Create Date:2022-07-28 11:41:27
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:kdb_local - The main code for kdb

Proto:static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, kdb_dbtrap_t db_result)

Type:int

Parameter:

TypeParameterName
kdb_reason_treason
interror
struct pt_regs *regs
kdb_dbtrap_tdb_result
1187  kdb_current = kdb_curr_task(These macros fold the SMP functionality into a single CPU system())
1191  kdb_go_count = 0
1192  If reason == Debug Fault - regs valid Then Else
1195  kdb_printf("\nEntering kdb (current=0x%px, pid %d) ", kdb_current, kdb_current ? process id : 0)
1210  Case db_result == Breakpoint
1211  kdb_printf("\nEntering kdb (0x%px, pid %d) ", kdb_current, process id)
1216  kdb_printf("due to Debug @ "kdb_machreg_fmt"\n", instruction_pointer(regs))
1218  Break
1220  Break
1223  Return 1
1224  Default
1225  kdb_printf("kdb: Bad result from kdba_db_trap: %d\n", db_result)
1227  Break
1231  Break
1232  Case reason == KDB_ENTER() trap/fault - regs valid
1233  If KDB_STATE(KEYBOARD) Then kdb_printf("due to Keyboard Entry\n")
1235  Else kdb_printf("due to KDB_ENTER()\n")
1237  Break
1238  Case reason == Keyboard entry - regs valid
1239  KDB_STATE_SET(KEYBOARD)
1240  kdb_printf("due to Keyboard Entry\n")
1241  Break
1242  Case reason == KDB_ENTER_SLAVE() trap/fault - regs valid
1244  Case reason == CPU switch - regs valid
1245  kdb_printf("due to cpu switch\n")
1246  Break
1247  Case reason == Kernel Oops - regs valid
1248  kdb_printf("Oops: %s\n", kdb_diemsg)
1249  kdb_printf("due to oops @ "kdb_machreg_fmt"\n", instruction_pointer(regs))
1251  kdb_dumpregs(regs)
1252  Break
1253  Case reason == In NMI due to SYSTEM cmd; regs valid
1254  kdb_printf("due to System NonMaskable Interrupt\n")
1255  Break
1256  Case reason == Non-maskable interrupt; regs valid
1257  kdb_printf("due to NonMaskable Interrupt @ "kdb_machreg_fmt"\n", instruction_pointer(regs))
1260  Break
1261  Case reason == Single Step trap. - regs valid
1262  Case reason == Breakpoint inst. - regs valid
1263  kdb_printf("due to %s @ "kdb_machreg_fmt"\n", reason == Breakpoint inst. - regs valid ? "Breakpoint" : "SS trap", instruction_pointer(regs))
1270  If db_result != Breakpoint Then
1271  kdb_printf("kdb: error return from kdba_bp_trap: %d\n", db_result)
1274  Return 0
1276  Break
1277  Case reason == Recursive entry to kdb;* regs probably valid
1278  kdb_printf("due to Recursion @ "kdb_machreg_fmt"\n", instruction_pointer(regs))
1280  Break
1281  Default
1282  kdb_printf("kdb: unexpected reason code: %d\n", reason)
1284  Return 0
1287  When 1 cycle
1291  kdb_nextline = 1
1292  KDB_STATE_CLEAR(SUPPRESS)
1293  kdb_grepping_flag = 0
1295  kdb_grep_string[0] = '\0'
1297  cmdbuf = cmd_cur
1298  cmdbuf = '\0'
1299  *cmd_hist[cmd_head] = '\0'
1301  do_full_getstr :
1306  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
1308  If defcmd_in_progress Then strncat(kdb_prompt_str, "[defcmd]", kdb_printf: max printline* size == 256 )
1314  cmdbuf = kdb_getstr* Print the prompt string and read a command from the* input device.* Parameters:* buffer Address of buffer to receive command* bufsize Size of buffer in bytes* prompt Pointer to string to use as prompt string* Returns:
1315  If cmdbuf != '\n' Then
1316  If cmdbuf < 32 Then
1327  Else
1333  If cmd_head == cmd_tail Then cmd_tail = (cmd_tail + 1) % Command history
1337  cmdptr = cmd_head
1338  diag = kdb_parse(cmdbuf)
1341  kdb_printf("Unknown kdb command: '%s'\n", cmdbuf)
1342  diag = 0
1344  If diag == Kernel Debugger Command codes. Must not overlap with error codes. || diag == KDB_CMD_CPU || diag == KDB_CMD_SS || diag == KDB_CMD_KGDB Then Break
1350  If diag Then kdb_cmderror(diag)
1354  Return diag
Caller
NameDescribe
kdb_main_loopkdb_main_loop - After initial setup and assignment of the* controlling cpu, all cpus are in this loop