linux/include/linux/tracehook.h
<<
n va.15/spa 3. .15/form3. .15a n va.1 href="../linux+v3.8.6/include/linux/tracehook.h">n va.15img src="../.static/gfx/right.png" alt=">>">n 5/spa 3.n 5spa class="lxr_search">n van va.15input typ hidden" nam navtarget" n> ">n va.15input typ text" nam search" id search">n va.15butttiotyp submit">Searchn va.1Prefs. .15/a>n 5/spa 3.va.1 15/div3.va.1 15form ac 2 ="ajax+*" method="post" onsubmit="return false;">n 5input typ hidden" nam ajax_lookup" id ajax_lookup" n> ">nva.1 15/form3.nva.1 15div class="headingbotttm">. 5div id file_contents"3
1 115/a>5spa  class="comment">/*5/spa 3.1 125/a>5spa  class="comment"> * Tracing hooks5/spa 3.1 135/a>5spa  class="comment"> *5/spa 3.1 145/a>5spa  class="comment"> * Copyright (C) 2008-2009 Red Hat, Inc.  All rights reserved.5/spa 3.1 155/a>5spa  class="comment"> *5/spa 3.1 165/a>5spa  class="comment"> * This copyrighted material is made available to anyone wishing to use,5/spa 3.1 175/a>5spa  class="comment"> * modify, copy, or redistribute it subject to the terms and condi
 2 s5/spa 3.1 185/a>5spa  class="comment"> * of the GNU General Public License v.2.5/spa 3.1 195/a>5spa  class="comment"> *5/spa 3.1 5"
	a>5spa  class="comment"> * This file defines hook entry points called by core code where5/spa 3.1 115/a>5spa  class="comment"> * user tracing/debugging support might need to do something.  These5/spa 3.1 125/a>5spa  class="comment"> * entry points are called tracehook_*().  Each hook declared below5/spa 3.1 135/a>5spa  class="comment"> * has a detailed kerneldoc comment giving the context (locking et5/spa 3.1 145/a>5spa  class="comment"> * al) from which it is called, and the meaning of its return n>
  .5/spa 3.1 155/a>5spa  class="comment"> *5/spa 3.1 165/a>5spa  class="comment"> * Each func
 2  here typically has only one call site, so it is ok5/spa 3.1 175/a>5spa  class="comment"> * to have some nontrivial tracehook_*() inlines.  In all cases, the5/spa 3.1 185/a>5spa  class="comment"> * fast path when no tracing is enabled should be very short.5/spa 3.1 195/a>5spa  class="comment"> *5/spa 3.1 2"
	a>5spa  class="comment"> * The purpose of this file and the tracehook_* layer is to consolidate5/spa 3.1 215/a>5spa  class="comment"> * the interface that the kernel core and arch code uses to enable any5/spa 3.1 225/a>5spa  class="comment"> * user debugging or tracing facility (such as ptrace).  The interfaces5/spa 3.1 235/a>5spa  class="comment"> * here are carefully documented so that maintainers of core and arch5/spa 3.1 245/a>5spa  class="comment"> * code do not need to think about the implementa
 2  details of the5/spa 3.1 255/a>5spa  class="comment"> * tracing facilities.  Likewise, maintainers of the tracing code do not5/spa 3.1 265/a>5spa  class="comment"> * need to understand all the calling core or arch code i  detail, just5/spa 3.1 275/a>5spa  class="comment"> * documented circumstances of each call, such as locking condi
 2 s.5/spa 3.1 285/a>5spa  class="comment"> *5/spa 3.1 295/a>5spa  class="comment"> * If the calling core code changes so that locking is different, then5/spa 3.1 3"
	a>5spa  class="comment"> * it is ok to change the interface documented here.  The maintainer of5/spa 3.1 315/a>5spa  class="comment"> * core code changing should notify the maintainers of the tracing code5/spa 3.1 325/a>5spa  class="comment"> * that they need to work out the change.5/spa 3.1 335/a>5spa  class="comment"> *5/spa 3.1 345/a>5spa  class="comment"> * Some tracehook_*() inlines take arguments that the current tracing5/spa 3.1 355/a>5spa  class="comment"> * implementa
 2 s might not necessarily use.  These func
 2  signatures5/spa 3.1 365/a>5spa  class="comment"> * are chosen to pass i  all the informa
 2  that is o  hand in the5/spa 3.1 375/a>5spa  class="comment"> * caller and might conceivably be relevant to a tracer, so that the5/spa 3.1 385/a>5spa  class="comment"> * core code won't have to be updated when tracing adds more features.5/spa 3.1 395/a>5spa  class="comment"> * If a call site changes so that some of those param ters are no longer5/spa 3.1 4"
	a>5spa  class="comment"> * already o  hand without extra work, then the tracehook_* interface5/spa 3.1 415/a>5spa  class="comment"> * ca  change so there is no make-work burden on the core code.  The5/spa 3.1 425/a>5spa  class="comment"> * maintainer of core code changing should notify the maintainers of the5/spa 3.1 435/a>5spa  class="comment"> * tracing code that they need to work out the change.5/spa 3.1 445/a>5spa  class="comment"> */5/spa 3.1 455/a>.1 465/a>#ifndef15a href="+code=_LINUX_TRACEHOOK_H" class="sref">_LINUX_TRACEHOOK_H5/a>.1 475/a>#define15a href="+code=_LINUX_TRACEHOOK_H" class="sref">_LINUX_TRACEHOOK_H5/a>va.1 11.1 485/a>.1 495/a>#include <linux/sched.h5/a>>.1 505/a>#include <linux/ptrace.h5/a>>.1 515/a>#include <linux/security.h5/a>>.1 525/a>#include <linux/task_work.h5/a>>.1 535/a>struct15a href="+code=linux_binprm" class="sref">linux_binprm5/a>;.1 545/a>.1 555/a>5spa  class="comment">/*5/spa 3.1 565/a>5spa  class="comment"> * ptrace report for syscall entry and exit looks identical.5/spa 3.1 575/a>5spa  class="comment"> */5/spa 3.1 585/a>static15a href="+code=inline" class="sref">inline5/a>vint15a href="+code=ptrace_report_syscall" class="sref">ptrace_report_syscall5/a>(struct15a href="+code=pt_regs" class="sref">pt_regs5/a>v*5a href="+code=regs" class="sref">regs5/a>).1 595/a>{.1 605/a>va.1 1 vint15a href="+code=ptrace" class="sref">ptrace5/a>v=15a href="+code=current" class="sref">current5/a>->5a href="+code=ptrace" class="sref">ptrace5/a>;.1 615/a>.1 625/a>va.1 1 vif (!(5a href="+code=ptrace" class="sref">ptrace5/a>v&15a href="+code=PT_PTRACED" class="sref">PT_PTRACED5/a>)).1 635/a>va.1 1 vvvvvvvvvreturn 0;.1 645/a>.1 655/a>va.1 1 v5a href="+code=ptrace_notify" class="sref">ptrace_notify5/a>(5a href="+code=SIGTRAP" class="sref">SIGTRAP5/a>v| ((5a href="+code=ptrace" class="sref">ptrace5/a>v&15a href="+code=PT_TRACESYSGOOD" class="sref">PT_TRACESYSGOOD5/a>) ? 0x80 : 0));.1 665/a>.1 675/a>va.1 1 v5spa  class="comment">/*5/spa 3.1 685/a>5spa  class="comment">         * this isn't the sam  as continuing with a signal, but it will do5/spa 3.1 695/a>5spa  class="comment">         * for normal use.  strace only continues with a signalvif the5/spa 3.1 7"
	a>5spa  class="comment">         * stopping signalvis not SIGTRAP.  -brl5/spa 3.1 715/a>5spa  class="comment">         */5/spa 3.1 725/a>va.1 1 vif (5a href="+code=current" class="sref">current5/a>->5a href="+code=exit_code" class="sref">exit_code5/a>) {.1 735/a>va.1 1 vvvvvvvvv5a href="+code=send_sig" class="sref">send_sig5/a>(5a href="+code=current" class="sref">current5/a>->5a href="+code=exit_code" class="sref">exit_code5/a>,15a href="+code=current" class="sref">current5/a>, 1);.1 745/a>va.1 1 vvvvvvvvv5a href="+code=current" class="sref">current5/a>->5a href="+code=exit_code" class="sref">exit_code5/a>v=10;.1 755/a>va.1 1 v}.1 765/a>.1 775/a>va.1 1 vreturn 5a href="+code=fatal_signal_pending" class="sref">fatal_signal_pending5/a>(5a href="+code=current" class="sref">current5/a>);.1 785/a>}.1 795/a>.1 8"
	a>5spa  class="comment">/**5/spa 3.1 815/a>5spa  class="comment"> * tracehook_report_syscall_entry - taskvis about to attempt a system call5/spa 3.1 825/a>5spa  class="comment"> * @regs:a.1 1 vvvvvvvvvuser register state of current task5/spa 3.1 835/a>5spa  class="comment"> *5/spa 3.1 845/a>5spa  class="comment"> * This will be called if %TIF_SYSCALL_TRACE has been set, when the5/spa 3.1 855/a>5spa  class="comment"> * current task has just entered the kernel for a system call.5/spa 3.1 865/a>5spa  class="comment"> * Fullvuser register state is available here.  Changing the n>
  s5/spa 3.1 875/a>5spa  class="comment"> * in @regs ca  affect the system call number and arguments to be tried.5/spa 3.1 885/a>5spa  class="comment"> * It is safe to block here, preventing the system call from beginning.5/spa 3.1 895/a>5spa  class="comment"> *5/spa 3.1 9"
	a>5spa  class="comment"> * Returns zero normally, or nonzero if the calling arch code should abort5/spa 3.1 915/a>5spa  class="comment"> * the system call.  That must prevent normal entry so no system call is5/spa 3.1 925/a>5spa  class="comment"> * made.  If @task evervreturns to user mod  after this, its register state5/spa 3.1 935/a>5spa  class="comment"> * is unspecified, but should be something harmless like an %ENOSYS error5/spa 3.1 945/a>5spa  class="comment"> * return.  It should preserve enough informa
 2  so that syscall_rollback()5/spa 3.1 955/a>5spa  class="comment"> * ca  work (se  asm-generic/syscall.h).5/spa 3.1 965/a>5spa  class="comment"> *5/spa 3.1 975/a>5spa  class="comment"> * Called without locks, just after entering kernel mod .5/spa 3.1 985/a>5spa  class="comment"> */5/spa 3.1 995/a>static15a href="+code=inline" class="sref">inline5/a>v5a href="+code=__must_check" class="sref">__must_check5/a>vint15a href="+code=tracehook_report_syscall_entry" class="sref">tracehook_report_syscall_entry5/a>(.11005/a>va.1 1 vstruct15a href="+code=pt_regs" class="sref">pt_regs5/a>v*5a href="+code=regs" class="sref">regs5/a>).11015/a>{.11025/a>va.1 1 vreturn 5a href="+code=ptrace_report_syscall" class="sref">ptrace_report_syscall5/a>(5a href="+code=regs" class="sref">regs5/a>);.11035/a>}.11045/a>.11055/a>5spa  class="comment">/**5/spa 3.11065/a>5spa  class="comment"> * tracehook_report_syscall_exit - task has just finished a system call5/spa 3.11075/a>5spa  class="comment"> * @regs:a.1 1 vvvvvvvvvuser register state of current task5/spa 3.11085/a>5spa  class="comment"> * @step:a.1 1 vvvvvvvvvnonzero if simulating single-step or block-step5/spa 3.11095/a>5spa  class="comment"> *5/spa 3.115"
	a>5spa  class="comment"> * This will be called if %TIF_SYSCALL_TRACE has been set, when the5/spa 3.11115/a>5spa  class="comment"> * current task has just finished an attempted system call.  Full5/spa 3.11125/a>5spa  class="comment"> * user register state is available here.  It is safe to block here,5/spa 3.11135/a>5spa  class="comment"> * preventing signals from being processed.5/spa 3.11145/a>5spa  class="comment"> *5/spa 3.11155/a>5spa  class="comment"> * If @step is nonzero, this report is also in lieu of the normal5/spa 3.11165/a>5spa  class="comment"> * trap that would follow the system call instruct 2  because5/spa 3.11175/a>5spa  class="comment"> * user_enable_block_step() or user_enable_single_step() was used.5/spa 3.11185/a>5spa  class="comment"> * In this case, %TIF_SYSCALL_TRACE might not be set.5/spa 3.11195/a>5spa  class="comment"> *5/spa 3.112"
	a>5spa  class="comment"> * Called without locks, just before checking for pending signals.5/spa 3.11215/a>5spa  class="comment"> */5/spa 3.11225/a>static15a href="+code=inline" class="sref">inline5/a>vvoid15a href="+code=tracehook_report_syscall_exit" class="sref">tracehook_report_syscall_exit5/a>(struct15a href="+code=pt_regs" class="sref">pt_regs5/a>v*5a href="+code=regs" class="sref">regs5/a>,vint15a href="+code=step" class="sref">step5/a>).11235/a>{.11245/a>va.1 1 vif (5a href="+code=step" class="sref">step5/a>) {.11255/a>va.1 1 vvvvvvvvv5a href="+code=siginfo_t" class="sref">siginfo_t5/a>v5a href="+code=info" class="sref">info5/a>;.11265/a>va.1 1 vvvvvvvvv5a href="+code=user_single_step_siginfo" class="sref">user_single_step_siginfo5/a>(5a href="+code=current" class="sref">current5/a>,15a href="+code=regs" class="sref">regs5/a>,v&5a href="+code=info" class="sref">info5/a>);.11275/a>va.1 1 vvvvvvvvv5a href="+code=force_sig_info" class="sref">force_sig_info5/a>(5a href="+code=SIGTRAP" class="sref">SIGTRAP5/a>,v&5a href="+code=info" class="sref">info5/a>,15a href="+code=current" class="sref">current5/a>);.11285/a>va.1 1 vvvvvvvvvreturn;.11295/a>va.1 1 v}.113"
	a>.11315/a>vvvvvvvv5a href="+code=ptrace_report_syscall" class="sref">ptrace_report_syscall5/a>(5a href="+code=regs" class="sref">regs5/a>);.11325/a>}.11335/a>.11345/a>5spa  class="comment">/**5/spa 3.11355/a>5spa  class="comment"> * tracehook_signal_handler - signalvhandler setup is complete5/spa 3.11365/a>5spa  class="comment"> * @sig:a.1 1 vvvvvvvvv number of signalvbeing delivered5/spa 3.11375/a>5spa  class="comment"> * @info:a.1 1 vvvvvvvvvsiginfo_t of signalvbeing delivered5/spa 3.11385/a>5spa  class="comment"> * @ka:a.1 1 vvvvvvvvv  sigac
 2  setting that chose the handler5/spa 3.11395/a>5spa  class="comment"> * @regs:a.1 1 vvvvvvvvvuser register state5/spa 3.114"
	a>5spa  class="comment"> * @stepping:a.1 1 vvvvvnonzero if debugger single-step or block-step in use5/spa 3.11415/a>5spa  class="comment"> *5/spa 3.11425/a>5spa  class="comment"> * Called by the arch code after a signalvhandler has been set up.5/spa 3.11435/a>5spa  class="comment"> * Register and stack state reflects the user handler about to run.5/spa 3.11445/a>5spa  class="comment"> * Signalvmask changes have already been made.5/spa 3.11455/a>5spa  class="comment"> *5/spa 3.11465/a>5spa  class="comment"> * Called without locks, shortly before returning to user mod 5/spa 3.11475/a>5spa  class="comment"> * (or handling more signals).5/spa 3.11485/a>5spa  class="comment"> */5/spa 3.11495/a>static15a href="+code=inline" class="sref">inline5/a>vvoid15a href="+code=tracehook_signal_handler" class="sref">tracehook_signal_handler5/a>(int15a href="+code=sig" class="sref">sig5/a>,15a href="+code=siginfo_t" class="sref">siginfo_t5/a>v*5a href="+code=info" class="sref">info5/a>,.11505/a>va.1 1 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvconstvstruct15a href="+code=k_sigac
 2 " class="sref">k_sigac
 2 5/a>v*5a href="+code=ka" class="sref">ka5/a>,.11515/a>va.1 1 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvstruct15a href="+code=pt_regs" class="sref">pt_regs5/a>v*5a href="+code=regs" class="sref">regs5/a>,vint15a href="+code=stepping" class="sref">stepping5/a>).11525/a>{.11535/a>va.1 1 vif (5a href="+code=stepping" class="sref">stepping5/a>).11545/a>va.1 1 vvvvvvvvv5a href="+code=ptrace_notify" class="sref">ptrace_notify5/a>(5a href="+code=SIGTRAP" class="sref">SIGTRAP5/a>);.11555/a>}.11565/a>.11575/a>5spa  class="comment">/**5/spa 3.11585/a>5spa  class="comment"> * set_notify_resume - cause tracehook_notify_resume() to be called5/spa 3.11595/a>5spa  class="comment"> * @task:a.1 1 vvvvvvvvvtask that will call tracehook_notify_resume()5/spa 3.116"
	a>5spa  class="comment"> *5/spa 3.11615/a>5spa  class="comment"> * Calling this arranges that @task will call tracehook_notify_resume()5/spa 3.11625/a>5spa  class="comment"> * before returning to user mod .  If it's already running in user mod ,5/spa 3.11635/a>5spa  class="comment"> * it will enter the kernel and call tracehook_notify_resume() soon.5/spa 3.11645/a>5spa  class="comment"> * If it's blocked, it will not be woken.5/spa 3.11655/a>5spa  class="comment"> */5/spa 3.11665/a>static15a href="+code=inline" class="sref">inline5/a>vvoid15a href="+code=set_notify_resume" class="sref">set_notify_resume5/a>(struct15a href="+code=task_struct" class="sref">task_struct5/a>v*5a href="+code=task" class="sref">task5/a>).11675/a>{.11685/a>#ifdef15a href="+code=TIF_NOTIFY_RESUME" class="sref">TIF_NOTIFY_RESUME5/a>.11695/a>va.1 1 vif (!5a href="+code=test_and_set_tsk_thread_flag" class="sref">test_and_set_tsk_thread_flag5/a>(5a href="+code=task" class="sref">task5/a>,15a href="+code=TIF_NOTIFY_RESUME" class="sref">TIF_NOTIFY_RESUME5/a>)).11705/a>va.1 1 vvvvvvvvv5a href="+code=kick_process" class="sref">kick_process5/a>(5a href="+code=task" class="sref">task5/a>);.11715/a>#endif.11725/a>}.11735/a>.11745/a>5spa  class="comment">/**5/spa 3.11755/a>5spa  class="comment"> * tracehook_notify_resume - report when about to return to user mod 5/spa 3.11765/a>5spa  class="comment"> * @regs:a.1 1 vvvvvvvvvuser-mod  registers of @current task5/spa 3.11775/a>5spa  class="comment"> *5/spa 3.11785/a>5spa  class="comment"> * This is called when %TIF_NOTIFY_RESUME has been set.  Now we are5/spa 3.11795/a>5spa  class="comment"> * about to return to user mod , and the user state in @regs ca  be5/spa 3.118"
	a>5spa  class="comment"> * inspected or adjusted.  The caller i  arch code has cleared5/spa 3.11815/a>5spa  class="comment"> * %TIF_NOTIFY_RESUME before the call.  If the flag gets set again5/spa 3.11825/a>5spa  class="comment"> * asynchronously, this will be called again before we return to5/spa 3.11835/a>5spa  class="comment"> * user mod .5/spa 3.11845/a>5spa  class="comment"> *5/spa 3.11855/a>5spa  class="comment"> * Called without locks.5/spa 3.11865/a>5spa  class="comment"> */5/spa 3.11875/a>static15a href="+code=inline" class="sref">inline5/a>vvoid15a href="+code=tracehook_notify_resume" class="sref">tracehook_notify_resume5/a>(struct15a href="+code=pt_regs" class="sref">pt_regs5/a>v*5a href="+code=regs" class="sref">regs5/a>).11885/a>{.11895/a>va.1 1 v5spa  class="comment">/*5/spa 3.119"
	a>5spa  class="comment">         * The caller just cleared TIF_NOTIFY_RESUME. This barrier5/spa 3.11915/a>5spa  class="comment">         * pairs with task_work_add()->set_notify_resume() after5/spa 3.11925/a>5spa  class="comment">         * hlist_add_head(task->task_works);5/spa 3.11935/a>5spa  class="comment">         */5/spa 3.11945/a>va.1 1 v5a href="+code=smp_mb__after_clear_bit" class="sref">smp_mb__after_clear_bit5/a>();.11955/a>va.1 1 vif (5a href="+code=unlikely" class="sref">unlikely5/a>(5a href="+code=current" class="sref">current5/a>->5a href="+code=task_works" class="sref">task_works5/a>)).11965/a>va.1 1 vvvvvvvvv5a href="+code=task_work_ru " class="sref">task_work_ru 5/a>();.11975/a>}.11985/a>.11995/a>#endif v5spa  class="comment">/* <linux/tracehook.h> */5/spa 3.12005/a>
The original LXR software by the LXR community5/a>,1this experimental vers 2 by lxr@linux.no5/a>. 5/div3.5div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS5/a>,1provider of Linuxvconsulting and opera 2 s services since11995. 5/div3. 5/body3.5/html3.