zoukankan      html  css  js  c++  java
  • WinCE: prefetch abort

    prefetch abort 是一类比较难解决的问题,因为很难定位出错的位置。

    更奇怪的是:程序单独运行就会出错,使用VS2008按 F5 运行就不会出错。更不用想单步调试了,也不会出错啦!

    类似于 Data Abort 的错误,prefetch abort 可能的原因有:

    1)操作过程中有Bug,内容被修改;

    2)内存重新映射以后,出错的地址处的内容没有初始化;arm,linux,winbond,nuvoton,w90p710,w90n745, 开源,嵌入式,操作系统,嵌入式开发,嵌入式联盟,linux,ecos,uclinux,t- kernel,freeos,rtems,ucos,skyeye,  y1 p) [1 d0 F, ]/ T2 K- W  - 我们只做简洁、实用、专业的嵌入式开发技术论坛。0 m2 `# m& a- d2 H3 P8 n  3)PC指针无效;

    在网上查找到有这样一篇文章:

    Windows CE: Prefetch Aborts, why they are difficult to locate

    转载其内容:

    Prefetch aborts can be difficult to locate and fix.  To understand why, we first need to understand what a prefetch abort is.  A prefetch abort occurs when the CPU runs out of instructions in its pipeline.  But that can also mean that a zero instruction is in the pipeline.

    Possible causes of prefetch aborts:

    1. The CPU really can't get instructions to run.  This could indicate a hardware problem.
    2. An uninitialized function pointer.  I have seen this used as a way to indicate a problem, although I can think of better ways to indicate problems.  This can also be a bug in the code.
    1 void CausePrefetchPointerAbort()  
    2 {  
    3      // declare a function pointer and set it to NULL  
    4      DWORD (* BadFunction)() = NULL;  
    5      // dereference the NULL function pointer (setting the PC to zero  
    6      BadFunction();  
    7 }  
      1. Causes the following debug output:
        Prefetch Abort: Thread=8339d4a8 Proc=81327730 'SDMenu.exe' AKY=00000021 PC=00000000(???+0x00000000) RA=00011a58(SDMenu.exe+0x00001a58) BVA= 00000000 FSR=000004f0
        Notice that the Program Counter (PC) is zero, which should never happen.  But the good news is that the Return Address (RA) is telling us where the code last was.  So this abort message does give us something to go on to find the problem.
      2. Stack overrun, or corrupted stack.
        Writting code to demonstrate this is a challenge becuase the compiler's job is to optimize out code that doesn't do anything.  So the following two functions will cause the prefetch abort.  The reason for the two functions is to trick the compiler into createing the necessary assembly code.
        This set of functions will cause a prefetch abort by corrupting the stack:.
     1 DWORD SetToZero( DWORD *Param )  
     2 {  
     3      *Param = 0;  
     4      RETAILMSG( 1, (TEXT("Param %X %d"), Param, *Param ));  
     5 }  
     6 void CausePrefetchStackAbort( int Count )  
     7 {  
     8      DWORD *Array;  
     9      int Index;  
    10      RETAILMSG( 1, (TEXT("Start CausePrefetchStackAbort( %d )/n"), Count));  
    11      // set the ponter to the address of index which is on the stack.  I tried to use an array  
    12      // but the compiler put it into global variables instead of the stack.  
    13      Array = &Index;  
    14      // Loop through Count DWORDS and set the data to zero.  This data is on the stack  
    15      // so we are clearing the stack.  
    16      for( Index = 0; Index < Count; Index++ )  
    17      {  
    18          SetToZero( Array );  
    19          Array++;  
    20      }  
    21      RETAILMSG( 1, (TEXT("returning CausePrefetchStackAbort( %d )/n"), Count));  
    22 }  
    1. When it runs, the following abort occurs.  Notice the PC is zero again. Notice that the RETAILMSG at the end of CausePrefetchStackAbort() is displayed, just before the return address is popped off the stack.
      returning CausePrefetchStackAbort( 500 ) Prefetch Abort: Thread=8339d550 Proc=81327730 '' AKY=00000021 PC=00000000(???+0x00000000) RA=00000000(???+0x00000000) BVA=0000000 0 FSR=000004f0

    So the problem with prefetch aborts is that the abort message doesn't always give much to go on to track back to the cause.  When it does, we can use that to find the problem in the code.  I will cover that in a post on Data Aborts soon.

  • 相关阅读:
    用bower命令创建项目
    HBuilder打包ios应用
    响应式布局--引入外部样式
    手机中点击链接或button按钮出现黄色边框的解决办法
    通过输入卡号前10位数字判断是哪个银行的卡和类型(储蓄卡or信用卡)
    只允许输入数字和小数点
    python中的实例方法、静态方法、类方法、类变量和实例变量浅析
    python中的实例方法、静态方法、类方法、类变量和实例变量浅析
    python导入csv文件出现SyntaxError问题分析
    python导入csv文件出现SyntaxError问题分析
  • 原文地址:https://www.cnblogs.com/91program/p/5208713.html
Copyright © 2011-2022 走看看