| <head> |
| <title>mach-cmd(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>MACH-CMD(3)</b><td align=right><b>MACH-CMD(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| attachargs, attachcore, attachdynamic, attachproc, proctextfile |
| – debugging processes and core files<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h><br> |
| #include <mach.h> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int attachcore(Fhdr *hdr) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int attachproc(int pid) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int attachdynamic(void) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>char* proctextfile(int pid) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int attachargs(int argc, char **argv, int omode) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>extern Fhdr* symhdr;<br> |
| </font></tt>extern char* symfil;<br> |
| extern Map* symmap;<br> |
| extern Fhdr* fhdrlist;<br> |
| extern Fhdr* corhdr;<br> |
| extern char* corfil;<br> |
| extern Map* cormap;<br> |
| extern int corpid;<br> |
| extern Regs* correg;<br> |
| |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| These routines provide access to the objects a typical debugger |
| manipulates: an executable binary, some number of shared libraries, |
| a memory image in the form of a core dump or active process, and |
| a register set. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The maintained state is:<br> |
| <i>symhdr<br> |
| </i> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The file header for the main binary.<br> |
| |
| </table> |
| <i>symfil</i>The file name of the main binary.<br> |
| <i>symmap<br> |
| </i> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The memory map of the main binary.<br> |
| |
| </table> |
| <i>fhdrlist<br> |
| </i> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| A linked list (via the <tt><font size=+1>Fhdr.next</font></tt> fields) of all currently open |
| headers (see <i>symopen</i> in <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>). When dynamically linked |
| objects have been attached, they are present in this linked list, |
| and therefore included in searches by <i>indexsym</i>, <i>lookupsym</i>, and |
| <i>findsym</i> (see <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>). |
| |
| </table> |
| <i>corhdr</i>The file header for the core dump, if any.<br> |
| <i>corfil</i>The file name of the core dump, if any.<br> |
| <i>cormap<br> |
| </i> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The memory map of the core dump or attached process.<br> |
| |
| </table> |
| <i>corpid</i>The process id of the attached process, if any.<br> |
| <i>correg</i>The register set of the core dump or attached process. If |
| these fields are not valid, they are zeroed. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Attachcore</i> and <i>attachproc</i> attach to an opened core file or an |
| executing process. They set <i>corhdr</i>, <i>corfil</i>, <i>cormap</i>, <i>corpid</i>, and |
| <i>correg</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Proctextfile</i> returns the name of the main binary for the process |
| with id <i>pid</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Attachdynamic</i> requires that the memory image already be attached. |
| It reads the dynamic linker’s internal run-time data structures |
| and then opens all the dynamic objects that are currently loaded. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Attachargs</i> uses all of these functions while parsing an argument |
| vector as would be passed to a debugger like <a href="../man1/db.html"><i>db</i>(1)</a> or <a href="../man1/acid.html"><i>acid</i>(1)</a>. |
| It expects a list of executable files, core dump files, or process |
| ids, given in any order. If extra arguments are given (for example, |
| more than one executable, or both a core dump and a |
| process id), they are ignored and diagnostics are printed to standard |
| error. If arguments are missing (for example, the process id is |
| given without an executable file), <i>attachargs</i> fills them in as |
| best it can.<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/libmach<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man3/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</i>(3)</a><br> |
| |
| </table> |
| <p><font size=+1><b>BUGS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The interface needs to be changed to support multiple threads, |
| each with its own register set.<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |