linux/kernel/trace/trace_kdb.c
<<
000<./spa 0<.spa class="lxr_search">0 ="+search" method="post" onsubmit="return do_search(this);">0 ">00Search00<./spa /o14 4./div /o14 4.form ac > ="ajax+*" method="post" onsubmit="return false;">0<.input typ hidden" nam ajax_lookup" id ajax_lookup" ion> ">0/o14 4./form 0/o14 4.div class="headingbottom">
.div id file_contents"
4 41./a>.spa
 class="comment">/*./spa
  4 42./a>.spa
 class="comment"> * kdb helper for dumping the ftrace buffer./spa
  4 43./a>.spa
 class="comment"> *./spa
  4 44./a>.spa
 class="comment"> * Copyright (C) 2010 JasoptWessel <jasop.wessel@windriver.com>./spa
  4 45./a>.spa
 class="comment"> *./spa
  4 46./a>.spa
 class="comment"> * ftrace_dump_buf based on ftrace_dump:./spa
  4 47./a>.spa
 class="comment"> * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>./spa
  4 48./a>.spa
 class="comment"> * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>./spa
  4 49./a>.spa
 class="comment"> *./spa
  4 ptioa>.spa
 class="comment"> */./spa
  4 11./a>#include <linux/init.h./a>> 4 12./a>#include <linux/kgdb.h./a>> 4 13./a>#include <linux/kdb.h./a>> 4 14./a>#include <linux/ftrace.h./a>> 4 15./a> 4 16./a>#include "trace.h./a>" 4 17./a>#include "trace_output.h./a>" 4 18./a> 4 19./a>static void4.a href="+code=ftrace_dump_buf" class="sref">ftrace_dump_buf./a>(int4.a href="+code=skip_lines" class="sref">skip_lines./a>, long .a href="+code=cpu_file" class="sref">cpu_file./a>) 4 2tioa>{ 4 21./a>        .spa
 class="comment">/* use static because iter ca
 be a bit big for the stack */./spa
  4 22./a>        static struct4.a href="+code=trace_iterator" class="sref">trace_iterator./a> .a href="+code=iter" class="sref">iter./a>; 4 23./a>        unsigned int4.a href="+code=old_userobj" class="sref">old_userobj./a>; 4 24./a>        int4.a href="+code=cnt" class="sref">cnt./a> = 0, .a href="+code=cpu" class="sref">cpu./a>; 4 25./a> 4 26./a>        .a href="+code=trace_init_global_iter" class="sref">trace_init_global_iter./a>(&.a href="+code=iter" class="sref">iter./a>); 4 27./a> 4 28./a>        .a href="+code=for_each_tracing_cpu" class="sref">for_each_tracing_cpu./a>(.a href="+code=cpu" class="sref">cpu./a>) { 4 29./a>                .a href="+code=atomic_inc" class="sref">atomic_inc./a>(&.a href="+code=iter" class="sref">iter./a>..a href="+code=tr" class="sref">tr./a>->.a href="+code=data" class="sref">data./a>[.a href="+code=cpu" class="sref">cpu./a>]->.a href="+code=disabled" class="sref">disabled./a>); 4 30./a>        } 4 31./a> 4 32./a>        .a href="+code=old_userobj" class="sref">old_userobj./a> = .a href="+code=trace_flags" class="sref">trace_flags./a>; 4 33./a> 4 34./a>        .spa
 class="comment">/* don't look at user memory in pa
ic mode */./spa
  4 35./a>        .a href="+code=trace_flags" class="sref">trace_flags./a> &= ~.a href="+code=TRACE_ITER_SYM_USEROBJ" class="sref">TRACE_ITER_SYM_USEROBJ./a>; 4 36./a> 4 37./a>        .a href="+code=kdb_printf" class="sref">kdb_printf./a>(.spa
 class="string">"Dumping ftrace buffer:\n"4 38./a> 4 39./a>        .spa
 class="comment">/* reset all but tr, trace, and overruns */./spa
  4 40./a>        .a href="+code=memset" class="sref">memset./a>(&.a href="+code=iter" class="sref">iter./a>..a href="+code=seq" class="sref">seq./a>, 0, 4 41./a>                   sizeof(struct4.a href="+code=trace_iterator" class="sref">trace_iterator./a>) - 4 42./a>                   .a href="+code=offsetof" class="sref">offsetof./a>(struct4.a href="+code=trace_iterator" class="sref">trace_iterator./a>, .a href="+code=seq" class="sref">seq./a>)); 4 43./a>        .a href="+code=iter" class="sref">iter./a>..a href="+code=iter_flags" class="sref">iter_flags./a> |= .a href="+code=TRACE_FILE_LAT_FMT" class="sref">TRACE_FILE_LAT_FMT./a>; 4 44./a>        .a href="+code=iter" class="sref">iter./a>..a href="+code=pos" class="sref">pos./a> = -1; 4 45./a> 4 46./a>        if (.a href="+code=cpu_file" class="sref">cpu_file./a> == .a href="+code=TRACE_PIPE_ALL_CPU" class="sref">TRACE_PIPE_ALL_CPU./a>) { 4 47./a>                .a href="+code=for_each_tracing_cpu" class="sref">for_each_tracing_cpu./a>(.a href="+code=cpu" class="sref">cpu./a>) { 4 48./a>                        .a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu" class="sref">cpu./a>] = 4 49./a>                        .a href="+code=ring_buffer_read_prepare" class="sref">ring_buffer_read_prepare./a>(.a href="+code=iter" class="sref">iter./a>..a href="+code=tr" class="sref">tr./a>->.a href="+code=buffer" class="sref">buffer./a>, .a href="+code=cpu" class="sref">cpu./a>); 4 50./a>                        .a href="+code=ring_buffer_read_start" class="sref">ring_buffer_read_start./a>(.a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu" class="sref">cpu./a>]); 4 51./a>                        .a href="+code=tracing_iter_reset" class="sref">tracing_iter_reset./a>(&.a href="+code=iter" class="sref">iter./a>, .a href="+code=cpu" class="sref">cpu./a>); 4 52./a>                } 4 53./a>        } else { 4 54./a>                .a href="+code=iter" class="sref">iter./a>..a href="+code=cpu_file" class="sref">cpu_file./a> = .a href="+code=cpu_file" class="sref">cpu_file./a>; 4 55./a>                .a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu_file" class="sref">cpu_file./a>] = 4 56./a>                        .a href="+code=ring_buffer_read_prepare" class="sref">ring_buffer_read_prepare./a>(.a href="+code=iter" class="sref">iter./a>..a href="+code=tr" class="sref">tr./a>->.a href="+code=buffer" class="sref">buffer./a>, .a href="+code=cpu_file" class="sref">cpu_file./a>); 4 57./a>                .a href="+code=ring_buffer_read_start" class="sref">ring_buffer_read_start./a>(.a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu_file" class="sref">cpu_file./a>]); 4 58./a>                .a href="+code=tracing_iter_reset" class="sref">tracing_iter_reset./a>(&.a href="+code=iter" class="sref">iter./a>, .a href="+code=cpu_file" class="sref">cpu_file./a>); 4 59./a>        } 4 60./a>        if (!.a href="+code=trace_empty" class="sref">trace_empty./a>(&.a href="+code=iter" class="sref">iter./a>)) 4 61./a>                .a href="+code=trace_find_next_entry_inc" class="sref">trace_find_next_entry_inc./a>(&.a href="+code=iter" class="sref">iter./a>); 4 62./a>        while (!.a href="+code=trace_empty" class="sref">trace_empty./a>(&.a href="+code=iter" class="sref">iter./a>)) { 4 63./a>                if (!.a href="+code=cnt" class="sref">cnt./a>) 4 64./a>                        .a href="+code=kdb_printf" class="sref">kdb_printf./a>(.spa
 class="string">"---------------------------------\n"4 65./a>                .a href="+code=cnt" class="sref">cnt./a>++; 4 66./a> 4 67./a>                if (.a href="+code=trace_find_next_entry_inc" class="sref">trace_find_next_entry_inc./a>(&.a href="+code=iter" class="sref">iter./a>) != .a href="+code=NULL" class="sref">NULL./a> && !.a href="+code=skip_lines" class="sref">skip_lines./a>) 4 68./a>                        .a href="+code=print_trace_line" class="sref">print_trace_line./a>(&.a href="+code=iter" class="sref">iter./a>); 4 69./a>                if (!.a href="+code=skip_lines" class="sref">skip_lines./a>) 4 70./a>                        .a href="+code=trace_printk_seq" class="sref">trace_printk_seq./a>(&.a href="+code=iter" class="sref">iter./a>..a href="+code=seq" class="sref">seq./a>); 4 71./a>                else 4 72./a>                        .a href="+code=skip_lines" class="sref">skip_lines./a>--; 4 73./a>                if (.a href="+code=KDB_FLAG" class="sref">KDB_FLAG./a>(.a href="+code=CMD_INTERRUPT" class="sref">CMD_INTERRUPT./a>)) 4 74./a>                        goto .a href="+code=out" class="sref">out./a>; 4 75./a>        } 4 76./a> 4 77./a>        if (!.a href="+code=cnt" class="sref">cnt./a>) 4 78./a>                .a href="+code=kdb_printf" class="sref">kdb_printf./a>(.spa
 class="string">"   (ftrace buffer empty)\n"4 79./a>        else 4 80./a>                .a href="+code=kdb_printf" class="sref">kdb_printf./a>(.spa
 class="string">"---------------------------------\n"4 81./a> 4 82./a>.a href="+code=out" class="sref">out./a>: 4 83./a>        .a href="+code=trace_flags" class="sref">trace_flags./a> = .a href="+code=old_userobj" class="sref">old_userobj./a>; 4 84./a> 4 85./a>        .a href="+code=for_each_tracing_cpu" class="sref">for_each_tracing_cpu./a>(.a href="+code=cpu" class="sref">cpu./a>) { 4 86./a>                .a href="+code=atomic_dec" class="sref">atomic_dec./a>(&.a href="+code=iter" class="sref">iter./a>..a href="+code=tr" class="sref">tr./a>->.a href="+code=data" class="sref">data./a>[.a href="+code=cpu" class="sref">cpu./a>]->.a href="+code=disabled" class="sref">disabled./a>); 4 87./a>        } 4 88./a> 4 89./a>        .a href="+code=for_each_tracing_cpu" class="sref">for_each_tracing_cpu./a>(.a href="+code=cpu" class="sref">cpu./a>) 4 90./a>                if (.a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu" class="sref">cpu./a>]) 4 91./a>                        .a href="+code=ring_buffer_read_finish" class="sref">ring_buffer_read_finish./a>(.a href="+code=iter" class="sref">iter./a>..a href="+code=buffer_iter" class="sref">buffer_iter./a>[.a href="+code=cpu" class="sref">cpu./a>]); 4 92./a>} 4 93./a> 4 94./a>.spa
 class="comment">/*./spa
  4 95./a>.spa
 class="comment"> * kdb_ftdump - Dump the ftrace log buffer./spa
  4 96./a>.spa
 class="comment"> */./spa
  4 97./a>static int4.a href="+code=kdb_ftdump" class="sref">kdb_ftdump./a>(int4.a href="+code=argc" class="sref">argc./a>, const char **.a href="+code=argv" class="sref">argv./a>) 4 98./a>{ 4 99./a>        int4.a href="+code=skip_lines" class="sref">skip_lines./a> = 0; 4100./a>        long .a href="+code=cpu_file" class="sref">cpu_file./a>; 4101./a>        char *.a href="+code=cp" class="sref">cp./a>; 4102./a> 4103./a>        if (.a href="+code=argc" class="sref">argc./a> > 2) 4104./a>                return .a href="+code=KDB_ARGCOUNT" class="sref">KDB_ARGCOUNT./a>; 4105./a> 4106./a>        if (.a href="+code=argc" class="sref">argc./a>) { 4107./a>                .a href="+code=skip_lines" class="sref">skip_lines./a> = .a href="+code=simple_strtol" class="sref">simple_strtol./a>(.a href="+code=argv" class="sref">argv./a>[1], &.a href="+code=cp" class="sref">cp./a>, 0); 4108./a>                if (*.a href="+code=cp" class="sref">cp./a>) 4109./a>                        .a href="+code=skip_lines" class="sref">skip_lines./a> = 0; 4110./a>        } 4111./a> 4112./a>        if (.a href="+code=argc" class="sref">argc./a> == 2) { 4113./a>                .a href="+code=cpu_file" class="sref">cpu_file./a> = .a href="+code=simple_strtol" class="sref">simple_strtol./a>(.a href="+code=argv" class="sref">argv./a>[2], &.a href="+code=cp" class="sref">cp./a>, 0); 4114./a>                if (*.a href="+code=cp" class="sref">cp./a> || .a href="+code=cpu_file" class="sref">cpu_file./a> >= .a href="+code=NR_CPUS" class="sref">NR_CPUS./a> || .a href="+code=cpu_file" class="sref">cpu_file./a> < 0 || 4115./a>                    !.a href="+code=cpu_online" class="sref">cpu_online./a>(.a href="+code=cpu_file" class="sref">cpu_file./a>)) 4116./a>                        return .a href="+code=KDB_BADINT" class="sref">KDB_BADINT./a>; 4117./a>        } else { 4118./a>                .a href="+code=cpu_file" class="sref">cpu_file./a> = .a href="+code=TRACE_PIPE_ALL_CPU" class="sref">TRACE_PIPE_ALL_CPU./a>; 4119./a>        } 412tioa> 4121./a>        .a href="+code=kdb_trap_printk" class="sref">kdb_trap_printk./a>++; 4122./a>        .a href="+code=ftrace_dump_buf" class="sref">ftrace_dump_buf./a>(.a href="+code=skip_lines" class="sref">skip_lines./a>, .a href="+code=cpu_file" class="sref">cpu_file./a>); 4123./a>        .a href="+code=kdb_trap_printk" class="sref">kdb_trap_printk./a>--; 4124./a> 4125./a>        return 0; 4126./a>} 4127./a> 4128./a>static .a href="+code=__init" class="sref">__init./a> int4.a href="+code=kdb_ftrace_register" class="sref">kdb_ftrace_register./a>(void) 4129./a>{ 4130./a>        .a href="+code=kdb_register_repeat" class="sref">kdb_register_repeat./a>(.spa
 class="string">"ftdump"kdb_ftdump./a>, .spa
 class="string">"[skip_#lines] [cpu]"4131./a>                            .spa
 class="string">"Dump ftrace log"KDB_REPEAT_NONE./a>); 4132./a>        return 0; 4133./a>} 4134./a> 4135./a>.a href="+code=late_initcall" class="sref">late_initcall./a>(.a href="+code=kdb_ftrace_register" class="sref">kdb_ftrace_register./a>); 4136./a>
The original LXR software by the LXR community./a>, this experimental vers/optby lxr@linux.no./a>. ./div .div class="subfooter"> lxr.linux.no kindly hostedtby Redpill Linpro AS./a>, provider of Linux consulting and operat/ops services since 1995. ./div ./body ./html