1.sx
sx* 命令用来控制被调试的程序发生某个异常或特定事件时,调试器要采取的动作
sx 命令显示当前进程的异常列表和所有非异常的事件列表,并且显示调试器遇到每个异常和事件时的行为。
sxr 命令将所有异常和事件过滤器的状态重设为默认值。命令被清除、中断和继续选项被重设为默认值,等等。
sx这个命令的输出信息可以分为三个部分:
第一部分是事件处理与相应处理模式的交互,第二部分是标准的异常交互和处理行为,最后一部分是用户自定义的异常交互和处理行为
以下面为例,我们先输入sxr再输入sx看下默认的处理行为都是怎么样的:
0:000> sxr sx state reset to defaults 0:000> sx ct - Create thread - ignore et - Exit thread - ignore cpr - Create process - ignore epr - Exit process - ignore ld - Load module - output ud - Unload module - ignore ser - System error - ignore ibp - Initial breakpoint - ignore iml - Initial module load - ignore out - Debuggee output - output av - Access violation - break - not handled asrt - Assertion failure - break - not handled aph - Application hang - break - not handled bpe - Break instruction exception - break bpec - Break instruction exception continue - handled eh - C++ EH exception - second-chance break - not handled clr - CLR exception - second-chance break - not handled clrn - CLR notification exception - second-chance break - handled cce - Control-Break exception - break cc - Control-Break exception continue - handled cce - Control-C exception - break cc - Control-C exception continue - handled dm - Data misaligned - break - not handled dbce - Debugger command exception - ignore - handled gp - Guard page violation - break - not handled ii - Illegal instruction - second-chance break - not handled ip - In-page I/O error - break - not handled dz - Integer divide-by-zero - break - not handled iov - Integer overflow - break - not handled ch - Invalid handle - break hc - Invalid handle continue - not handled lsq - Invalid lock sequence - break - not handled isc - Invalid system call - break - not handled 3c - Port disconnected - second-chance break - not handl
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemFrequency variable.
*/
void SystemInit (void)
{
#if (FLASH_SETUP == 1) /* Flash Accelerator Setup */
LPC_SC->FLASHCFG = FLASHCFG_Val;
#endif
#if (CLOCK_SETUP) /* Clock Setup */
LPC_SC->SCS = SCS_Val; /* bit[5]=1;The main oscillator is enabled, added by fulinux. */
if (SCS_Val & (1 << 5)) { /* If Main Oscillator is enabled */
while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready */
}
LPC_SC->PCLKSEL = PCLKSEL_Val; /* Peripheral Clock Selection */
LPC_SC->EMCCLKSEL = EMCCLKSEL_Val; /* EMC Clock Selection */
LPC_SC->SPIFISEL = SPIFISEL_Val; /* SPIFI Clock Selection */
/* bit[9:8]=0x0; Sysclk is used as the input to the SPIFI clock divider. added by fulinux. */
LPC_SC->CLKSRCSEL = CLKSRCSEL_Val; /* Select Clock Source for PLL0 */
/* bit[0]=1; Selects the main oscillator as the sysclk and PLL0 clock source. added by fulinux. */
LPC_SC->CCLKSEL = CCLKSEL_Val; /* Setup Clock Divider,and select sysclk(12M) for cpu clock divider. added by fulinux. */
/* And cpu frequency is 12M at frist */
#if (PLL0_SETUP)
LPC_SC->PLL0CFG = PLL0CFG_Val; /* PLL0 frequency is 120M, added by fulinux. */
LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */
LPC_SC->PLL0FEED = 0xAA;
LPC_SC->PLL0FEED = 0x55;
while (!(LPC_SC->PLL0STAT & (1<<10)));/* Wait for PLOCK0 */
/* Can also use interrupt without waiting for. added by fulinux. */
LPC_SC->PLL0CON = 0x03; /* PLL0 Enable & Connect */
LPC_SC->PLL0FEED = 0xAA;
LPC_SC->PLL0FEED = 0x55;
LPC_SC->CCLKSEL |= 0x100; /* This time the cpu frequency is 120M. added by fulinux. */
LPC_SC->SPIFISEL = 0x100 | SPIFISEL_Val; /* It seems that the LPC_SC->SPIFISEL is W only */
/* bit[9:8]=0x1; The output of the Main PLL is used as the input to the SPIFI clock divider.added by fulinux. */
#endif
#if (PLL1_SETUP)
LPC_SC->USBCLKSEL = USBSEL_Val; /* Setup USB Clock Divider */
/* Sysclk is used as the input to USB clock divider. */
LPC_SC->PLL1CFG = PLL1CFG_Val; /* PLL1 frequency is 12M. added by fulinux.*/
LPC_SC->PLL1CON = 0x01; /* PLL1 Enable */
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
while (!(LPC_SC->PLL1STAT & (1<<10)));/* Wait for PLOCK1 */
LPC_SC->PLL1CON = 0x03; /* PLL1 Enable & Connect */
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
LPC_SC->USBCLKSEL |= 0x200; /* The output of the alt pll is used as the input to USB clock divider. */
// LPC_SC->SPIFISEL = 0x200 | SPIFISEL_Val; /* It seems that the LPC_SC->SPIFISEL is W only */
#else
LPC_SC->USBCLKSEL = USBSEL_Val; /* Setup USB Clock Divider */
#endif
LPC_SC->PCONP = PCONP_Val; /* Power Control for Peripherals */
LPC_SC->CLKOUTCFG = CLKOUTCFG_Val; /* Clock Output Configuration */
#endif
/* Determine clock frequency according to clock register values */
if (((LPC_SC->PLL0STAT >> 8)&3)==3) {/* If PLL0 enabled and connected */
switch (LPC_SC->CLKSRCSEL & 0x03) {
case 0: /* Internal RC oscillator => PLL0 */
SystemFrequency = (IRC_OSC *
((LPC_SC->PLL0STAT & 0x1F) + 1) /
(LPC_SC->CCLKSEL & 0x1F));
PeripheralFrequency = (IRC_OSC *
((LPC_SC->PLL0STAT & 0x1F) + 1) /
(LPC_SC->PCLKSEL & 0x1F));
break;
case 1: /* Main oscillator => PLL0 */
SystemFrequency = (OSC_CLK *
((LPC_SC->PLL0STAT & 0x1F) + 1) /
(LPC_SC->CCLKSEL & 0x1F));
PeripheralFrequency = (OSC_CLK *
((LPC_SC->PLL0STAT & 0x1F) + 1) /
(LPC_SC->PCLKSEL & 0x1F));
break;
}
} else {
switch (LPC_SC->CLKSRCSEL & 0x03) {
case 0: /* Internal RC oscillator => PLL0 */
SystemFrequency = IRC_OSC / (LPC_SC->CCLKSEL & 0x1F);
break;
case 1: /* Main oscillator => PLL0 */
SystemFrequency = OSC_CLK / (LPC_SC->CCLKSEL & 0x1F);
break;
}
}
}
windbg是windows下一个分析调试的工具,功能非常强大。这里主要记录利用windbg来分析windows蓝屏时所产生的内存转储文件*.dmp。
1,下载:
http://www.microsoft.com/whdc/devtools/debugging/default.mspx
2,配置symbol path:
windows程序在编译生成后,会产生一些.exe,dll文件。同时也会用到一些symbol文件,这些文件包含全局变量,局部变量等信息。在调试不同的系统的时候,用到的symbol是不同的,而且这些文件会很大,如果下载安装会占用很大的硬盘空间。如果下载,在上面提供的地址也可以下载。微软还提供了一个网络上的symbol服务器。其网络地址是:http://msdl.microsoft.com/download/symbols,设置symbol时可以在打开windbg后,file->symbol file path 设置如下:其d:\temp 是本地缓存的目录:SRV*d:/temp/*http://msdl.microsoft.com/download/symbols。也可以用命令如下设置:
set _NT_SYMBOL_PATH=srv*DownstreamStore*http://msdl.microsoft.com/download/symbols
利用windbg分析dump文件(二)基本调试1,打开dump文件,在正确设置了symbol路径后,会有如下的显示:
Microsoft (R) Windows Debugger Version 6.5.0003.7
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Dump File [D:\important\document\win系统\debug\Mini121605-01.dmp]
Mini Kernel Dump File: Only registers and stack trace are available
Symbol search path is: SRV*d:/temp/*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows 2000 Kernel Version 2195 (Service Pack 4) UP Free x86 compatible
Kernel base = 0x80400000 PsLoadedModuleList = 0x8046e8f0
Debug session time: Fri Dec 16 13:30:21.203 2005 (GMT+8)
System Uptime: not available
Loading Kernel Symbols
....................................................................................................................
Loading unloaded module list
...................
Loading User Symbols
*******************************************************************************
* *
*