<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter 3. Machine State</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="The utrace User Debugging Infrastructure" /><link rel="up" href="index.html" title="The utrace User Debugging Infrastructure" /><link rel="prev" href="re21.html" title="utrace_finish_examine" /><link rel="next" href="re22.html" title="user_regset_active_fn" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. Machine State</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re21.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="re22.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 3. Machine State"><div class="titlepage"><div><div><h2 class="title"><a id="machine"></a>Chapter 3. Machine State</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch03.html#regset"><span class="structname">struct user_regset</span></a></span></dt><dt><span class="sect1"><a href="ch03s02.html"><code class="filename">System Call Information</code></a></span></dt><dt><span class="sect1"><a href="ch03s03.html"><code class="filename">System Call Tracing</code></a></span></dt></dl></div><p> The <code class="function">task_current_syscall</code> function can be used on any valid <span class="structname">struct task_struct</span> at any time, and does not even require that <code class="function">utrace_attach_task</code> was used at all. </p><p> The other ways to access the registers and other machine-dependent state of a task can only be used on a task that is at a known safe point. The safe points are all the places where <code class="function">utrace_set_events</code> can request callbacks (except for the <code class="constant">DEATH</code> and <code class="constant">REAP</code> events). So at any event callback, it is safe to examine <code class="varname">current</code>. </p><p> One task can examine another only after a callback in the target task that returns <code class="constant">UTRACE_STOP</code> so that task will not return to user mode after the safe point. This guarantees that the task will not resume until the same engine uses <code class="function">utrace_control</code>, unless the task dies suddenly. To examine safely, one must use a pair of calls to <code class="function">utrace_prepare_examine</code> and <code class="function">utrace_finish_examine</code> surrounding the calls to <span class="structname">struct user_regset</span> functions or direct examination of task data structures. <code class="function">utrace_prepare_examine</code> returns an error if the task is not properly stopped, or is dead. After a successful examination, the paired <code class="function">utrace_finish_examine</code> call returns an error if the task ever woke up during the examination. If so, any data gathered may be scrambled and should be discarded. This means there was a spurious wake-up (which should not happen), or a sudden death. </p><div class="sect1" title="struct user_regset"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="regset"></a><span class="structname">struct user_regset</span></h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="re22.html"><span>user_regset_active_fn</span></a></span><span class="refpurpose"> — type of <em class="parameter"><code>active</code></em> function in <span class="structname">struct user_regset</span> </span></dt><dt><span class="refentrytitle"><a href="re23.html"><span>user_regset_get_fn</span></a></span><span class="refpurpose"> — type of <em class="parameter"><code>get</code></em> function in <span class="structname">struct user_regset</span> </span></dt><dt><span class="refentrytitle"><a href="re24.html"><span>user_regset_set_fn</span></a></span><span class="refpurpose"> — type of <em class="parameter"><code>set</code></em> function in <span class="structname">struct user_regset</span> </span></dt><dt><span class="refentrytitle"><a href="re25.html"><span>user_regset_writeback_fn</span></a></span><span class="refpurpose"> — type of <em class="parameter"><code>writeback</code></em> function in <span class="structname">struct user_regset</span> </span></dt><dt><span class="refentrytitle"><a href="re26.html"><span>struct user_regset</span></a></span><span class="refpurpose"> — accessible thread CPU state </span></dt><dt><span class="refentrytitle"><a href="re27.html"><span>struct user_regset_view</span></a></span><span class="refpurpose"> — available regsets </span></dt><dt><span class="refentrytitle"><a href="re28.html"><span>task_user_regset_view</span></a></span><span class="refpurpose"> — Return the process's native regset view. </span></dt><dt><span class="refentrytitle"><a href="re29.html"><span>copy_regset_to_user</span></a></span><span class="refpurpose"> — fetch a thread's user_regset data into user memory </span></dt><dt><span class="refentrytitle"><a href="re30.html"><span>copy_regset_from_user</span></a></span><span class="refpurpose"> — store into thread's user_regset data from user memory </span></dt></dl></div><p> The <span class="structname">struct user_regset</span> API is declared in <code class="filename"><linux/regset.h></code>. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re21.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="re22.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>utrace_finish_examine</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>user_regset_active_fn</span></td></tr></table></div></body></html>