-2

通常、関数にパラメーターとして渡される構造データにアクセスしようとすると、いくつかの関数で実行時エラーが発生します。

問題の最初の例は次のとおりです。

signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const p\

vBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )

{

..............



if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TY\

PE ) 0 )



.......................



}

ここで、pxQueue は構造体です。

typedef xQUEUE * xQueueHandle;

と:

typedef struct QueueDefinition

{

        signed char *pcHead;                            /*< Points to the begin\

ning of the queue storage area. */

    signed char *pcTail;                            /*< Points to the byte \

at the end of the queue storage area.  Once more byte is allocated than necessa\

ry to store the queue items, this is used as a marker. */



        signed char *pcWriteTo;                         /*< Points to the free \

next place in the storage area. */

        signed char *pcReadFrom;  
                    /*< Points to the last \

place that a queued item was read from. */


        xList xTasksWaitingToSend;                              /*< List of tas\

ks that are blocked waiting to post onto this queue.  Stored in priority order.\

*/
        xList xTasksWaitingToReceive;                   /*< List of tasks that \

are blocked waiting to read from this queue.  Stored in priority order. */


        volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of ite\

ms currently in the queue. */
        unsigned portBASE_TYPE uxLength;                /*< The length of the q\

ueue defined as the number of items it will hold, not the number of bytes. */
        unsigned portBASE_TYPE uxItemSize;              /*< The size of each it\

ems that the queue will hold. */


        signed portBASE_TYPE xRxLock;                   /*< Stores the number o\

f items received from the queue (removed from the queue) while the queue was lo\

cked.  Set to queueUNLOCKED when the queue is not locked. */
        signed portBASE_TYPE xTxLock;                   /*< Stores the number o\

f items transmitted to the queue (added to the queue)

while the queue was locke\

d.  Set to qu.......................



}

ここで、pxQueue は構造体です。

typedef xQUEUE * xQueueHandle;

と:

typedef struct QueueDefinition

{

        signed char *pcHead;                            /*< Points to the begin\

ning of the queue storage area. */

    signed char *pcTail;                            /*< Points to the byte \

at the end of the queue storage area.  Once more byte is allocated than necessa\

ry to store the queue items, this is used as a marker. */



        signed char *pcWriteTo;                         /*< Points to the free \

next place in the storage area. */

        signed char *pcReadFrom;  
                    /*< Points to the last \

place that a queued item was read from. */


        xList xTasksWaitingToSend;                              /*< List of tas\

ks that are blocked waiting to post onto this queue.  Stored in priority order.\

*/
        xList xTasksWaitingToReceive;                   /*< List of tasks that \

are blocked waiting to read from this queue.  Stored in priority order. */


        volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of ite\

ms currently in the queue. */
        unsigned portBASE_TYPE uxLength;                /*< The length of the q\

ueue defined as the number of items it will hold, not the number of bytes. */
        unsigned portBASE_TYPE uxItemSize;              /*< The size of each it\

ems that the queue will hold. */


        signed portBASE_TYPE xRxLock;                   /*< Stores the number o\

f items received from the queue (removed from the queue) while the queue was lo\

cked.  Set to queueUNLOCKED when the queue is not locked. */
        signed portBASE_TYPE xTxLock;                   /*< Stores the number o\

f items transmitted to the queue (added to the queue)

while the queue was locke\

d.  Set to queueUNLOCKED when the queue is not locked. */



} xQUEUE;
eueUNLOCKED when the queue is not locked. */



} xQUEUE;

実行時エラーは次のとおりです。

.....
COREB: start xQueueGenericReceive                                           
COREB: execption 24 addr 3c00384                                            
COREB: coreb dump stack                                                     
COREB: found fp: ff700900                                                   
COREB:  call frame 0 -12 feb055e2                                           
COREB:  call frame 0 -11 00000000                                           
COREB:  call frame 0 -9 00000000                                            
COREB:  call frame 0 -8 ff7008d0    

......

同様に、次の関数にも同じ問題があります。

void vListRemove( xListItem *pxItemToRemove )

{

xList * pxList;



   pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;

        pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;

}

pxItemToRemove->pxPrevious は読み取れますが、pxItemToRemove->pxNext->pxPrevious は読み取れません

その構造は次のとおりです。

struct xLIST_ITEM

{

     portTickType xItemValue;                                /*< The value b\

eing listed.  In most cases this is used to sort the list in descending order. \

*/

        volatile struct xLIST_ITEM * pxNext;    /*< Pointer to the next xListIt\

em in the list. */

        volatile struct xLIST_ITEM * pxPrevious;/*< Pointer to the previous xLi\

stItem in the list. */

        void * pvOwner;                                                 /*< Poi\

nter to the object (normally a TCB) that contains the list item.  There is ther\

efore a two way link between the object containing the list item and the list i\

tem itself. */

        void * pvContainer;                                             /*< Poi\

nter to the list in which this list item is placed (if any). */

};

typedef struct xLIST_ITEM xListItem;            /* For some reason lint wants t\

his as two separate definitions. */

実行時エラーは次のとおりです。

COREB: got to vTaskDelete                                                   
COREB: pxTCB GLI prev: a5a5a5a5                                             
COREB: sent to list: 3d02004                                                
COREB: list_rem px prev: a5a5a5a5                                           
COREB: execption 24 addr 3c05444                                            
COREB: coreb dump stack                                                     
COREB: found fp: ff7008fc                                                   
COREB:  call frame 0 -12 feb055e2                                           
COREB:  call frame 0 -11 00000000                                           
COREB:  call frame 0 -9 00000000                                            
COREB:  call frame 0 -8 ff7008cc                                            
COREB:  call frame 0 -7 ff700ff4    

前もって感謝します。

ウィリアム


gdb を使用してさらにデバッグすると、pxQueue があります。

p/x *pxQueue

$9 = {pcHead = 0xadadadad, pcTail = 0xadadadad, pcWriteTo = 0xadadadad,

  pcReadFrom = 0xadadadad, xTasksWaitingToSend = {

    uxNumberOfItems = 0xadadadad, pxIndex = 0xadadadad, xListEnd = {

      xItemValue = 0xadad, pxNext = 0xadadadad, pxPrevious = 0xadadadad}},

  xTasksWaitingToReceive = {uxNumberOfItems = 0xadadadad,

    pxIndex = 0xadadadad, xListEnd = {xItemValue = 0xadad,

      pxNext = 0xadadadad, pxPrevious = 0xadadadad}},

  uxMessagesWaiting = 0xadadadad, uxLength = 0xadadadad,

  uxItemSize = 0xadadadad, xRxLock = 0xadadadad, xTxLock = 0xadadadad}

本当に奇妙です。構造体のすべてのパラメーターが同じ値を持っています: 0xadadadad

さらにデバッグして、セマフォの作成をキュー作成関数のキュー オブジェクトとして見ると、通常の値が得られます。

 p *pxNewQueue

$7 = {pcHead = 0x3d17000 "", pcTail = 0x3d17000 "", pcWriteTo = 0x3d17000 "", 

  pcReadFrom = 0x3d17000 "", xTasksWaitingToSend = {uxNumberOfItems = 0, 

    pxIndex = 0x3d16018, xListEnd = {xItemValue = 65535, pxNext = 0x3d16018, 

      pxPrevious = 0x3d16018}}, xTasksWaitingToReceive = {uxNumberOfItems = 0, 

    pxIndex = 0x3d1602c, xListEnd = {xItemValue = 65535, pxNext = 0x3d1602c, 

      pxPrevious = 0x3d1602c}}, uxMessagesWaiting = 0, uxLength = 1, 

  uxItemSize = 0, xRxLock = -1, xTxLock = -1}

ありがとう、

ウィリアム

4

2 に答える 2

0

私は答えを見つけました、

基本的に、FreeRTOSにはそれに関するドキュメントがなかったため、gdbを使用して、タスクの作成中にpvParameterを探し、スタックのどこに格納されているかを調べました。次に、taskhook関数を使用してタスクをトリガーすると、パラメーターが返されます。

void *param = *(pxCurrentTCB->pxTopOfStack+31);

                //        xTaskCallApplicationTaskHook( pxCurrentTCB, pxCurrent\
TCB->pxTopOfStack);                                                             
                xTaskCallApplicationTaskHook( pxCurrentTCB,param );

次に、semaforのキューとlisが呼び出されると、正しいアドレスを指します。データ構造が取得されます。

于 2012-03-14T11:36:21.023 に答える
0

何をしようとしているのか、どのようにしようとしているのか。コアブとは?

コードのスニペットを投稿した関数は、公式の FreeRTOS コードから変更されていませんか? 通常、コードはコンパイルされて実行可能ファイルにリンクされるため、このような実行時エラーは発生しません。問題が発生した場合、コンパイル/リンク エラーのみが発生します。実行時エラーが発生した場合、コードをコンパイルするのではなく解釈しようとしていますか?

于 2012-02-07T09:40:17.957 に答える