| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 1 | #if HAVE_CONFIG_H |
| 2 | #include "config.h" |
| 3 | #endif |
| 4 | |
| Juan Cespedes | 3268a16 | 1997-08-25 16:45:22 +0200 | [diff] [blame] | 5 | #include <stdio.h> |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 6 | #include <stdlib.h> |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 7 | #include <stdarg.h> |
| Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 8 | #include <string.h> |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 9 | #include <time.h> |
| 10 | #include <sys/time.h> |
| 11 | #include <unistd.h> |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 12 | |
| 13 | #include "ltrace.h" |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 14 | #include "options.h" |
| 15 | #include "output.h" |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 16 | #include "dict.h" |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 17 | |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 18 | #ifdef USE_DEMANGLE |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 19 | #include "demangle.h" |
| 20 | #endif |
| 21 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 22 | /* TODO FIXME XXX: include in ltrace.h: */ |
| 23 | extern struct timeval current_time_spent; |
| 24 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 25 | struct dict *dict_opt_c = NULL; |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 26 | |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 27 | static struct process *current_proc = 0; |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 28 | static int current_depth = 0; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 29 | static int current_column = 0; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 30 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 31 | static void output_indent(struct process *proc) |
| 32 | { |
| 33 | current_column += |
| 34 | fprintf(output, "%*s", opt_n * proc->callstack_depth, ""); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 35 | } |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 36 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 37 | static void begin_of_line(enum tof type, struct process *proc) |
| 38 | { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 39 | current_column = 0; |
| 40 | if (!proc) { |
| 41 | return; |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 42 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 43 | if ((output != stderr) && (opt_p || opt_f)) { |
| Juan Cespedes | 273ea6d | 1998-03-14 23:02:40 +0100 | [diff] [blame] | 44 | current_column += fprintf(output, "%u ", proc->pid); |
| 45 | } else if (list_of_processes->next) { |
| 46 | current_column += fprintf(output, "[pid %u] ", proc->pid); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 47 | } |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 48 | if (opt_r) { |
| 49 | struct timeval tv; |
| 50 | struct timezone tz; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 51 | static struct timeval old_tv = { 0, 0 }; |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 52 | struct timeval diff; |
| 53 | |
| 54 | gettimeofday(&tv, &tz); |
| 55 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 56 | if (old_tv.tv_sec == 0 && old_tv.tv_usec == 0) { |
| 57 | old_tv.tv_sec = tv.tv_sec; |
| 58 | old_tv.tv_usec = tv.tv_usec; |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 59 | } |
| 60 | diff.tv_sec = tv.tv_sec - old_tv.tv_sec; |
| 61 | if (tv.tv_usec >= old_tv.tv_usec) { |
| 62 | diff.tv_usec = tv.tv_usec - old_tv.tv_usec; |
| 63 | } else { |
| Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 64 | diff.tv_sec--; |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 65 | diff.tv_usec = 1000000 + tv.tv_usec - old_tv.tv_usec; |
| 66 | } |
| 67 | old_tv.tv_sec = tv.tv_sec; |
| 68 | old_tv.tv_usec = tv.tv_usec; |
| 69 | current_column += fprintf(output, "%3lu.%06d ", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 70 | diff.tv_sec, (int)diff.tv_usec); |
| Juan Cespedes | f666d19 | 1998-09-20 23:04:34 +0200 | [diff] [blame] | 71 | } |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 72 | if (opt_t) { |
| 73 | struct timeval tv; |
| 74 | struct timezone tz; |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 75 | |
| 76 | gettimeofday(&tv, &tz); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 77 | if (opt_t > 2) { |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 78 | current_column += fprintf(output, "%lu.%06d ", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 79 | tv.tv_sec, (int)tv.tv_usec); |
| 80 | } else if (opt_t > 1) { |
| 81 | struct tm *tmp = localtime(&tv.tv_sec); |
| 82 | current_column += |
| 83 | fprintf(output, "%02d:%02d:%02d.%06d ", |
| 84 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec, |
| 85 | (int)tv.tv_usec); |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 86 | } else { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 87 | struct tm *tmp = localtime(&tv.tv_sec); |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 88 | current_column += fprintf(output, "%02d:%02d:%02d ", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 89 | tmp->tm_hour, tmp->tm_min, |
| 90 | tmp->tm_sec); |
| Juan Cespedes | 5e0acdb | 1998-04-04 08:34:07 +0200 | [diff] [blame] | 91 | } |
| 92 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 93 | if (opt_i) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 94 | if (type == LT_TOF_FUNCTION || type == LT_TOF_FUNCTIONR) { |
| Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 95 | current_column += fprintf(output, "[%p] ", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 96 | proc->return_addr); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 97 | } else { |
| Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 98 | current_column += fprintf(output, "[%p] ", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 99 | proc->instruction_pointer); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 100 | } |
| 101 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 102 | if (opt_n > 0 && type != LT_TOF_NONE) { |
| Juan Cespedes | 3f0b62e | 2001-07-09 01:02:52 +0200 | [diff] [blame] | 103 | output_indent(proc); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 104 | } |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 105 | } |
| 106 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 107 | static struct function *name2func(char *name) |
| 108 | { |
| 109 | struct function *tmp; |
| 110 | const char *str1, *str2; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 111 | |
| 112 | tmp = list_of_functions; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 113 | while (tmp) { |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 114 | #ifdef USE_DEMANGLE |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 115 | str1 = opt_C ? my_demangle(tmp->name) : tmp->name; |
| 116 | str2 = opt_C ? my_demangle(name) : name; |
| 117 | #else |
| 118 | str1 = tmp->name; |
| 119 | str2 = name; |
| 120 | #endif |
| 121 | if (!strcmp(str1, str2)) { |
| 122 | |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 123 | return tmp; |
| 124 | } |
| 125 | tmp = tmp->next; |
| 126 | } |
| 127 | return NULL; |
| 128 | } |
| 129 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 130 | void output_line(struct process *proc, char *fmt, ...) |
| 131 | { |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 132 | va_list args; |
| 133 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 134 | if (opt_c) { |
| 135 | return; |
| 136 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 137 | if (current_proc) { |
| 138 | if (current_proc->callstack[current_depth].return_addr) { |
| 139 | fprintf(output, " <unfinished ...>\n"); |
| 140 | } else { |
| 141 | fprintf(output, " <no return ...>\n"); |
| 142 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 143 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 144 | current_proc = 0; |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 145 | if (!fmt) { |
| 146 | return; |
| 147 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 148 | begin_of_line(LT_TOF_NONE, proc); |
| 149 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 150 | va_start(args, fmt); |
| 151 | vfprintf(output, fmt, args); |
| 152 | fprintf(output, "\n"); |
| 153 | va_end(args); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 154 | current_column = 0; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 155 | } |
| 156 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 157 | static void tabto(int col) |
| 158 | { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 159 | if (current_column < col) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 160 | fprintf(output, "%*s", col - current_column, ""); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 164 | void output_left(enum tof type, struct process *proc, char *function_name) |
| 165 | { |
| 166 | struct function *func; |
| Steve Fink | b0315a0 | 2006-08-07 04:22:06 +0200 | [diff] [blame] | 167 | static arg_type_info *arg_unknown = NULL; |
| 168 | if (arg_unknown == NULL) |
| Steve Fink | 65b53df | 2006-09-25 02:27:08 +0200 | [diff] [blame] | 169 | arg_unknown = lookup_prototype(ARGTYPE_UNKNOWN); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 170 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 171 | if (opt_c) { |
| 172 | return; |
| 173 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 174 | if (current_proc) { |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 175 | fprintf(output, " <unfinished ...>\n"); |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 176 | current_proc = 0; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 177 | current_column = 0; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 178 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 179 | current_proc = proc; |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 180 | current_depth = proc->callstack_depth; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 181 | proc->type_being_displayed = type; |
| 182 | begin_of_line(type, proc); |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 183 | #ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 184 | current_column += |
| 185 | fprintf(output, "%s(", |
| 186 | opt_C ? my_demangle(function_name) : function_name); |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 187 | #else |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 188 | current_column += fprintf(output, "%s(", function_name); |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 189 | #endif |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 190 | |
| 191 | func = name2func(function_name); |
| 192 | if (!func) { |
| 193 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 194 | for (i = 0; i < 4; i++) { |
| 195 | current_column += |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 196 | display_arg(type, proc, i, arg_unknown); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 197 | current_column += fprintf(output, ", "); |
| 198 | } |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 199 | current_column += display_arg(type, proc, 4, arg_unknown); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 200 | return; |
| 201 | } else { |
| 202 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 203 | for (i = 0; i < func->num_params - func->params_right - 1; i++) { |
| 204 | current_column += |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 205 | display_arg(type, proc, i, func->arg_info[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 206 | current_column += fprintf(output, ", "); |
| 207 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 208 | if (func->num_params > func->params_right) { |
| 209 | current_column += |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 210 | display_arg(type, proc, i, func->arg_info[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 211 | if (func->params_right) { |
| 212 | current_column += fprintf(output, ", "); |
| 213 | } |
| 214 | } |
| Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 215 | if (func->params_right) { |
| 216 | save_register_args(type, proc); |
| 217 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 221 | void output_right(enum tof type, struct process *proc, char *function_name) |
| 222 | { |
| 223 | struct function *func = name2func(function_name); |
| Steve Fink | b0315a0 | 2006-08-07 04:22:06 +0200 | [diff] [blame] | 224 | static arg_type_info *arg_unknown = NULL; |
| 225 | if (arg_unknown == NULL) |
| Steve Fink | 65b53df | 2006-09-25 02:27:08 +0200 | [diff] [blame] | 226 | arg_unknown = lookup_prototype(ARGTYPE_UNKNOWN); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 227 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 228 | if (opt_c) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 229 | struct opt_c_struct *st; |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 230 | if (!dict_opt_c) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 231 | dict_opt_c = |
| 232 | dict_init(dict_key2hash_string, |
| 233 | dict_key_cmp_string); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 234 | } |
| 235 | st = dict_find_entry(dict_opt_c, function_name); |
| 236 | if (!st) { |
| 237 | char *na; |
| 238 | st = malloc(sizeof(struct opt_c_struct)); |
| 239 | na = strdup(function_name); |
| 240 | if (!st || !na) { |
| 241 | perror("malloc()"); |
| 242 | exit(1); |
| 243 | } |
| 244 | st->count = 0; |
| 245 | st->tv.tv_sec = st->tv.tv_usec = 0; |
| 246 | dict_enter(dict_opt_c, na, st); |
| 247 | } |
| 248 | if (st->tv.tv_usec + current_time_spent.tv_usec > 1000000) { |
| 249 | st->tv.tv_usec += current_time_spent.tv_usec - 1000000; |
| 250 | st->tv.tv_sec++; |
| 251 | } else { |
| 252 | st->tv.tv_usec += current_time_spent.tv_usec; |
| 253 | } |
| 254 | st->count++; |
| 255 | st->tv.tv_sec += current_time_spent.tv_sec; |
| 256 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 257 | // fprintf(output, "%s <%lu.%06d>\n", function_name, |
| 258 | // current_time_spent.tv_sec, (int)current_time_spent.tv_usec); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 259 | return; |
| 260 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 261 | if (current_proc && (current_proc != proc || |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 262 | current_depth != proc->callstack_depth)) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 263 | fprintf(output, " <unfinished ...>\n"); |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 264 | current_proc = 0; |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 265 | } |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 266 | if (current_proc != proc) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 267 | begin_of_line(type, proc); |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 268 | #ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 269 | current_column += |
| 270 | fprintf(output, "<... %s resumed> ", |
| 271 | opt_C ? my_demangle(function_name) : function_name); |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 272 | #else |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 273 | current_column += |
| 274 | fprintf(output, "<... %s resumed> ", function_name); |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 275 | #endif |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (!func) { |
| 279 | current_column += fprintf(output, ") "); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 280 | tabto(opt_a - 1); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 281 | fprintf(output, "= "); |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 282 | display_arg(type, proc, -1, arg_unknown); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 283 | } else { |
| 284 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 285 | for (i = func->num_params - func->params_right; |
| 286 | i < func->num_params - 1; i++) { |
| 287 | current_column += |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 288 | display_arg(type, proc, i, func->arg_info[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 289 | current_column += fprintf(output, ", "); |
| 290 | } |
| 291 | if (func->params_right) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 292 | current_column += |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 293 | display_arg(type, proc, i, func->arg_info[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 294 | } |
| 295 | current_column += fprintf(output, ") "); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 296 | tabto(opt_a - 1); |
| 297 | fprintf(output, "= "); |
| Steve Fink | b0315a0 | 2006-08-07 04:22:06 +0200 | [diff] [blame] | 298 | if (func->return_info->type == ARGTYPE_VOID) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 299 | fprintf(output, "<void>"); |
| 300 | } else { |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 301 | display_arg(type, proc, -1, func->return_info); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 302 | } |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 303 | } |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 304 | if (opt_T) { |
| 305 | fprintf(output, " <%lu.%06d>", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 306 | current_time_spent.tv_sec, |
| 307 | (int)current_time_spent.tv_usec); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 308 | } |
| 309 | fprintf(output, "\n"); |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 310 | current_proc = 0; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 311 | current_column = 0; |
| Juan Cespedes | c40e64a | 1997-10-26 20:34:00 +0100 | [diff] [blame] | 312 | } |