/* * dump_section - dump the current section */ void Dump_section( void ) /***********************/ { section_dbg_header sdh; Wread( &sdh, sizeof( section_dbg_header ) ); Wdputs( "Section " ); Putdec( sdh.section_id ); Wdputs( " (off=" ); Puthex( Curr_sectoff, 8 ); Wdputslc( ")\n" ); Wdputslc( "=========================\n" ); Dump_header( (char *)&sdh.mod_offset, sdh_msg ); Wdputslc( "\n" ); currSect = sdh.section_id; if( Debug_options & MODULE_INFO ) { dump_module_info( &sdh ); } if( Debug_options & GLOBAL_INFO ) { dump_global_info( &sdh ); } if( Debug_options & ADDR_INFO ) { dump_addr_info( &sdh ); } } /* dump_section */
/* * @brief register module to be monitored by daemon * this api should not be called before monitor_init() * @param attr -i- module attribute for registration * callback_fn -i- callback function (optional) * @return module id (a positive number) if success * @node the id returned has nothing to do with its position in the * logical linked list, but the position in the memory pool */ INT32 M_DAEMON_RegisterModule(struct M_DAEMON_ModAttr_t *p_attr, M_DAEMON_Callback callback_fn) { HRESULT ret = E_FAIL; struct mp_node_t *p_node = NULL; M_DAEMON_PRINT(LOG_WARN, "enter, name: %s, timeout: %d\n", p_attr->name, p_attr->timeout); #ifndef __BIONIC__ if (strcmp(p_attr->name, "monitord") != 0) { shmid = mp_shm_alloc(&h_mem, PUBLIC_SHM_KEY, MODULE_NUMBER_MAX); M_DAEMON_ASSERT(h_mem != NULL); M_DAEMON_PRINT(LOG_INFO, "shmid: %d, h_mem: %p\n", shmid, h_mem); semid = mp_sem_create(PUBLIC_SEM_KEY); M_DAEMON_ASSERT(semid != -1); M_DAEMON_PRINT(LOG_INFO, "semid: %d\n", semid); } #endif p_node = mp_new_node_of(h_mem); if (p_node == NULL) return 0; #ifndef __BIONIC__ ret = mp_sem_acquire(semid); M_DAEMON_ASSERT(ret == 0); #endif strcpy(p_node->data.attr.name, p_attr->name); if (callback_fn == NULL) p_node->data.attr.timeout = p_attr->timeout; else p_node->data.attr.timeout = DEFAULT_TIMEOUT; p_node->data.attr.type = p_attr->type; p_node->data.mid = p_node->node_id; p_node->data.callback_fn = callback_fn; p_node->data.time = get_clock(); p_node->data.ready = 1; #ifndef __BIONIC__ ret = mp_sem_release(semid); M_DAEMON_ASSERT(ret == 0); #endif dump_module_info(&p_node->data); mp_update_pool(h_mem); mp_dump_pool(h_mem); M_DAEMON_PRINT(LOG_WARN, "leave, this time = %llu\n", p_node->data.time); return p_node->data.mid; }