FacadeImpl::~FacadeImpl() { LogTraceObjLn(); HostFree(heap_type, m_dir); HostFree(heap_type, m_ppi); }
traceback::Bfd::Context::~Context() { if (image) LogTraceObj(L"[%s]", image); HostFree(memory::heap::DefaultStat, symbol); if (handle) bfd_close(handle); HostFree(memory::heap::DefaultStat, image); }
static int HostBitTest11 (void) { int ret = 0; HostInitConfig(TRUE); Host *h = HostAlloc(); if (h == NULL) goto end; HostBitAdd(h, 0, 90); HostBitAdd(h, 1, 90); HostBitAdd(h, 2, 90); HostBitAdd(h, 3, 90); XBit *fb = HostBitGet(h,3); if (fb == NULL) goto end; HostBitRemove(h,3); fb = HostBitGet(h,3); if (fb != NULL) { printf("fb != NULL even though it was removed: "); goto end; } ret = 1; HostFree(h); end: HostCleanup(); return ret; }
static int HostBitTest03 (void) { int ret = 0; HostInitConfig(TRUE); Host *h = HostAlloc(); if (h == NULL) goto end; HostBitAdd(h, 0, 30); XBit *fb = HostBitGet(h,0); if (fb == NULL) { printf("fb == NULL although it was just added: "); goto end; } HostBitRemove(h, 0); fb = HostBitGet(h,0); if (fb != NULL) { printf("fb != NULL although it was just removed: "); goto end; } else { ret = 1; } HostFree(h); end: HostCleanup(); return ret; }
/** \brief shutdown the flow engine * \warning Not thread safe */ void HostShutdown(void) { Host *h; uint32_t u; HostPrintStats(); /* free spare queue */ while((h = HostDequeue(&host_spare_q))) { BUG_ON(SC_ATOMIC_GET(h->use_cnt) > 0); HostFree(h); } /* clear and free the hash */ if (host_hash != NULL) { for (u = 0; u < host_config.hash_size; u++) { Host *h = host_hash[u].head; while (h) { Host *n = h->hnext; HostClearMemory(h); HostFree(h); h = n; } HRLOCK_DESTROY(&host_hash[u]); } SCFree(host_hash); host_hash = NULL; } (void) SC_ATOMIC_SUB(host_memuse, host_config.hash_size * sizeof(HostHashRow)); HostQueueDestroy(&host_spare_q); SC_ATOMIC_DESTROY(host_prune_idx); SC_ATOMIC_DESTROY(host_memuse); SC_ATOMIC_DESTROY(host_counter); //SC_ATOMIC_DESTROY(flow_flags); return; }
static int HostBitTest02 (void) { int ret = 0; HostInitConfig(TRUE); Host *h = HostAlloc(); if (h == NULL) goto end; XBit *fb = HostBitGet(h,0); if (fb == NULL) ret = 1; HostFree(h); end: HostCleanup(); return ret; }
bool FrameImpl::LoadFromPDB(void* address) { TraceFunc(); LogTraceLn(); bool ret = false; { size_t size = sizeof(SYMBOL_INFOW) + MAX_SYM_NAME * sizeof(wchar_t); SYMBOL_INFOW* symInfo = static_cast<SYMBOL_INFOW*>(HostAlloc(memory::heap::DefaultStat, size)); memory::zero(symInfo, sizeof(*symInfo)); symInfo->SizeOfStruct = sizeof(*symInfo); symInfo->MaxNameLen = MAX_SYM_NAME; DWORD64 displacement; bool res = os::Dbghelp_dll::inst().SymFromAddrW(::GetCurrentProcess(), reinterpret_cast<DWORD64>(address), &displacement, symInfo); LogWarnIf(!res, L"%s\n", totext::api_error().c_str()); if (res) { m_address = reinterpret_cast<void*>(symInfo->Address); m_function = symInfo->Name; m_offset = (size_t)displacement; ret = true; } HostFree(memory::heap::DefaultStat, symInfo); } { IMAGEHLP_LINEW64 info; memory::zero(info); info.SizeOfStruct = sizeof(info); DWORD dwLineDisplacement = 0; bool res = os::Dbghelp_dll::inst().SymGetLineFromAddrW64(::GetCurrentProcess(), reinterpret_cast<DWORD64>(address), &dwLineDisplacement, &info); // LogErrorIf(!res, L"%s\n", totext::api_error().c_str()); if (res) { m_line = info.LineNumber; m_file = info.FileName; } } TraceFunc(); return ret; }
void set_options(const wchar_t* url) { TraceFunc(); auto urlCopy = cstr::dup(url); TraceFunc(); URL_COMPONENTSW info; bool res = url::crack(urlCopy, &info); if (res && cstr::compare_ci(L"logger", info.lpszScheme, info.dwSchemeLength) == 0) { if (cstr::compare_ci(L"/default", info.lpszUrlPath, info.dwUrlPathLength) == 0) { set_defaults(info.lpszExtraInfo, info.dwExtraInfoLength); } else if (cstr::compare_ci(L"/global", info.lpszUrlPath, info.dwUrlPathLength) == 0) { set_globals(info.lpszExtraInfo, info.dwExtraInfoLength); } else if (cstr::compare_ci(L"/module", info.lpszUrlPath, info.dwUrlPathLength) == 0) { set_module(info.lpszExtraInfo, info.dwExtraInfoLength); } } HostFree(memory::heap::DefaultStat, urlCopy); TraceFunc(); }
void test_memory() { LogWarn(""); auto heap = ::GetProcessHeap(); PROCESS_HEAP_ENTRY entry; memory::zero(entry); LogReport("Walking heap %p...", heap); while (::HeapWalk(heap, &entry) != FALSE) { if ((entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) { LogReport("Allocated block"); if ((entry.wFlags & PROCESS_HEAP_ENTRY_MOVEABLE) != 0) { LogReport(", movable with HANDLE %p", entry.Block.hMem); } if ((entry.wFlags & PROCESS_HEAP_ENTRY_DDESHARE) != 0) { LogReport(", DDESHARE"); } } else if ((entry.wFlags & PROCESS_HEAP_REGION) != 0) { LogReport("Region\n %d bytes committed" \ " %d bytes uncommitted\n First block address: %p" \ " Last block address: %p", entry.Region.dwCommittedSize, entry.Region.dwUnCommittedSize, entry.Region.lpFirstBlock, entry.Region.lpLastBlock); } else if ((entry.wFlags & PROCESS_HEAP_UNCOMMITTED_RANGE) != 0) { LogReport("Uncommitted range"); } else { LogReport("Block"); } LogReport(" Data portion begins at: %p\n Size: %d bytes" \ " Overhead: %d bytes\n Region index: %d", entry.lpData, entry.cbData, entry.cbOverhead, entry.iRegionIndex); } // LastError = GetLastError(); // if (LastError != ERROR_NO_MORE_ITEMS) { // _tprintf(TEXT("HeapWalk failed with LastError %d."), LastError); // } return; struct TypeTag {}; typedef typename memory::heap::DecoratorStat<memory::heap::Default, memory::heap::StatLog, TypeTag> heap_type; struct TypeTag1 {}; typedef typename memory::heap::DecoratorStat<memory::heap::Default, memory::heap::StatLog, TypeTag1> heap_type1; struct TypeTag2 {}; typedef typename memory::heap::DecoratorStat<memory::heap::Default, memory::heap::StatLog, TypeTag2> heap_type2; auto ptr = HostAlloc(heap_type, 47); HostFree(heap_type, ptr); HostAlloc(heap_type, 42); { const auto stat = heap_type::get_stat(); LogReport("stat alloc: %I64u, %I64u", stat.get_allocations(), stat.get_allocations_size()); LogReport("stat free : %I64u, %I64u", stat.get_frees(), stat.get_frees_size()); LogReport("stat diff : %I64d", stat.get_allocations_size() - stat.get_frees_size()); } { const auto stat = heap_type1::get_stat(); LogReport("stat1 alloc: %I64u, %I64u", stat.get_allocations(), stat.get_allocations_size()); LogReport("stat1 free : %I64u, %I64u", stat.get_frees(), stat.get_frees_size()); LogReport("stat1 diff : %I64d", stat.get_allocations_size() - stat.get_frees_size()); } HostAlloc(heap_type1, 17); HostAlloc(heap_type1, 12); HostAlloc(heap_type2, 71); HostAlloc(heap_type2, 22); { const auto stat = heap_type1::get_stat(); LogReport("stat1 alloc: %I64u, %I64u", stat.get_allocations(), stat.get_allocations_size()); LogReport("stat1 free : %I64u, %I64u", stat.get_frees(), stat.get_frees_size()); LogReport("stat1 diff : %I64d", stat.get_allocations_size() - stat.get_frees_size()); } { const auto stat = heap_type2::get_stat(); LogReport("stat2 alloc: %I64u, %I64u", stat.get_allocations(), stat.get_allocations_size()); LogReport("stat2 free : %I64u, %I64u", stat.get_frees(), stat.get_frees_size()); LogReport("stat2 diff : %I64d", stat.get_allocations_size() - stat.get_frees_size()); } }