templeos-info/public/Wb/Kernel/FunSeg.HC.HTML

392 lines
40 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!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=cF9>I64</span><span class=cF0> </span><span class=cFD>HasLower</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l4"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*src++)
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'a'</span><span class=cF0>&lt;=ch&lt;=</span><span class=cF6>'z'</span><span class=cF0>)
<a name="l6"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l7"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l8"></a>}
<a name="l9"></a>
<a name="l10"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>HashFunSegFind</span><span class=cF0>(</span><span class=cF9>CHashTable</span><span class=cF0> *h,</span><span class=cF1>U8</span><span class=cF0> *addr,
<a name="l11"></a> </span><span class=cF1>Bool</span><span class=cF0> *_has_lower,</span><span class=cF9>U64</span><span class=cF0> *_best,</span><span class=cF9>CHash</span><span class=cF0> **_res)
<a name="l12"></a>{
<a name="l13"></a> </span><span class=cF1>Bool</span><span class=cF0> *has_lower=*_has_lower;
<a name="l14"></a> </span><span class=cF9>CHashExport</span><span class=cF0> *tmpex;
<a name="l15"></a> </span><span class=cF9>U64</span><span class=cF0> i,j,best=*_best;
<a name="l16"></a> </span><span class=cF9>CHash</span><span class=cF0> *res=*_res;
<a name="l17"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;=h-&gt;mask;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> tmpex=h-&gt;body[i];
<a name="l19"></a> </span><span class=cF1>while</span><span class=cF0> (tmpex) {
<a name="l20"></a> j=0;
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex-&gt;type&amp;</span><span class=cF3>HTT_FUN</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;tmpex(</span><span class=cF9>CHashFun</span><span class=cF0> *)-&gt;flags,</span><span class=cF3>Cf_EXTERN</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l23"></a> !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;tmpex(</span><span class=cF9>CHashFun</span><span class=cF0> *)-&gt;flags,</span><span class=cF3>Ff_INTERNAL</span><span class=cF7>)</span><span class=cF0>)
<a name="l24"></a> j=tmpex(</span><span class=cF9>CHashFun</span><span class=cF0> *)-&gt;exe_addr;
<a name="l25"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpex-&gt;type&amp;</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>)
<a name="l26"></a> j=tmpex-&gt;val;
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (j) </span><span class=cF7>{</span><span class=cF0>
<a name="l28"></a> j=addr(</span><span class=cF9>I64</span><span class=cF0>)-j;
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=j&lt;=best) {
<a name="l30"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex-&gt;type&amp;</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (j&lt;best || j==best &amp;&amp; !has_lower) {
<a name="l32"></a> has_lower=</span><span class=cFD>HasLower</span><span class=cF0>(tmpex-&gt;str);
<a name="l33"></a> best=j;
<a name="l34"></a> res=tmpex;
<a name="l35"></a> }
<a name="l36"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpex-&gt;type&amp;</span><span class=cF3>HTT_FUN</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (j&lt;best || j==best &amp;&amp;
<a name="l38"></a> </span><span class=cF7>(</span><span class=cF0>res &amp;&amp; res-&gt;type&amp;</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>||!has_lower</span><span class=cF7>)</span><span class=cF0>) {
<a name="l39"></a> has_lower=</span><span class=cFD>HasLower</span><span class=cF0>(tmpex-&gt;str);
<a name="l40"></a> best=j;
<a name="l41"></a> res=tmpex;
<a name="l42"></a> }
<a name="l43"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l44"></a> }
<a name="l45"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l46"></a> tmpex=tmpex-&gt;next;
<a name="l47"></a> }
<a name="l48"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l49"></a> *_has_lower=has_lower;
<a name="l50"></a> *_best=best;
<a name="l51"></a> *_res =res;
<a name="l52"></a>}
<a name="l53"></a>
<a name="l54"></a></span><span class=cF9>CHash</span><span class=cF0> *</span><span class=cF5>FunSegFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> *_offset)
<a name="l55"></a>{</span><span class=cF2>//See </span><span class=cF4><u>Hash</u></span><span class=cF2>.</span><span class=cF0>
<a name="l56"></a> </span><span class=cF9>CHash</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l57"></a> </span><span class=cF1>Bool</span><span class=cF0> has_lower=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l58"></a> </span><span class=cF9>CTask</span><span class=cF0> *task;
<a name="l59"></a> </span><span class=cF9>CHashTable</span><span class=cF0> *h;
<a name="l60"></a> </span><span class=cF9>CCPU</span><span class=cF0> *c;
<a name="l61"></a> </span><span class=cF9>U64</span><span class=cF0> i,best=0xFFFF;
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>ChkCodePtr</span><span class=cF7>(</span><span class=cF0>addr</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l63"></a> *_offset=best;
<a name="l64"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDbgMode</span><span class=cF0>)
<a name="l67"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l68"></a> c=&amp;</span><span class=cFB>cpu_structs</span><span class=cF0>[i];
<a name="l69"></a> task=c-&gt;seth_task;
<a name="l70"></a> </span><span class=cF1>do</span><span class=cF0> {
<a name="l71"></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>) </span><span class=cF1>goto</span><span class=cF0> fs_abort_task;
<a name="l72"></a> h=task-&gt;hash_table;
<a name="l73"></a> </span><span class=cF1>while</span><span class=cF0> (h) </span><span class=cF7>{</span><span class=cF0>
<a name="l74"></a> </span><span class=cFD>HashFunSegFind</span><span class=cF0>(h,addr,&amp;has_lower,&amp;best,&amp;res);
<a name="l75"></a> h=h-&gt;next;
<a name="l76"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l77"></a> task=task-&gt;next_task;
<a name="l78"></a> } </span><span class=cF1>while</span><span class=cF0> (task!=c-&gt;seth_task);
<a name="l79"></a>fs_abort_task:
<a name="l80"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l81"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l82"></a> h=</span><span class=cF5>Fs</span><span class=cF0>-&gt;hash_table;
<a name="l83"></a> </span><span class=cF1>while</span><span class=cF0> (h) {
<a name="l84"></a> </span><span class=cFD>HashFunSegFind</span><span class=cF0>(h,addr,&amp;has_lower,&amp;best,&amp;res);
<a name="l85"></a> h=h-&gt;next;
<a name="l86"></a> }
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l88"></a> *_offset=best;
<a name="l89"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l90"></a>}
<a name="l91"></a>
<a name="l92"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>FunSegCacheAdd</span><span class=cF0>(</span><span class=cF9>CHash</span><span class=cF0> *tmps,</span><span class=cF1>U8</span><span class=cF0> *addr)
<a name="l93"></a>{
<a name="l94"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l95"></a> </span><span class=cF9>CDbgInfo</span><span class=cF0> *dbg_info;
<a name="l96"></a> </span><span class=cF9>CFunSegCache</span><span class=cF0> *tmpfsc;
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (tmps &amp;&amp; tmps-&gt;type&amp;</span><span class=cF3>HTT_FUN</span><span class=cF0> &amp;&amp;
<a name="l98"></a> </span><span class=cF7>(</span><span class=cF0>dbg_info=tmps(</span><span class=cF9>CHashFun</span><span class=cF0> *)-&gt;dbg_info</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l99"></a> </span><span class=cF1>lock</span><span class=cF0> i=</span><span class=cFB>dbg</span><span class=cF0>.fun_seg_cache_index++;
<a name="l100"></a> tmpfsc=&amp;</span><span class=cFB>dbg</span><span class=cF0>.fun_seg_cache[i&amp;(</span><span class=cF3>FUN_SEG_CACHE_SIZE</span><span class=cF0>-1)];
<a name="l101"></a> tmpfsc-&gt;base=dbg_info-&gt;body[0];
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (addr&lt;tmpfsc-&gt;base)
<a name="l103"></a> tmpfsc-&gt;base=addr;
<a name="l104"></a> tmpfsc-&gt;limit=dbg_info-&gt;body[dbg_info-&gt;max_line+1-dbg_info-&gt;min_line];
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (addr&gt;=tmpfsc-&gt;limit)
<a name="l106"></a> tmpfsc-&gt;limit=addr+1;
<a name="l107"></a> i=</span><span class=cF5>MinI64</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>tmps-&gt;str</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF3>FUN_SEG_CACHE_STR_LEN</span><span class=cF0>-1);
<a name="l108"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmpfsc-&gt;str,tmps-&gt;str,i);
<a name="l109"></a> tmpfsc-&gt;str[i]=0;
<a name="l110"></a> tmpfsc-&gt;time_stamp=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l111"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l112"></a>}
<a name="l113"></a>
<a name="l114"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>FunSegCacheFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> *_offset)
<a name="l115"></a>{
<a name="l116"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l117"></a> </span><span class=cF1>F64</span><span class=cF0> timeout;
<a name="l118"></a> </span><span class=cF9>CFunSegCache</span><span class=cF0> *tmpfsc=</span><span class=cFB>dbg</span><span class=cF0>.fun_seg_cache;
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (addr==</span><span class=cFD>SYS_IDLE_PT</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l120"></a> *_offset=0;
<a name="l121"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF6>&quot;SYS_IDLE_PT&quot;</span><span class=cF0>;
<a name="l122"></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="l123"></a> timeout=</span><span class=cF5>tS</span><span class=cF0>+8.0;
<a name="l124"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>FUN_SEG_CACHE_SIZE</span><span class=cF0>;i++,tmpfsc++)
<a name="l125"></a> </span><span class=cF1>if</span><span class=cF0> (tmpfsc-&gt;base&lt;=addr&lt;tmpfsc-&gt;limit &amp;&amp;
<a name="l126"></a> tmpfsc-&gt;time_stamp&gt;timeout) {
<a name="l127"></a> *_offset=addr-tmpfsc-&gt;base;
<a name="l128"></a> </span><span class=cF1>return</span><span class=cF0> tmpfsc-&gt;str;
<a name="l129"></a> }
<a name="l130"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l131"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l132"></a>}
<a name="l133"></a>
<a name="l134"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>StrPrintFunSeg</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *buf,</span><span class=cF9>I64</span><span class=cF0> addr,</span><span class=cF9>I64</span><span class=cF0> field_len,</span><span class=cF9>I64</span><span class=cF0> flags)
<a name="l135"></a>{
<a name="l136"></a> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF1>offset</span><span class=cF0>;
<a name="l137"></a> </span><span class=cF9>CHashExport</span><span class=cF0> *tmpex;
<a name="l138"></a> </span><span class=cF1>U8</span><span class=cF0> *str,*str2;
<a name="l139"></a> </span><span class=cF1>Bool</span><span class=cF0> is_fun=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l140"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>flags&amp;</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF7>)</span><span class=cF0>)
<a name="l141"></a> field_len=0;
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (addr) </span><span class=cF7>{</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>if</span><span class=cF0> (str=</span><span class=cFD>FunSegCacheFind</span><span class=cF7>(</span><span class=cF0>addr,&amp;</span><span class=cF1>offset</span><span class=cF7>)</span><span class=cF0>) {
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (addr!=</span><span class=cFD>SYS_IDLE_PT</span><span class=cF0>)
<a name="l145"></a> is_fun=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l146"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex=</span><span class=cF5>FunSegFind</span><span class=cF7>(</span><span class=cF0>addr,&amp;</span><span class=cF1>offset</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex-&gt;type&amp;</span><span class=cF3>HTT_FUN</span><span class=cF0>)
<a name="l149"></a> is_fun=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l150"></a> </span><span class=cFD>FunSegCacheAdd</span><span class=cF0>(tmpex,addr);
<a name="l151"></a> str=tmpex-&gt;str;
<a name="l152"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l153"></a> }
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (str) {
<a name="l155"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF1>offset</span><span class=cF0>&gt;0xFFFF) </span><span class=cF1>offset</span><span class=cF0>=0xFFFF;
<a name="l156"></a> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (is_fun) {
<a name="l158"></a> str2=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;&amp;%s&quot;</span><span class=cF0>,str);
<a name="l159"></a> </span><span class=cF1>if</span><span class=cF0> (!field_len)
<a name="l160"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,str2);
<a name="l161"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0> &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>str2</span><span class=cF7>)</span><span class=cF0>&lt;field_len)
<a name="l162"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,str2);
<a name="l163"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l164"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%*ts&quot;</span><span class=cF0>,field_len,str2);
<a name="l165"></a> </span><span class=cF5>Free</span><span class=cF0>(str2);
<a name="l166"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (!field_len)
<a name="l168"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,str);
<a name="l169"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0> &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>str</span><span class=cF7>)</span><span class=cF0>&lt;field_len)
<a name="l170"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,str);
<a name="l171"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l172"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%*ts&quot;</span><span class=cF0>,field_len,str);
<a name="l173"></a> }
<a name="l174"></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="l175"></a> </span><span class=cF1>if</span><span class=cF0> (is_fun) {
<a name="l176"></a> str2=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;&amp;%s&quot;</span><span class=cF0>,str);
<a name="l177"></a> </span><span class=cF1>if</span><span class=cF0> (field_len &amp;&amp; field_len&gt;7) </span><span class=cF7>{</span><span class=cF0>
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0> &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>str2</span><span class=cF7>)</span><span class=cF0>&lt;field_len-7)
<a name="l179"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%s+0x%04X&quot;</span><span class=cF0>,str2,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l180"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l181"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%*ts+0x%04X&quot;</span><span class=cF0>,field_len-7,str2,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l182"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l183"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%s+0x%04X&quot;</span><span class=cF0>,str2,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l184"></a> </span><span class=cF5>Free</span><span class=cF0>(str2);
<a name="l185"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (field_len &amp;&amp; field_len&gt;7) </span><span class=cF7>{</span><span class=cF0>
<a name="l187"></a> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0> &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>str</span><span class=cF7>)</span><span class=cF0>&lt;field_len-7)
<a name="l188"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%s+0x%04X&quot;</span><span class=cF0>,str,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l189"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l190"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%*ts+0x%04X&quot;</span><span class=cF0>,field_len-7,str,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l191"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l192"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%s+0x%04X&quot;</span><span class=cF0>,str,</span><span class=cF1>offset</span><span class=cF0>);
<a name="l193"></a> }
<a name="l194"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l195"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l196"></a> }
<a name="l197"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_COMMA</span><span class=cF0>)
<a name="l199"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;.&quot;</span><span class=cF0>);
<a name="l200"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (flags&amp;</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0> &amp;&amp; field_len)
<a name="l201"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%*tX&quot;</span><span class=cF0>,field_len,addr);
<a name="l202"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l203"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;%X&quot;</span><span class=cF0>,addr);
<a name="l204"></a>}
<a name="l205"></a>
<a name="l206"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>SrcLineNum</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> cnt=1)
<a name="l207"></a>{</span><span class=cF2>//linenum for src of addr.</span><span class=cF0>
<a name="l208"></a> </span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph;
<a name="l209"></a> </span><span class=cF9>I64</span><span class=cF0> cur_line,first_line,last_line,num_lines,</span><span class=cF1>offset</span><span class=cF0>;
<a name="l210"></a> </span><span class=cF9>CDbgInfo</span><span class=cF0> *dbg_info;
<a name="l211"></a> </span><span class=cF9>U32</span><span class=cF0> *body;
<a name="l212"></a> </span><span class=cF1>U8</span><span class=cF0> *src,*src2;
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (tmph=</span><span class=cF5>FunSegFind</span><span class=cF7>(</span><span class=cF0>addr,&amp;</span><span class=cF1>offset</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type&amp;</span><span class=cF7>(</span><span class=cF3>HTT_FUN</span><span class=cF0>|</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF7>)</span><span class=cF0>) {
<a name="l215"></a> </span><span class=cF1>if</span><span class=cF0> (dbg_info=tmph-&gt;dbg_info) </span><span class=cF7>{</span><span class=cF0>
<a name="l216"></a> num_lines=dbg_info-&gt;max_line-dbg_info-&gt;min_line+1;
<a name="l217"></a> body=dbg_info-&gt;body;
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF2>//find first nonzero</span><span class=cF0>
<a name="l220"></a> first_line=0;
<a name="l221"></a> </span><span class=cF1>while</span><span class=cF0> (!body[first_line]) {
<a name="l222"></a> first_line++;
<a name="l223"></a> </span><span class=cF1>if</span><span class=cF0> (first_line&gt;=num_lines)
<a name="l224"></a> </span><span class=cF1>return</span><span class=cF0> -1;
<a name="l225"></a> }
<a name="l226"></a>
<a name="l227"></a> </span><span class=cF2>//find last nonzero</span><span class=cF0>
<a name="l228"></a> last_line=num_lines-1;
<a name="l229"></a> </span><span class=cF1>while</span><span class=cF0> (!body[last_line] &amp;&amp; last_line&gt;first_line)
<a name="l230"></a> last_line--;
<a name="l231"></a>
<a name="l232"></a> </span><span class=cF2>//interpolate to guess line num</span><span class=cF0>
<a name="l233"></a> cur_line=</span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cF5>ToF64</span><span class=cF7>(</span><span class=cF0>addr-body[first_line]</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>last_line-first_line+1</span><span class=cF7>)</span><span class=cF0>/
<a name="l234"></a> </span><span class=cF7>(</span><span class=cF0>body[last_line]-body[first_line]+1</span><span class=cF7>)</span><span class=cF0>,first_line,last_line);
<a name="l235"></a>
<a name="l236"></a> </span><span class=cF2>//retreat while too high</span><span class=cF0>
<a name="l237"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>!body[cur_line] || body[cur_line]&gt;=addr</span><span class=cF7>)</span><span class=cF0> &amp;&amp; cur_line&gt;first_line)
<a name="l238"></a> cur_line--;
<a name="l239"></a>
<a name="l240"></a> </span><span class=cF2>//advance while to low</span><span class=cF0>
<a name="l241"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>!body[cur_line] || body[cur_line]&lt;addr</span><span class=cF7>)</span><span class=cF0> &amp;&amp; cur_line&lt;last_line)
<a name="l242"></a> cur_line++;
<a name="l243"></a>
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (addr&lt;body[cur_line]+cnt)
<a name="l245"></a> </span><span class=cF1>return</span><span class=cF0> cur_line+dbg_info-&gt;min_line;
<a name="l246"></a>
<a name="l247"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;src_link) </span><span class=cF7>{</span><span class=cF0>
<a name="l248"></a> src =</span><span class=cF5>StrNew</span><span class=cF0>(tmph-&gt;src_link);
<a name="l249"></a> src2=</span><span class=cF5>StrNew</span><span class=cF0>(tmph-&gt;src_link);
<a name="l250"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(src,</span><span class=cF6>&quot;,&quot;</span><span class=cF0>,src2);
<a name="l251"></a> cur_line=</span><span class=cF5>Str2I64</span><span class=cF0>(src2);
<a name="l252"></a> </span><span class=cF5>Free</span><span class=cF0>(src);
<a name="l253"></a> </span><span class=cF5>Free</span><span class=cF0>(src2);
<a name="l254"></a> </span><span class=cF1>return</span><span class=cF0> cur_line;
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l256"></a> }
<a name="l257"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l258"></a> </span><span class=cF1>return</span><span class=cF0> -1;
<a name="l259"></a>}
<a name="l260"></a>
<a name="l261"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>SrcFileName</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> cnt=1,</span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l262"></a>{</span><span class=cF2>//MAlloc filename for src of addr.</span><span class=cF0>
<a name="l263"></a> </span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph;
<a name="l264"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,ii,</span><span class=cF1>offset</span><span class=cF0>,best=</span><span class=cF3>NULL</span><span class=cF0>,d,best_d;
<a name="l265"></a> </span><span class=cF9>U32</span><span class=cF0> *body;
<a name="l266"></a> </span><span class=cF9>CDbgInfo</span><span class=cF0> *dbg_info;
<a name="l267"></a> </span><span class=cF1>U8</span><span class=cF0> *src;
<a name="l268"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>tmph=</span><span class=cF5>FunSegFind</span><span class=cF0>(addr,&amp;</span><span class=cF1>offset</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l269"></a> tmph-&gt;type&amp;</span><span class=cF7>(</span><span class=cF3>HTT_FUN</span><span class=cF0>|</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l270"></a> </span><span class=cF1>if</span><span class=cF0> (dbg_info=tmph-&gt;dbg_info) {
<a name="l271"></a> j=dbg_info-&gt;max_line-dbg_info-&gt;min_line+1;
<a name="l272"></a> body=dbg_info-&gt;body;
<a name="l273"></a> best_d=</span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l274"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;j;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l275"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;body[i]&lt;=addr&lt;body[i]+cnt) {
<a name="l276"></a> ii=i+1;
<a name="l277"></a> </span><span class=cF1>while</span><span class=cF0> (!body[ii])
<a name="l278"></a> ii++;
<a name="l279"></a> </span><span class=cF1>if</span><span class=cF0> (addr&lt;body[ii]) </span><span class=cF7>{</span><span class=cF0>
<a name="l280"></a> d=addr(</span><span class=cF9>I64</span><span class=cF0>)-body[i];
<a name="l281"></a> </span><span class=cF1>if</span><span class=cF0> (d&lt;best_d) {
<a name="l282"></a> best_d=d;
<a name="l283"></a> best=tmph-&gt;src_link;
<a name="l284"></a> }
<a name="l285"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l286"></a> }
<a name="l287"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l288"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l289"></a> best=tmph-&gt;src_link;
<a name="l290"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l291"></a> </span><span class=cF1>if</span><span class=cF0> (best) </span><span class=cF7>{</span><span class=cF0>
<a name="l292"></a> src=</span><span class=cF5>StrNew</span><span class=cF0>(best,mem_task);
<a name="l293"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(src,</span><span class=cF6>&quot;:&quot;</span><span class=cF0>);
<a name="l294"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(src,</span><span class=cF6>&quot;,&quot;</span><span class=cF0>);
<a name="l295"></a> </span><span class=cF1>return</span><span class=cF0> src;
<a name="l296"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l297"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l298"></a>}
<a name="l299"></a>
<a name="l300"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>SrcEdLink</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> cnt=1,</span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l301"></a>{</span><span class=cF2>//MAlloc file,line link to src of addr.</span><span class=cF0>
<a name="l302"></a> </span><span class=cF1>U8</span><span class=cF0> *filename,*st,*st2;
<a name="l303"></a> </span><span class=cF9>I64</span><span class=cF0> linenum;
<a name="l304"></a> </span><span class=cF1>if</span><span class=cF0> (filename=</span><span class=cF5>SrcFileName</span><span class=cF7>(</span><span class=cF0>addr,cnt</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l305"></a> linenum=</span><span class=cF5>SrcLineNum</span><span class=cF0>(addr,cnt);
<a name="l306"></a> </span><span class=cF1>if</span><span class=cF0> (linenum&lt;1)
<a name="l307"></a> linenum=1;
<a name="l308"></a> st2=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;FL:%s,%d&quot;</span><span class=cF0>,filename,linenum);
<a name="l309"></a> </span><span class=cF5>Free</span><span class=cF0>(filename);
<a name="l310"></a> st=</span><span class=cF5>StrNew</span><span class=cF0>(st2,mem_task);
<a name="l311"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l312"></a> </span><span class=cF1>return</span><span class=cF0> st;
<a name="l313"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l314"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l315"></a>}
<a name="l316"></a>
<a name="l317"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>PutSrcLink</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> cnt=1,</span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l318"></a>{</span><span class=cF2>//Put to StdOut a </span><a href="/Wb/Doc/DolDocOverview.DD.HTML#l1"><span class=cF4>DolDoc</span></a><span class=cF2> file,line link to src of addr.</span><span class=cF0>
<a name="l319"></a> </span><span class=cF1>U8</span><span class=cF0> *src;
<a name="l320"></a> </span><span class=cF1>if</span><span class=cF0> (src=</span><span class=cF5>SrcEdLink</span><span class=cF7>(</span><span class=cF0>addr,cnt</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l321"></a> </span><span class=cF1>if</span><span class=cF0> (buf)
<a name="l322"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;$LK,\&quot;%p\&quot;,A=\&quot;%s\&quot;$&quot;</span><span class=cF0>,addr,src);
<a name="l323"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l324"></a> </span><span class=cF6>&quot;$LK,\&quot;%p\&quot;,A=\&quot;%s\&quot;$&quot;</span><span class=cF0>,addr,src;
<a name="l325"></a> </span><span class=cF5>Free</span><span class=cF0>(src);
<a name="l326"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l327"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (buf)
<a name="l328"></a> *buf=0;
<a name="l329"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l330"></a>}
<a name="l331"></a>
<a name="l332"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>E</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr,</span><span class=cF9>I64</span><span class=cF0> cnt=512,</span><span class=cF9>I64</span><span class=cF0> edf_dof_flags=0)
<a name="l333"></a>{</span><span class=cF2>//Edit src at addr.</span><span class=cF0>
<a name="l334"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l335"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l336"></a> </span><span class=cF1>if</span><span class=cF0> (st=</span><span class=cF5>SrcEdLink</span><span class=cF7>(</span><span class=cF0>addr,cnt</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l337"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l338"></a> res=</span><span class=cF5>EdLiteFileLine</span><span class=cF0>(st,edf_dof_flags);
<a name="l339"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l340"></a> res=</span><span class=cF5>Ed</span><span class=cF0>(st,edf_dof_flags);
<a name="l341"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l342"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l343"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l344"></a>}
<a name="l345"></a>
<a name="l346"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Man</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *st,</span><span class=cF9>I64</span><span class=cF0> edf_dof_flags=0)
<a name="l347"></a>{</span><span class=cF2>//Owner's manual for symbol. Edit src code for symbol.</span><span class=cF0>
<a name="l348"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l349"></a> </span><span class=cF1>U8</span><span class=cF0> **st2;
<a name="l350"></a> </span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph;
<a name="l351"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l352"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>tmph=</span><span class=cF5>HashFind</span><span class=cF0>(st,</span><span class=cF5>Fs</span><span class=cF0>-&gt;hash_table,</span><span class=cF3>HTG_SRC_SYM</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; tmph-&gt;src_link)
<a name="l353"></a> res=</span><span class=cF5>EdLiteFileLine</span><span class=cF0>(tmph-&gt;src_link,edf_dof_flags);
<a name="l354"></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="l355"></a> st2=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;MN:%s&quot;</span><span class=cF0>,st);
<a name="l356"></a> res=</span><span class=cF5>Ed</span><span class=cF0>(st2,edf_dof_flags);
<a name="l357"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l358"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l359"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l360"></a>}
</span></pre></body>
</html>