From 655ee2825121e149a9976e562946892efb20aea1 Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 7 Apr 2005 21:48:47 +0000 Subject: *** empty log message *** --- runtime/docs/html/stack_8c-source.html | 280 +++++++++++++++++---------------- 1 file changed, 147 insertions(+), 133 deletions(-) (limited to 'runtime/docs/html/stack_8c-source.html') diff --git a/runtime/docs/html/stack_8c-source.html b/runtime/docs/html/stack_8c-source.html index 552f51cc..eda90dc4 100644 --- a/runtime/docs/html/stack_8c-source.html +++ b/runtime/docs/html/stack_8c-source.html @@ -4,10 +4,10 @@ -
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
-

stack.c

Go to the documentation of this file.
00001 #ifndef _STACK_C_
-00002 #define _STACK_C_
-00003 /* -*- linux-c -*- */
+
+

stack.c

Go to the documentation of this file.
00001 #ifndef _STACK_C_ /* -*- linux-c -*- */
+00002 #define _STACK_C_
+00003 
 00004 
 00005 /** @file stack.c
 00006  * @brief Stack Tracing Functions
@@ -27,148 +27,162 @@
 00020         unsigned long addr;
 00021 
 00022         if (verbose)
-00023                 _stp_print ("trace for %d (%s)\n", current->pid, current->comm);
+00023                 _stp_printf ("trace for %d (%s)\n", current->pid, current->comm);
 00024 
 00025         while (((long) stack & (THREAD_SIZE-1)) != 0) {
 00026                 addr = *stack++;
 00027                 if (_stp_kta(addr)) {
-00028                         if (verbose)
-00029                                 _stp_symbol_print (addr);
-00030                         else
-00031                                 _stp_print ("0x%lx ", addr);
-00032                 }
-00033         }
-00034         _stp_print_str ("\n");
-00035 }
-00036 
+00028                         if (verbose) {
+00029                                 _stp_symbol_print (addr);
+00030                                 _stp_print ("\n");
+00031                         } else
+00032                                 _stp_printf ("0x%lx ", addr);
+00033                 }
+00034         }
+00035         _stp_print_flush();
+00036 }
 00037 
-00038 static char *__stp_stack_sprint (unsigned long *stack, int verbose, int levels)
-00039 {
-00040         unsigned long addr;
-00041         char *ptr = _stp_scbuf_cur();
+00038 
+00039 static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels)
+00040 {
+00041         unsigned long addr;
 00042         while (((long) stack & (THREAD_SIZE-1)) != 0) {
 00043                 addr = *stack++;
 00044                 if (_stp_kta(addr)) {
 00045                         if (verbose)
-00046                                 _stp_symbol_sprint (addr);
+00046                                 _stp_symbol_sprint (str, addr);
 00047                         else
-00048                                 _stp_sprint ("0x%lx ", addr);
+00048                                 _stp_sprintf (str, "0x%lx ", addr);
 00049                 }
 00050         }
-00051         return ptr;
-00052 }
-00053 
-00054 #else  /* i386 */
-00055 
-00056 static inline int valid_stack_ptr (struct thread_info *tinfo, void *p)
-00057 {
-00058         return  p > (void *)tinfo &&
-00059                 p < (void *)tinfo + THREAD_SIZE - 3;
-00060 }
-00061 
-00062 static inline unsigned long _stp_print_context_stack (
-00063         struct thread_info *tinfo,
-00064         unsigned long *stack, 
-00065         unsigned long ebp )
-00066 {
-00067         unsigned long addr;
-00068 
-00069 #ifdef  CONFIG_FRAME_POINTER
-00070         while (valid_stack_ptr(tinfo, (void *)ebp)) {
-00071                 addr = *(unsigned long *)(ebp + 4);
-00072                 _stp_symbol_print (addr);
-00073                 _stp_print_str("\n");
-00074                 ebp = *(unsigned long *)ebp;
-00075         }
-00076 #else
-00077         while (valid_stack_ptr(tinfo, stack)) {
-00078                 addr = *stack++;
-00079                 if (_stp_kta (addr)) {
-00080                         _stp_symbol_print (addr);
-00081                         _stp_print_str ("\n");
-00082                 }
-00083         }
-00084 #endif
-00085         return ebp;
+00051 }
+00052 
+00053 #else  /* i386 */
+00054 
+00055 static inline int valid_stack_ptr (struct thread_info *tinfo, void *p)
+00056 {
+00057         return  p > (void *)tinfo &&
+00058                 p < (void *)tinfo + THREAD_SIZE - 3;
+00059 }
+00060 
+00061 static inline unsigned long _stp_print_context_stack (
+00062         struct thread_info *tinfo,
+00063         unsigned long *stack, 
+00064         unsigned long ebp )
+00065 {
+00066         unsigned long addr;
+00067 
+00068 #ifdef  CONFIG_FRAME_POINTER
+00069         while (valid_stack_ptr(tinfo, (void *)ebp)) {
+00070                 addr = *(unsigned long *)(ebp + 4);
+00071                 _stp_symbol_print (addr);
+00072                 _stp_print_cstr("\n");
+00073                 ebp = *(unsigned long *)ebp;
+00074         }
+00075 #else
+00076         while (valid_stack_ptr(tinfo, stack)) {
+00077                 addr = *stack++;
+00078                 if (_stp_kta (addr)) {
+00079                         _stp_symbol_print (addr);
+00080                         _stp_print_cstr ("\n");
+00081                 }
+00082         }
+00083 #endif
+00084         _stp_print_flush();
+00085         return ebp;
 00086 }
 00087 
 00088 static inline unsigned long _stp_sprint_context_stack (
-00089         struct thread_info *tinfo,
-00090         unsigned long *stack, 
-00091         unsigned long ebp )
-00092 {
-00093         unsigned long addr;
-00094 
-00095 #ifdef  CONFIG_FRAME_POINTER
-00096         while (valid_stack_ptr(tinfo, (void *)ebp)) {
-00097                 addr = *(unsigned long *)(ebp + 4);
-00098                 _stp_symbol_sprint (addr);
-00099                 _stp_sprint_str("\n");
-00100                 ebp = *(unsigned long *)ebp;
-00101         }
-00102 #else
-00103         while (valid_stack_ptr(tinfo, stack)) {
-00104                 addr = *stack++;
-00105                 if (_stp_kta (addr)) {
-00106                         _stp_symbol_sprint (addr);
-00107                         _stp_sprint_str ("\n");
-00108                 }
-00109         }
-00110 #endif
-00111         return ebp;
-00112 }
-00113 
-00114 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
-00115 {
-00116         unsigned long ebp;
-00117 
-00118         /* Grab ebp right from our regs */
-00119         asm ("movl %%ebp, %0" : "=r" (ebp) : );
-00120 
-00121         while (stack) {
-00122                 struct thread_info *context = (struct thread_info *)
-00123                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
-00124                 ebp = _stp_print_context_stack (context, stack, ebp);
-00125                 stack = (unsigned long*)context->previous_esp;
-00126         }
-00127 }
-00128 
-00129 static void __stp_stack_sprint (unsigned long *stack, int verbose, int levels)
-00130 {
-00131         unsigned long ebp;
-00132 
-00133         /* Grab ebp right from our regs */
-00134         asm ("movl %%ebp, %0" : "=r" (ebp) : );
-00135 
-00136         while (stack) {
-00137                 struct thread_info *context = (struct thread_info *)
-00138                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
-00139                 ebp = _stp_sprint_context_stack (context, stack, ebp);
-00140                 stack = (unsigned long*)context->previous_esp;
-00141         }
-00142 }
-00143 
-00144 #endif /* i386 */
-00145 
-00146 /** Print stack dump.
-00147  * Prints a stack dump to the trace buffer.
-00148  * @param verbose Verbosity:
-00149  */
-00150 
-00151 void _stp_stack_print (int verbose, int levels)
-00152 {
-00153   unsigned long stack;
-00154   return __stp_stack_print (&stack, verbose, levels);
-00155 }
-00156 
-00157 char *_stp_stack_sprint (int verbose, int levels)
-00158 {
-00159   unsigned long stack;
-00160   char *ptr = _stp_scbuf_cur();
-00161   __stp_stack_sprint (&stack, verbose, levels);
-00162   return ptr;
-00163 }
-00164 
-00165 /** @} */
-00166 #endif /* _STACK_C_ */
+00089         String str,
+00090         struct thread_info *tinfo,
+00091         unsigned long *stack, 
+00092         unsigned long ebp )
+00093 {
+00094         unsigned long addr;
+00095 
+00096 #ifdef  CONFIG_FRAME_POINTER
+00097         while (valid_stack_ptr(tinfo, (void *)ebp)) {
+00098                 addr = *(unsigned long *)(ebp + 4);
+00099                 _stp_symbol_sprint (str, addr);
+00100                 _stp_string_cat ("\n");
+00101                 ebp = *(unsigned long *)ebp;
+00102         }
+00103 #else
+00104         while (valid_stack_ptr(tinfo, stack)) {
+00105                 addr = *stack++;
+00106                 if (_stp_kta (addr)) {
+00107                         _stp_symbol_sprint (addr);
+00108                         _stp_string_cat ("\n");
+00109                 }
+00110         }
+00111 #endif
+00112         return ebp;
+00113 }
+00114 
+00115 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
+00116 {
+00117         unsigned long ebp;
+00118 
+00119         /* Grab ebp right from our regs */
+00120         asm ("movl %%ebp, %0" : "=r" (ebp) : );
+00121 
+00122         while (stack) {
+00123                 struct thread_info *context = (struct thread_info *)
+00124                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
+00125                 ebp = _stp_print_context_stack (context, stack, ebp);
+00126                 stack = (unsigned long*)context->previous_esp;
+00127         }
+00128 }
+00129 
+00130 static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels)
+00131 {
+00132         unsigned long ebp;
+00133 
+00134         /* Grab ebp right from our regs */
+00135         asm ("movl %%ebp, %0" : "=r" (ebp) : );
+00136 
+00137         while (stack) {
+00138                 struct thread_info *context = (struct thread_info *)
+00139                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
+00140                 ebp = _stp_sprint_context_stack (str, context, stack, ebp);
+00141                 stack = (unsigned long*)context->previous_esp;
+00142         }
+00143 }
+00144 
+00145 #endif /* i386 */
+00146 
+00147 /** Print stack dump.
+00148  * Prints a stack dump to the print buffer.
+00149  * @param verbose Verbosity
+00150  * @param levels Number of levels to trace.
+00151  * @todo Implement verbosity and levels parameters.
+00152  * @bug levels parameter is not functional
+00153  */
+00154 
+00155 void _stp_stack_print (int verbose, int levels)
+00156 {
+00157   unsigned long stack;
+00158   __stp_stack_print (&stack, verbose, levels);
+00159 }
+00160 
+00161 /** Writes stack dump to a String
+00162  *
+00163  * @param str String
+00164  * @param verbose Verbosity
+00165  * @param levels Number of levels to trace.
+00166  * @returns Same String as was input.
+00167  * @todo Implement verbosity and levels parameters.
+00168  * @bug levels parameter is not functional
+00169  */
+00170 
+00171 String _stp_stack_sprint (String str, int verbose, int levels)
+00172 {
+00173   unsigned long stack;
+00174   __stp_stack_sprint (str, &stack, verbose, levels);
+00175   _stp_log ("sss: str=%s\n", str->buf);
+00176   return str;
+00177 }
+00178 
+00179 /** @} */
+00180 #endif /* _STACK_C_ */
 
-- cgit