blob: bd050e7dd6db214d3597b0b14380982bc950c338 [file] [log] [blame]
Juan Cespedesd44c6b81998-09-25 14:48:42 +02001#if HAVE_CONFIG_H
2#include "config.h"
3#endif
4
Steve Fink7bafff02006-08-07 04:50:42 +02005#include <ctype.h>
Juan Cespedes5e01f651998-03-08 22:31:44 +01006#include <stdio.h>
7#include <stdlib.h>
Juan Cespedesd914a202004-11-10 00:15:33 +01008#include <string.h>
Juan Cespedes2c4a8cb1998-03-11 23:33:18 +01009#include <limits.h>
Juan Cespedes5e01f651998-03-08 22:31:44 +010010
11#include "ltrace.h"
12#include "options.h"
13
Juan Cespedesac3db291998-04-25 14:31:58 +020014static int display_char(int what);
Steve Fink6a48a6d2006-08-07 04:29:06 +020015static int display_string(enum tof type, struct process *proc,
Steve Fink7bafff02006-08-07 04:50:42 +020016 void* addr, size_t maxlen);
17static int display_value(enum tof type, struct process *proc,
Steve Finke4b32632006-08-07 06:10:08 +020018 long value, arg_type_info *info,
19 void *st, arg_type_info* st_info);
Steve Fink7bafff02006-08-07 04:50:42 +020020static int display_unknown(enum tof type, struct process *proc, long value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +010021static int display_format(enum tof type, struct process *proc, int arg_num);
Juan Cespedes5e01f651998-03-08 22:31:44 +010022
Steve Fink6a48a6d2006-08-07 04:29:06 +020023static int string_maxlength = INT_MAX;
Steve Fink1150bc42006-08-07 06:04:43 +020024static int array_maxlength = INT_MAX;
Steve Fink6a48a6d2006-08-07 04:29:06 +020025
Steve Finke4b32632006-08-07 06:10:08 +020026static long get_length(enum tof type, struct process *proc, int len_spec,
27 void *st, arg_type_info* st_info)
Steve Fink6a48a6d2006-08-07 04:29:06 +020028{
Steve Finke4b32632006-08-07 06:10:08 +020029 long len;
Steve Fink65b53df2006-09-25 02:27:08 +020030 arg_type_info info;
31
Steve Fink6a48a6d2006-08-07 04:29:06 +020032 if (len_spec > 0)
33 return len_spec;
Steve Finke4b32632006-08-07 06:10:08 +020034 if (type == LT_TOF_STRUCT) {
35 umovelong(proc, st + st_info->u.struct_info.offset[-len_spec-1], &len);
36 return len;
37 }
Steve Fink65b53df2006-09-25 02:27:08 +020038
39 info.arg_num = -len_spec - 1;
40 info.type = ARGTYPE_INT;
41 return gimme_arg(type, proc, &info);
Steve Fink6a48a6d2006-08-07 04:29:06 +020042}
43
Steve Fink1150bc42006-08-07 06:04:43 +020044static int display_ptrto(enum tof type, struct process *proc, long item,
Steve Finke4b32632006-08-07 06:10:08 +020045 arg_type_info * info,
46 void *st, arg_type_info* st_info)
Steve Fink1150bc42006-08-07 06:04:43 +020047{
48 arg_type_info temp;
49 temp.type = ARGTYPE_POINTER;
50 temp.u.ptr_info.info = info;
Steve Finke4b32632006-08-07 06:10:08 +020051 return display_value(type, proc, item, &temp, st, st_info);
Steve Fink1150bc42006-08-07 06:04:43 +020052}
53
54/*
55 * addr - A pointer to the first element of the array
56 *
57 * The function name is used to indicate that we're not actually
58 * looking at an 'array', which is a contiguous region of memory
59 * containing a sequence of elements of some type; instead, we have a
60 * pointer to that region of memory.
61 */
62static int display_arrayptr(enum tof type, struct process *proc,
Steve Finke4b32632006-08-07 06:10:08 +020063 void *addr, arg_type_info * info,
64 void *st, arg_type_info* st_info)
Steve Fink1150bc42006-08-07 06:04:43 +020065{
66 int len = 0;
67 int i;
68 int array_len;
69
70 if (addr == NULL)
71 return fprintf(output, "NULL");
72
Steve Finke4b32632006-08-07 06:10:08 +020073 array_len = get_length(type, proc, info->u.array_info.len_spec,
74 st, st_info);
Steve Fink1150bc42006-08-07 06:04:43 +020075 len += fprintf(output, "[ ");
76 for (i = 0; i < opt_A && i < array_maxlength && i < array_len; i++) {
77 arg_type_info *elt_type = info->u.array_info.elt_type;
78 size_t elt_size = info->u.array_info.elt_size;
79 if (i != 0)
80 len += fprintf(output, ", ");
81 if (opt_d)
82 len += fprintf(output, "%p=", addr);
83 len +=
Steve Finke4b32632006-08-07 06:10:08 +020084 display_ptrto(type, proc, (long) addr, elt_type, st, st_info);
Steve Fink1150bc42006-08-07 06:04:43 +020085 addr += elt_size;
86 }
87 if (i < array_len)
88 len += fprintf(output, "...");
89 len += fprintf(output, " ]");
90 return len;
91}
92
Steve Finke4b32632006-08-07 06:10:08 +020093/* addr - A pointer to the beginning of the memory region occupied by
94 * the struct (aka a pointer to the struct)
95 */
96static int display_structptr(enum tof type, struct process *proc,
97 void *addr, arg_type_info * info)
98{
99 int i;
100 arg_type_info *field;
101 int len = 0;
102
103 if (addr == NULL)
104 return fprintf(output, "NULL");
105
106 len += fprintf(output, "{ ");
107 for (i = 0; (field = info->u.struct_info.fields[i]) != NULL; i++) {
108 if (i != 0)
109 len += fprintf(output, ", ");
110 if (opt_d)
111 len +=
112 fprintf(output, "%p=",
113 addr + info->u.struct_info.offset[i]);
114 len +=
115 display_ptrto(LT_TOF_STRUCT, proc,
116 (long) addr + info->u.struct_info.offset[i],
117 field, addr, info);
118 }
119 len += fprintf(output, " }");
120
121 return len;
122}
123
Steve Fink7bafff02006-08-07 04:50:42 +0200124static int display_pointer(enum tof type, struct process *proc, long value,
Steve Finke4b32632006-08-07 06:10:08 +0200125 arg_type_info * info,
126 void *st, arg_type_info* st_info)
Steve Fink7bafff02006-08-07 04:50:42 +0200127{
128 long pointed_to;
129 arg_type_info *inner = info->u.ptr_info.info;
130
Steve Fink1150bc42006-08-07 06:04:43 +0200131 if (inner->type == ARGTYPE_ARRAY) {
Steve Finke4b32632006-08-07 06:10:08 +0200132 return display_arrayptr(type, proc, (void*) value, inner,
133 st, st_info);
134 } else if (inner->type == ARGTYPE_STRUCT) {
135 return display_structptr(type, proc, (void *) value, inner);
Steve Fink1150bc42006-08-07 06:04:43 +0200136 } else {
137 if (value == 0)
138 return fprintf(output, "NULL");
139 else if (umovelong(proc, (void *) value, &pointed_to) < 0)
140 return fprintf(output, "?");
141 else
Steve Finke4b32632006-08-07 06:10:08 +0200142 return display_value(type, proc, pointed_to, inner,
143 st, st_info);
Steve Fink1150bc42006-08-07 06:04:43 +0200144 }
Steve Fink7bafff02006-08-07 04:50:42 +0200145}
146
Steve Fink6a3e24d2006-08-07 05:53:19 +0200147static int display_enum(enum tof type, struct process *proc,
148 arg_type_info* info, long value)
149{
150 int ii;
151 for (ii = 0; ii < info->u.enum_info.entries; ++ii) {
152 if (info->u.enum_info.values[ii] == value)
153 return fprintf(output, "%s", info->u.enum_info.keys[ii]);
154 }
155
156 return display_unknown(type, proc, value);
157}
158
Steve Fink7bafff02006-08-07 04:50:42 +0200159/* Args:
160 type - syscall or shared library function or memory
161 proc - information about the traced process
162 value - the value to display
163 info - the description of the type to display
Steve Finke4b32632006-08-07 06:10:08 +0200164 st - if the current value is a struct member, the address of the struct
165 st_info - type of the above struct
166
167 Those last two parameters are used for structs containing arrays or
168 strings whose length is given by another structure element.
Steve Fink7bafff02006-08-07 04:50:42 +0200169*/
170int display_value(enum tof type, struct process *proc,
Steve Finke4b32632006-08-07 06:10:08 +0200171 long value, arg_type_info *info,
172 void *st, arg_type_info* st_info)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100173{
Juan Cespedes5e01f651998-03-08 22:31:44 +0100174 int tmp;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100175
Steve Fink6a48a6d2006-08-07 04:29:06 +0200176 switch (info->type) {
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100177 case ARGTYPE_VOID:
178 return 0;
179 case ARGTYPE_INT:
Juan Cespedesaee09312007-08-31 18:49:48 +0200180 return fprintf(output, "%d", (int) value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100181 case ARGTYPE_UINT:
Juan Cespedesaee09312007-08-31 18:49:48 +0200182 return fprintf(output, "%u", (unsigned) value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100183 case ARGTYPE_LONG:
184 if (proc->mask_32bit)
Steve Fink7bafff02006-08-07 04:50:42 +0200185 return fprintf(output, "%d", (int) value);
186 else
187 return fprintf(output, "%ld", value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100188 case ARGTYPE_ULONG:
189 if (proc->mask_32bit)
Steve Fink7bafff02006-08-07 04:50:42 +0200190 return fprintf(output, "%u", (unsigned) value);
191 else
192 return fprintf(output, "%lu", (unsigned long) value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100193 case ARGTYPE_OCTAL:
Steve Fink7bafff02006-08-07 04:50:42 +0200194 return fprintf(output, "0%o", (unsigned) value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100195 case ARGTYPE_CHAR:
196 tmp = fprintf(output, "'");
Steve Fink7bafff02006-08-07 04:50:42 +0200197 tmp += display_char(value == -1 ? value : (char) value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100198 tmp += fprintf(output, "'");
199 return tmp;
Steve Fink6fa27c32006-08-07 05:56:56 +0200200 case ARGTYPE_SHORT:
201 return fprintf(output, "%hd", (short) value);
202 case ARGTYPE_USHORT:
203 return fprintf(output, "%hu", (unsigned short) value);
204 case ARGTYPE_FLOAT: {
Steve Fink65b53df2006-09-25 02:27:08 +0200205 union { long l; float f; double d; } cvt;
Steve Fink6fa27c32006-08-07 05:56:56 +0200206 cvt.l = value;
207 return fprintf(output, "%f", cvt.f);
208 }
Steve Fink65b53df2006-09-25 02:27:08 +0200209 case ARGTYPE_DOUBLE: {
210 union { long l; float f; double d; } cvt;
211 cvt.l = value;
212 return fprintf(output, "%lf", cvt.d);
213 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100214 case ARGTYPE_ADDR:
Steve Fink7bafff02006-08-07 04:50:42 +0200215 if (!value)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100216 return fprintf(output, "NULL");
Steve Fink7bafff02006-08-07 04:50:42 +0200217 else
218 return fprintf(output, "0x%08lx", value);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100219 case ARGTYPE_FORMAT:
Steve Fink7bafff02006-08-07 04:50:42 +0200220 fprintf(stderr, "Should never encounter a format anywhere but at the top level (for now?)\n");
221 exit(1);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100222 case ARGTYPE_STRING:
Steve Fink7bafff02006-08-07 04:50:42 +0200223 return display_string(type, proc, (void*) value,
Steve Fink6a48a6d2006-08-07 04:29:06 +0200224 string_maxlength);
225 case ARGTYPE_STRING_N:
Steve Fink7bafff02006-08-07 04:50:42 +0200226 return display_string(type, proc, (void*) value,
Steve Fink6a48a6d2006-08-07 04:29:06 +0200227 get_length(type, proc,
Steve Finke4b32632006-08-07 06:10:08 +0200228 info->u.string_n_info.size_spec, st, st_info));
Steve Fink1150bc42006-08-07 06:04:43 +0200229 case ARGTYPE_ARRAY:
230 return fprintf(output, "<array without address>");
Steve Fink6a3e24d2006-08-07 05:53:19 +0200231 case ARGTYPE_ENUM:
232 return display_enum(type, proc, info, value);
Steve Finke4b32632006-08-07 06:10:08 +0200233 case ARGTYPE_STRUCT:
234 return fprintf(output, "<struct without address>");
Steve Fink7bafff02006-08-07 04:50:42 +0200235 case ARGTYPE_POINTER:
Steve Finke4b32632006-08-07 06:10:08 +0200236 return display_pointer(type, proc, value, info,
237 st, st_info);
Steve Fink7bafff02006-08-07 04:50:42 +0200238 case ARGTYPE_UNKNOWN:
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100239 default:
Steve Fink7bafff02006-08-07 04:50:42 +0200240 return display_unknown(type, proc, value);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100241 }
Steve Fink7bafff02006-08-07 04:50:42 +0200242}
243
Steve Fink65b53df2006-09-25 02:27:08 +0200244int display_arg(enum tof type, struct process *proc, arg_type_info * info)
Steve Fink7bafff02006-08-07 04:50:42 +0200245{
246 long arg;
247
248 if (info->type == ARGTYPE_VOID) {
249 return 0;
250 } else if (info->type == ARGTYPE_FORMAT) {
Steve Fink65b53df2006-09-25 02:27:08 +0200251 return display_format(type, proc, info->arg_num);
Steve Fink7bafff02006-08-07 04:50:42 +0200252 } else {
Steve Fink65b53df2006-09-25 02:27:08 +0200253 arg = gimme_arg(type, proc, info);
Steve Finke4b32632006-08-07 06:10:08 +0200254 return display_value(type, proc, arg, info, NULL, NULL);
Steve Fink7bafff02006-08-07 04:50:42 +0200255 }
Juan Cespedes5e01f651998-03-08 22:31:44 +0100256}
257
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100258static int display_char(int what)
259{
260 switch (what) {
261 case -1:
262 return fprintf(output, "EOF");
263 case '\r':
264 return fprintf(output, "\\r");
265 case '\n':
266 return fprintf(output, "\\n");
267 case '\t':
268 return fprintf(output, "\\t");
269 case '\b':
270 return fprintf(output, "\\b");
271 case '\\':
272 return fprintf(output, "\\\\");
273 default:
Steve Fink7bafff02006-08-07 04:50:42 +0200274 if (isprint(what)) {
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100275 return fprintf(output, "%c", what);
Steve Fink7bafff02006-08-07 04:50:42 +0200276 } else {
277 return fprintf(output, "\\%03o", (unsigned char)what);
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100278 }
Juan Cespedes5e01f651998-03-08 22:31:44 +0100279 }
280}
281
Juan Cespedes2c4a8cb1998-03-11 23:33:18 +0100282#define MIN(a,b) (((a)<(b)) ? (a) : (b))
283
Steve Fink7bafff02006-08-07 04:50:42 +0200284static int display_string(enum tof type, struct process *proc, void *addr,
285 size_t maxlength)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100286{
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100287 unsigned char *str1;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100288 int i;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100289 int len = 0;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100290
Juan Cespedes5e01f651998-03-08 22:31:44 +0100291 if (!addr) {
292 return fprintf(output, "NULL");
293 }
294
Steve Fink6a48a6d2006-08-07 04:29:06 +0200295 str1 = malloc(MIN(opt_s, maxlength) + 3);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100296 if (!str1) {
297 return fprintf(output, "???");
298 }
Steve Fink6a48a6d2006-08-07 04:29:06 +0200299 umovestr(proc, addr, MIN(opt_s, maxlength) + 1, str1);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100300 len = fprintf(output, "\"");
Steve Fink6a48a6d2006-08-07 04:29:06 +0200301 for (i = 0; i < MIN(opt_s, maxlength); i++) {
Juan Cespedes5e01f651998-03-08 22:31:44 +0100302 if (str1[i]) {
303 len += display_char(str1[i]);
304 } else {
305 break;
306 }
307 }
308 len += fprintf(output, "\"");
Steve Fink6a48a6d2006-08-07 04:29:06 +0200309 if (str1[i] && (opt_s <= maxlength)) {
Juan Cespedes5e01f651998-03-08 22:31:44 +0100310 len += fprintf(output, "...");
311 }
312 free(str1);
313 return len;
314}
315
Steve Fink7bafff02006-08-07 04:50:42 +0200316static int display_unknown(enum tof type, struct process *proc, long value)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100317{
Ian Wienand9a2ad352006-02-20 22:44:45 +0100318 if (proc->mask_32bit) {
Steve Fink7bafff02006-08-07 04:50:42 +0200319 if ((int)value < 1000000 && (int)value > -1000000)
320 return fprintf(output, "%d", (int)value);
Ian Wienand9a2ad352006-02-20 22:44:45 +0100321 else
Steve Fink7bafff02006-08-07 04:50:42 +0200322 return fprintf(output, "%p", (void *)value);
323 } else if (value < 1000000 && value > -1000000) {
324 return fprintf(output, "%ld", value);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100325 } else {
Steve Fink7bafff02006-08-07 04:50:42 +0200326 return fprintf(output, "%p", (void *)value);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100327 }
328}
Juan Cespedesac3db291998-04-25 14:31:58 +0200329
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100330static int display_format(enum tof type, struct process *proc, int arg_num)
331{
332 void *addr;
333 unsigned char *str1;
Juan Cespedesac3db291998-04-25 14:31:58 +0200334 int i;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100335 int len = 0;
Steve Fink65b53df2006-09-25 02:27:08 +0200336 arg_type_info info;
Juan Cespedesac3db291998-04-25 14:31:58 +0200337
Steve Fink65b53df2006-09-25 02:27:08 +0200338 info.arg_num = arg_num;
339 info.type = ARGTYPE_POINTER;
340 addr = (void *)gimme_arg(type, proc, &info);
Juan Cespedesac3db291998-04-25 14:31:58 +0200341 if (!addr) {
342 return fprintf(output, "NULL");
343 }
344
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100345 str1 = malloc(MIN(opt_s, string_maxlength) + 3);
Juan Cespedesac3db291998-04-25 14:31:58 +0200346 if (!str1) {
347 return fprintf(output, "???");
348 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100349 umovestr(proc, addr, MIN(opt_s, string_maxlength) + 1, str1);
Juan Cespedesac3db291998-04-25 14:31:58 +0200350 len = fprintf(output, "\"");
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100351 for (i = 0; len < MIN(opt_s, string_maxlength) + 1; i++) {
Juan Cespedesac3db291998-04-25 14:31:58 +0200352 if (str1[i]) {
353 len += display_char(str1[i]);
354 } else {
355 break;
356 }
357 }
358 len += fprintf(output, "\"");
359 if (str1[i] && (opt_s <= string_maxlength)) {
360 len += fprintf(output, "...");
361 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100362 for (i = 0; str1[i]; i++) {
363 if (str1[i] == '%') {
Juan Cespedesd914a202004-11-10 00:15:33 +0100364 int is_long = 0;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100365 while (1) {
Juan Cespedes5c3fe062004-06-14 18:08:37 +0200366 unsigned char c = str1[++i];
Juan Cespedesac3db291998-04-25 14:31:58 +0200367 if (c == '%') {
368 break;
369 } else if (!c) {
370 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100371 } else if (strchr("lzZtj", c)) {
Juan Cespedesd914a202004-11-10 00:15:33 +0100372 is_long++;
373 if (c == 'j')
374 is_long++;
Ian Wienand3219f322006-02-16 06:00:00 +0100375 if (is_long > 1
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100376 && (sizeof(long) < sizeof(long long)
377 || proc->mask_32bit)) {
Juan Cespedesd914a202004-11-10 00:15:33 +0100378 len += fprintf(output, ", ...");
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100379 str1[i + 1] = '\0';
Juan Cespedesd914a202004-11-10 00:15:33 +0100380 break;
381 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100382 } else if (c == 'd' || c == 'i') {
Steve Fink65b53df2006-09-25 02:27:08 +0200383 info.arg_num = ++arg_num;
384 info.type = ARGTYPE_LONG;
Ian Wienand9a2ad352006-02-20 22:44:45 +0100385 if (!is_long || proc->mask_32bit)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100386 len +=
387 fprintf(output, ", %d",
388 (int)gimme_arg(type,
389 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200390 &info));
Juan Cespedesd914a202004-11-10 00:15:33 +0100391 else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100392 len +=
393 fprintf(output, ", %ld",
394 gimme_arg(type,
395 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200396 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200397 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100398 } else if (c == 'u') {
Steve Fink65b53df2006-09-25 02:27:08 +0200399 info.arg_num = ++arg_num;
400 info.type = ARGTYPE_LONG;
Ian Wienand9a2ad352006-02-20 22:44:45 +0100401 if (!is_long || proc->mask_32bit)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100402 len +=
403 fprintf(output, ", %u",
404 (int)gimme_arg(type,
405 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200406 &info));
Juan Cespedesd914a202004-11-10 00:15:33 +0100407 else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100408 len +=
409 fprintf(output, ", %lu",
410 gimme_arg(type,
411 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200412 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200413 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100414 } else if (c == 'o') {
Steve Fink65b53df2006-09-25 02:27:08 +0200415 info.arg_num = ++arg_num;
416 info.type = ARGTYPE_LONG;
Ian Wienand9a2ad352006-02-20 22:44:45 +0100417 if (!is_long || proc->mask_32bit)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100418 len +=
419 fprintf(output, ", 0%o",
420 (int)gimme_arg(type,
421 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200422 &info));
Juan Cespedesd914a202004-11-10 00:15:33 +0100423 else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100424 len +=
425 fprintf(output, ", 0%lo",
426 gimme_arg(type,
427 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200428 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200429 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100430 } else if (c == 'x' || c == 'X') {
Steve Fink65b53df2006-09-25 02:27:08 +0200431 info.arg_num = ++arg_num;
432 info.type = ARGTYPE_LONG;
Ian Wienand9a2ad352006-02-20 22:44:45 +0100433 if (!is_long || proc->mask_32bit)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100434 len +=
435 fprintf(output, ", %#x",
436 (int)gimme_arg(type,
437 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200438 &info));
Juan Cespedesd914a202004-11-10 00:15:33 +0100439 else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100440 len +=
441 fprintf(output, ", %#lx",
442 gimme_arg(type,
443 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200444 &info));
Juan Cespedesd914a202004-11-10 00:15:33 +0100445 break;
446 } else if (strchr("eEfFgGaACS", c)
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100447 || (is_long
448 && (c == 'c' || c == 's'))) {
Juan Cespedesd914a202004-11-10 00:15:33 +0100449 len += fprintf(output, ", ...");
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100450 str1[i + 1] = '\0';
Juan Cespedesac3db291998-04-25 14:31:58 +0200451 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100452 } else if (c == 'c') {
Steve Fink65b53df2006-09-25 02:27:08 +0200453 info.arg_num = ++arg_num;
454 info.type = ARGTYPE_LONG;
Juan Cespedesac3db291998-04-25 14:31:58 +0200455 len += fprintf(output, ", '");
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100456 len +=
457 display_char((int)
458 gimme_arg(type, proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200459 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200460 len += fprintf(output, "'");
461 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100462 } else if (c == 's') {
Steve Fink65b53df2006-09-25 02:27:08 +0200463 info.arg_num = ++arg_num;
464 info.type = ARGTYPE_POINTER;
Juan Cespedesac3db291998-04-25 14:31:58 +0200465 len += fprintf(output, ", ");
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100466 len +=
467 display_string(type, proc,
Steve Fink7bafff02006-08-07 04:50:42 +0200468 (void *)gimme_arg(type,
469 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200470 &info),
Steve Fink6a48a6d2006-08-07 04:29:06 +0200471 string_maxlength);
Juan Cespedesac3db291998-04-25 14:31:58 +0200472 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100473 } else if (c == 'p' || c == 'n') {
Steve Fink65b53df2006-09-25 02:27:08 +0200474 info.arg_num = ++arg_num;
475 info.type = ARGTYPE_POINTER;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100476 len +=
477 fprintf(output, ", %p",
478 (void *)gimme_arg(type,
479 proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200480 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200481 break;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100482 } else if (c == '*') {
Steve Fink65b53df2006-09-25 02:27:08 +0200483 info.arg_num = ++arg_num;
484 info.type = ARGTYPE_LONG;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100485 len +=
486 fprintf(output, ", %d",
487 (int)gimme_arg(type, proc,
Steve Fink65b53df2006-09-25 02:27:08 +0200488 &info));
Juan Cespedesac3db291998-04-25 14:31:58 +0200489 }
490 }
491 }
492 }
493 free(str1);
494 return len;
495}