Ignore:
Timestamp:
Nov 10, 2018, 2:16:38 PM (5 years ago)
Author:
alain
Message:

Cosmetic: improve debug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/thread.c

    r583 r593  
    124124// It updates the local DQDT.
    125125/////////////////////////////////////////////////////////////////////////////////////
    126 // @ thread       : pointer on thread descriptor
    127 // @ process      : pointer on process descriptor.
     126// @ thread       : pointer on local thread descriptor
     127// @ process      : pointer on local process descriptor.
    128128// @ type         : thread type.
    129129// @ func         : pointer on thread entry function.
     
    148148
    149149#if DEBUG_THREAD_INIT
    150 uint32_t cycle = (uint32_t)hal_get_cycles();
     150uint32_t   cycle = (uint32_t)hal_get_cycles();
     151thread_t * this  = CURRENT_THREAD;
    151152if( DEBUG_THREAD_INIT < cycle )
    152 printk("\n[DBG] %s : thread %x in process %x enter fot thread %x in process %x / cycle %d\n",
    153 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
    154  thread, process->pid , cycle );
     153printk("\n[%s] thread[%x,%x] enter for thread %x in process %x / cycle %d\n",
     154__FUNCTION__, this->process->pid, this->trdid, thread, process->pid , cycle );
    155155#endif
    156156
     
    229229cycle = (uint32_t)hal_get_cycles();
    230230if( DEBUG_THREAD_INIT < cycle )
    231 printk("\n[DBG] %s : thread %x in process %x exit for thread %x in process %x / cycle %d\n",
    232 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
    233 thread, process->pid , cycle );
     231printk("\n[%s] thread[%x,%x] exit for thread %x in process %x / cycle %d\n",
     232__FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );
    234233#endif
    235234
     
    251250    vseg_t       * vseg;         // stack vseg
    252251
    253     assert( (attr != NULL) , "pthread attributes must be defined" );
     252assert( (attr != NULL) , "pthread attributes must be defined" );
    254253
    255254#if DEBUG_THREAD_USER_CREATE
    256 uint32_t cycle = (uint32_t)hal_get_cycles();
     255thread_t * this  = CURRENT_THREAD;
     256uint32_t   cycle = (uint32_t)hal_get_cycles();
    257257if( DEBUG_THREAD_USER_CREATE < cycle )
    258 printk("\n[DBG] %s : thread %x in process %x enter in cluster %x / cycle %d\n",
    259 __FUNCTION__, CURRENT_THREAD->trdid, pid , local_cxy , cycle );
     258printk("\n[%s] thread[%x,%x] enter in cluster %x for process %x / cycle %d\n",
     259__FUNCTION__, this->process->pid , this->trdid , local_cxy , pid , cycle );
    260260#endif
    261261
     
    272272#if( DEBUG_THREAD_USER_CREATE & 1)
    273273if( DEBUG_THREAD_USER_CREATE < cycle )
    274 printk("\n[DBG] %s : process descriptor = %x for process %x in cluster %x\n",
     274printk("\n[%s] process descriptor = %x for process %x in cluster %x\n",
    275275__FUNCTION__, process , pid , local_cxy );
    276276#endif
     
    294294#if( DEBUG_THREAD_USER_CREATE & 1)
    295295if( DEBUG_THREAD_USER_CREATE < cycle )
    296 printk("\n[DBG] %s : core[%x,%d] selected\n",
     296printk("\n[%s] core[%x,%d] selected\n",
    297297__FUNCTION__, local_cxy , core_lid );
    298298#endif
     
    316316#if( DEBUG_THREAD_USER_CREATE & 1)
    317317if( DEBUG_THREAD_USER_CREATE < cycle )
    318 printk("\n[DBG] %s : stack vseg created / vpn_base %x / %d pages\n",
     318printk("\n[%s] stack vseg created / vpn_base %x / %d pages\n",
    319319__FUNCTION__, vseg->vpn_base, vseg->vpn_size );
    320320#endif
     
    332332#if( DEBUG_THREAD_USER_CREATE & 1)
    333333if( DEBUG_THREAD_USER_CREATE < cycle )
    334 printk("\n[DBG] %s : new thread descriptor %x allocated\n",
     334printk("\n[%s] new thread descriptor %x allocated\n",
    335335__FUNCTION__, thread );
    336336#endif
     
    355355#if( DEBUG_THREAD_USER_CREATE & 1)
    356356if( DEBUG_THREAD_USER_CREATE < cycle )
    357 printk("\n[DBG] %s : new thread descriptor initialised / trdid %x\n",
     357printk("\n[%s] new thread descriptor initialised / trdid %x\n",
    358358__FUNCTION__, thread->trdid );
    359359#endif
     
    387387#if( DEBUG_THREAD_USER_CREATE & 1)
    388388if( DEBUG_THREAD_USER_CREATE < cycle )
    389 printk("\n[DBG] %s : CPU & FPU contexts created\n",
     389printk("\n[%s] CPU & FPU contexts created\n",
    390390__FUNCTION__, thread->trdid );
    391391vmm_display( process , true );
     
    395395cycle = (uint32_t)hal_get_cycles();
    396396if( DEBUG_THREAD_USER_CREATE < cycle )
    397 printk("\n[DBG] %s : thread %x in process %x exit / new_thread %x / core %d / cycle %d\n",
    398 __FUNCTION__, CURRENT_THREAD->trdid , pid, thread->trdid, core_lid, cycle );
     397printk("\n[%s] thread[%x,%x] exit / new_thread %x / core %d / cycle %d\n",
     398__FUNCTION__, this->process->pid , this->trdid , thread->trdid, core_lid, cycle );
    399399#endif
    400400
     
    430430
    431431#if DEBUG_THREAD_USER_FORK
    432 uint32_t cycle = (uint32_t)hal_get_cycles();
     432uint32_t   cycle = (uint32_t)hal_get_cycles();
     433thread_t * this  = CURRENT_THREAD;
    433434if( DEBUG_THREAD_USER_FORK < cycle )
    434 printk("\n[DBG] %s : thread %x in process %x enter / child_process %x / cycle %d\n",
    435 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_process->pid, cycle );
     435printk("\n[%s] thread[%x,%x] enter / child_process %x / cycle %d\n",
     436__FUNCTION__, this->process->pid, this->trdid, child_process->pid, cycle );
    436437#endif
    437438
     
    487488#if (DEBUG_THREAD_USER_FORK & 1)
    488489if( DEBUG_THREAD_USER_FORK < cycle )
    489 printk("\n[DBG] %s : thread %x in process %x / initialised thread %x in process %x\n",
    490 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
    491 child_ptr->trdid, child_process->pid );
     490printk("\n[%s] thread[%x,%x] initialised thread %x in process %x\n",
     491__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
    492492#endif
    493493
     
    522522#if (DEBUG_THREAD_USER_FORK & 1)
    523523if( DEBUG_THREAD_USER_FORK < cycle )
    524 printk("\n[DBG] %s : thread %x in process %x / created CPU & FPU contexts\n",
    525 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     524printk("\n[%s] thread[%x,%x] created CPU & FPU contexts for thread %x in process %x\n",
     525__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
    526526#endif
    527527
     
    542542#if (DEBUG_THREAD_USER_FORK & 1)
    543543if( DEBUG_THREAD_USER_FORK < cycle )
    544 printk("\n[DBG] %s : thread %x in process %x / created stack vseg\n",
    545 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     544printk("\n[%s] thread[%x,%x] created stack vseg for thread %x in process %x\n",
     545__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
    546546#endif
    547547
     
    591591cycle = (uint32_t)hal_get_cycles();
    592592if( DEBUG_THREAD_USER_FORK < cycle )
    593 printk("\n[DBG] %s : thread %x in process %x copied one PTE to child GPT : vpn %x / forks %d\n",
    594 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, vpn,
    595 hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) );
     593printk("\n[%s] thread[%x,%x] copied one PTE to child GPT : vpn %x / forks %d\n",
     594__FUNCTION__, this->process->pid, this->trdid,
     595vpn, hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) );
    596596#endif
    597597
     
    607607cycle = (uint32_t)hal_get_cycles();
    608608if( DEBUG_THREAD_USER_FORK < cycle )
    609 printk("\n[DBG] %s : thread %x in process %x exit / child_thread %x / cycle %d\n",
    610 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_ptr, cycle );
     609printk("\n[%s] thread[%x,%x] exit / child_thread %x / cycle %d\n",
     610__FUNCTION__, this->process->pid, this->trdid, child_ptr, cycle );
    611611#endif
    612612
     
    626626uint32_t cycle = (uint32_t)hal_get_cycles();
    627627if( DEBUG_THREAD_USER_EXEC < cycle )
    628 printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
    629 __FUNCTION__, thread->trdid, process->pid, cycle );
     628printk("\n[%s] thread[%x,%x] enter / cycle %d\n",
     629__FUNCTION__, process->pid, thread->trdid, cycle );
    630630#endif
    631631
     
    688688cycle = (uint32_t)hal_get_cycles();
    689689if( DEBUG_THREAD_USER_EXEC < cycle )
    690 printk("\n[DBG] %s : thread %x in process %x set CPU context & jump to user code / cycle %d\n",
    691 __FUNCTION__, thread->trdid, process->pid, cycle );
     690printk("\n[%s] thread[%x,%x] set CPU context & jump to user code / cycle %d\n",
     691__FUNCTION__, process->pid, thread->trdid, cycle );
    692692vmm_display( process , true );
    693693#endif
     
    712712        thread_t     * thread;       // pointer on new thread descriptor
    713713
    714     assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
    715     "illegal thread type" );
    716 
    717     assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
    718     "illegal core_lid" );
     714    thread_t * this = CURRENT_THREAD;
     715
     716assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
     717"illegal thread type" );
     718
     719assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
     720"illegal core_lid" );
    719721
    720722#if DEBUG_THREAD_KERNEL_CREATE
    721 uint32_t cycle = (uint32_t)hal_get_cycles();
     723uint32_t   cycle = (uint32_t)hal_get_cycles();
    722724if( DEBUG_THREAD_KERNEL_CREATE < cycle )
    723 printk("\n[DBG] %s : thread %x enter / requested_type %s / cycle %d\n",
    724 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
     725printk("\n[%s] thread[%x,%x] enter / requested_type %s / cycle %d\n",
     726__FUNCTION__, this->process->pid, this->trdid, thread_type_str(type), cycle );
    725727#endif
    726728
     
    732734        printk("\n[ERROR] in %s : thread %x in process %x\n"
    733735        "   no memory for thread descriptor\n",
    734         __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     736        __FUNCTION__, this->trdid, this->process->pid );
    735737        return ENOMEM;
    736738    }
     
    749751        printk("\n[ERROR] in %s : thread %x in process %x\n"
    750752        "   cannot initialize thread descriptor\n",
    751         __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     753        __FUNCTION__, this->trdid, this->process->pid );
    752754        thread_release( thread );
    753755        return ENOMEM;
     
    760762    {
    761763        printk("\n[ERROR] in %s : thread %x in process %x\n"
    762         "   cannot cannot create CPU context\n",
    763         __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     764        "    cannot create CPU context\n",
     765        __FUNCTION__, this->trdid, this->process->pid );
    764766        thread_release( thread );
    765767        return EINVAL;
     
    774776cycle = (uint32_t)hal_get_cycles();
    775777if( DEBUG_THREAD_KERNEL_CREATE < cycle )
    776 printk("\n[DBG] %s : thread %x exit / new_thread %x / type %s / cycle %d\n",
    777 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
     778printk("\n[%s] thread[%x,%x] exit / new_thread %x / type %s / cycle %d\n",
     779__FUNCTION__, this->process->pid, this->trdid, thread, thread_type_str(type), cycle );
    778780#endif
    779781
     
    830832thread_t * this  = CURRENT_THREAD;
    831833if( DEBUG_THREAD_DESTROY < cycle )
    832 printk("\n[DBG] %s : thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n",
     834printk("\n[%s] thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n",
    833835__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    834836#endif
     
    862864cycle = (uint32_t)hal_get_cycles();
    863865if( DEBUG_THREAD_DESTROY < cycle )
    864 printk("\n[DBG] %s : thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n",
     866printk("\n[%s] thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n",
    865867__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    866868#endif
     
    944946uint32_t    cycle   = (uint32_t)hal_get_cycles();
    945947process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) );
     948thread_t  * this    = CURRENT_THREAD;
    946949if( DEBUG_THREAD_BLOCK < cycle )
    947 printk("\n[DBG] %s : thread %x in process %x blocked thread %x in process %x / cause %x\n",
    948 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     950printk("\n[%s] thread[%x,%x] blocked thread %x in process %x / cause %x\n",
     951__FUNCTION__, this->process->pid, this->trdid,
    949952ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause );
    950953#endif
     
    967970uint32_t    cycle   = (uint32_t)hal_get_cycles();
    968971process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) );
     972thread_t  * this    = CURRENT_THREAD;
    969973if( DEBUG_THREAD_BLOCK < cycle )
    970 printk("\n[DBG] %s : thread %x in process %x unblocked thread %x in process %x / cause %x\n",
    971 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     974printk("\n[%s] thread[%x,%x] unblocked thread %x in process %x / cause %x\n",
     975__FUNCTION__, this->process->pid, this->trdid,
    972976ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause );
    973977#endif
     
    10161020uint32_t cycle  = (uint32_t)hal_get_cycles();
    10171021if( DEBUG_THREAD_DELETE < cycle )
    1018 printk("\n[DBG] %s : killer[%x,%x] enters / target[%x,%x] / cycle %d\n",
     1022printk("\n[%s] killer[%x,%x] enters / target[%x,%x] / cycle %d\n",
    10191023__FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 
    10201024target_ptr->process->pid, target_ptr->trdid, cycle );
     
    10751079cycle  = (uint32_t)hal_get_cycles;
    10761080if( DEBUG_THREAD_DELETE < cycle )
    1077 printk("\n[DBG] %s : killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
     1081printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
    10781082__FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
    10791083target_ptr->process->pid, target_ptr->trdid, cycle );
     
    10981102cycle  = (uint32_t)hal_get_cycles;
    10991103if( DEBUG_THREAD_DELETE < cycle )
    1100 printk("\n[DBG] %s : killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n",
     1104printk("\n[%s] killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n",
    11011105__FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
    11021106target_ptr->process->pid, target_ptr->trdid, cycle );
     
    11171121cycle  = (uint32_t)hal_get_cycles;
    11181122if( DEBUG_THREAD_DELETE < cycle )
    1119 printk("\n[DBG] %s : killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
     1123printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
    11201124__FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
    11211125target_ptr->process->pid, target_ptr->trdid, cycle );
     
    11351139cycle  = (uint32_t)hal_get_cycles;
    11361140if( DEBUG_THREAD_DELETE < cycle )
    1137 printk("\n[DBG] %s : killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n",
     1141printk("\n[%s] killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n",
    11381142__FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
    11391143target_ptr->process->pid, target_ptr->trdid, cycle );
     
    11411145
    11421146    }
    1143 
    11441147}  // end thread_delete()
    11451148
     
    11621165uint32_t cycle = (uint32_t)hal_get_cycles();
    11631166if( DEBUG_THREAD_IDLE < cycle )
    1164 printk("\n[DBG] %s : idle thread on core[%x,%d] goes to sleep / cycle %d\n",
     1167printk("\n[%s] idle thread on core[%x,%d] goes to sleep / cycle %d\n",
    11651168__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle );
    11661169}
     
    11731176uint32_t cycle = (uint32_t)hal_get_cycles();
    11741177if( DEBUG_THREAD_IDLE < cycle )
    1175 printk("\n[DBG] %s : idle thread on core[%x,%d] wake up / cycle %d\n",
     1178printk("\n[%s] idle thread on core[%x,%d] wake up / cycle %d\n",
    11761179__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle );
    11771180}
     
    12371240thread_t * this = CURRENT_THREAD;
    12381241if( DEBUG_THREAD_GET_XPTR < cycle )
    1239 printk("\n[DBG] %s : thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",
     1242printk("\n[%s] thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",
    12401243__FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
    12411244#endif
     
    12621265#if( DEBUG_THREAD_GET_XPTR & 1 )
    12631266if( DEBUG_THREAD_GET_XPTR < cycle )
    1264 printk("\n[DBG]  %s : scan processes in cluster %x :\n", __FUNCTION__, target_cxy );
     1267printk("\n[%s] scan processes in cluster %x :\n", __FUNCTION__, target_cxy );
    12651268#endif
    12661269
     
    12951298#if( DEBUG_THREAD_GET_XPTR & 1 )
    12961299if( DEBUG_THREAD_GET_XPTR < cycle )
    1297 printk("\n[DBG] %s : pid %x not found in cluster %x\n",
     1300printk("\n[%s] pid %x not found in cluster %x\n",
    12981301__FUNCTION__, pid, target_cxy );
    12991302#endif
     
    13101313#if( DEBUG_THREAD_GET_XPTR & 1 )
    13111314if( DEBUG_THREAD_GET_XPTR < cycle )
    1312 printk("\n[DBG] %s : thread %x not registered in process %x in cluster %x\n",
     1315printk("\n[%s] thread %x not registered in process %x in cluster %x\n",
    13131316__FUNCTION__, trdid, pid, target_cxy );
    13141317#endif
     
    13191322cycle  = (uint32_t)hal_get_cycles();
    13201323if( DEBUG_THREAD_GET_XPTR < cycle )
    1321 printk("\n[DBG] %s : thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",
     1324printk("\n[%s] thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",
    13221325__FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
    13231326#endif
     
    13471350
    13481351        // display error message on TXT0
    1349         nolock_printk("\n[PANIC] in %s / thread %x in process %x [%x] cannot yield : "
     1352        nolock_printk("\n[PANIC] in %s / thread[%x,%x] cannot yield : "
    13501353        "hold %d busylock(s) / cycle %d\n",
    1351         func_str, thread->trdid, thread->process->pid, thread,
     1354        func_str, thread->process->pid, thread->trdid,
    13521355        thread->busylocks, (uint32_t)hal_get_cycles() );
    13531356
Note: See TracChangeset for help on using the changeset viewer.