Changeset 059529e in rtems


Ignore:
Timestamp:
Jul 21, 2016, 8:15:02 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
64ed0bb3
Parents:
3cdda03
git-author:
Sebastian Huber <sebastian.huber@…> (07/21/16 08:15:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/22/16 07:13:07)
Message:

score: Add debug support to chains

This helps to detect

  • double insert, append, prepend errors, and
  • get from empty chain errors.
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/malloc_deferred.c

    r3cdda03 r059529e  
    128128{
    129129  rtems_interrupt_lock_context lock_context;
     130  rtems_chain_node *node;
     131
     132  node = (rtems_chain_node *) p;
    130133
    131134  rtems_interrupt_lock_acquire( &_Malloc_GC_lock, &lock_context );
    132   rtems_chain_append_unprotected( &_Malloc_GC_list, (rtems_chain_node *) p );
     135  rtems_chain_initialize_node( node );
     136  rtems_chain_append_unprotected( &_Malloc_GC_list, node );
    133137  rtems_interrupt_lock_release( &_Malloc_GC_lock, &lock_context );
    134138}
  • cpukit/libcsupport/src/mount-mgr.c

    r3cdda03 r059529e  
    125125  rtems_libio_lock();
    126126  if ( rtems_filesystem_get_mount_handler( type ) == NULL ) {
     127    rtems_chain_initialize_node( &fsn->node );
    127128    rtems_chain_append_unprotected( chain, &fsn->node );
    128129  } else {
  • cpukit/libcsupport/src/printertask.c

    r3cdda03 r059529e  
    195195  printer_task_buffer buffer;
    196196
     197  rtems_chain_initialize_node( &buffer.node );
    197198  buffer.action_kind = ACTION_DRAIN;
    198199  buffer.action_data.task = rtems_task_self();
  • cpukit/libcsupport/src/sup_fs_location.c

    r3cdda03 r059529e  
    4949  dst->handlers = src->handlers;
    5050  dst->mt_entry = src->mt_entry;
     51  rtems_chain_initialize_node(&dst->mt_entry_node);
    5152  rtems_filesystem_location_add_to_mt_entry(dst);
    5253
  • cpukit/libcsupport/src/termios.c

    r3cdda03 r059529e  
    150150  }
    151151
     152  rtems_chain_initialize_node(&new_device_node->node);
    152153  new_device_node->major = major;
    153154  new_device_node->minor = minor;
  • cpukit/posix/src/aio_misc.c

    r3cdda03 r059529e  
    117117      r_chain = malloc (sizeof (rtems_aio_request_chain));
    118118      rtems_chain_initialize_empty (&r_chain->perfd);
     119      rtems_chain_initialize_node (&r_chain->next_fd);
    119120
    120121      if (rtems_chain_is_empty (chain))
     
    223224  while (!rtems_chain_is_tail (chain, node))
    224225    {
    225       rtems_chain_extract (node);
    226226      rtems_aio_request *req = (rtems_aio_request *) node;
    227227      node = rtems_chain_next (node);
     228      rtems_chain_extract (&req->next_prio);
    228229      req->aiocbp->error_code = ECANCELED;
    229230      req->aiocbp->return_value = -1;
     
    312313  pthread_getschedparam (pthread_self(), &policy, &param);
    313314
     315  rtems_chain_initialize_node (&req->next_prio);
    314316  req->caller_thread = pthread_self ();
    315317  req->priority = param.sched_priority - req->aiocbp->aio_reqprio;
  • cpukit/sapi/include/rtems/chain.h

    r3cdda03 r059529e  
    189189
    190190/**
     191 * @brief Initializes a chain node.
     192 *
     193 * In debug configurations, the node is set off chain.  In all other
     194 * configurations, this function does nothing.
     195 *
     196 * @param[in] the_node The chain node to initialize.
     197 */
     198RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node(
     199  rtems_chain_node *node
     200)
     201{
     202  _Chain_Initialize_node( node );
     203}
     204
     205/**
    191206 * @brief Is the node off chain.
    192207 *
  • cpukit/sapi/include/rtems/rbheap.h

    r3cdda03 r059529e  
    211211    rtems_rbheap_get_spare_descriptor_chain(control);
    212212
     213  rtems_chain_initialize_node(&chunk->chain_node);
    213214  rtems_chain_prepend_unprotected(chain, &chunk->chain_node);
    214215}
  • cpukit/sapi/src/rbheap.c

    r3cdda03 r059529e  
    7777)
    7878{
     79  rtems_chain_initialize_node(&chunk->chain_node);
    7980  rtems_chain_prepend_unprotected(chain, &chunk->chain_node);
    8081}
  • cpukit/score/include/rtems/score/chainimpl.h

    r3cdda03 r059529e  
    105105{
    106106  node->next = NULL;
     107#if defined(RTEMS_DEBUG)
     108  node->previous = NULL;
     109#endif
     110}
     111
     112/**
     113 * @brief Initializes a chain node.
     114 *
     115 * In debug configurations, the node is set off chain.  In all other
     116 * configurations, this function does nothing.
     117 *
     118 * @param[in] the_node The chain node to initialize.
     119 */
     120RTEMS_INLINE_ROUTINE void _Chain_Initialize_node( Chain_Node *the_node )
     121{
     122#if defined(RTEMS_DEBUG)
     123  _Chain_Set_off_chain( the_node );
     124#else
     125  (void) the_node;
     126#endif
    107127}
    108128
     
    520540  next->previous = previous;
    521541  previous->next = next;
     542
     543#if defined(RTEMS_DEBUG)
     544  _Chain_Set_off_chain( the_node );
     545#endif
    522546}
    523547
     
    541565)
    542566{
    543   Chain_Node *head = _Chain_Head( the_chain );
    544   Chain_Node *old_first = head->next;
    545   Chain_Node *new_first = old_first->next;
     567  Chain_Node *head;
     568  Chain_Node *old_first;
     569  Chain_Node *new_first;
     570
     571  _Assert( !_Chain_Is_empty( the_chain ) );
     572
     573  head = _Chain_Head( the_chain );
     574  old_first = head->next;
     575  new_first = old_first->next;
    546576
    547577  head->next = new_first;
    548578  new_first->previous = head;
     579
     580#if defined(RTEMS_DEBUG)
     581  _Chain_Set_off_chain( old_first );
     582#endif
    549583
    550584  return old_first;
     
    594628{
    595629  Chain_Node *before_node;
     630
     631  _Assert( _Chain_Is_node_off_chain( the_node ) );
    596632
    597633  the_node->previous    = after_node;
     
    618654)
    619655{
    620   Chain_Node *tail = _Chain_Tail( the_chain );
    621   Chain_Node *old_last = tail->previous;
     656  Chain_Node *tail;
     657  Chain_Node *old_last;
     658
     659  _Assert( _Chain_Is_node_off_chain( the_node ) );
     660
     661  tail = _Chain_Tail( the_chain );
     662  old_last = tail->previous;
    622663
    623664  the_node->next = tail;
     
    9791020)
    9801021{
     1022  _Chain_Initialize_node( &the_iterator->Registry_node );
    9811023  _Chain_Append_unprotected(
    9821024    &the_registry->Iterators,
  • cpukit/score/include/rtems/score/resourceimpl.h

    r3cdda03 r059529e  
    6060  node->dependency = NULL;
    6161  node->root = node;
     62  _Chain_Initialize_node( &node->Node );
    6263  _Chain_Initialize_empty( &node->Resources );
    6364}
     
    107108{
    108109  resource->owner = NULL;
     110  _Chain_Initialize_node( &resource->Node );
    109111  _Chain_Initialize_empty( &resource->Rivals );
    110112}
  • cpukit/score/include/rtems/score/schedulerpriorityimpl.h

    r3cdda03 r059529e  
    132132  if ( _Chain_Has_only_one_node( ready_chain ) ) {
    133133    _Chain_Initialize_empty( ready_chain );
     134    _Chain_Initialize_node( node );
    134135    _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
    135136  } else {
  • cpukit/score/include/rtems/score/threadqimpl.h

    r3cdda03 r059529e  
    123123
    124124  for ( i = 0; i < _Scheduler_Count; ++i ) {
     125    _Chain_Initialize_node( &heads->Priority[ i ].Node );
    125126    _RBTree_Initialize_empty( &heads->Priority[ i ].Queue );
    126127  }
     
    128129
    129130  _Chain_Initialize_empty( &heads->Free_chain );
     131  _Chain_Initialize_node( &heads->Free_node );
    130132}
    131133
  • cpukit/score/src/freechain.c

    r3cdda03 r059529e  
    7676{
    7777  if ( node != NULL ) {
     78    _Chain_Initialize_node( node );
    7879    _Chain_Prepend_unprotected( &freechain->Free, node );
    7980  }
  • cpukit/score/src/objectextendinformation.c

    r3cdda03 r059529e  
    266266    );
    267267
     268    _Chain_Initialize_node( &the_object->Node );
    268269    _Chain_Append_unprotected( &information->Inactive, &the_object->Node );
    269270
  • cpukit/score/src/threadqops.c

    r3cdda03 r059529e  
    100100)
    101101{
     102  _Chain_Initialize_node( &the_thread->Wait.Node.Chain );
    102103  _Chain_Append_unprotected(
    103104    &heads->Heads.Fifo,
  • testsuites/sptests/spchain/init.c

    r3cdda03 r059529e  
    4444
    4545  _Chain_Initialize_empty( &chain );
     46  _Chain_Initialize_node( &a );
     47  _Chain_Initialize_node( &b );
     48  _Chain_Initialize_node( &c );
    4649  _Chain_Iterator_registry_initialize( &reg );
    4750  _Chain_Iterator_initialize( &chain, &reg, &fit, CHAIN_ITERATOR_FORWARD );
     
    226229
    227230  rtems_chain_initialize_empty( &chain );
     231  rtems_chain_initialize_node( &node1 );
     232  rtems_chain_initialize_node( &node2 );
    228233  rtems_chain_append( &chain, &node1 );
    229234  rtems_chain_insert( &node1, &node2 );
     
    256261  puts( "INIT - Verify rtems_chain_append_with_notification" );
    257262  rtems_chain_initialize_empty( &chain );
     263  rtems_chain_initialize_node( &a );
    258264  sc = rtems_chain_append_with_notification(
    259265    &chain,
     
    268274
    269275  rtems_chain_initialize_empty( &chain );
     276  rtems_chain_initialize_node( &a );
     277  rtems_chain_initialize_node( &b );
    270278
    271279  rtems_chain_append( &chain, &b );
     
    281289  puts( "INIT - Verify rtems_chain_prepend_with_notification" );
    282290  rtems_chain_initialize_empty( &chain );
     291  rtems_chain_initialize_node( &a );
     292  rtems_chain_initialize_node( &b );
    283293  sc = rtems_chain_prepend_with_notification(
    284294    &chain,
     
    304314  puts( "INIT - Verify rtems_chain_get_with_notification" );
    305315  rtems_chain_initialize_empty( &chain );
     316  rtems_chain_initialize_node( &a );
     317  rtems_chain_initialize_node( &b );
    306318
    307319  rtems_chain_append( &chain, &b );
     
    330342  rtems_chain_node a;
    331343  rtems_chain_node b;
     344  rtems_chain_node c;
    332345  rtems_chain_node *p;
    333346  bool empty;
     
    335348  puts( "INIT - Verify rtems_chain_append_with_empty_check" );
    336349  rtems_chain_initialize_empty( &chain );
     350  rtems_chain_initialize_node( &a );
     351  rtems_chain_initialize_node( &b );
    337352  empty = rtems_chain_append_with_empty_check( &chain, &a );
    338353  rtems_test_assert( empty );
    339   empty = rtems_chain_append_with_empty_check( &chain, &a );
     354  empty = rtems_chain_append_with_empty_check( &chain, &b );
    340355  rtems_test_assert( !empty );
    341356
    342357  puts( "INIT - Verify rtems_chain_prepend_with_empty_check" );
    343358  rtems_chain_initialize_empty( &chain );
     359  rtems_chain_initialize_node( &a );
     360  rtems_chain_initialize_node( &b );
     361  rtems_chain_initialize_node( &c );
    344362  empty = rtems_chain_prepend_with_empty_check( &chain, &a );
    345363  rtems_test_assert( empty );
    346   empty = rtems_chain_prepend_with_empty_check( &chain, &a );
    347   rtems_test_assert( !empty );
    348364  empty = rtems_chain_prepend_with_empty_check( &chain, &b );
    349365  rtems_test_assert( !empty );
     366  empty = rtems_chain_prepend_with_empty_check( &chain, &c );
     367  rtems_test_assert( !empty );
    350368
    351369  puts( "INIT - Verify rtems_chain_get_with_empty_check" );
    352370  rtems_chain_initialize_empty( &chain );
     371  rtems_chain_initialize_node( &a );
     372  rtems_chain_initialize_node( &b );
    353373  empty = rtems_chain_get_with_empty_check( &chain, &p );
    354374  rtems_test_assert( empty );
     
    378398
    379399  for (i = 0; i < RTEMS_ARRAY_SIZE( nodes ); ++i) {
     400    rtems_chain_initialize_node( &nodes[ i ] );
    380401    rtems_chain_append_unprotected( &chain, &nodes[i] );
    381402    count = rtems_chain_node_count_unprotected( &chain );
     
    396417  const Chain_Node *node;
    397418  size_t n = RTEMS_ARRAY_SIZE( nodes );
    398   size_t i = 0;
     419  size_t i;
    399420
    400421  puts( "INIT - Verify _Chain_Insert_ordered_unprotected" );
     422
     423  for ( i = 0; i < n; ++i ) {
     424    _Chain_Initialize_node( &nodes[ i ] );
     425  }
    401426
    402427  _Chain_Insert_ordered_unprotected( &chain, &nodes[4], test_order );
     
    408433  tail = _Chain_Immutable_tail( &chain );
    409434  node = _Chain_Immutable_first( &chain );
     435  i = 0;
    410436  while ( node != tail && i < n ) {
    411437    rtems_test_assert( node == &nodes[ i ] );
     
    430456  puts( "Init - Initialize chain empty" );
    431457  rtems_chain_initialize_empty( &chain1 );
     458  rtems_chain_initialize_node( &node1.Node );
     459  rtems_chain_initialize_node( &node2.Node );
    432460
    433461  /* verify that the chain append and insert work */
Note: See TracChangeset for help on using the changeset viewer.