| 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 | |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 27 | static pid_t current_pid = 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 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 137 | if (current_pid) { |
| 138 | fprintf(output, " <unfinished ...>\n"); |
| 139 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 140 | current_pid = 0; |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 141 | if (!fmt) { |
| 142 | return; |
| 143 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 144 | begin_of_line(LT_TOF_NONE, proc); |
| 145 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 146 | va_start(args, fmt); |
| 147 | vfprintf(output, fmt, args); |
| 148 | fprintf(output, "\n"); |
| 149 | va_end(args); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 150 | current_column = 0; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 151 | } |
| 152 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 153 | static void tabto(int col) |
| 154 | { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 155 | if (current_column < col) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 156 | fprintf(output, "%*s", col - current_column, ""); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 160 | void output_left(enum tof type, struct process *proc, char *function_name) |
| 161 | { |
| 162 | struct function *func; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 163 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 164 | if (opt_c) { |
| 165 | return; |
| 166 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 167 | if (current_pid) { |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 168 | fprintf(output, " <unfinished ...>\n"); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 169 | current_pid = 0; |
| 170 | current_column = 0; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 171 | } |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 172 | current_pid = proc->pid; |
| 173 | current_depth = proc->callstack_depth; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 174 | proc->type_being_displayed = type; |
| 175 | begin_of_line(type, proc); |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 176 | #ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 177 | current_column += |
| 178 | fprintf(output, "%s(", |
| 179 | opt_C ? my_demangle(function_name) : function_name); |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 180 | #else |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 181 | current_column += fprintf(output, "%s(", function_name); |
| Juan Cespedes | ac3db29 | 1998-04-25 14:31:58 +0200 | [diff] [blame] | 182 | #endif |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 183 | |
| 184 | func = name2func(function_name); |
| 185 | if (!func) { |
| 186 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 187 | for (i = 0; i < 4; i++) { |
| 188 | current_column += |
| 189 | display_arg(type, proc, i, ARGTYPE_UNKNOWN); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 190 | current_column += fprintf(output, ", "); |
| 191 | } |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 192 | current_column += display_arg(type, proc, 4, ARGTYPE_UNKNOWN); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 193 | return; |
| 194 | } else { |
| 195 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 196 | for (i = 0; i < func->num_params - func->params_right - 1; i++) { |
| 197 | current_column += |
| 198 | display_arg(type, proc, i, func->arg_types[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 199 | current_column += fprintf(output, ", "); |
| 200 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 201 | if (func->num_params > func->params_right) { |
| 202 | current_column += |
| 203 | display_arg(type, proc, i, func->arg_types[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 204 | if (func->params_right) { |
| 205 | current_column += fprintf(output, ", "); |
| 206 | } |
| 207 | } |
| Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 208 | if (func->params_right) { |
| 209 | save_register_args(type, proc); |
| 210 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 214 | void output_right(enum tof type, struct process *proc, char *function_name) |
| 215 | { |
| 216 | struct function *func = name2func(function_name); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 217 | |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 218 | if (opt_c) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 219 | struct opt_c_struct *st; |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 220 | if (!dict_opt_c) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 221 | dict_opt_c = |
| 222 | dict_init(dict_key2hash_string, |
| 223 | dict_key_cmp_string); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 224 | } |
| 225 | st = dict_find_entry(dict_opt_c, function_name); |
| 226 | if (!st) { |
| 227 | char *na; |
| 228 | st = malloc(sizeof(struct opt_c_struct)); |
| 229 | na = strdup(function_name); |
| 230 | if (!st || !na) { |
| 231 | perror("malloc()"); |
| 232 | exit(1); |
| 233 | } |
| 234 | st->count = 0; |
| 235 | st->tv.tv_sec = st->tv.tv_usec = 0; |
| 236 | dict_enter(dict_opt_c, na, st); |
| 237 | } |
| 238 | if (st->tv.tv_usec + current_time_spent.tv_usec > 1000000) { |
| 239 | st->tv.tv_usec += current_time_spent.tv_usec - 1000000; |
| 240 | st->tv.tv_sec++; |
| 241 | } else { |
| 242 | st->tv.tv_usec += current_time_spent.tv_usec; |
| 243 | } |
| 244 | st->count++; |
| 245 | st->tv.tv_sec += current_time_spent.tv_sec; |
| 246 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 247 | // fprintf(output, "%s <%lu.%06d>\n", function_name, |
| 248 | // current_time_spent.tv_sec, (int)current_time_spent.tv_usec); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 249 | return; |
| 250 | } |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 251 | if (current_pid && (current_pid != proc->pid || |
| 252 | current_depth != proc->callstack_depth)) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 253 | fprintf(output, " <unfinished ...>\n"); |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 254 | current_pid = 0; |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 255 | } |
| 256 | if (current_pid != proc->pid) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 257 | begin_of_line(type, proc); |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 258 | #ifdef USE_DEMANGLE |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 259 | current_column += |
| 260 | fprintf(output, "<... %s resumed> ", |
| 261 | opt_C ? my_demangle(function_name) : function_name); |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 262 | #else |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 263 | current_column += |
| 264 | fprintf(output, "<... %s resumed> ", function_name); |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 265 | #endif |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | if (!func) { |
| 269 | current_column += fprintf(output, ") "); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 270 | tabto(opt_a - 1); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 271 | fprintf(output, "= "); |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 272 | display_arg(type, proc, -1, ARGTYPE_UNKNOWN); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 273 | } else { |
| 274 | int i; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 275 | for (i = func->num_params - func->params_right; |
| 276 | i < func->num_params - 1; i++) { |
| 277 | current_column += |
| 278 | display_arg(type, proc, i, func->arg_types[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 279 | current_column += fprintf(output, ", "); |
| 280 | } |
| 281 | if (func->params_right) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 282 | current_column += |
| 283 | display_arg(type, proc, i, func->arg_types[i]); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 284 | } |
| 285 | current_column += fprintf(output, ") "); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 286 | tabto(opt_a - 1); |
| 287 | fprintf(output, "= "); |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 288 | if (func->return_type == ARGTYPE_VOID) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 289 | fprintf(output, "<void>"); |
| 290 | } else { |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 291 | display_arg(type, proc, -1, func->return_type); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 292 | } |
| Juan Cespedes | 5e4455b | 1997-08-24 01:48:26 +0200 | [diff] [blame] | 293 | } |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 294 | if (opt_T) { |
| 295 | fprintf(output, " <%lu.%06d>", |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 296 | current_time_spent.tv_sec, |
| 297 | (int)current_time_spent.tv_usec); |
| Juan Cespedes | d65efa3 | 2003-02-03 00:22:30 +0100 | [diff] [blame] | 298 | } |
| 299 | fprintf(output, "\n"); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame^] | 300 | current_pid = 0; |
| 301 | current_column = 0; |
| Juan Cespedes | c40e64a | 1997-10-26 20:34:00 +0100 | [diff] [blame] | 302 | } |