mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 00:06:35 +00:00
dbf8647d59
Added top & right borders to RawDr. Improved spacing in some debug and compiler reporting. Fixed RawPutChar and EdLite tab width. Fixed Ui missing '0x' prefix syntax highlighter bug. Added 32BitPaint demo.
782 lines
79 KiB
HTML
Executable file
782 lines
79 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.08">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CheckPtr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr)
|
|
<a name="l2"></a>{</span><span class=cF2>//Check if addr is valid ptr.</span><span class=cF0>
|
|
<a name="l3"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mem_heap_base</span><span class=cF0> <= ptr <= </span><span class=cFB>mem_mapped_space</span><span class=cF0>)
|
|
<a name="l4"></a> </span><span class=cF1>return</span><span class=cF0> *</span><span class=cF5>MemPageTable</span><span class=cF0>(ptr) & </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l5"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l6"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>mem_boot_base</span><span class=cF0> < ptr < </span><span class=cF3>VGAM_GRAPHICS</span><span class=cF0>;
|
|
<a name="l7"></a>}
|
|
<a name="l8"></a>
|
|
<a name="l9"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CheckCodePtr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr)
|
|
<a name="l10"></a>{</span><span class=cF2>//Check if addr is valid code addr.</span><span class=cF0>
|
|
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mem_heap_base</span><span class=cF0> <= ptr <= </span><span class=cFB>mem_heap_limit</span><span class=cF0>)
|
|
<a name="l12"></a> </span><span class=cF1>return</span><span class=cF0> *</span><span class=cF5>MemPageTable</span><span class=cF0>(ptr) & </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l13"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l14"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>mem_boot_base</span><span class=cF0> < ptr < </span><span class=cF3>VGAM_GRAPHICS</span><span class=cF0>;
|
|
<a name="l15"></a>}
|
|
<a name="l16"></a>
|
|
<a name="l17"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CheckOnStack</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l18"></a>{</span><span class=cF2>//Check if addr is valid stack addr.</span><span class=cF0>
|
|
<a name="l19"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l20"></a>
|
|
<a name="l21"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l22"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l23"></a> </span><span class=cF1>if</span><span class=cF0> (task)
|
|
<a name="l24"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (&task->stack->stack_base <= ptr <= </span><span class=cF7>(</span><span class=cF0>&task->stack->stack_base</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0> + task->stack->stack_size)
|
|
<a name="l26"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l27"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mem_heap_base</span><span class=cF0> <= ptr <= </span><span class=cFB>mem_heap_limit</span><span class=cF0>)
|
|
<a name="l29"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l30"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l31"></a>
|
|
<a name="l32"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l33"></a>}
|
|
<a name="l34"></a>
|
|
<a name="l35"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>UnusedStack</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="l36"></a>{</span><span class=cF2>//Count of usused bytes in task's stack.</span><span class=cF0>
|
|
<a name="l37"></a> </span><span class=cF9>I64</span><span class=cF0> res;
|
|
<a name="l38"></a>
|
|
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l40"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l41"></a>
|
|
<a name="l42"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l43"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l45"></a> res = </span><span class=cF5>RSPGet</span><span class=cF0>()(</span><span class=cF1>U8</span><span class=cF0> *) - (&task->stack->stack_base)(</span><span class=cF1>U8</span><span class=cF0> *);
|
|
<a name="l46"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l47"></a> res = task->rsp(</span><span class=cF1>U8</span><span class=cF0> *) - (&task->stack->stack_base)(</span><span class=cF1>U8</span><span class=cF0> *);
|
|
<a name="l48"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l49"></a>
|
|
<a name="l50"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l51"></a>}
|
|
<a name="l52"></a>
|
|
<a name="l53"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>Caller</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> num=</span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l54"></a>{</span><span class=cF2>//Returns the addr of the fun which called this one,</span><span class=cF0>
|
|
<a name="l55"></a></span><span class=cF2>//or the caller of the caller, etc.</span><span class=cF0>
|
|
<a name="l56"></a> </span><span class=cF1>U8</span><span class=cF0> **rbp = </span><span class=cF5>RBPGet</span><span class=cF0>, **ptr;
|
|
<a name="l57"></a>
|
|
<a name="l58"></a> </span><span class=cF1>while</span><span class=cF0> (num--)
|
|
<a name="l59"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (rbp >= *rbp)
|
|
<a name="l61"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l62"></a> rbp = *rbp;
|
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>CheckOnStack</span><span class=cF7>(</span><span class=cF0>rbp, </span><span class=cF5>Fs</span><span class=cF7>)</span><span class=cF0>)
|
|
<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> ptr = rbp + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l67"></a> </span><span class=cF1>return</span><span class=cF0> *ptr;
|
|
<a name="l68"></a>}
|
|
<a name="l69"></a>
|
|
<a name="l70"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>TaskCaller</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> num=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> saved_context=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l71"></a>{</span><span class=cF2>//Fetches addr of Nth caller on task's stack.</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF1>U8</span><span class=cF0> **ptr, **rbp, **rsp;
|
|
<a name="l73"></a>
|
|
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l75"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (!saved_context && task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l77"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Caller</span><span class=cF0>(num + </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l78"></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="l79"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l80"></a> rbp = task->rbp;
|
|
<a name="l81"></a> rsp = task->rsp;
|
|
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (num)
|
|
<a name="l83"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>CheckOnStack</span><span class=cF7>(</span><span class=cF0>rbp, task</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l85"></a> {
|
|
<a name="l86"></a> ptr = rbp + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (! --num)
|
|
<a name="l88"></a> </span><span class=cF1>return</span><span class=cF0> *ptr;
|
|
<a name="l89"></a> </span><span class=cF1>if</span><span class=cF0> (rbp >= *rbp)
|
|
<a name="l90"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l91"></a> rbp = *rbp;
|
|
<a name="l92"></a> }
|
|
<a name="l93"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l94"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l95"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l96"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (task->rip == </span><span class=cFD>_RET</span><span class=cF0>)
|
|
<a name="l98"></a> </span><span class=cF1>return</span><span class=cF0> *rsp;
|
|
<a name="l99"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l100"></a> </span><span class=cF1>return</span><span class=cF0> task->rip;
|
|
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l102"></a>}
|
|
<a name="l103"></a>#</span><span class=cF1>define</span><span class=cF0> STACK_REP_LEN </span><span class=cFE>32</span><span class=cF0>
|
|
<a name="l104"></a>
|
|
<a name="l105"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>StackRep</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="l106"></a>{</span><span class=cF2>//Reports whats on the stack.</span><span class=cF0>
|
|
<a name="l107"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, addr, **rbp, **rsp, *my_rsp[STACK_REP_LEN];
|
|
<a name="l108"></a> </span><span class=cF9>CHashTable</span><span class=cF0> *old_hash = </span><span class=cF5>Fs</span><span class=cF0>->hash_table;
|
|
<a name="l109"></a>
|
|
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l111"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l112"></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="l113"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l114"></a>
|
|
<a name="l115"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l116"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l117"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l118"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l119"></a> rbp = </span><span class=cF5>RBPGet</span><span class=cF0>;
|
|
<a name="l120"></a> rsp = rbp + </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l121"></a> rbp = *rbp;
|
|
<a name="l122"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l123"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l124"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l125"></a> rsp = task->rsp;
|
|
<a name="l126"></a> rbp = task->rbp;
|
|
<a name="l127"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l128"></a> </span><span class=cF1>if</span><span class=cF0> (task->rip == </span><span class=cFD>_RET</span><span class=cF0>)
|
|
<a name="l129"></a> addr = *rsp;
|
|
<a name="l130"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l131"></a> addr = task->rip;
|
|
<a name="l132"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(my_rsp, rsp, STACK_REP_LEN * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l133"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l134"></a>
|
|
<a name="l135"></a> </span><span class=cF5>Fs</span><span class=cF0>->hash_table = task->hash_table;
|
|
<a name="l136"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < STACK_REP_LEN; i++)
|
|
<a name="l137"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF6>"%08X [RSP+%04X]: %016X "</span><span class=cF0>, rsp + i, i * </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *), my_rsp[i];
|
|
<a name="l139"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l140"></a> {
|
|
<a name="l141"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>&task->stack->stack_base <= rbp < (&task->stack->stack_base)(</span><span class=cF1>U8</span><span class=cF0> *) + task->stack->stack_size</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l142"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l143"></a> j = rbp - rsp;
|
|
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (j >= i)
|
|
<a name="l145"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l146"></a> addr = my_rsp[j + </span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (rbp >= my_rsp[j])
|
|
<a name="l148"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l149"></a> rbp = my_rsp[j];
|
|
<a name="l150"></a> }
|
|
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (my_rsp[i] == addr)
|
|
<a name="l152"></a> </span><span class=cF6>"$RED$"</span><span class=cF0>;
|
|
<a name="l153"></a> </span><span class=cF6>"%P$FG$\n"</span><span class=cF0>, my_rsp[i];
|
|
<a name="l154"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l155"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l156"></a> </span><span class=cF5>Fs</span><span class=cF0>->hash_table = old_hash;
|
|
<a name="l157"></a>}
|
|
<a name="l158"></a>
|
|
<a name="l159"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>CallerRep</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> **rbp=</span><span class=cF3>NULL</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="l160"></a>{</span><span class=cF2>//Prints a report of calling routines.</span><span class=cF0>
|
|
<a name="l161"></a> </span><span class=cF9>I64</span><span class=cF0> **ptr;
|
|
<a name="l162"></a>
|
|
<a name="l163"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l164"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l165"></a> </span><span class=cF1>if</span><span class=cF0> (!rbp)
|
|
<a name="l166"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l168"></a> rbp = </span><span class=cF5>RBPGet</span><span class=cF0>;
|
|
<a name="l169"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l170"></a> rbp = task->rbp;
|
|
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l172"></a> </span><span class=cF6>"CallerRep:\n"</span><span class=cF0>;
|
|
<a name="l173"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>CheckOnStack</span><span class=cF7>(</span><span class=cF0>rbp, task</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l174"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l175"></a> ptr = rbp + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l176"></a> </span><span class=cF6>"%08X: %08tX: %P\n"</span><span class=cF0>, ptr, *ptr, *ptr;
|
|
<a name="l177"></a> </span><span class=cF1>if</span><span class=cF0> (rbp >= *rbp)
|
|
<a name="l178"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l179"></a> rbp = *rbp;
|
|
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l181"></a>}
|
|
<a name="l182"></a>
|
|
<a name="l183"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>D</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>I64</span><span class=cF0> count=</span><span class=cFE>0x80</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> show_offset=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l184"></a>{</span><span class=cF2>//Dump mem, showing offsets.</span><span class=cF0>
|
|
<a name="l185"></a></span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocPutS.CC.html#l366"><span class=cF4>DocD</span></a><span class=cF2>() for a live dump.</span><span class=cF0>
|
|
<a name="l186"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, ch;
|
|
<a name="l187"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr = addr;
|
|
<a name="l188"></a>
|
|
<a name="l189"></a> </span><span class=cF1>while</span><span class=cF0> (count)
|
|
<a name="l190"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l191"></a> </span><span class=cF1>if</span><span class=cF0> (show_offset)
|
|
<a name="l192"></a> </span><span class=cF6>"%08X "</span><span class=cF0>, ptr - addr;
|
|
<a name="l193"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l194"></a> </span><span class=cF6>"%010X "</span><span class=cF0>, ptr;
|
|
<a name="l195"></a> </span><span class=cF1>if</span><span class=cF0> (count > </span><span class=cFE>16</span><span class=cF0>)
|
|
<a name="l196"></a> j = </span><span class=cFE>16</span><span class=cF0>;
|
|
<a name="l197"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l198"></a> j = count;
|
|
<a name="l199"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < j; i++)
|
|
<a name="l200"></a> </span><span class=cF6>"%02X "</span><span class=cF0>, ptr[i];
|
|
<a name="l201"></a> </span><span class=cF1>for</span><span class=cF0> (; i < </span><span class=cFE>16</span><span class=cF0>; i++)
|
|
<a name="l202"></a> </span><span class=cF6>" "</span><span class=cF0>;
|
|
<a name="l203"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < j; i++)
|
|
<a name="l204"></a> {
|
|
<a name="l205"></a> ch = ptr[i];
|
|
<a name="l206"></a> </span><span class=cF1>if</span><span class=cF0> (ch < </span><span class=cF3>CH_SPACE</span><span class=cF0> || ch == </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>)
|
|
<a name="l207"></a> ch = </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l208"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
|
<a name="l209"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF6>'$'</span><span class=cF0>)
|
|
<a name="l210"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
|
<a name="l211"></a> }
|
|
<a name="l212"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l213"></a> count -= j;
|
|
<a name="l214"></a> ptr += j;
|
|
<a name="l215"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l216"></a>}
|
|
<a name="l217"></a>
|
|
<a name="l218"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Dm</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>I64</span><span class=cF0> count=</span><span class=cFE>0x80</span><span class=cF0>)
|
|
<a name="l219"></a>{</span><span class=cF2>//Show mem addr, not offsets.</span><span class=cF0>
|
|
<a name="l220"></a> </span><span class=cF5>D</span><span class=cF0>(addr, count, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l221"></a>}
|
|
<a name="l222"></a>
|
|
<a name="l223"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Da</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> **addr, </span><span class=cF9>I64</span><span class=cF0> count=</span><span class=cFE>0x10</span><span class=cF0>)
|
|
<a name="l224"></a>{</span><span class=cF2>//Dump mem, showing symbolic addresses.</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF1>while</span><span class=cF0> (count-- > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l226"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l227"></a> </span><span class=cF6>"%08X:%08X,%P\n"</span><span class=cF0>, addr, *addr, *addr;
|
|
<a name="l228"></a> addr++;
|
|
<a name="l229"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l230"></a>}
|
|
<a name="l231"></a>
|
|
<a name="l232"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RawPrint</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> mS=</span><span class=cFE>100</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *format, ...)
|
|
<a name="l233"></a>{</span><span class=cF2>//Print using </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.CC.html#l257"><span class=cF4>Raw</span></a><span class=cF2> screen output for a length of time.</span><span class=cF0>
|
|
<a name="l234"></a></span><span class=cF2>//Your heap must be good.</span><span class=cF0>
|
|
<a name="l235"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
|
|
<a name="l236"></a> </span><span class=cF1>Bool</span><span class=cF0> old_raw, old_input_filter;
|
|
<a name="l237"></a>
|
|
<a name="l238"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l239"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l240"></a> old_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l241"></a> old_input_filter = </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>);
|
|
<a name="l242"></a> </span><span class=cF6>"%s"</span><span class=cF0>, buf;
|
|
<a name="l243"></a> </span><span class=cF5>Busy</span><span class=cF0>(mS << </span><span class=cFE>10</span><span class=cF0>);
|
|
<a name="l244"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l245"></a>
|
|
<a name="l246"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>, old_input_filter);
|
|
<a name="l247"></a> </span><span class=cF5>Raw</span><span class=cF0>(old_raw);
|
|
<a name="l248"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l249"></a>}
|
|
<a name="l250"></a>
|
|
<a name="l251"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RawD</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> mS=</span><span class=cFE>100</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>I64</span><span class=cF0> count=</span><span class=cFE>0x80</span><span class=cF0>)
|
|
<a name="l252"></a>{</span><span class=cF2>//Dumps a block of mem using </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.CC.html#l257"><span class=cF4>Raw</span></a><span class=cF0>
|
|
<a name="l253"></a></span><span class=cF2>//screen output for a fixed length</span><span class=cF0>
|
|
<a name="l254"></a> </span><span class=cF2>//of time.</span><span class=cF0>
|
|
<a name="l255"></a> </span><span class=cF1>Bool</span><span class=cF0> old_raw, old_input_filter;
|
|
<a name="l256"></a>
|
|
<a name="l257"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l258"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l259"></a> old_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l260"></a> old_input_filter = </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>);
|
|
<a name="l261"></a> </span><span class=cF5>D</span><span class=cF0>(addr, count);
|
|
<a name="l262"></a> </span><span class=cF5>Busy</span><span class=cF0>(mS << </span><span class=cFE>10</span><span class=cF0>);
|
|
<a name="l263"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l264"></a>
|
|
<a name="l265"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>, old_input_filter);
|
|
<a name="l266"></a> </span><span class=cF5>Raw</span><span class=cF0>(old_raw);
|
|
<a name="l267"></a>}
|
|
<a name="l268"></a>
|
|
<a name="l269"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RawDm</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> mS=</span><span class=cFE>100</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>I64</span><span class=cF0> count=</span><span class=cFE>0x80</span><span class=cF0>)
|
|
<a name="l270"></a>{</span><span class=cF2>//Dumps a block of mem using </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMisc.CC.html#l257"><span class=cF4>Raw</span></a><span class=cF0>
|
|
<a name="l271"></a></span><span class=cF2>//screen output for a fixed length</span><span class=cF0>
|
|
<a name="l272"></a> </span><span class=cF2>//of time.</span><span class=cF0>
|
|
<a name="l273"></a> </span><span class=cF1>Bool</span><span class=cF0> old_raw, old_input_filter;
|
|
<a name="l274"></a>
|
|
<a name="l275"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l276"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l277"></a> old_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l278"></a> old_input_filter = </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>);
|
|
<a name="l279"></a> </span><span class=cF5>Dm</span><span class=cF0>(addr, count);
|
|
<a name="l280"></a> </span><span class=cF5>Busy</span><span class=cF0>(mS << </span><span class=cFE>10</span><span class=cF0>);
|
|
<a name="l281"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l282"></a>
|
|
<a name="l283"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>, old_input_filter);
|
|
<a name="l284"></a> </span><span class=cF5>Raw</span><span class=cF0>(old_raw);
|
|
<a name="l285"></a>}
|
|
<a name="l286"></a>
|
|
<a name="l287"></a></span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>TaskRegAddr</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>I64</span><span class=cF0> reg_num)
|
|
<a name="l288"></a>{
|
|
<a name="l289"></a> </span><span class=cF1>switch</span><span class=cF0> (reg_num)
|
|
<a name="l290"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l291"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RAX</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rax;
|
|
<a name="l292"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RCX</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rcx;
|
|
<a name="l293"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RDX</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rdx;
|
|
<a name="l294"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RBX</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rbx;
|
|
<a name="l295"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RSP</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rsp;
|
|
<a name="l296"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RBP</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rbp;
|
|
<a name="l297"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RSI</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rsi;
|
|
<a name="l298"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>REG_RDI</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->rdi;
|
|
<a name="l299"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0> : </span><span class=cF1>return</span><span class=cF0> &task->r8;
|
|
<a name="l300"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>9</span><span class=cF0> : </span><span class=cF1>return</span><span class=cF0> &task->r9;
|
|
<a name="l301"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>10</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r10;
|
|
<a name="l302"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>11</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r11;
|
|
<a name="l303"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>12</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r12;
|
|
<a name="l304"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>13</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r13;
|
|
<a name="l305"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>14</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r14;
|
|
<a name="l306"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>15</span><span class=cF0>: </span><span class=cF1>return</span><span class=cF0> &task->r15;
|
|
<a name="l307"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l308"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l309"></a>}
|
|
<a name="l310"></a>
|
|
<a name="l311"></a>#</span><span class=cF1>define</span><span class=cF0> RAWDR_COL (</span><span class=cFB>text</span><span class=cF0>.cols - </span><span class=cFE>40</span><span class=cF0>)
|
|
<a name="l312"></a>
|
|
<a name="l313"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RawDr</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="l314"></a>{
|
|
<a name="l315"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, old_col = </span><span class=cFB>text</span><span class=cF0>.raw_col;
|
|
<a name="l316"></a> </span><span class=cF1>Bool</span><span class=cF0> old_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l317"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cFE>200</span><span class=cF0>];
|
|
<a name="l318"></a>
|
|
<a name="l319"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l320"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l321"></a>
|
|
<a name="l322"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = RAWDR_COL;
|
|
<a name="l323"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l324"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < </span><span class=cFB>text</span><span class=cF0>.cols - RAWDR_COL - </span><span class=cFE>1</span><span class=cF0>; j++)
|
|
<a name="l325"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l326"></a>
|
|
<a name="l327"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>16</span><span class=cF0>; i++)
|
|
<a name="l328"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l329"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = (i + </span><span class=cFE>1</span><span class=cF0>) * </span><span class=cFB>text</span><span class=cF0>.cols + RAWDR_COL;
|
|
<a name="l330"></a> </span><span class=cF6>".%3Z: %016X\n"</span><span class=cF0>, i, </span><span class=cF6>"ST_U64_REGS"</span><span class=cF0>, *</span><span class=cF5>TaskRegAddr</span><span class=cF0>(task, i);
|
|
<a name="l331"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l332"></a>
|
|
<a name="l333"></a> i++;
|
|
<a name="l334"></a>
|
|
<a name="l335"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = i++ * </span><span class=cFB>text</span><span class=cF0>.cols + RAWDR_COL;
|
|
<a name="l336"></a> </span><span class=cF6>".RIP: %016X\n"</span><span class=cF0>, task->rip;
|
|
<a name="l337"></a>
|
|
<a name="l338"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = i++ * </span><span class=cFB>text</span><span class=cF0>.cols + RAWDR_COL;
|
|
<a name="l339"></a> </span><span class=cF6>".%-*tp\n"</span><span class=cF0>, </span><span class=cFB>text</span><span class=cF0>.cols - (RAWDR_COL + </span><span class=cFE>1</span><span class=cF0>) - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>->rip;
|
|
<a name="l340"></a>
|
|
<a name="l341"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = i++ * </span><span class=cFB>text</span><span class=cF0>.cols + RAWDR_COL;
|
|
<a name="l342"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l343"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&</span><span class=cFB>sys_run_level</span><span class=cF0>, </span><span class=cF3>RLf_COMPILER</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l344"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l345"></a> j = </span><span class=cF5>Fs</span><span class=cF0>->rip;
|
|
<a name="l346"></a> </span><span class=cF5>Ui</span><span class=cF0>(buf, &j,,, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l347"></a> </span><span class=cF6>"%s"</span><span class=cF0>, buf;
|
|
<a name="l348"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l349"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l350"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l351"></a>
|
|
<a name="l352"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = i * </span><span class=cFB>text</span><span class=cF0>.cols + RAWDR_COL;
|
|
<a name="l353"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l354"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < </span><span class=cFB>text</span><span class=cF0>.cols - RAWDR_COL - </span><span class=cFE>1</span><span class=cF0>; j++)
|
|
<a name="l355"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l356"></a>
|
|
<a name="l357"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = </span><span class=cFB>text</span><span class=cF0>.cols - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l358"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l359"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>2</span><span class=cF0>; j < i + </span><span class=cFE>1</span><span class=cF0>; j++)
|
|
<a name="l360"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l361"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = j * </span><span class=cFB>text</span><span class=cF0>.cols - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l362"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l363"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l364"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = j * </span><span class=cFB>text</span><span class=cF0>.cols - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l365"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l366"></a>
|
|
<a name="l367"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = old_col;
|
|
<a name="l368"></a> </span><span class=cF5>Raw</span><span class=cF0>(old_raw);
|
|
<a name="l369"></a>}
|
|
<a name="l370"></a>
|
|
<a name="l371"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Dr</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="l372"></a>{</span><span class=cF2>//Dump regs</span><span class=cF0>
|
|
<a name="l373"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l374"></a>
|
|
<a name="l375"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l376"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l377"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>16</span><span class=cF0>; i++)
|
|
<a name="l378"></a> </span><span class=cF6>"%3Z: %016X\n"</span><span class=cF0>, i, </span><span class=cF6>"ST_U64_REGS"</span><span class=cF0>, *</span><span class=cF5>TaskRegAddr</span><span class=cF0>(task, i);
|
|
<a name="l379"></a> </span><span class=cF6>"RIP: %016X\n"</span><span class=cF0>, task->rip;
|
|
<a name="l380"></a>}
|
|
<a name="l381"></a>
|
|
<a name="l382"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>SysGetStr2</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l383"></a>{
|
|
<a name="l384"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cFE>512</span><span class=cF0>];
|
|
<a name="l385"></a>
|
|
<a name="l386"></a> </span><span class=cF5>StrNGet</span><span class=cF0>(buf, </span><span class=cFE>512</span><span class=cF0>, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l387"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(buf);
|
|
<a name="l388"></a>}
|
|
<a name="l389"></a>
|
|
<a name="l390"></a></span><span class=cF9>CBpt</span><span class=cF0> *</span><span class=cF5>BptFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *needle_addr, </span><span class=cF9>CTask</span><span class=cF0> *haystack_task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> rem=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l391"></a>{
|
|
<a name="l392"></a> </span><span class=cF9>CBpt</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>, *tmpb, *tmpb1, *tmpb2;
|
|
<a name="l393"></a>
|
|
<a name="l394"></a> </span><span class=cF1>if</span><span class=cF0> (!haystack_task)
|
|
<a name="l395"></a> haystack_task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l396"></a>
|
|
<a name="l397"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l398"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l399"></a> tmpb1 = &haystack_task->bpt_list;
|
|
<a name="l400"></a> tmpb = haystack_task->bpt_list;
|
|
<a name="l401"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb)
|
|
<a name="l402"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l403"></a> tmpb2 = tmpb->next;
|
|
<a name="l404"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb->addr == needle_addr)
|
|
<a name="l405"></a> {
|
|
<a name="l406"></a> res = tmpb;
|
|
<a name="l407"></a> </span><span class=cF1>if</span><span class=cF0> (rem)
|
|
<a name="l408"></a> tmpb1->next = tmpb2;
|
|
<a name="l409"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l410"></a> tmpb1 = &tmpb->next;
|
|
<a name="l411"></a> }
|
|
<a name="l412"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l413"></a> tmpb1 = &tmpb->next;
|
|
<a name="l414"></a> tmpb = tmpb2;
|
|
<a name="l415"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l416"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l417"></a>
|
|
<a name="l418"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l419"></a>}
|
|
<a name="l420"></a>
|
|
<a name="l421"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>BptS</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> live=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l422"></a>{</span><span class=cF2>//Set breakpoint.</span><span class=cF0>
|
|
<a name="l423"></a> </span><span class=cF9>CBpt</span><span class=cF0> *tmpb;
|
|
<a name="l424"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l425"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l426"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l427"></a>
|
|
<a name="l428"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l429"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l430"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpb = </span><span class=cF5>BptFind</span><span class=cF0>(addr, task, </span><span class=cF3>FALSE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l431"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l432"></a> tmpb = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBpt</span><span class=cF7>)</span><span class=cF0>, task);
|
|
<a name="l433"></a> tmpb->addr = addr;
|
|
<a name="l434"></a> tmpb->val = *addr;
|
|
<a name="l435"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l436"></a> tmpb->next = task->bpt_list;
|
|
<a name="l437"></a>
|
|
<a name="l438"></a> task->bpt_list = tmpb;
|
|
<a name="l439"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0> && live)
|
|
<a name="l440"></a> *addr = </span><span class=cF3>OC_BPT</span><span class=cF0>;
|
|
<a name="l441"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l442"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l443"></a>
|
|
<a name="l444"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l445"></a>}
|
|
<a name="l446"></a>
|
|
<a name="l447"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>BptR</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> live=</span><span class=cF3>TRUE</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> rem=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l448"></a>{</span><span class=cF2>//Remove breakpoint.</span><span class=cF0>
|
|
<a name="l449"></a> </span><span class=cF9>CBpt</span><span class=cF0> *tmpb;
|
|
<a name="l450"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l451"></a>
|
|
<a name="l452"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l453"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l454"></a>
|
|
<a name="l455"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l456"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l457"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb = </span><span class=cF5>BptFind</span><span class=cF7>(</span><span class=cF0>addr, task, rem</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l458"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l459"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0> && live)
|
|
<a name="l460"></a> *tmpb->addr = tmpb->val;
|
|
<a name="l461"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l462"></a> </span><span class=cF1>if</span><span class=cF0> (rem)
|
|
<a name="l463"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpb);
|
|
<a name="l464"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l465"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l466"></a>
|
|
<a name="l467"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l468"></a>}
|
|
<a name="l469"></a>
|
|
<a name="l470"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>B</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *addr, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> live=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l471"></a>{</span><span class=cF2>//Toggle breakpoint.</span><span class=cF0>
|
|
<a name="l472"></a></span><span class=cF2>//Return: TRUE if removed.</span><span class=cF0>
|
|
<a name="l473"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l474"></a>
|
|
<a name="l475"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l476"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l477"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>BptFind</span><span class=cF7>(</span><span class=cF0>addr, task, </span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l478"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l479"></a> </span><span class=cF5>BptR</span><span class=cF0>(addr, task, live, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l480"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l481"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l482"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l483"></a> </span><span class=cF5>BptS</span><span class=cF0>(addr, task, live);
|
|
<a name="l484"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l485"></a>
|
|
<a name="l486"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l487"></a>}
|
|
<a name="l488"></a>
|
|
<a name="l489"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>B2</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> live=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l490"></a>{</span><span class=cF2>//Remove all breakpoints.</span><span class=cF0>
|
|
<a name="l491"></a></span><span class=cF2>//Return: count of removed.</span><span class=cF0>
|
|
<a name="l492"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l493"></a> </span><span class=cF9>CBpt</span><span class=cF0> *tmpb, *tmpb1;
|
|
<a name="l494"></a>
|
|
<a name="l495"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l496"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l497"></a>
|
|
<a name="l498"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l499"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l500"></a> tmpb = task->bpt_list;
|
|
<a name="l501"></a> task->bpt_list = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l502"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb)
|
|
<a name="l503"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l504"></a> tmpb1 = tmpb->next;
|
|
<a name="l505"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0> && live)
|
|
<a name="l506"></a> *tmpb->addr = tmpb->val;
|
|
<a name="l507"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpb);
|
|
<a name="l508"></a> tmpb = tmpb1;
|
|
<a name="l509"></a> res++;
|
|
<a name="l510"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l511"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l512"></a>
|
|
<a name="l513"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l514"></a>}
|
|
<a name="l515"></a>
|
|
<a name="l516"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>G</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ip=</span><span class=cF3>INVALID_PTR</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="l517"></a>{</span><span class=cF2>//Go</span><span class=cF0>
|
|
<a name="l518"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l519"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l520"></a> </span><span class=cF1>if</span><span class=cF0> (ip != </span><span class=cF3>INVALID_PTR</span><span class=cF0>)
|
|
<a name="l521"></a> task->rip = ip;
|
|
<a name="l522"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>BptFind</span><span class=cF7>(</span><span class=cF0>task->rip, task</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l523"></a> </span><span class=cF6>"\nDo one of the following, first:\n"</span><span class=cF0>
|
|
<a name="l524"></a> </span><span class=cF6>">S;\t\t\t//Single step\n"</span><span class=cF0>
|
|
<a name="l525"></a> </span><span class=cF6>">B2;\t\t\t//Clear all break points\n"</span><span class=cF0>
|
|
<a name="l526"></a> </span><span class=cF6>">G2;\t\t\t//Clear all break points and Go\n\n"</span><span class=cF0>
|
|
<a name="l527"></a> </span><span class=cF6>"After resuming, <CTRL-ALT-n> next focus task\n"</span><span class=cF0>
|
|
<a name="l528"></a> </span><span class=cF6>"After resuming, <CTRL-ALT-v> flushes screen VGA cache\n"</span><span class=cF0>;
|
|
<a name="l529"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l530"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l531"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->task_flags, </span><span class=cF3>TASKf_DISABLE_BPTS</span><span class=cF0>);
|
|
<a name="l532"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->rflags, </span><span class=cF3>RFLAGf_TRAP</span><span class=cF0>);</span><span class=cF2>//No single step</span><span class=cF0>
|
|
<a name="l533"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l534"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l535"></a> {
|
|
<a name="l536"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDebugMode</span><span class=cF0> && task->next_cc != &task->next_cc)
|
|
<a name="l537"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l538"></a> </span><span class=cF6>"Exit Debug\n"</span><span class=cF0>;
|
|
<a name="l539"></a> </span><span class=cF5>Btr</span><span class=cF0>(&task->last_cc->flags, </span><span class=cF3>CCf_PROMPT</span><span class=cF0>);
|
|
<a name="l540"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l541"></a> }
|
|
<a name="l542"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l543"></a> </span><span class=cF5>Exit</span><span class=cF0>;
|
|
<a name="l544"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l545"></a>}
|
|
<a name="l546"></a>
|
|
<a name="l547"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>G2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ip=</span><span class=cF3>INVALID_PTR</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="l548"></a>{</span><span class=cF2>//Remove all breakpoints and Go.</span><span class=cF0>
|
|
<a name="l549"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l550"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l551"></a> </span><span class=cF5>B2</span><span class=cF0>(task);
|
|
<a name="l552"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ext</span><span class=cF0>[</span><span class=cF3>EXT_WIN_FOCUS</span><span class=cF0>])
|
|
<a name="l553"></a> </span><span class=cF5>CallExtNum</span><span class=cF0>(</span><span class=cF3>EXT_WIN_FOCUS</span><span class=cF0>, </span><span class=cFB>debug</span><span class=cF0>.focus_task);
|
|
<a name="l554"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
|
|
<a name="l555"></a> </span><span class=cF5>G</span><span class=cF0>(ip, task);
|
|
<a name="l556"></a>}
|
|
<a name="l557"></a>
|
|
<a name="l558"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>S</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ip=</span><span class=cF3>INVALID_PTR</span><span class=cF0>, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>) </span><span class=cF2>//Single-step.</span><span class=cF0>
|
|
<a name="l559"></a>{</span><span class=cF2>//Single step.</span><span class=cF0>
|
|
<a name="l560"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l561"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l562"></a>
|
|
<a name="l563"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l564"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l565"></a> </span><span class=cF1>if</span><span class=cF0> (ip != </span><span class=cF3>INVALID_PTR</span><span class=cF0>)
|
|
<a name="l566"></a> task->rip = ip;
|
|
<a name="l567"></a> </span><span class=cF5>LBts</span><span class=cF0>(&task->task_flags, </span><span class=cF3>TASKf_DISABLE_BPTS</span><span class=cF0>);
|
|
<a name="l568"></a> </span><span class=cF5>LBts</span><span class=cF0>(&task->rflags, </span><span class=cF3>RFLAGf_TRAP</span><span class=cF0>);
|
|
<a name="l569"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l570"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l571"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l572"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDebugMode</span><span class=cF0>)
|
|
<a name="l573"></a> {
|
|
<a name="l574"></a> </span><span class=cF1>if</span><span class=cF0> (task->next_cc != &task->next_cc)
|
|
<a name="l575"></a> </span><span class=cF5>Btr</span><span class=cF0>(&task->last_cc->flags, </span><span class=cF3>CCf_PROMPT</span><span class=cF0>);
|
|
<a name="l576"></a> }
|
|
<a name="l577"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l578"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l579"></a> </span><span class=cF5>Exit</span><span class=cF0>;
|
|
<a name="l580"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l581"></a>}
|
|
<a name="l582"></a>
|
|
<a name="l583"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>DebugHelp</span><span class=cF0>()
|
|
<a name="l584"></a>{
|
|
<a name="l585"></a> </span><span class=cF6>"\n"</span><span class=cF0>
|
|
<a name="l586"></a> </span><span class=cF6>"The cmd line is basically the same as normal.</span><span class=cF0> </span><span class=cF6>Here are some common\n"</span><span class=cF0>
|
|
<a name="l587"></a> </span><span class=cF6>"debugging commands.\n\n"</span><span class=cF0>
|
|
<a name="l588"></a> </span><span class=cF6>">EdLite(\"FileName\");\t\t\t\t// Edit file.\n"</span><span class=cF0>
|
|
<a name="l589"></a> </span><span class=cF6>">D(0x100000);\t\t\t\t\t\t// Dump page tables.\n"</span><span class=cF0>
|
|
<a name="l590"></a> </span><span class=cF6>">Dm(0x100000);\t\t\t\t\t\t// Dump page tables.\n"</span><span class=cF0>
|
|
<a name="l591"></a> </span><span class=cF6>">Dm(Fs, sizeof(CTask));\t\t\t\t// Dump current task record.\n"</span><span class=cF0>
|
|
<a name="l592"></a> </span><span class=cF6>">ClassRep(Fs, \"CTask\", 1);\t\t\t// Dump current task record.\n"</span><span class=cF0>
|
|
<a name="l593"></a> </span><span class=cF6>">ClassRep(Fs,, 1);\t\t\t\t\t// (It knows lastclass.)\n"</span><span class=cF0>
|
|
<a name="l594"></a> </span><span class=cF6>">CallerRep;\t\t\t\t\t\t\t// Stack trace report.\n"</span><span class=cF0>
|
|
<a name="l595"></a> </span><span class=cF6>">Da(_RSP);\t\t\t\t\t\t\t// Dump stack.\n"</span><span class=cF0>
|
|
<a name="l596"></a> </span><span class=cF6>">Dr;\t\t\t\t\t\t\t\t// Dump Regs.\n"</span><span class=cF0>
|
|
<a name="l597"></a> </span><span class=cF6>">1 + 2 * 3 + &Print;\t\t\t\t// Show calculation res.\n"</span><span class=cF0>
|
|
<a name="l598"></a> </span><span class=cF6>">*(0x70000)(I64 *) = 0x123456789;\t// Assign value to 0x70000-0x70007.\n"</span><span class=cF0>
|
|
<a name="l599"></a> </span><span class=cF6>">_RAX = 0x1234;\t\t\t\t\t\t// Set RAX to 0x1234.\n"</span><span class=cF0>
|
|
<a name="l600"></a> </span><span class=cF6>">_RIP = &Break;\t\t\t\t\t\t// Set RIP.\n"</span><span class=cF0>
|
|
<a name="l601"></a> </span><span class=cF6>">I64 i;\t\t\t\t\t\t\t\t// Declare variable.\n"</span><span class=cF0>
|
|
<a name="l602"></a> </span><span class=cF6>">i = _RCX + _RDX;\t\t\t\t\t// Assign to variable.\n"</span><span class=cF0>
|
|
<a name="l603"></a> </span><span class=cF6>">U(&Print+0x8);\t\t\t\t\t\t// Unassemble Print.\n"</span><span class=cF0>
|
|
<a name="l604"></a> </span><span class=cF6>">Uf(\"Print\");\t\t\t\t\t\t// Unassembler function \"Print\".\n"</span><span class=cF0>
|
|
<a name="l605"></a> </span><span class=cF6>">Man(\"Print\");\t\t\t\t\t\t// Edit Src for \"Print\".\n"</span><span class=cF0>
|
|
<a name="l606"></a> </span><span class=cF6>">E(_RIP);\t\t\t\t\t\t\t// Edit Src Code.\n"</span><span class=cF0>
|
|
<a name="l607"></a> </span><span class=cF6>">Fix;\t\t\t\t\t\t\t\t// Edit Last Err Src Code.\n"</span><span class=cF0>
|
|
<a name="l608"></a> </span><span class=cF6>">B(&Main+0x20);\t\t\t\t\t\t// Toggle break point.\n"</span><span class=cF0>
|
|
<a name="l609"></a> </span><span class=cF6>">B2;\t\t\t\t\t\t\t\t// Clear all break points.\n"</span><span class=cF0>
|
|
<a name="l610"></a> </span><span class=cF6>">S;\t\t\t\t\t\t\t\t\t// Single step.\n"</span><span class=cF0>
|
|
<a name="l611"></a> </span><span class=cF6>">G;\t\t\t\t\t\t\t\t\t// Resume execution.\n"</span><span class=cF0>
|
|
<a name="l612"></a> </span><span class=cF6>">G2;\t\t\t\t\t\t\t\t// B2;LFBFlush;WinFocus;G;\n"</span><span class=cF0>
|
|
<a name="l613"></a> </span><span class=cF6>">Exit;\t\t\t\t\t\t\t\t// Exit (kill) task.\n\n"</span><span class=cF0>
|
|
<a name="l614"></a> </span><span class=cF6>"After resuming, <CTRL-ALT-n> next focus task.\n"</span><span class=cF0>
|
|
<a name="l615"></a> </span><span class=cF6>"After resuming, <CTRL-ALT-v> flushes screen VGA cache.\n\n"</span><span class=cF0>;
|
|
<a name="l616"></a>}
|
|
<a name="l617"></a>
|
|
<a name="l618"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>Debug2</span><span class=cF0>()
|
|
<a name="l619"></a>{
|
|
<a name="l620"></a> </span><span class=cF1>Bool</span><span class=cF0> old_win_inhibit, old_waiting_message, old_single;
|
|
<a name="l621"></a> </span><span class=cF9>I64</span><span class=cF0> i, old_getstr2;
|
|
<a name="l622"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cFE>200</span><span class=cF0>];
|
|
<a name="l623"></a>
|
|
<a name="l624"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>debug</span><span class=cF0>.panic)
|
|
<a name="l625"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l626"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>)
|
|
<a name="l627"></a> {
|
|
<a name="l628"></a> i = </span><span class=cF5>Fs</span><span class=cF0>->rip;
|
|
<a name="l629"></a> </span><span class=cF5>Ui</span><span class=cF0>(buf, &i);
|
|
<a name="l630"></a> </span><span class=cF6>"%s"</span><span class=cF0>, buf;
|
|
<a name="l631"></a> }
|
|
<a name="l632"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l633"></a> </span><span class=cF5>U</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->rip, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l634"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l635"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l636"></a> </span><span class=cFB>debug</span><span class=cF0>.panic = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l637"></a> old_waiting_message = </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_AWAITING_MESSAGE</span><span class=cF0>);
|
|
<a name="l638"></a> old_win_inhibit = </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit;
|
|
<a name="l639"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit = </span><span class=cF3>WIG_USER_TASK_DEFAULT</span><span class=cF0>;
|
|
<a name="l640"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l641"></a> </span><span class=cFB>kbd</span><span class=cF0>.scan_code = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l642"></a> old_getstr2 = </span><span class=cFB>fp_getstr2</span><span class=cF0>;
|
|
<a name="l643"></a> </span><span class=cFB>fp_getstr2</span><span class=cF0> = &</span><span class=cFD>SysGetStr2</span><span class=cF0>;
|
|
<a name="l644"></a> old_single = </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
|
|
<a name="l645"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cFB>mouse_hard</span><span class=cF0>.install_attempts)
|
|
<a name="l646"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l647"></a> </span><span class=cF5>SingleUser</span><span class=cF0>(old_single);
|
|
<a name="l648"></a> </span><span class=cF5>UserTaskCont</span><span class=cF0>;
|
|
<a name="l649"></a> </span><span class=cFB>fp_getstr2</span><span class=cF0> = old_getstr2;
|
|
<a name="l650"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit = old_win_inhibit;
|
|
<a name="l651"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_AWAITING_MESSAGE</span><span class=cF0>, old_waiting_message);
|
|
<a name="l652"></a>}
|
|
<a name="l653"></a>
|
|
<a name="l654"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>Fault3</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> fault_num, </span><span class=cF9>I64</span><span class=cF0> fault_err_code)
|
|
<a name="l655"></a>{
|
|
<a name="l656"></a> </span><span class=cF1>no_warn</span><span class=cF0> fault_err_code;
|
|
<a name="l657"></a>
|
|
<a name="l658"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l659"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l660"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Gs</span><span class=cF0>->num && </span><span class=cFB>debug</span><span class=cF0>.mp_crash)
|
|
<a name="l661"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l662"></a> </span><span class=cFB>mp_count</span><span class=cF0> = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l663"></a> </span><span class=cFB>debug</span><span class=cF0>.mp_crash->cpu_num = </span><span class=cF5>Gs</span><span class=cF0>->num;
|
|
<a name="l664"></a> </span><span class=cFB>debug</span><span class=cF0>.mp_crash->task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l665"></a> </span><span class=cFB>debug</span><span class=cF0>.mp_crash->rip = </span><span class=cF5>Fs</span><span class=cF0>->rip;
|
|
<a name="l666"></a> </span><span class=cFB>debug</span><span class=cF0>.mp_crash->message = </span><span class=cFB>debug</span><span class=cF0>.message;
|
|
<a name="l667"></a> </span><span class=cFB>debug</span><span class=cF0>.mp_crash->message_num = </span><span class=cFB>debug</span><span class=cF0>.message_num;
|
|
<a name="l668"></a> </span><span class=cF5>MPInt</span><span class=cF0>(</span><span class=cF3>I_MP_CRASH</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l669"></a> </span><span class=cF5>SysHlt</span><span class=cF0>;
|
|
<a name="l670"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l671"></a>
|
|
<a name="l672"></a> </span><span class=cF6>"\n\tZealOS Debugger\n\n"</span><span class=cF0>
|
|
<a name="l673"></a> </span><span class=cF6>" Type Help; for help.\n\n"</span><span class=cF0>;
|
|
<a name="l674"></a>
|
|
<a name="l675"></a> </span><span class=cF5>Beep</span><span class=cF0>(</span><span class=cFE>62</span><span class=cF0>, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l676"></a> </span><span class=cF1>if</span><span class=cF0> (fault_num == </span><span class=cF3>I_DEBUG</span><span class=cF0>)
|
|
<a name="l677"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l678"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>debug</span><span class=cF0>.message)
|
|
<a name="l679"></a> {
|
|
<a name="l680"></a> </span><span class=cF6>"\n!!! %s"</span><span class=cF0>, </span><span class=cFB>debug</span><span class=cF0>.message;
|
|
<a name="l681"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>debug</span><span class=cF0>.message_num)
|
|
<a name="l682"></a> </span><span class=cF6>"%016X"</span><span class=cF0>, </span><span class=cFB>debug</span><span class=cF0>.message_num;
|
|
<a name="l683"></a> </span><span class=cF6>" !!!\n\n"</span><span class=cF0>;
|
|
<a name="l684"></a> }
|
|
<a name="l685"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l686"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>debug</span><span class=cF0>.panic)
|
|
<a name="l687"></a> </span><span class=cF5>CallerRep</span><span class=cF0>;
|
|
<a name="l688"></a> </span><span class=cFD>Debug2</span><span class=cF0>;
|
|
<a name="l689"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l690"></a>}
|
|
<a name="l691"></a>
|
|
<a name="l692"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>Fault2</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> fault_num, </span><span class=cF9>I64</span><span class=cF0> fault_err_code)
|
|
<a name="l693"></a>{</span><span class=cF2>//Called from </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KInterrupts.CC.html#l91"><span class=cF4>Fault2</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l694"></a></span><span class=cF2>//Be careful not to swap-out and ruin the saved context</span><span class=cF0>
|
|
<a name="l695"></a> </span><span class=cF1>Bool</span><span class=cF0> was_raw, was_single_user, was_silent, was_in_debug, was_mouse_enabled;
|
|
<a name="l696"></a> </span><span class=cF9>I64</span><span class=cF0> i, old_raw_flags = </span><span class=cFB>text</span><span class=cF0>.raw_flags;
|
|
<a name="l697"></a>
|
|
<a name="l698"></a> was_single_user = </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l699"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsDebugMode</span><span class=cF0>)
|
|
<a name="l700"></a> </span><span class=cFB>debug</span><span class=cF0>.focus_task = </span><span class=cFB>sys_focus_task</span><span class=cF0>;
|
|
<a name="l701"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l702"></a> </span><span class=cF1>if</span><span class=cF0> (fault_num == </span><span class=cF3>I_BPT</span><span class=cF0>)
|
|
<a name="l703"></a> </span><span class=cF5>Fs</span><span class=cF0>->rip--;
|
|
<a name="l704"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>->debug_task)
|
|
<a name="l705"></a> </span><span class=cF5>CallExtNum</span><span class=cF0>(</span><span class=cF3>EXT_DEBUG_RESUME</span><span class=cF0>, fault_num, fault_err_code);
|
|
<a name="l706"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l707"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l708"></a> was_mouse_enabled = </span><span class=cF5>CallExtStr</span><span class=cF0>(</span><span class=cF6>"MouseHardEnable"</span><span class=cF0>, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l709"></a> was_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l710"></a> was_silent = </span><span class=cF5>Silent</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
|
|
<a name="l711"></a> </span><span class=cFB>text</span><span class=cF0>.raw_flags |= </span><span class=cF3>RAWF_SHOW_DOLLAR</span><span class=cF0>|</span><span class=cF3>RAWF_SCROLL</span><span class=cF0>;
|
|
<a name="l712"></a>
|
|
<a name="l713"></a> </span><span class=cF6>"Task \""</span><span class=cF0>;
|
|
<a name="l714"></a> </span><span class=cF6>"%s"</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>->task_title;
|
|
<a name="l715"></a> </span><span class=cF6>"\"\n"</span><span class=cF0>;
|
|
<a name="l716"></a> </span><span class=cF6>"Fault: 0x%02X %Z\n"</span><span class=cF0>, fault_num, fault_num, </span><span class=cF6>"ST_INT_NAMES"</span><span class=cF0>;
|
|
<a name="l717"></a> </span><span class=cF6>"Err Code: %08X\n"</span><span class=cF0>, fault_err_code;
|
|
<a name="l718"></a> was_in_debug = </span><span class=cF5>DebugMode</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l719"></a> </span><span class=cF6>"RIP: %08X"</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>->rip; </span><span class=cF2>//Sometimes crashes on %p, so do this first</span><span class=cF0>
|
|
<a name="l720"></a> </span><span class=cF6>":%p\nRSP: %08X\n"</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>->rip, </span><span class=cF5>Fs</span><span class=cF0>->rsp;
|
|
<a name="l721"></a> </span><span class=cF1>if</span><span class=cF0> (fault_num == </span><span class=cF3>I_PAGE_FAULT</span><span class=cF0>)
|
|
<a name="l722"></a> {
|
|
<a name="l723"></a> </span><span class=cF1>MOV_RAX_CR2</span><span class=cF0>
|
|
<a name="l724"></a> i = </span><span class=cF5>RAXGet</span><span class=cF0>;
|
|
<a name="l725"></a> </span><span class=cF6>"Fault Addr: %08X:%p\n"</span><span class=cF0>, i, i;
|
|
<a name="l726"></a> }
|
|
<a name="l727"></a> </span><span class=cFD>Fault3</span><span class=cF0>(fault_num, fault_err_code);
|
|
<a name="l728"></a> </span><span class=cF5>DebugMode</span><span class=cF0>(was_in_debug);
|
|
<a name="l729"></a> </span><span class=cF5>Silent</span><span class=cF0>(was_silent);
|
|
<a name="l730"></a> </span><span class=cF5>Raw</span><span class=cF0>(was_raw);
|
|
<a name="l731"></a> </span><span class=cF5>CallExtStr</span><span class=cF0>(</span><span class=cF6>"MouseHardEnable"</span><span class=cF0>, was_mouse_enabled);
|
|
<a name="l732"></a> </span><span class=cFB>text</span><span class=cF0>.raw_flags = old_raw_flags;
|
|
<a name="l733"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l734"></a> </span><span class=cF5>SingleUser</span><span class=cF0>(was_single_user);
|
|
<a name="l735"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>LBtr</span><span class=cF7>(</span><span class=cF0>&</span><span class=cF5>Fs</span><span class=cF0>->task_flags, </span><span class=cF3>TASKf_KILL_AFTER_DEBUG</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l736"></a> </span><span class=cF5>Exit</span><span class=cF0>;
|
|
<a name="l737"></a>}
|
|
<a name="l738"></a>
|
|
<a name="l739"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Panic</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *message=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> message_num=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> panic=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l740"></a>{</span><span class=cF2>//Enter the debugger with panic?</span><span class=cF0>
|
|
<a name="l741"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l742"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l743"></a> </span><span class=cFB>debug</span><span class=cF0>.message = message;
|
|
<a name="l744"></a> </span><span class=cFB>debug</span><span class=cF0>.message_num = message_num;
|
|
<a name="l745"></a> </span><span class=cFB>debug</span><span class=cF0>.panic = panic;
|
|
<a name="l746"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cF3>I_DEBUG</span><span class=cF0>
|
|
<a name="l747"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l748"></a>}
|
|
<a name="l749"></a>
|
|
<a name="l750"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Debug</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *message=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> message_num=</span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l751"></a>{</span><span class=cF2>//Enter debugger, no panic.</span><span class=cF0>
|
|
<a name="l752"></a> </span><span class=cF5>Panic</span><span class=cF0>(message, message_num, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l753"></a>}
|
|
</span></pre></body>
|
|
</html>
|