DebugManager.cpp 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747
  1. #include "DebugManager.h"
  2. #include "BeefySysLib/util/CritSect.h"
  3. #include "Compiler/BfSystem.h"
  4. #include "Compiler/BfParser.h"
  5. #include "Compiler/MemReporter.h"
  6. #include "Compiler/BfIRCodeGen.h"
  7. #include "Debugger.h"
  8. #include "DebugVisualizers.h"
  9. #include "RadixMap.h"
  10. #include "Compiler/BfDemangler.h"
  11. #include "llvm/Support/ErrorHandling.h"
  12. #include "BeefySysLib/util/BeefPerf.h"
  13. #include "NetManager.h"
  14. #include "Compiler/CeDebugger.h"
  15. #ifdef BF_PLATFORM_WINDOWS
  16. #include "DbgMiniDump.h"
  17. #endif
  18. #include <iostream>
  19. #pragma warning(push)
  20. #pragma warning(disable:4141)
  21. #pragma warning(disable:4146)
  22. #pragma warning(disable:4291)
  23. #pragma warning(disable:4244)
  24. #pragma warning(disable:4267)
  25. #pragma warning(disable:4624)
  26. #pragma warning(disable:4800)
  27. #pragma warning(disable:4996)
  28. #include "llvm/IR/LLVMContext.h"
  29. #include "llvm/IRReader/IRReader.h"
  30. //#include "llvm/Bitcode/ReaderWriter.h"
  31. #pragma warning(pop)
  32. #ifdef BF_PLATFORM_WINDOWS
  33. #include <psapi.h>
  34. #include <shlobj.h>
  35. #endif
  36. #include "BeefySysLib/util/AllocDebug.h"
  37. #pragma warning(disable:4190)
  38. #define ENABLE_DBG_32
  39. //#define BF_DBG_32
  40. //#include "WinDebugger.h"
  41. //#undef BF_DBG_32
  42. /*#define BF_DBG_64
  43. #include "WinDebugger.h"
  44. #undef BF_DBG_64*/
  45. int Beefy::sRadixMapCount = 0;
  46. int Beefy::sRootSize = 0;
  47. int Beefy::sMidSize = 0;
  48. int Beefy::sLeafSize = 0;
  49. USING_NS_BF;
  50. DebugManager* Beefy::gDebugManager = NULL;
  51. Debugger* Beefy::gDebugger = NULL;
  52. PerfManager* Beefy::gDbgPerfManager = NULL;
  53. int64 gBfAllocCount = 0;
  54. int64 gBfFreeCount = 0;
  55. static Dictionary<long, int> gBfAllocMap;
  56. static Dictionary<void*, long> gBfAllocAddrMap;
  57. //////////////////////////////////////////////////////////////////////////
  58. DebugManager::DebugManager()
  59. {
  60. gDbgPerfManager = new PerfManager();
  61. mDebugVisualizers = new DebugVisualizers();
  62. mStepFilterVersion = 0;
  63. mStepOverExternalFiles = false;
  64. mDebugger32 = NULL;
  65. mDebugger64 = NULL;
  66. mNetManager = new NetManager();
  67. mNetManager->mDebugManager = this;
  68. mSymSrvOptions.mCacheDir = "C:\\SymCache";
  69. mSymSrvOptions.mSymbolServers.Add("C:\\BeefSyms");
  70. mSymSrvOptions.mSymbolServers.Add("https://msdl.microsoft.com/download/symbols");
  71. mSymSrvOptions.mSymbolServers.Add("http://wintest.beefy2d.com/symbols/");
  72. mSymSrvOptions.mSymbolServers.Add("https://chromium-browser-symsrv.commondatastorage.googleapis.com");
  73. //TODO: Just for testing
  74. mSymSrvOptions.mSymbolServers.Add("http://127.0.0.1/symbols");
  75. SetSourceServerCacheDir();
  76. }
  77. DebugManager::~DebugManager()
  78. {
  79. if ((gDebugger != NULL) && (gDebugger->IsOnDemandDebugger()))
  80. {
  81. delete gDebugger;
  82. gDebugger = NULL;
  83. }
  84. delete mNetManager;
  85. delete mDebugger64;
  86. delete mDebugger32;
  87. /*for (auto stepFilter : mStepFilters)
  88. {
  89. }*/
  90. delete mDebugVisualizers;
  91. }
  92. void DebugManager::OutputMessage(const StringImpl& msg)
  93. {
  94. AutoCrit autoCrit(mCritSect);
  95. mOutMessages.push_back("msg " + msg);
  96. }
  97. void DebugManager::OutputRawMessage(const StringImpl& msg)
  98. {
  99. AutoCrit autoCrit(mCritSect);
  100. mOutMessages.push_back(msg);
  101. }
  102. void DebugManager::SetSourceServerCacheDir()
  103. {
  104. #ifdef BF_PLATFORM_WINDOWS
  105. AutoCrit autoCrit(mCritSect);
  106. WCHAR appDataPath[MAX_PATH] = { 0 };
  107. SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, appDataPath);
  108. mSymSrvOptions.mSourceServerCacheDir = UTF8Encode(appDataPath);
  109. mSymSrvOptions.mSourceServerCacheDir += "\\SourceServer";
  110. if (mSymSrvOptions.mFlags & BfSymSrvFlag_TempCache)
  111. {
  112. mSymSrvOptions.mSourceServerCacheDir += "\\temp";
  113. RecursiveDeleteDirectory(mSymSrvOptions.mSourceServerCacheDir);
  114. }
  115. #endif
  116. }
  117. //#define CAPTURE_ALLOC_BACKTRACE
  118. //#define CAPTURE_ALLOC_SOURCES
  119. #ifdef CAPTURE_ALLOC_BACKTRACE
  120. const int sNumAllocAddrs = 0x300000;
  121. const int sCaptureDepth = 14;
  122. const int sCaptureOffset = 4;
  123. static intptr gAllocAddrs[sNumAllocAddrs][sCaptureDepth];
  124. #endif
  125. #ifdef CAPTURE_ALLOC_SOURCES
  126. #include <Dbghelp.h>
  127. #pragma comment(lib, "dbghelp.lib")
  128. struct CaptureAllocLocation
  129. {
  130. public:
  131. char* mSymName;
  132. int mTotalSize;
  133. bool mIsEndpoint;
  134. };
  135. struct CaptureAllocEntry
  136. {
  137. public:
  138. CaptureAllocLocation* mLoc;
  139. int mAllocSize;
  140. };
  141. std::map<long, CaptureAllocEntry> gBfCaptureSourceAllocMap;
  142. //std::map<void*, CaptureAllocLocation> gBfCaptureAllocLocation;
  143. #define CAPTURE_ALLOC_POOL_SIZE 0x100000
  144. CaptureAllocLocation* gHashCaptureAllocSize[CAPTURE_ALLOC_POOL_SIZE] = { 0 };
  145. static void ReallocEntry(long oldRequest, long newRequest, int newSize)
  146. {
  147. auto itr = gBfCaptureSourceAllocMap.find(oldRequest);
  148. if (itr != gBfCaptureSourceAllocMap.end())
  149. {
  150. CaptureAllocEntry* entry = &itr->second;
  151. entry->mLoc->mTotalSize -= entry->mAllocSize;
  152. entry->mLoc->mTotalSize += newSize;
  153. entry->mAllocSize = newSize;
  154. gBfCaptureSourceAllocMap[newRequest] = *entry;
  155. gBfCaptureSourceAllocMap.erase(itr);
  156. }
  157. }
  158. static void RemoveAllocEntry(long lRequest)
  159. {
  160. auto itr = gBfCaptureSourceAllocMap.find(lRequest);
  161. if (itr != gBfCaptureSourceAllocMap.end())
  162. {
  163. CaptureAllocEntry* entry = &itr->second;
  164. entry->mLoc->mTotalSize -= entry->mAllocSize;
  165. gBfCaptureSourceAllocMap.erase(itr);
  166. }
  167. }
  168. //const LOC_HASHES
  169. #endif
  170. static int gBfNumAllocs = 0;
  171. #ifdef BF_PLATFORM_WINDOWS
  172. static bool gBgTrackingAllocs = false; ///// Leave false most of the time
  173. CritSect gBfCritSect;
  174. static bool gInsideAlloc = false;
  175. static int gLastReqId = 0;
  176. static int BfAllocHook(int nAllocType, void *pvData,
  177. size_t nSize, int nBlockUse, long lRequest,
  178. const unsigned char * szFileName, int nLine)
  179. {
  180. #ifdef CAPTURE_ALLOC_SOURCES
  181. if (gInsideAlloc)
  182. return TRUE;
  183. gInsideAlloc = true;
  184. intptr stackTrace[20];
  185. int traceCount = (int)RtlCaptureStackBackTrace(1, 20, (void**)&stackTrace, 0);
  186. /*intptr ebpVal;
  187. __asm
  188. {
  189. mov ebpVal, ebp
  190. }*/
  191. //intptr ebp = ebpVal;
  192. //intptr eip = 0;
  193. static HANDLE hProcess = 0;
  194. if (hProcess == NULL)
  195. {
  196. hProcess = GetCurrentProcess();
  197. BOOL worked = SymInitialize(hProcess, NULL, TRUE);
  198. }
  199. if (nAllocType == _HOOK_ALLOC)
  200. {
  201. for (int i = 0; i < traceCount; i++)
  202. {
  203. /*__try
  204. {
  205. ebp = *((intptr*)ebp + 0);
  206. if (ebp < 0x100000)
  207. break;
  208. eip = *((intptr*)ebp + 1);
  209. }
  210. __except (EXCEPTION_EXECUTE_HANDLER)
  211. {
  212. break;
  213. }*/
  214. intptr curAddr = stackTrace[i];
  215. const char* name = "?";
  216. int hashVal = (curAddr & 0x7FFFFFFF) % CAPTURE_ALLOC_POOL_SIZE;
  217. if (gHashCaptureAllocSize[hashVal] == NULL)
  218. {
  219. //static HPROCESS hProc = GEtProcessH
  220. char symData[4096];
  221. DWORD64 disp = 0;
  222. SYMBOL_INFO* symInfo = (SYMBOL_INFO*)&symData;
  223. memset(symInfo, 0, sizeof(SYMBOL_INFO));
  224. symInfo->SizeOfStruct = sizeof(SYMBOL_INFO);
  225. symInfo->MaxNameLen = sizeof(symData) - sizeof(SYMBOL_INFO);
  226. bool foundSym = false;
  227. if (SymFromAddr(hProcess, (DWORD64)curAddr, &disp, symInfo))
  228. {
  229. name = symInfo->Name;
  230. foundSym = true;
  231. }
  232. CaptureAllocLocation* captureAllocLoc = new CaptureAllocLocation();
  233. captureAllocLoc->mSymName = strdup(name);
  234. captureAllocLoc->mTotalSize = 0;
  235. captureAllocLoc->mIsEndpoint = (!foundSym) || (strncmp(name, "Beefy::", 7) == 0) || (strncmp(name, "llvm::", 6) == 0);
  236. if (strstr(name, "operator new") != NULL)
  237. captureAllocLoc->mIsEndpoint = false;
  238. if (strstr(name, "::allocateBuckets") != NULL)
  239. captureAllocLoc->mIsEndpoint = false;
  240. if (strstr(name, "::grow") != NULL)
  241. captureAllocLoc->mIsEndpoint = false;
  242. if (strstr(name, "::DenseMap") != NULL)
  243. captureAllocLoc->mIsEndpoint = false;
  244. /*if (strstr(name, "::Allocate") != NULL)
  245. captureAllocLoc->mIsEndpoint = false;*/
  246. if (strstr(name, "::Alloc") != NULL)
  247. captureAllocLoc->mIsEndpoint = false;
  248. /*if (strstr(name, "::AllocBytes") != NULL)
  249. captureAllocLoc->mIsEndpoint = false;
  250. if (strstr(name, "::AllocMemoryBlock") != NULL)
  251. captureAllocLoc->mIsEndpoint = false;*/
  252. if (strstr(name, "::GrowPool") != NULL)
  253. captureAllocLoc->mIsEndpoint = false;
  254. // Testing COnstantInt::get
  255. if (strstr(name, "::CreateConst") != NULL)
  256. captureAllocLoc->mIsEndpoint = false;
  257. if (strstr(name, "::get") != NULL)
  258. captureAllocLoc->mIsEndpoint = false;
  259. if ((captureAllocLoc->mIsEndpoint) && (foundSym))
  260. {
  261. }
  262. gHashCaptureAllocSize[hashVal] = captureAllocLoc;
  263. }
  264. CaptureAllocLocation* captureAllocLoc = gHashCaptureAllocSize[hashVal];
  265. if ((i < 19) && (!captureAllocLoc->mIsEndpoint))
  266. {
  267. continue;
  268. }
  269. captureAllocLoc->mTotalSize += (int)nSize;
  270. CaptureAllocEntry entry;
  271. entry.mAllocSize = (int)nSize;
  272. entry.mLoc = captureAllocLoc;
  273. gBfCaptureSourceAllocMap[lRequest] = entry;
  274. break;
  275. //if (i >= sCaptureOffset)
  276. //gAllocAddrs[lRequest][i - sCaptureOffset] = eip;
  277. }
  278. }
  279. else if (nAllocType == _HOOK_REALLOC)
  280. {
  281. long oldRequest = ((int*)pvData)[-2];
  282. ReallocEntry(oldRequest, lRequest, nSize);
  283. }
  284. else if (nAllocType == _HOOK_FREE)
  285. {
  286. lRequest = ((int*)pvData)[-2];
  287. RemoveAllocEntry(lRequest);
  288. }
  289. gInsideAlloc = false;
  290. #endif
  291. #ifdef CAPTURE_ALLOC_BACKTRACE
  292. if (lRequest < sNumAllocAddrs)
  293. {
  294. gAllocAddrs[lRequest][0] = 1;
  295. intptr ebpVal;
  296. __asm
  297. {
  298. mov ebpVal, ebp
  299. }
  300. intptr ebp = ebpVal;
  301. intptr eip = 0;
  302. for (int i = 0; i < sCaptureDepth + sCaptureOffset; i++)
  303. {
  304. __try
  305. {
  306. ebp = *((intptr*)ebp + 0);
  307. if (ebp < 0x100000)
  308. break;
  309. eip = *((intptr*)ebp + 1);
  310. }
  311. __except (EXCEPTION_EXECUTE_HANDLER)
  312. {
  313. break;
  314. }
  315. if (i >= sCaptureOffset)
  316. gAllocAddrs[lRequest][i - sCaptureOffset] = eip;
  317. }
  318. }
  319. #else
  320. if (!gBgTrackingAllocs)
  321. return TRUE;
  322. /*AutoCrit critSect(gBfCritSect);
  323. if (gLastReqId == lRequest)
  324. return TRUE;
  325. if (!gInsideAlloc)
  326. {
  327. gInsideAlloc = true;
  328. if (nAllocType == _HOOK_ALLOC)
  329. {
  330. gBfNumAllocs++;
  331. gBfAllocCount += nSize;
  332. gBfAllocMap[lRequest] = nSize;
  333. }
  334. if (nAllocType == _HOOK_FREE)
  335. {
  336. lRequest = ((int*)pvData)[-2];
  337. auto itr = gBfAllocMap.find(lRequest);
  338. if (itr != gBfAllocMap.end())
  339. {
  340. gBfFreeCount += itr->second;
  341. gBfAllocMap.erase(itr);
  342. }
  343. }
  344. gInsideAlloc = false;
  345. }
  346. gLastReqId = lRequest;
  347. if (szFileName == NULL)
  348. return TRUE; */
  349. /*char str[1024];
  350. sprintf(str, "Alloc: %d File: %s Line: %d\n", lRequest, szFileName, nLine);
  351. OutputDebugStringA(str);*/
  352. #endif
  353. return TRUE;
  354. }
  355. #endif //BF_PLATFORM_WINDOWS
  356. void BfReportMemory()
  357. {
  358. BfLogDbg("Used: %.2fM NumAllocs: %d Allocs: %.2fM\n", (gBfAllocCount - gBfFreeCount) / (1024.0 * 1024.0), gBfNumAllocs, gBfAllocCount / (1024.0 * 1024.0));
  359. }
  360. void BfFullReportMemory()
  361. {
  362. /*OutputDebugStrF("Testing OOB\n");
  363. char* str = new char[12];
  364. delete str;
  365. char c = str[1];*/
  366. if (gBfParserCache != NULL)
  367. {
  368. MemReporter memReporter;
  369. memReporter.BeginSection("ParserCache");
  370. gBfParserCache->ReportMemory(&memReporter);
  371. memReporter.EndSection();
  372. memReporter.Report();
  373. }
  374. OutputDebugStrF("Used: %.2fM NumAllocs: %d Allocs: %.2fM\n", (gBfAllocCount - gBfFreeCount) / (1024.0 * 1024.0), gBfNumAllocs, gBfAllocCount / (1024.0 * 1024.0));
  375. OutputDebugStrF("ChunkedDataBuffer allocated blocks: %d\n", ChunkedDataBuffer::sBlocksAllocated);
  376. if (gDebugManager != NULL)
  377. {
  378. MemReporter memReporter;
  379. if (gDebugManager->mDebugger32 != NULL)
  380. {
  381. memReporter.BeginSection("Debugger32");
  382. gDebugManager->mDebugger32->ReportMemory(&memReporter);
  383. memReporter.EndSection();
  384. }
  385. memReporter.BeginSection("Debugger64");
  386. gDebugManager->mDebugger64->ReportMemory(&memReporter);
  387. memReporter.EndSection();
  388. memReporter.Report();
  389. }
  390. BpDump();
  391. #ifdef CAPTURE_ALLOC_SOURCES
  392. int memTotal = 0;
  393. std::map<String, int> byNameMap;
  394. for (int i = 0; i < CAPTURE_ALLOC_POOL_SIZE; i++)
  395. {
  396. CaptureAllocLocation* allocLoc = gHashCaptureAllocSize[i];
  397. if ((allocLoc != NULL) && (allocLoc->mTotalSize > 0))
  398. {
  399. auto itr = byNameMap.insert(std::map<String, int>::value_type(allocLoc->mSymName, 0));
  400. itr.first->second += allocLoc->mTotalSize;
  401. memTotal += allocLoc->mTotalSize;
  402. }
  403. }
  404. std::multimap<int, String> bySizeMap;
  405. for (auto kv : byNameMap)
  406. {
  407. //OutputDebugStrF("%dk %s\n", (kv.second + 1023) / 1024, kv.first.c_str());
  408. bySizeMap.insert(std::multimap<int, String>::value_type(-kv.second, kv.first));
  409. }
  410. for (auto kv : bySizeMap)
  411. {
  412. OutputDebugStrF("%dk %s\n", (-kv.first + 1023) / 1024, kv.second.c_str());
  413. }
  414. OutputDebugStrF("Total %dk\n", memTotal / 1024);
  415. #endif
  416. }
  417. struct _CrtMemBlockHeader
  418. {
  419. _CrtMemBlockHeader* _block_header_next;
  420. _CrtMemBlockHeader* _block_header_prev;
  421. char const* _file_name;
  422. int _line_number;
  423. int _block_use;
  424. size_t _data_size;
  425. long _request_number;
  426. //unsigned char _gap[no_mans_land_size];
  427. // Followed by:
  428. // unsigned char _data[_data_size];
  429. // unsigned char _another_gap[no_mans_land_size];
  430. };
  431. //static _CrtMemBlockHeader* __acrt_first_block;
  432. //static _CrtMemBlockHeader* __acrt_last_block;
  433. void ShowMemoryUsage()
  434. {
  435. #ifdef BF_PLATFORM_WINDOWS
  436. PROCESS_MEMORY_COUNTERS processMemCounters;
  437. processMemCounters.cb = sizeof(PROCESS_MEMORY_COUNTERS);
  438. GetProcessMemoryInfo(GetCurrentProcess(), &processMemCounters, sizeof(PROCESS_MEMORY_COUNTERS));
  439. OutputDebugStrF("WorkingSet : %dk\n", (int)(processMemCounters.WorkingSetSize / 1024));
  440. OutputDebugStrF("VirtualMem : %dk\n", (int)(processMemCounters.PagefileUsage/1024));
  441. static bool hasCheckpoint = true;
  442. _CrtMemState memState;
  443. _CrtMemCheckpoint(&memState);
  444. //OutputDebugStrF("Crt Size: %dk\n", (int)(memState.lTotalCount / 1024));
  445. char* names[6] = { "_FREE_BLOCK", "_NORMAL_BLOCK", "_CRT_BLOCK", "_IGNORE_BLOCK", "_CLIENT_BLOCK", "_MAX_BLOCKS" };
  446. for (int i = 0; i < 5; i++)
  447. {
  448. OutputDebugStrF("%s : %d %dk\n", names[i], memState.lCounts[i], memState.lSizes[i] / 1024);
  449. }
  450. #ifdef _DEBUG
  451. // int64 totalCrtSize = 0;
  452. // int64 totalUseCrtSize = 0;
  453. // _CrtMemBlockHeader* blockPtr = memState.pBlockHeader;
  454. // while (blockPtr != NULL)
  455. // {
  456. // totalCrtSize += blockPtr->_data_size;
  457. // if (blockPtr->_block_use != _FREE_BLOCK)
  458. // totalUseCrtSize += blockPtr->_data_size;
  459. // blockPtr = blockPtr->_block_header_next;
  460. // }
  461. // OutputDebugStrF("Crt Size: %dk Used: %dk\n", (int)(totalCrtSize / 1024), (int)(totalUseCrtSize / 1024));
  462. #endif
  463. _HEAPINFO heapInfo = {0};
  464. int64 heapSize = 0;
  465. int heapStatus;
  466. while ((heapStatus = _heapwalk(&heapInfo)) == _HEAPOK)
  467. {
  468. heapSize += (int64)heapInfo._size;
  469. }
  470. OutputDebugStrF("WALKED HEAP SIZE: %dk\n", heapSize / 1024);
  471. //_CrtMemDumpStatistics(&memState);
  472. #endif
  473. }
  474. /*void* TestHeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
  475. {
  476. return HeapAlloc(hHeap, dwFlags, dwBytes);
  477. }*/
  478. static void BfFatalErrorHandler(void *user_data, const std::string& reason, bool gen_crash_diag)
  479. {
  480. BF_FATAL(reason.c_str());
  481. OutputDebugStrF("LLVM ERROR: %s\n", reason.c_str());
  482. }
  483. #ifdef BF_PLATFORM_WINDOWS
  484. BOOL WINAPI DllMain(
  485. HANDLE hDllHandle,
  486. DWORD dwReason,
  487. LPVOID lpreserved)
  488. {
  489. if (dwReason == DLL_PROCESS_ATTACH)
  490. {
  491. BpInit("127.0.0.1", "Beef IDE");
  492. BpSetThreadName("Main");
  493. BfpThread_SetName(NULL, "Main", NULL);
  494. llvm::install_fatal_error_handler(BfFatalErrorHandler, NULL);
  495. //_CRTDBG_CHECK_EVERY_16_DF
  496. //_CRTDBG_CHECK_ALWAYS_DF
  497. //_CRTDBG_DELAY_FREE_MEM_DF
  498. //_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF /*| _CRTDBG_CHECK_ALWAYS_DF*/);
  499. _CrtSetAllocHook(BfAllocHook);
  500. }
  501. if (dwReason == -123)
  502. {
  503. BpDump();
  504. }
  505. return TRUE;
  506. }
  507. #endif //BF_PLATFORM_WINDOWS
  508. //////
  509. void SleepTest()
  510. {
  511. BfpThread_Sleep(3000);
  512. }
  513. void WdAllocTest();
  514. namespace BeefyDbg64
  515. {
  516. class WinDebugger;
  517. void TestPDB(const StringImpl& fileName, WinDebugger* debugger);
  518. }
  519. #ifdef BF_PLATFORM_WINDOWS
  520. static _CrtMemState gStartMemCheckpoint;
  521. #endif
  522. BF_EXPORT void BF_CALLTYPE Debugger_Create()
  523. {
  524. //TODO: Very slow, remove
  525. //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
  526. //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_EVERY_16_DF);
  527. //TODO: _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF /*| _CRTDBG_CHECK_EVERY_16_DF*/);
  528. //_CrtSetAllocHook(BfAllocHook);
  529. #ifdef BF_PLATFORM_WINDOWS
  530. _CrtMemCheckpoint(&gStartMemCheckpoint);
  531. #endif
  532. //_CrtSetBreakAlloc(621);
  533. gDebugManager = new DebugManager();
  534. #ifdef ENABLE_DBG_32
  535. gDebugManager->mDebugger32 = CreateDebugger32(gDebugManager, NULL);
  536. #else
  537. gDebugManager->mDebugger32 = NULL;
  538. #endif
  539. #ifdef BF32
  540. gDebugManager->mDebugger64 = NULL;
  541. #else
  542. gDebugManager->mDebugger64 = CreateDebugger64(gDebugManager, NULL);
  543. #endif
  544. #ifdef BF_PLATFORM_WINDOWS
  545. ::AllowSetForegroundWindow(ASFW_ANY);
  546. #endif
  547. //BeefyDbg64::TestPDB("C:/Beef/IDE/dist/IDEHelper64_d.pdb", (BeefyDbg64::WinDebugger*)gDebugManager->mDebugger64);
  548. }
  549. BF_EXPORT void BF_CALLTYPE Debugger_SetCallbacks(void* callback)
  550. {
  551. }
  552. BF_EXPORT void BF_CALLTYPE Debugger_FullReportMemory()
  553. {
  554. //WdAllocTest();
  555. ShowMemoryUsage();
  556. BfFullReportMemory();
  557. }
  558. BF_EXPORT void BF_CALLTYPE Debugger_Delete()
  559. {
  560. delete gDebugManager;
  561. gDebugManager = NULL;
  562. delete gPerfManager;
  563. gPerfManager = NULL;
  564. //OutputDebugStrF("Deleting Debugger\n");
  565. //BfReportMemory();
  566. #ifdef BF_PLATFORM_WINDOWS
  567. gBgTrackingAllocs = false;
  568. #endif
  569. }
  570. BF_EXPORT void BF_CALLTYPE IDEHelper_ProgramStart()
  571. {
  572. BfIRCodeGen::StaticInit();
  573. }
  574. BF_EXPORT void BF_CALLTYPE IDEHelper_ProgramDone()
  575. {
  576. //TODO:
  577. //::MessageBoxA(NULL, "Done", "Done", MB_OK);
  578. BF_ASSERT(gDebugger == NULL);
  579. //ShowMemoryUsage();
  580. //BfFullReportMemory();
  581. #ifdef CAPTURE_ALLOC_SOURCES
  582. gInsideAlloc = true;
  583. for (int i = 0; i < CAPTURE_ALLOC_POOL_SIZE; i++)
  584. {
  585. if (gHashCaptureAllocSize[i] != NULL)
  586. {
  587. free(gHashCaptureAllocSize[i]->mSymName);
  588. delete gHashCaptureAllocSize[i];
  589. gHashCaptureAllocSize[i] = NULL;
  590. }
  591. }
  592. gBfCaptureSourceAllocMap.clear();
  593. #endif
  594. #ifdef BF_PLATFORM_WINDOWS
  595. _CrtMemDumpAllObjectsSince(&gStartMemCheckpoint);
  596. /*_CrtMemState curMemCheckpoint;
  597. _CrtMemCheckpoint(&curMemCheckpoint);
  598. _CrtMemState memDiff;
  599. if (_CrtMemDifference(&memDiff, &gStartMemCheckpoint, &curMemCheckpoint))
  600. _CrtMemDumpStatistics(&memDiff);*/
  601. _CrtMemState curMemCheckpoint = { 0 };
  602. _CrtMemCheckpoint(&curMemCheckpoint);
  603. OutputDebugStrF("Heap memory usage: %dk\n", curMemCheckpoint.lTotalCount / 1024);
  604. #endif //BF_PLATFORM_WINDOWS
  605. BpShutdown();
  606. }
  607. BF_EXPORT int BF_CALLTYPE Debugger_GetAddrSize()
  608. {
  609. if (gDebugger == NULL)
  610. return 0;
  611. return gDebugger->GetAddrSize();
  612. }
  613. BF_EXPORT bool BF_CALLTYPE Debugger_OpenFile(const char* launchPath, const char* targetPath, const char* args, const char* workingDir, void* envBlockPtr, int envBlockSize, bool hotSwapEnabled)
  614. {
  615. BF_ASSERT(gDebugger == NULL);
  616. if (!FileExists(launchPath))
  617. {
  618. gDebugManager->mOutMessages.push_back(StrFormat("error Unable to locate specified launch target '%s'", launchPath));
  619. return false;
  620. }
  621. DebuggerResult debuggerResult = DebuggerResult_Ok;
  622. if ((gDebugManager->mDebugger64 != NULL) && (gDebugManager->mDebugger64->CanOpen(launchPath, &debuggerResult)))
  623. gDebugger = gDebugManager->mDebugger64;
  624. else
  625. gDebugger = gDebugManager->mDebugger32;
  626. if (gDebugger == NULL)
  627. {
  628. if (debuggerResult == DebuggerResult_WrongBitSize)
  629. gDebugManager->mOutMessages.push_back(StrFormat("error The file 32-bit file '%s' cannot be debugged because 32-bit debugger has been disabled", launchPath));
  630. return false;
  631. }
  632. Array<uint8> envBlock;
  633. if (envBlockPtr != NULL)
  634. {
  635. if (envBlockSize != 0)
  636. envBlock.Insert(0, (uint8*)envBlockPtr, envBlockSize);
  637. }
  638. gDebugger->OpenFile(launchPath, targetPath, args, workingDir, envBlock, hotSwapEnabled);
  639. return true;
  640. }
  641. BF_EXPORT bool BF_CALLTYPE Debugger_ComptimeAttach(void* bfCompiler)
  642. {
  643. gDebugger = new CeDebugger(gDebugManager, (BfCompiler*)bfCompiler);
  644. return true;
  645. }
  646. BF_EXPORT void BF_CALLTYPE Debugger_SetSymSrvOptions(const char* symCacheDir, const char* symSrvStr, int flags)
  647. {
  648. Array<String> symServers;
  649. const char* startStr = symSrvStr;
  650. for (const char* cPtr = symSrvStr; true; cPtr++)
  651. {
  652. if ((*cPtr == '\n') || (*cPtr == 0))
  653. {
  654. String symStr = String(startStr, cPtr - startStr);
  655. symStr.Trim();
  656. if (symStr.EndsWith('/'))
  657. symStr.Remove((int)symStr.length() - 1, 1);
  658. if (!symStr.IsEmpty())
  659. symServers.Add(symStr);
  660. startStr = cPtr;
  661. }
  662. if (*cPtr == 0)
  663. break;
  664. }
  665. AutoCrit autoCrit(gDebugManager->mCritSect);
  666. gDebugManager->mSymSrvOptions.mCacheDir = symCacheDir;
  667. gDebugManager->mSymSrvOptions.mSymbolServers = symServers;
  668. gDebugManager->mSymSrvOptions.mFlags = (BfSymSrvFlags)flags;
  669. gDebugManager->mSymSrvOptions.mCacheDir.Trim();
  670. if (gDebugManager->mSymSrvOptions.mCacheDir.IsEmpty())
  671. gDebugManager->mSymSrvOptions.mFlags = BfSymSrvFlag_Disable;
  672. if (flags & BfSymSrvFlag_TempCache)
  673. {
  674. if (!gDebugManager->mSymSrvOptions.mCacheDir.IsEmpty())
  675. {
  676. gDebugManager->mSymSrvOptions.mCacheDir.Append("\\temp");
  677. RecursiveDeleteDirectory(gDebugManager->mSymSrvOptions.mCacheDir);
  678. }
  679. }
  680. gDebugManager->SetSourceServerCacheDir();
  681. }
  682. BF_EXPORT bool BF_CALLTYPE Debugger_OpenMiniDump(const char* fileName)
  683. {
  684. #ifdef BF_PLATFORM_WINDOWS
  685. DbgMiniDump* dbgMiniDump = new DbgMiniDump();
  686. bool result = dbgMiniDump->StartLoad(fileName);
  687. if (!result)
  688. {
  689. delete dbgMiniDump;
  690. return false;
  691. }
  692. if (dbgMiniDump->GetTargetBitCount() == 32)
  693. gDebugger = CreateDebugger32(gDebugManager, dbgMiniDump);
  694. else
  695. gDebugger = CreateDebugger64(gDebugManager, dbgMiniDump);
  696. return result;
  697. #else //BF_PLATFORM_WINDOWS
  698. return false;
  699. #endif
  700. }
  701. BF_EXPORT bool BF_CALLTYPE Debugger_Attach(int processId, BfDbgAttachFlags attachFlags)
  702. {
  703. BF_ASSERT(gDebugger == NULL);
  704. if (gDebugManager->mDebugger64->Attach(processId, attachFlags))
  705. {
  706. gDebugger = gDebugManager->mDebugger64;
  707. return true;
  708. }
  709. if (gDebugManager->mDebugger32->Attach(processId, attachFlags))
  710. {
  711. gDebugger = gDebugManager->mDebugger32;
  712. return true;
  713. }
  714. return false;
  715. }
  716. BF_EXPORT void BF_CALLTYPE Debugger_Run()
  717. {
  718. gDebugger->Run();
  719. }
  720. BF_EXPORT bool BF_CALLTYPE Debugger_HotLoad(const char* fileNamesStr, int hotIdx)
  721. {
  722. //DbgModule* dwarf = new DbgModule(gDebugger);
  723. //dwarf->ReadPE(fileName);
  724. Array<String> fileNames;
  725. const char* curPtr = fileNamesStr;
  726. for (int i = 0; true; i++)
  727. {
  728. if ((fileNamesStr[i] == '\0') || (fileNamesStr[i] == '\n'))
  729. {
  730. String curFileName = String(curPtr, fileNamesStr + i);
  731. if ((curFileName.IndexOf("/vdata.") != -1) || (curFileName.IndexOf("\\vdata.") != -1))
  732. {
  733. // Do vdata first - so new data and special functions don't have to be deferred resolved
  734. fileNames.Insert(0, curFileName);
  735. }
  736. else
  737. fileNames.Add(curFileName);
  738. curPtr = fileNamesStr + i + 1;
  739. }
  740. if (fileNamesStr[i] == '\0')
  741. break;
  742. }
  743. gDebugger->HotLoad(fileNames, hotIdx);
  744. return true;
  745. }
  746. BF_EXPORT bool BF_CALLTYPE Debugger_LoadDebugVisualizers(const char* fileName)
  747. {
  748. String fn = fileName;
  749. bool worked = false;
  750. worked = gDebugManager->mDebugVisualizers->Load(fileName);
  751. if (!gDebugManager->mDebugVisualizers->mErrorString.empty())
  752. {
  753. gDebugManager->mOutMessages.push_back(StrFormat("msg ERROR: %s\n", gDebugManager->mDebugVisualizers->mErrorString.c_str()));
  754. }
  755. // {
  756. // BF_FATAL(gDebugManager->mDebugVisualizers->mErrorString.c_str());
  757. // }
  758. return worked;
  759. }
  760. BF_EXPORT void BF_CALLTYPE Debugger_StopDebugging()
  761. {
  762. gDebugger->StopDebugging();
  763. }
  764. BF_EXPORT void BF_CALLTYPE Debugger_Terminate()
  765. {
  766. gDebugger->Terminate();
  767. }
  768. BF_EXPORT void BF_CALLTYPE Debugger_Detach()
  769. {
  770. gDebugManager->mNetManager->CancelAll();
  771. gDebugger->Detach();
  772. if (gDebugger->IsOnDemandDebugger())
  773. delete gDebugger;
  774. gDebugger = NULL;
  775. gDebugManager->mNetManager->Clear();
  776. }
  777. BF_EXPORT Breakpoint* BF_CALLTYPE Debugger_CreateBreakpoint(const char* fileName, int lineNum, int wantColumn, int instrOffset)
  778. {
  779. return gDebugger->CreateBreakpoint(fileName, lineNum, wantColumn, instrOffset);
  780. }
  781. BF_EXPORT Breakpoint* BF_CALLTYPE Debugger_CreateMemoryBreakpoint(intptr address, int byteCount)
  782. {
  783. return gDebugger->CreateMemoryBreakpoint(address, byteCount);
  784. }
  785. BF_EXPORT Breakpoint* BF_CALLTYPE Debugger_CreateSymbolBreakpoint(const char* symbolName)
  786. {
  787. return gDebugger->CreateSymbolBreakpoint(symbolName);
  788. }
  789. BF_EXPORT Breakpoint* BF_CALLTYPE Debugger_CreateAddressBreakpoint(intptr address)
  790. {
  791. return gDebugger->CreateAddressBreakpoint(address);
  792. }
  793. BF_EXPORT Breakpoint* BF_CALLTYPE Debugger_GetActiveBreakpoint()
  794. {
  795. return gDebugger->GetActiveBreakpoint();
  796. }
  797. BF_EXPORT void BF_CALLTYPE Breakpoint_Delete(Breakpoint* wdBreakpoint)
  798. {
  799. gDebugger->DeleteBreakpoint(wdBreakpoint);
  800. }
  801. BF_EXPORT void BF_CALLTYPE Breakpoint_Check(Breakpoint* breakpoint)
  802. {
  803. gDebugger->CheckBreakpoint(breakpoint);
  804. }
  805. BF_EXPORT int BF_CALLTYPE Breakpoint_GetPendingHotBindIdx(Breakpoint* breakpoint)
  806. {
  807. return breakpoint->mPendingHotBindIdx;
  808. }
  809. BF_EXPORT void BF_CALLTYPE Breakpoint_HotBindBreakpoint(Breakpoint* breakpoint, int lineNum, int hotIdx)
  810. {
  811. gDebugger->HotBindBreakpoint(breakpoint, lineNum, hotIdx);
  812. }
  813. BF_EXPORT void BF_CALLTYPE Breakpoint_SetThreadId(Breakpoint* breakpoint, intptr threadId)
  814. {
  815. BfLogDbg("Breakpoint %p set ThreadId=%d\n", breakpoint, threadId);
  816. breakpoint->mThreadId = threadId;
  817. gDebugger->CheckBreakpoint(breakpoint);
  818. }
  819. BF_EXPORT int BF_CALLTYPE Breakpoint_GetHitCount(Breakpoint* breapoint)
  820. {
  821. return breapoint->mHitCount;
  822. }
  823. BF_EXPORT void BF_CALLTYPE Breakpoint_ClearHitCount(Breakpoint* breapoint)
  824. {
  825. breapoint->mHitCount = 0;
  826. }
  827. BF_EXPORT void BF_CALLTYPE Breakpoint_SetHitCountTarget(Breakpoint* breakpoint, int targetHitCount, DbgHitCountBreakKind breakKind)
  828. {
  829. breakpoint->mTargetHitCount = targetHitCount;
  830. breakpoint->mHitCountBreakKind = breakKind;
  831. }
  832. BF_EXPORT void BF_CALLTYPE Breakpoint_SetCondition(Breakpoint* wdBreakpoint, const char* condition)
  833. {
  834. gDebugger->SetBreakpointCondition(wdBreakpoint, condition);
  835. }
  836. BF_EXPORT void BF_CALLTYPE Breakpoint_SetLogging(Breakpoint* wdBreakpoint, const char* logging, bool breakAfterLogging)
  837. {
  838. gDebugger->SetBreakpointLogging(wdBreakpoint, logging, breakAfterLogging);
  839. }
  840. BF_EXPORT uintptr BF_CALLTYPE Breakpoint_GetAddress(Breakpoint* wdBreakpoint, Breakpoint** outLinkedSibling)
  841. {
  842. if (outLinkedSibling != NULL)
  843. *outLinkedSibling = wdBreakpoint->mLinkedSibling;
  844. return gDebugger->GetBreakpointAddr(wdBreakpoint);
  845. }
  846. BF_EXPORT bool BF_CALLTYPE Breakpoint_IsMemoryBreakpointBound(Breakpoint* wdBreakpoint)
  847. {
  848. return wdBreakpoint->IsMemoryBreakpointBound();
  849. }
  850. BF_EXPORT intptr BF_CALLTYPE Breakpoint_GetLineNum(Breakpoint* wdBreakpoint)
  851. {
  852. return wdBreakpoint->mLineNum;
  853. }
  854. BF_EXPORT void BF_CALLTYPE Breakpoint_Move(Breakpoint* breakpoint, int lineNum, int wantColumn, bool rebindNow)
  855. {
  856. gDebugger->MoveBreakpoint(breakpoint, lineNum, wantColumn, rebindNow);
  857. }
  858. BF_EXPORT void BF_CALLTYPE Breakpoint_MoveMemoryBreakpoint(Breakpoint* breakpoint, intptr addr, int byteCount)
  859. {
  860. gDebugger->MoveMemoryBreakpoint(breakpoint, addr, byteCount);
  861. }
  862. BF_EXPORT void BF_CALLTYPE Breakpoint_Disable(Breakpoint* wdBreakpoint)
  863. {
  864. gDebugger->DisableBreakpoint(wdBreakpoint);
  865. }
  866. BF_EXPORT void BF_CALLTYPE Debugger_CreateStepFilter(const char* filter, bool isGlobal, BfStepFilterKind filterKind)
  867. {
  868. AutoCrit autoCrit(gDebugManager->mCritSect);
  869. StepFilter stepFilter;
  870. stepFilter.mFilterKind = filterKind;
  871. gDebugManager->mStepFilters[filter] = stepFilter;
  872. gDebugManager->mStepFilterVersion++;
  873. }
  874. BF_EXPORT void BF_CALLTYPE StepFilter_Delete(const char* filter)
  875. {
  876. AutoCrit autoCrit(gDebugManager->mCritSect);
  877. bool didRemove = gDebugManager->mStepFilters.Remove(filter);
  878. BF_ASSERT(didRemove);
  879. gDebugManager->mStepFilterVersion++;
  880. }
  881. BF_EXPORT int BF_CALLTYPE Debugger_GetRunState()
  882. {
  883. AutoCrit autoCrit(gDebugManager->mCritSect);
  884. if (gDebugger == NULL)
  885. return RunState_NotStarted;
  886. return gDebugger->mRunState;
  887. }
  888. BF_EXPORT bool BF_CALLTYPE Debugger_HasPendingDebugLoads()
  889. {
  890. if (gDebugger == NULL)
  891. return false;
  892. return gDebugger->HasPendingDebugLoads();
  893. }
  894. BF_EXPORT const char* BF_CALLTYPE Debugger_PopMessage()
  895. {
  896. AutoCrit autoCrit(gDebugManager->mCritSect);
  897. if (gDebugManager->mOutMessages.size() == 0)
  898. return NULL;
  899. String& outString = *gTLStrReturn.Get();
  900. outString = gDebugManager->mOutMessages.front();
  901. gDebugManager->mOutMessages.pop_front();
  902. //gDebugManager->mOutMessages.erase(gDebugManager->mOutMessages.begin());
  903. return outString.c_str();
  904. }
  905. BF_EXPORT bool BF_CALLTYPE Debugger_HasMessages()
  906. {
  907. AutoCrit autoCrit(gDebugManager->mCritSect);
  908. return gDebugManager->mOutMessages.size() != 0;
  909. }
  910. BF_EXPORT const char* BF_CALLTYPE Debugger_GetCurrentException()
  911. {
  912. /*outString = StrFormat("Exception at 0x%p, exception code 0x%08X",
  913. gDebugger->mCurException.ExceptionAddress, gDebugger->mCurException.ExceptionCode);*/
  914. String& outString = *gTLStrReturn.Get();
  915. outString = gDebugger->GetCurrentException();
  916. return outString.c_str();
  917. }
  918. BF_EXPORT void BF_CALLTYPE Debugger_BreakAll()
  919. {
  920. if (gDebugger != NULL)
  921. gDebugger->BreakAll();
  922. }
  923. BF_EXPORT void BF_CALLTYPE Debugger_Continue()
  924. {
  925. BfLogDbg("Debugger_Continue\n");
  926. gDebugger->ContinueDebugEvent();
  927. }
  928. BF_EXPORT void BF_CALLTYPE Debugger_StepInto(bool inAssembly)
  929. {
  930. gDebugger->StepInto(inAssembly);
  931. }
  932. BF_EXPORT void BF_CALLTYPE Debugger_StepIntoSpecific(intptr addr)
  933. {
  934. gDebugger->StepIntoSpecific(addr);
  935. }
  936. BF_EXPORT void BF_CALLTYPE Debugger_StepOver(bool inAssembly)
  937. {
  938. gDebugger->StepOver(inAssembly);
  939. }
  940. BF_EXPORT void BF_CALLTYPE Debugger_StepOut(bool inAssembly)
  941. {
  942. gDebugger->StepOut(inAssembly);
  943. }
  944. BF_EXPORT void BF_CALLTYPE Debugger_SetNextStatement(bool inAssembly, const char* fileName, int64 wantLineNumOrAsmAddr, int wantColumn)
  945. {
  946. if (fileName == NULL)
  947. fileName = "";
  948. gDebugger->SetNextStatement(inAssembly, fileName, wantLineNumOrAsmAddr, wantColumn);
  949. }
  950. BF_EXPORT void BF_CALLTYPE Debugger_Update()
  951. {
  952. if (gDebugger != NULL)
  953. gDebugger->Update();
  954. }
  955. BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
  956. {
  957. DwDisplayInfo displayInfo;
  958. displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType;
  959. displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType;
  960. displayInfo.mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
  961. if (referenceId == NULL)
  962. {
  963. gDebugManager->mDefaultDisplayInfo = displayInfo;
  964. }
  965. else if ((displayInfo.mIntDisplayType == DwIntDisplayType_Default) &&
  966. (displayInfo.mMmDisplayType == DwMmDisplayType_Default) &&
  967. (displayInfo.mFloatDisplayType == DwFloatDisplayType_Default))
  968. {
  969. gDebugManager->mDisplayInfos.Remove(referenceId);
  970. }
  971. else
  972. {
  973. gDebugManager->mDisplayInfos[referenceId] = displayInfo;
  974. }
  975. }
  976. BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType)
  977. {
  978. bool foundSpecific = false;
  979. DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo;
  980. if (referenceId != NULL)
  981. {
  982. /*auto itr = gDebugManager->mDisplayInfos.find(referenceId);
  983. if (itr != gDebugManager->mDisplayInfos.end())
  984. {
  985. displayInfo = &itr->second;
  986. foundSpecific = true;
  987. }*/
  988. if (gDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo))
  989. {
  990. foundSpecific = true;
  991. }
  992. }
  993. *intDisplayType = (int8)displayInfo->mIntDisplayType;
  994. *mmDisplayType = (int8)displayInfo->mMmDisplayType;
  995. *floatDisplayType = (int8)displayInfo->mFloatDisplayType;
  996. return foundSpecific;
  997. }
  998. BF_EXPORT const char* BF_CALLTYPE Debugger_GetDisplayTypeNames()
  999. {
  1000. String& outString = *gTLStrReturn.Get();
  1001. outString.clear();
  1002. for (auto& displayInfoEntry : gDebugManager->mDisplayInfos)
  1003. {
  1004. outString += displayInfoEntry.mKey + "\n";
  1005. }
  1006. return outString.c_str();
  1007. }
  1008. BF_EXPORT const char* BF_CALLTYPE Debugger_EvaluateContinue()
  1009. {
  1010. auto debugger = gDebugger;
  1011. String& outString = *gTLStrReturn.Get();
  1012. outString = debugger->EvaluateContinue();
  1013. return outString.c_str();
  1014. }
  1015. BF_EXPORT void BF_CALLTYPE Debugger_EvaluateContinueKeep()
  1016. {
  1017. auto debugger = gDebugger;
  1018. debugger->EvaluateContinueKeep();
  1019. }
  1020. BF_EXPORT StringView BF_CALLTYPE Debugger_Evaluate(const char* expr, int callStackIdx, int cursorPos, int32 language, uint16 expressionFlags)
  1021. {
  1022. auto debugger = gDebugger;
  1023. if (debugger == NULL)
  1024. debugger = gDebugManager->mDebugger64;
  1025. String& outString = *gTLStrReturn.Get();
  1026. outString.clear();
  1027. outString = debugger->Evaluate(expr, callStackIdx, cursorPos, language, (DwEvalExpressionFlags)expressionFlags);
  1028. #ifdef BF_WANTS_LOG_DBG
  1029. {
  1030. int crPos = (int)outString.IndexOf('\n');
  1031. if (crPos != -1)
  1032. BfLogDbg("Debugger_Evaluate Result=%s\n", outString.Substring(0, crPos).c_str());
  1033. else
  1034. BfLogDbg("Debugger_Evaluate Result=%s\n", outString.c_str());
  1035. }
  1036. #endif
  1037. return outString;
  1038. }
  1039. BF_EXPORT const char* BF_CALLTYPE Debugger_EvaluateToAddress(const char* expr, int callStackIdx, int cursorPos)
  1040. {
  1041. String& outString = *gTLStrReturn.Get();
  1042. outString.clear();
  1043. if (gDebugger != NULL)
  1044. outString = gDebugger->EvaluateToAddress(expr, callStackIdx, cursorPos);
  1045. return outString.c_str();
  1046. }
  1047. BF_EXPORT const char* BF_CALLTYPE Debugger_EvaluateAtAddress(const char* expr, intptr atAddr, int cursorPos)
  1048. {
  1049. String& outString = *gTLStrReturn.Get();
  1050. outString.clear();
  1051. if (gDebugger != NULL)
  1052. outString = gDebugger->EvaluateAtAddress(expr, atAddr, cursorPos);
  1053. return outString.c_str();
  1054. }
  1055. BF_EXPORT const char* BF_CALLTYPE Debugger_GetAutoExpressions(int callStackIdx, uint64 memoryRangeStart, uint64 memoryRangeLen)
  1056. {
  1057. String& outString = *gTLStrReturn.Get();
  1058. outString = gDebugger->GetAutoExpressions(callStackIdx, memoryRangeStart, memoryRangeLen);
  1059. return outString.c_str();
  1060. }
  1061. BF_EXPORT const char* BF_CALLTYPE Debugger_GetAutoLocals(int callStackIdx, bool showRegs)
  1062. {
  1063. String& outString = *gTLStrReturn.Get();
  1064. outString = gDebugger->GetAutoLocals(callStackIdx, showRegs);
  1065. return outString.c_str();
  1066. }
  1067. BF_EXPORT const char* BF_CALLTYPE Debugger_CompactChildExpression(const char* expr, const char* parentExpr, int callStackIdx)
  1068. {
  1069. String& outString = *gTLStrReturn.Get();
  1070. outString = gDebugger->CompactChildExpression(expr, parentExpr, callStackIdx);
  1071. return outString.c_str();
  1072. }
  1073. BF_EXPORT const char* BF_CALLTYPE Debugger_GetCollectionContinuation(const char* continuationData, int callStackIdx, int count)
  1074. {
  1075. String& outString = *gTLStrReturn.Get();
  1076. outString = gDebugger->GetCollectionContinuation(continuationData, callStackIdx, count);
  1077. return outString.c_str();
  1078. }
  1079. BF_EXPORT void BF_CALLTYPE Debugger_ForegroundTarget()
  1080. {
  1081. gDebugger->ForegroundTarget();
  1082. //BOOL worked = EnumThreadWindows(gDebugger->mProcessInfo.dwThreadId, WdEnumWindowsProc, 0);
  1083. //BF_ASSERT(worked);
  1084. }
  1085. BF_EXPORT const char* BF_CALLTYPE Debugger_GetProcessInfo()
  1086. {
  1087. String& outString = *gTLStrReturn.Get();
  1088. outString = gDebugger->GetProcessInfo();
  1089. return outString.c_str();
  1090. }
  1091. BF_EXPORT const char* BF_CALLTYPE Debugger_GetThreadInfo()
  1092. {
  1093. String& outString = *gTLStrReturn.Get();
  1094. outString = gDebugger->GetThreadInfo();
  1095. return outString.c_str();
  1096. }
  1097. BF_EXPORT void BF_CALLTYPE Debugger_SetActiveThread(int threadId)
  1098. {
  1099. gDebugger->SetActiveThread(threadId);
  1100. }
  1101. BF_EXPORT int BF_CALLTYPE Debugger_GetActiveThread()
  1102. {
  1103. return gDebugger->GetActiveThread();
  1104. }
  1105. BF_EXPORT void BF_CALLTYPE Debugger_FreezeThread(int threadId)
  1106. {
  1107. gDebugger->FreezeThread(threadId);
  1108. }
  1109. BF_EXPORT void BF_CALLTYPE Debugger_ThawThread(int threadId)
  1110. {
  1111. gDebugger->ThawThread(threadId);
  1112. }
  1113. BF_EXPORT bool BF_CALLTYPE Debugger_IsActiveThreadWaiting()
  1114. {
  1115. return gDebugger->IsActiveThreadWaiting();
  1116. }
  1117. BF_EXPORT void BF_CALLTYPE CallStack_Update()
  1118. {
  1119. gDebugger->UpdateCallStack();
  1120. }
  1121. BF_EXPORT void BF_CALLTYPE CallStack_Rehup()
  1122. {
  1123. AutoCrit autoCrit(gDebugManager->mCritSect);
  1124. gDebugger->ClearCallStack();
  1125. }
  1126. BF_EXPORT int BF_CALLTYPE CallStack_GetCount()
  1127. {
  1128. return gDebugger->GetCallStackCount();
  1129. }
  1130. BF_EXPORT int BF_CALLTYPE CallStack_GetRequestedStackFrameIdx()
  1131. {
  1132. return gDebugger->GetRequestedStackFrameIdx();
  1133. }
  1134. BF_EXPORT int BF_CALLTYPE CallStack_GetBreakStackFrameIdx()
  1135. {
  1136. return gDebugger->GetBreakStackFrameIdx();
  1137. }
  1138. BF_EXPORT const char* BF_CALLTYPE CallStack_GetStackFrameInfo(int stackFrameIdx, intptr* addr, const char** outFile, int32* outHotIdx, int32* outDefLineStart, int32* outDefLineEnd,
  1139. int32* outLine, int32* outColumn, int32* outLanguage, int32* outStackSize, int8* outFlags)
  1140. {
  1141. String& outString = *gTLStrReturn.Get();
  1142. String& outString2 = *gTLStrReturn2.Get();
  1143. outString = gDebugger->GetStackFrameInfo(stackFrameIdx, addr, &outString2, outHotIdx, outDefLineStart, outDefLineEnd, outLine, outColumn, outLanguage, outStackSize, outFlags);
  1144. *outFile = outString2.c_str();
  1145. return outString.c_str();
  1146. }
  1147. BF_EXPORT const char* BF_CALLTYPE Callstack_GetStackFrameOldFileInfo(int stackFrameIdx)
  1148. {
  1149. String& outString = *gTLStrReturn.Get();
  1150. outString = gDebugger->Callstack_GetStackFrameOldFileInfo(stackFrameIdx);
  1151. return outString.c_str();
  1152. }
  1153. // -1 = no jump, 0 = won't jump, 1 = will jump
  1154. BF_EXPORT int BF_CALLTYPE CallStack_GetJmpState(int stackFrameIdx)
  1155. {
  1156. return gDebugger->GetJmpState(stackFrameIdx);
  1157. }
  1158. BF_EXPORT intptr BF_CALLTYPE Debugger_GetStackFrameCalleeAddr(int stackFrameIdx)
  1159. {
  1160. return gDebugger->GetStackFrameCalleeAddr(stackFrameIdx);
  1161. }
  1162. BF_EXPORT const char* BF_CALLTYPE Debugger_GetCodeAddrInfo(intptr addr, int* outHotIdx, int* outDefLineStart, int* outDefLineEnd, int* outLine, int* outColumn)
  1163. {
  1164. String& outString = *gTLStrReturn.Get();
  1165. outString.clear();
  1166. gDebugger->GetCodeAddrInfo(addr, &outString, outHotIdx, outDefLineStart, outDefLineEnd, outLine, outColumn);
  1167. return outString.c_str();
  1168. }
  1169. BF_EXPORT void BF_CALLTYPE Debugger_GetStackAllocInfo(intptr addr, int* outThreadId, int* outStackIdx)
  1170. {
  1171. gDebugger->GetStackAllocInfo(addr, outThreadId, outStackIdx);
  1172. }
  1173. BF_EXPORT const char* BF_CALLTYPE CallStack_GetStackMethodOwner(int stackFrameIdx, int& language)
  1174. {
  1175. String& outString = *gTLStrReturn.Get();
  1176. outString = gDebugger->GetStackMethodOwner(stackFrameIdx, language);
  1177. return outString.c_str();
  1178. }
  1179. BF_EXPORT const char* BF_CALLTYPE Debugger_FindCodeAddresses(const char* fileName, int line, int column, bool allowAutoResolve)
  1180. {
  1181. String& outString = *gTLStrReturn.Get();
  1182. outString = gDebugger->FindCodeAddresses(fileName, line, column, allowAutoResolve);
  1183. return outString.c_str();
  1184. }
  1185. BF_EXPORT const char* BF_CALLTYPE Debugger_GetAddressSourceLocation(intptr address)
  1186. {
  1187. String& outString = *gTLStrReturn.Get();
  1188. if (gDebugger != NULL)
  1189. outString = gDebugger->GetAddressSourceLocation(address);
  1190. else
  1191. outString = "";
  1192. return outString.c_str();
  1193. }
  1194. BF_EXPORT const char* BF_CALLTYPE Debugger_GetAddressSymbolName(intptr address, bool demangle)
  1195. {
  1196. String& outString = *gTLStrReturn.Get();
  1197. if (gDebugger != NULL)
  1198. outString = gDebugger->GetAddressSymbolName(address, demangle);
  1199. else
  1200. outString = "";
  1201. return outString.c_str();
  1202. }
  1203. BF_EXPORT const char* BF_CALLTYPE Debugger_FindLineCallAddresses(intptr address)
  1204. {
  1205. String& outString = *gTLStrReturn.Get();
  1206. outString = gDebugger->FindLineCallAddresses(address);
  1207. return outString.c_str();
  1208. }
  1209. BF_EXPORT const char* BF_CALLTYPE Debugger_DisassembleAt(intptr address)
  1210. {
  1211. String& outString = *gTLStrReturn.Get();
  1212. outString = gDebugger->DisassembleAt(address);
  1213. return outString.c_str();
  1214. }
  1215. BF_EXPORT void BF_CALLTYPE Debugger_ReadMemory(uintptr address, uintptr size, unsigned char* data)
  1216. {
  1217. if (gDebugger == NULL)
  1218. return;
  1219. gDebugger->ReadMemory(address, size, data);
  1220. }
  1221. BF_EXPORT void BF_CALLTYPE Debugger_WriteMemory(uintptr address, uintptr size, unsigned char* data)
  1222. {
  1223. if (gDebugger == NULL)
  1224. return;
  1225. gDebugger->WriteMemory(address, data, size);
  1226. }
  1227. BF_EXPORT const char* BF_CALLTYPE Debugger_GetModulesInfo()
  1228. {
  1229. String& outString = *gTLStrReturn.Get();
  1230. outString = gDebugger->GetModulesInfo();
  1231. return outString.c_str();
  1232. }
  1233. BF_EXPORT void BF_CALLTYPE Debugger_CancelSymSrv()
  1234. {
  1235. gDebugger->CancelSymSrv();
  1236. }
  1237. BF_EXPORT int BF_CALLTYPE Debugger_LoadImageForModuleWith(const char* moduleName, const char* debugFilePath) // 0 = No Change, 1 = Loaded, 2 = Loading in background
  1238. {
  1239. return gDebugger->LoadImageForModule(moduleName, debugFilePath);
  1240. }
  1241. BF_EXPORT int BF_CALLTYPE Debugger_LoadDebugInfoForModule(const char* moduleName) // 0 = No Change, 1 = Loaded, 2 = Loading in background
  1242. {
  1243. return gDebugger->LoadDebugInfoForModule(moduleName);
  1244. }
  1245. BF_EXPORT int BF_CALLTYPE Debugger_LoadDebugInfoForModuleWith(const char* moduleName, const char* debugFilePath) // 0 = No Change, 1 = Loaded, 2 = Loading in background
  1246. {
  1247. return gDebugger->LoadDebugInfoForModule(moduleName, debugFilePath);
  1248. }
  1249. BF_EXPORT void BF_CALLTYPE Debugger_SetStepOverExternalFiles(bool stepOverExternalFiles)
  1250. {
  1251. gDebugManager->mStepOverExternalFiles = stepOverExternalFiles;
  1252. gDebugManager->mStepFilterVersion++;
  1253. }
  1254. BF_EXPORT void BF_CALLTYPE BfLog_Log(char* str)
  1255. {
  1256. BfLog(str);
  1257. }
  1258. BF_EXPORT void BF_CALLTYPE BfLog_LogDbg(char* str)
  1259. {
  1260. BfLogDbg(str);
  1261. }
  1262. BF_EXPORT Profiler* BF_CALLTYPE Debugger_StartProfiling(intptr threadId, char* desc, int sampleRate)
  1263. {
  1264. BF_ASSERT(sampleRate > 0);
  1265. Profiler* profiler = gDebugger->StartProfiling();
  1266. profiler->mTargetThreadId = threadId;
  1267. if (desc != NULL)
  1268. profiler->mDescription = desc;
  1269. profiler->mSamplesPerSecond = sampleRate;
  1270. profiler->Start();
  1271. return profiler;
  1272. }
  1273. BF_EXPORT Profiler* BF_CALLTYPE Debugger_PopProfiler()
  1274. {
  1275. Profiler* profiler = gDebugger->PopProfiler();
  1276. return profiler;
  1277. }
  1278. BF_EXPORT void BF_CALLTYPE Debugger_InitiateHotResolve(int flags)
  1279. {
  1280. if (gDebugger != NULL)
  1281. gDebugger->InitiateHotResolve((DbgHotResolveFlags)flags);
  1282. }
  1283. BF_EXPORT intptr BF_CALLTYPE Debugger_GetDbgAllocHeapSize()
  1284. {
  1285. AutoCrit autoCrit(gDebugManager->mCritSect);
  1286. return gDebugger->GetDbgAllocHeapSize();
  1287. }
  1288. BF_EXPORT const char* BF_CALLTYPE Debugger_GetDbgAllocInfo()
  1289. {
  1290. AutoCrit autoCrit(gDebugManager->mCritSect);
  1291. String& outString = *gTLStrReturn.Get();
  1292. outString = gDebugger->GetDbgAllocInfo();
  1293. return outString.c_str();
  1294. }
  1295. BF_EXPORT const char* BF_CALLTYPE Debugger_GetHotResolveData(uint8* outTypeData, int* outTypeDataSize)
  1296. {
  1297. AutoCrit autoCrit(gDebugManager->mCritSect);
  1298. if (gDebugger->mHotResolveData == NULL)
  1299. {
  1300. *outTypeDataSize = -1;
  1301. return NULL;
  1302. }
  1303. int dataSize = (int)gDebugger->mHotResolveData->mTypeData.size();
  1304. if (*outTypeDataSize < dataSize)
  1305. {
  1306. *outTypeDataSize = dataSize;
  1307. return NULL;
  1308. }
  1309. *outTypeDataSize = dataSize;
  1310. if (dataSize > 0)
  1311. {
  1312. for (int i = 0; i < dataSize; i++)
  1313. outTypeData[i] = (gDebugger->mHotResolveData->mTypeData[i].mCount > 0) ? 1 : 0;
  1314. }
  1315. String& outString = *gTLStrReturn.Get();
  1316. outString.Clear();
  1317. for (auto& str : gDebugger->mHotResolveData->mBeefCallStackEntries)
  1318. {
  1319. if (!outString.IsEmpty())
  1320. outString += "\n";
  1321. outString += str;
  1322. }
  1323. return outString.c_str();
  1324. }
  1325. BF_EXPORT const char* BF_CALLTYPE Debugger_GetEmitSource(char* inFilePath)
  1326. {
  1327. AutoCrit autoCrit(gDebugManager->mCritSect);
  1328. String& outString = *gTLStrReturn.Get();
  1329. outString.Clear();
  1330. if (!gDebugger->GetEmitSource(inFilePath, outString))
  1331. return NULL;
  1332. return outString.c_str();
  1333. }
  1334. BF_EXPORT NetResult* HTTP_GetFile(char* url, char* destPath)
  1335. {
  1336. AutoCrit autoCrit(gDebugManager->mNetManager->mThreadPool.mCritSect);
  1337. auto netResult = gDebugManager->mNetManager->QueueGet(url, destPath, false);
  1338. netResult->mDoneEvent = new SyncEvent();
  1339. return netResult;
  1340. }
  1341. BF_EXPORT int HTTP_GetResult(NetResult* netResult, int waitMS)
  1342. {
  1343. if (netResult->mDoneEvent->WaitFor(waitMS))
  1344. {
  1345. return netResult->mFailed ? 0 : 1;
  1346. }
  1347. else
  1348. {
  1349. return -1;
  1350. }
  1351. }
  1352. BF_EXPORT void HTTP_GetLastError(NetResult* netResult, const char** error, int* errorLength)
  1353. {
  1354. *error = netResult->mError.GetPtr();
  1355. *errorLength = netResult->mError.GetLength();
  1356. }
  1357. BF_EXPORT void HTTP_Delete(NetResult* netResult)
  1358. {
  1359. if (!netResult->mDoneEvent->WaitFor(0))
  1360. {
  1361. ///
  1362. {
  1363. AutoCrit autoCrit(gDebugManager->mNetManager->mThreadPool.mCritSect);
  1364. if (netResult->mCurRequest != NULL)
  1365. netResult->mCurRequest->Cancel();
  1366. }
  1367. netResult->mDoneEvent->WaitFor(-1);
  1368. }
  1369. delete netResult;
  1370. }
  1371. BF_EXPORT void Debugger_SetAliasPath(char* origPath, char* localPath)
  1372. {
  1373. gDebugger->SetAliasPath(origPath, localPath);
  1374. }
  1375. ///
  1376. BF_EXPORT bool BF_CALLTYPE Profiler_IsRunning(Profiler* profiler)
  1377. {
  1378. return profiler->IsSampling();
  1379. }
  1380. BF_EXPORT void BF_CALLTYPE Profiler_Stop(Profiler* profiler)
  1381. {
  1382. profiler->Stop();
  1383. }
  1384. BF_EXPORT void BF_CALLTYPE Profiler_Clear(Profiler* profiler)
  1385. {
  1386. profiler->Clear();
  1387. }
  1388. BF_EXPORT const char* BF_CALLTYPE Profiler_GetOverview(Profiler* profiler)
  1389. {
  1390. String& outString = *gTLStrReturn.Get();
  1391. outString = profiler->GetOverview();
  1392. return outString.c_str();
  1393. }
  1394. BF_EXPORT const char* BF_CALLTYPE Profiler_GetThreadList(Profiler* profiler)
  1395. {
  1396. String& outString = *gTLStrReturn.Get();
  1397. outString = profiler->GetThreadList();
  1398. return outString.c_str();
  1399. }
  1400. BF_EXPORT const char* BF_CALLTYPE Profiler_GetCallTree(Profiler* profiler, int threadId, bool reverse)
  1401. {
  1402. String& outString = *gTLStrReturn.Get();
  1403. outString = profiler->GetCallTree(threadId, reverse);
  1404. return outString.c_str();
  1405. }
  1406. BF_EXPORT void BF_CALLTYPE Profiler_Delete(Profiler* profiler)
  1407. {
  1408. int z = 0;
  1409. delete profiler;
  1410. }
  1411. BF_TLS_DECLSPEC static int gTLSValue = 3;
  1412. BF_EXPORT void BF_CALLTYPE TimeTest(uint32 startTime)
  1413. {
  1414. gTLSValue++;
  1415. int elapsedTime = BFTickCount() - startTime;
  1416. OutputDebugStrF("Load Time: %d\n", elapsedTime);
  1417. }
  1418. BF_EXPORT void BF_CALLTYPE BFTest()
  1419. {
  1420. struct DeferredResolveEntry2
  1421. {
  1422. BfFieldDef* mFieldDef;
  1423. int mTypeArrayIdx;
  1424. };
  1425. DeferredResolveEntry2 entry = { NULL, 333 };
  1426. llvm::SmallVector<DeferredResolveEntry2, 8> vec;
  1427. vec.push_back(DeferredResolveEntry2 { NULL, 111 } );
  1428. vec.push_back(DeferredResolveEntry2 { NULL, 222 } );
  1429. }
  1430. ///
  1431. // __attribute__((weak))
  1432. // Debugger* Beefy::CreateDebugger32(DebugManager* debugManager, DbgMiniDump* miniDump)
  1433. // {
  1434. // return NULL;
  1435. // }