templeos-info/public/Wb/Adam/Opt/Utils/HeapLog.HC.HTML

243 lines
26 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Debugging/Heap;Memory/Debugging&quot;</span><span class=cF0>
<a name="l2"></a>#</span><span class=cF1>help_file</span><span class=cF0> </span><span class=cF6>&quot;::/Doc/HeapDbg&quot;</span><span class=cF0>
<a name="l3"></a>
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0> 5 </span><span class=cF2>//Feel free to change this.</span><span class=cF0>
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>HL_HASH_SIZE</span><span class=cF0> 0x1000
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>class</span><span class=cF0> </span><span class=cF9>CHeapLog</span><span class=cF0>
<a name="l8"></a>{
<a name="l9"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *next,*last;
<a name="l10"></a> </span><span class=cF1>union</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>U8</span><span class=cF0> *addr;
<a name="l12"></a> </span><span class=cF9>I64</span><span class=cF0> size;
<a name="l13"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l14"></a> </span><span class=cF9>I64</span><span class=cF0> cnt;
<a name="l15"></a> </span><span class=cF1>U8</span><span class=cF0> *caller[</span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0>];
<a name="l16"></a>};
<a name="l17"></a>
<a name="l18"></a></span><span class=cF1>class</span><span class=cF0> </span><span class=cF9>CHeapLogHash</span><span class=cF0>
<a name="l19"></a>{
<a name="l20"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *next,*last;
<a name="l21"></a>};
<a name="l22"></a>
<a name="l23"></a></span><span class=cF9>CHeapCtrl</span><span class=cF0> *</span><span class=cFB>heaplog_hc_watched</span><span class=cF0>,*</span><span class=cFB>heaplog_hc</span><span class=cF0>=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l24"></a></span><span class=cF9>CHeapLogHash</span><span class=cF0> *</span><span class=cFB>heaplog_head</span><span class=cF0>=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l25"></a>
<a name="l26"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>HeapLogMAlloc</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr)
<a name="l27"></a>{
<a name="l28"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *tmphl;
<a name="l29"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l30"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>MHeapCtrl</span><span class=cF7>(</span><span class=cF0>addr</span><span class=cF7>)</span><span class=cF0>==</span><span class=cFB>heaplog_hc_watched</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l31"></a> tmphl=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLog</span><span class=cF7>)</span><span class=cF0>,</span><span class=cFB>heaplog_hc</span><span class=cF0>);
<a name="l32"></a> tmphl-&gt;addr=addr;
<a name="l33"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0>;i++)
<a name="l34"></a> tmphl-&gt;caller[i]=</span><span class=cF5>Caller</span><span class=cF0>(i+2);
<a name="l35"></a> i=addr&gt;&gt;3 &amp;(</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>-1);
<a name="l36"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l37"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l38"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>)
<a name="l39"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l40"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmphl,</span><span class=cFB>heaplog_head</span><span class=cF0>[i].last);
<a name="l41"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l42"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l43"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l44"></a>}
<a name="l45"></a>
<a name="l46"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>HeapLogFree</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr)
<a name="l47"></a>{
<a name="l48"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l49"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *tmphl;
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (!addr) </span><span class=cF1>return</span><span class=cF0>;
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>MHeapCtrl</span><span class=cF7>(</span><span class=cF0>addr</span><span class=cF7>)</span><span class=cF0>==</span><span class=cFB>heaplog_hc_watched</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l52"></a> i=addr&gt;&gt;3 &amp;(</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>-1);
<a name="l53"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l54"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l55"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>)
<a name="l56"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l57"></a> tmphl=</span><span class=cFB>heaplog_head</span><span class=cF0>[i].next;
<a name="l58"></a> </span><span class=cF1>while</span><span class=cF0> (tmphl!=&amp;</span><span class=cFB>heaplog_head</span><span class=cF0>[i]) {
<a name="l59"></a> </span><span class=cF1>if</span><span class=cF0> (addr==tmphl-&gt;addr) </span><span class=cF7>{</span><span class=cF0>
<a name="l60"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmphl);
<a name="l61"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l62"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l63"></a> </span><span class=cF5>Free</span><span class=cF0>(tmphl);
<a name="l64"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> tmphl=tmphl-&gt;next;
<a name="l67"></a> }
<a name="l68"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l69"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l70"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l71"></a>}
<a name="l72"></a>
<a name="l73"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>HeapLog</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val=</span><span class=cF3>ON</span><span class=cF0>,</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l74"></a>{</span><span class=cF2>//Turn on. Collect data. Call </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC.HTML#l115"><span class=cF4>HeapLogAddrRep</span></a><span class=cF2>() or </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC.HTML#l146"><span class=cF4>HeapLogSizeRep</span></a><span class=cF2>().</span><span class=cF0>
<a name="l75"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (val) </span><span class=cF7>{</span><span class=cF0>
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>) {
<a name="l78"></a> </span><span class=cF6>&quot;HeapLog Already Active\n&quot;</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l80"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (!task) task=</span><span class=cF5>Fs</span><span class=cF0>;
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0>)
<a name="l83"></a> </span><span class=cFB>heaplog_hc_watched</span><span class=cF0>=task-&gt;data_heap;
<a name="l84"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l85"></a> </span><span class=cFB>heaplog_hc_watched</span><span class=cF0>=task;</span><span class=cF2>//Actually, not a task, must be a HeapCtrl.</span><span class=cF0>
<a name="l86"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l87"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l88"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>)
<a name="l89"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l90"></a> </span><span class=cFB>heaplog_hc</span><span class=cF0>=</span><span class=cF5>HeapCtrlInit</span><span class=cF0>(,,</span><span class=cFB>sys_data_bp</span><span class=cF0>);
<a name="l91"></a> </span><span class=cFB>ext</span><span class=cF0>[</span><span class=cF3>EXT_HEAPLOG_MALLOC</span><span class=cF0>]=&amp;</span><span class=cF5>HeapLogMAlloc</span><span class=cF0>;
<a name="l92"></a> </span><span class=cFB>ext</span><span class=cF0>[</span><span class=cF3>EXT_HEAPLOG_FREE</span><span class=cF0>]=&amp;</span><span class=cF5>HeapLogFree</span><span class=cF0>;
<a name="l93"></a> </span><span class=cFB>heaplog_head</span><span class=cF0>=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLogHash</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>,</span><span class=cFB>heaplog_hc</span><span class=cF0>);
<a name="l94"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>;i++)
<a name="l95"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;</span><span class=cFB>heaplog_head</span><span class=cF0>[i]);
<a name="l96"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l97"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l98"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0);
<a name="l99"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l100"></a> }
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>LBtr</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>) {
<a name="l103"></a> </span><span class=cF6>&quot;HeapLog Not Active\n&quot;</span><span class=cF0>;
<a name="l104"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l105"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l106"></a> </span><span class=cF5>HeapCtrlDel</span><span class=cF0>(</span><span class=cFB>heaplog_hc</span><span class=cF0>);
<a name="l107"></a> </span><span class=cFB>heaplog_head</span><span class=cF0>=</span><span class=cFB>heaplog_hc</span><span class=cF0>=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l108"></a> </span><span class=cFB>ext</span><span class=cF0>[</span><span class=cF3>EXT_HEAPLOG_MALLOC</span><span class=cF0>]=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l109"></a> </span><span class=cFB>ext</span><span class=cF0>[</span><span class=cF3>EXT_HEAPLOG_FREE</span><span class=cF0>]=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l110"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l111"></a> }
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l113"></a>}
<a name="l114"></a>
<a name="l115"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>HeapLogAddrRep</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> leave_it=</span><span class=cF3>OFF</span><span class=cF0>)
<a name="l116"></a>{</span><span class=cF2>//Call </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC.HTML#l73"><span class=cF4>HeapLog</span></a><span class=cF2>() first and collect data.</span><span class=cF0>
<a name="l117"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,total=0;
<a name="l118"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *tmphl,hl;
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>LBtr</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l120"></a> </span><span class=cF6>&quot;HeapLog Not Active\n&quot;</span><span class=cF0>;
<a name="l121"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l122"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l123"></a> </span><span class=cF6>&quot;$WW,0$&quot;</span><span class=cF0>;
<a name="l124"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>)
<a name="l125"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l126"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l127"></a> tmphl=</span><span class=cFB>heaplog_head</span><span class=cF0>[i].next;
<a name="l128"></a> </span><span class=cF1>while</span><span class=cF0> (tmphl!=&amp;</span><span class=cFB>heaplog_head</span><span class=cF0>[i]) {
<a name="l129"></a></span><span class=cF2>//Take snapshot in case modified. (while we work)</span><span class=cF0>
<a name="l130"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&amp;hl,tmphl,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLog</span><span class=cF7>)</span><span class=cF0>);
<a name="l131"></a> </span><span class=cF6>&quot;$PURPLE$%08X$FG$ %08X&quot;</span><span class=cF0>,</span><span class=cF5>MSize</span><span class=cF0>(hl.addr),hl.addr;
<a name="l132"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;</span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0>;j++)
<a name="l133"></a> </span><span class=cF6>&quot; %P&quot;</span><span class=cF0>,hl.caller[j];
<a name="l134"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l135"></a> total+=</span><span class=cF5>MSize</span><span class=cF0>(hl.addr);
<a name="l136"></a> tmphl=hl.next;
<a name="l137"></a> }
<a name="l138"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l139"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l140"></a> </span><span class=cF6>&quot;\n$LTRED$Total:%08X$FG$\n&quot;</span><span class=cF0>,total;
<a name="l141"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0);
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (!leave_it)
<a name="l143"></a> </span><span class=cF5>HeapLog</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l144"></a>}
<a name="l145"></a>
<a name="l146"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>HeapLogSizeRep</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> leave_it=</span><span class=cF3>OFF</span><span class=cF0>)
<a name="l147"></a>{</span><span class=cF2>//Call </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC.HTML#l73"><span class=cF4>HeapLog</span></a><span class=cF2>() first and collect data.</span><span class=cF0>
<a name="l148"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,k,total=0;
<a name="l149"></a> </span><span class=cF9>CHeapLog</span><span class=cF0> *tmphla,hla,*tmphls,*tmphls1;
<a name="l150"></a> </span><span class=cF9>CHeapLogHash</span><span class=cF0> *size_head;
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>LBtr</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l152"></a> </span><span class=cF6>&quot;HeapLog Not Active\n&quot;</span><span class=cF0>;
<a name="l153"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l154"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l155"></a>
<a name="l156"></a> size_head=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLogHash</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>,</span><span class=cFB>heaplog_hc</span><span class=cF0>);
<a name="l157"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>;i++)
<a name="l158"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;size_head[i]);
<a name="l159"></a>
<a name="l160"></a> </span><span class=cF6>&quot;$WW,0$&quot;</span><span class=cF0>;
<a name="l161"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0</span><span class=cF7>)</span><span class=cF0>)
<a name="l162"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l163"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l164"></a> tmphla=</span><span class=cFB>heaplog_head</span><span class=cF0>[i].next;
<a name="l165"></a> </span><span class=cF1>while</span><span class=cF0> (tmphla!=&amp;</span><span class=cFB>heaplog_head</span><span class=cF0>[i]) {
<a name="l166"></a></span><span class=cF2>//Take snapshot in case modified. (while we work)</span><span class=cF0>
<a name="l167"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&amp;hla,tmphla,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLog</span><span class=cF7>)</span><span class=cF0>);
<a name="l168"></a> k=(</span><span class=cF5>MSize</span><span class=cF7>(</span><span class=cF0>hla.addr</span><span class=cF7>)</span><span class=cF0>&gt;&gt;3+hla.caller[0])&amp;(</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>-1);
<a name="l169"></a> tmphls=size_head[k].next;
<a name="l170"></a> </span><span class=cF1>while</span><span class=cF0> (tmphls!=&amp;size_head[k]) </span><span class=cF7>{</span><span class=cF0>
<a name="l171"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>MSize</span><span class=cF7>(</span><span class=cF0>hla.addr</span><span class=cF7>)</span><span class=cF0>==tmphls-&gt;size) {
<a name="l172"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;</span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0>;j++)
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (hla.caller[j]!=tmphls-&gt;caller[j])
<a name="l174"></a> </span><span class=cF1>goto</span><span class=cF0> hl_next;
<a name="l175"></a> tmphls-&gt;cnt++;
<a name="l176"></a> </span><span class=cF1>goto</span><span class=cF0> hl_found;
<a name="l177"></a> }
<a name="l178"></a>hl_next:
<a name="l179"></a> tmphls=tmphls-&gt;next;
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l181"></a> tmphls=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLog</span><span class=cF7>)</span><span class=cF0>,</span><span class=cFB>heaplog_hc</span><span class=cF0>);
<a name="l182"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmphls,&amp;hla,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHeapLog</span><span class=cF7>)</span><span class=cF0>);
<a name="l183"></a> tmphls-&gt;cnt=1;
<a name="l184"></a> tmphls-&gt;size=</span><span class=cF5>MSize</span><span class=cF0>(hla.addr);
<a name="l185"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmphls,size_head[k].last);
<a name="l186"></a>hl_found:
<a name="l187"></a> tmphla=hla.next;
<a name="l188"></a> }
<a name="l189"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l190"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_LOCK</span><span class=cF0>],0);
<a name="l191"></a>
<a name="l192"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>HL_HASH_SIZE</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l193"></a> tmphls=size_head[i].next;
<a name="l194"></a> </span><span class=cF1>while</span><span class=cF0> (tmphls!=&amp;size_head[i]) {
<a name="l195"></a> tmphls1=tmphls-&gt;next;
<a name="l196"></a> </span><span class=cF6>&quot;%08X*%08X=%08X&quot;</span><span class=cF0>,tmphls-&gt;size,tmphls-&gt;cnt,tmphls-&gt;size*tmphls-&gt;cnt;
<a name="l197"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;</span><span class=cF3>HL_CALLER_DEPTH</span><span class=cF0>;j++)
<a name="l198"></a> </span><span class=cF6>&quot; %P&quot;</span><span class=cF0>,tmphls-&gt;caller[j];
<a name="l199"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l200"></a> total+=tmphls-&gt;size*tmphls-&gt;cnt;
<a name="l201"></a> </span><span class=cF5>Free</span><span class=cF0>(tmphls);
<a name="l202"></a> tmphls=tmphls1;
<a name="l203"></a> }
<a name="l204"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l205"></a> </span><span class=cF5>Free</span><span class=cF0>(size_head);
<a name="l206"></a>
<a name="l207"></a> </span><span class=cF6>&quot;\n$LTRED$Total:%08X$FG$\n&quot;</span><span class=cF0>,total;
<a name="l208"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_HEAPLOG_ACTIVE</span><span class=cF0>],0);
<a name="l209"></a> </span><span class=cF1>if</span><span class=cF0> (!leave_it)
<a name="l210"></a> </span><span class=cF5>HeapLog</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l211"></a>}
</span></pre></body>
</html>