Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Kernel Debugging Help



At 10:25 +0100 7/8/07, Arvind Dalvi wrote:
I will read the GDB documentation in more depth, and will try a few stint......

Cool. For those of us that live and breath this stuff, it's tricky to remember how hard it is to get started.


In the meantime, Quinn, if you could expand the showtask macro to also include the status field (p->stat) of the BSD proc structure, it would be great....

The following is the diffs from a standard kgmacros file (in my case taken from the 10.4.9 Intel KDK).


$ diff -u /Volumes/KernelDebugKit/kgmacros kgmacros
--- /Volumes/KernelDebugKit/kgmacros    2006-06-21 04:59:49.000000000 +0100
+++ kgmacros    2007-08-07 10:58:03.000000000 +0100
@@ -1015,13 +1015,35 @@


define showprocheader - printf " pid proc command\n" + printf " pid stat proc command\n" end

 define showprocint
     set $kgm_procp = (struct proc *)$arg0
     if $kgm_procp != 0
         printf "%5d  ", $kgm_procp->p_pid
+        set $kgm_proc_stat = $kgm_procp->p_stat
+        if $kgm_proc_stat == 1
+            printf "   I  "
+        else
+        if $kgm_proc_stat == 2
+            printf "   R  "
+        else
+        if $kgm_proc_stat == 3
+            printf "   S  "
+        else
+        if $kgm_proc_stat == 4
+            printf "   T  "
+        else
+        if $kgm_proc_stat == 5
+            printf "   Z  "
+        else
+           printf "%4d  ", $kgm_proc_stat
+       end
+       end
+       end
+       end
+       end
        printf "0x%08x  ", $kgm_procp
        printf "%s\n", $kgm_procp->p_comm
     else

The basic idea is pretty simple:

o I modified showprocheader to print an extra header column.

o I modified showprocint (which is called by showalltasks, and others) to print the contents of that column. The only tricky part is converting the state value to a character; GDB's scripting language doesn't have a switch statement or any "else if" construct.

I am too sure whether reporting status of a process would be the right thing, as it are threads that have state (waiting/suspended/ready/running) rather than the process.

The process state /is/ meaningful (for example, if you stop a process using ^Z, you'll get a state value of SSTOP (4) which is printed as "T") but, as you surmised, it's not the only part of the picture.


S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/email@hidden

This email sent to email@hidden
References: 
 >Re: Kernel Debugging Help (From: "Arvind Dalvi" <email@hidden>)
 >Re: Kernel Debugging Help (From: "Arvind Dalvi" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.