blob: 7ad2ee4a68b05447fc2170e5040dd2d1bac188fa [file] [log] [blame]
Petr Machata94078ec2012-01-05 18:07:02 +01001/*
2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
4 * Copyright (C) 1998,2004,2007,2008,2009 Juan Cespedes
5 * Copyright (C) 2006 Ian Wienand
6 * Copyright (C) 2006 Steve Fink
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
Steve Fink7bafff02006-08-07 04:50:42 +020024#include <ctype.h>
Juan Cespedes5e01f651998-03-08 22:31:44 +010025#include <stdlib.h>
Petr Machata94078ec2012-01-05 18:07:02 +010026#include <assert.h>
27#include <inttypes.h>
28#include <stdarg.h>
29#include <stdio.h>
Petr Machata307b90b2012-11-19 00:35:38 +010030#include <string.h>
Juan Cespedes5e01f651998-03-08 22:31:44 +010031
Petr Machata366c2f42012-02-09 19:34:36 +010032#include "proc.h"
Petr Machata31af32c2012-01-08 02:36:50 +010033#include "lens_default.h"
Petr Machata94078ec2012-01-05 18:07:02 +010034#include "value.h"
35#include "expr.h"
Petr Machata000e3112012-01-03 17:03:39 +010036#include "type.h"
Petr Machata94078ec2012-01-05 18:07:02 +010037#include "common.h"
Petr Machatad7b22922012-01-06 18:34:22 +010038#include "zero.h"
Juan Cespedes5e01f651998-03-08 22:31:44 +010039
Petr Machata94078ec2012-01-05 18:07:02 +010040#define READER(NAME, TYPE) \
41 static int \
42 NAME(struct value *value, TYPE *ret, struct value_dict *arguments) \
43 { \
44 union { \
45 TYPE val; \
46 unsigned char buf[0]; \
47 } u; \
48 if (value_extract_buf(value, u.buf, arguments) < 0) \
49 return -1; \
50 *ret = u.val; \
51 return 0; \
Juan Cespedesa413e5b2007-09-04 17:34:53 +020052 }
Steve Fink65b53df2006-09-25 02:27:08 +020053
Petr Machata94078ec2012-01-05 18:07:02 +010054READER(read_float, float)
55READER(read_double, double)
56
57#undef READER
58
59#define HANDLE_WIDTH(BITS) \
60 do { \
61 long l; \
62 if (value_extract_word(value, &l, arguments) < 0) \
63 return -1; \
64 int##BITS##_t i = l; \
Petr Machatae773f632012-11-09 18:52:53 +010065 uint64_t v = (uint64_t)(uint##BITS##_t)i; \
Petr Machata94078ec2012-01-05 18:07:02 +010066 switch (format) { \
67 case INT_FMT_unknown: \
Petr Machatac1e41862012-08-31 15:13:16 +020068 if (l < -10000 || l > 10000) \
Petr Machata94078ec2012-01-05 18:07:02 +010069 case INT_FMT_x: \
Petr Machatae773f632012-11-09 18:52:53 +010070 return fprintf(stream, "%#"PRIx64, v); \
Petr Machata94078ec2012-01-05 18:07:02 +010071 case INT_FMT_i: \
Petr Machatae773f632012-11-09 18:52:53 +010072 case INT_FMT_default: \
Petr Machata94078ec2012-01-05 18:07:02 +010073 return fprintf(stream, "%"PRIi##BITS, i); \
74 case INT_FMT_u: \
Petr Machatae773f632012-11-09 18:52:53 +010075 return fprintf(stream, "%"PRIu64, v); \
Petr Machata94078ec2012-01-05 18:07:02 +010076 case INT_FMT_o: \
Petr Machatae773f632012-11-09 18:52:53 +010077 return fprintf(stream, "0%"PRIo64, v); \
Petr Machata94078ec2012-01-05 18:07:02 +010078 } \
79 } while (0)
80
81enum int_fmt_t
82{
83 INT_FMT_i,
84 INT_FMT_u,
85 INT_FMT_o,
86 INT_FMT_x,
87 INT_FMT_unknown,
Petr Machatae773f632012-11-09 18:52:53 +010088 INT_FMT_default,
Petr Machata94078ec2012-01-05 18:07:02 +010089};
90
91static int
92format_integer(FILE *stream, struct value *value, enum int_fmt_t format,
93 struct value_dict *arguments)
94{
95 switch (type_sizeof(value->inferior, value->type)) {
96
97 case 1: HANDLE_WIDTH(8);
98 case 2: HANDLE_WIDTH(16);
99 case 4: HANDLE_WIDTH(32);
100 case 8: HANDLE_WIDTH(64);
101
102 default:
103 assert(!"unsupported integer width");
104 abort();
105
106 case -1:
107 return -1;
108 }
109}
110
111#undef HANDLE_WIDTH
112
113static int
Petr Machata94078ec2012-01-05 18:07:02 +0100114acc_fprintf(int *countp, FILE *stream, const char *format, ...)
115{
116 va_list pa;
117 va_start(pa, format);
Petr Machataadec2012012-11-01 22:05:04 +0100118 int i = account_output(countp, vfprintf(stream, format, pa));
Petr Machata94078ec2012-01-05 18:07:02 +0100119 va_end(pa);
120
Petr Machata94078ec2012-01-05 18:07:02 +0100121 return i;
122}
123
124static int
125format_char(FILE *stream, struct value *value, struct value_dict *arguments)
126{
127 long lc;
128 if (value_extract_word(value, &lc, arguments) < 0)
129 return -1;
130 int c = (int)lc;
131
Petr Machata94078ec2012-01-05 18:07:02 +0100132 const char *fmt;
133 switch (c) {
134 case -1:
135 fmt = "EOF";
136 break;
137 case 0:
138 fmt = "\\0";
139 break;
140 case '\a':
141 fmt = "\\a";
142 break;
143 case '\b':
144 fmt = "\\b";
145 break;
146 case '\t':
147 fmt = "\\t";
148 break;
149 case '\n':
150 fmt = "\\n";
151 break;
152 case '\v':
153 fmt = "\\v";
154 break;
155 case '\f':
156 fmt = "\\f";
157 break;
158 case '\r':
159 fmt = "\\r";
160 break;
161 case '\\':
162 fmt = "\\\\";
163 break;
164 default:
165 if (isprint(c) || c == ' ')
166 fmt = "%c";
Petr Machata94078ec2012-01-05 18:07:02 +0100167 else
Petr Machata987d27b2012-01-17 19:04:04 +0100168 fmt = "\\%03o";
Petr Machata94078ec2012-01-05 18:07:02 +0100169 }
170
Petr Machata987d27b2012-01-17 19:04:04 +0100171 return fprintf(stream, fmt, c);
Petr Machatae3f4a982012-01-09 04:27:26 +0100172}
173
174static int
175format_naked_char(FILE *stream, struct value *value,
176 struct value_dict *arguments)
177{
178 int written = 0;
179 if (acc_fprintf(&written, stream, "'") < 0
Petr Machataadec2012012-11-01 22:05:04 +0100180 || account_output(&written,
181 format_char(stream, value, arguments)) < 0
Petr Machatae3f4a982012-01-09 04:27:26 +0100182 || acc_fprintf(&written, stream, "'") < 0)
Petr Machata94078ec2012-01-05 18:07:02 +0100183 return -1;
Petr Machatae3f4a982012-01-09 04:27:26 +0100184
Petr Machata94078ec2012-01-05 18:07:02 +0100185 return written;
186}
187
188static int
189format_floating(FILE *stream, struct value *value, struct value_dict *arguments)
190{
191 switch (value->type->type) {
192 float f;
193 double d;
194 case ARGTYPE_FLOAT:
195 if (read_float(value, &f, arguments) < 0)
196 return -1;
197 return fprintf(stream, "%f", (double)f);
198 case ARGTYPE_DOUBLE:
199 if (read_double(value, &d, arguments) < 0)
200 return -1;
201 return fprintf(stream, "%f", d);
202 default:
203 abort();
204 }
205}
206
Petr Machataf7c46bb2012-11-01 22:15:45 +0100207struct format_argument_data
208{
209 struct value *value;
210 struct value_dict *arguments;
211};
212
213static int
214format_argument_cb(FILE *stream, void *ptr)
215{
216 struct format_argument_data *data = ptr;
217 return format_argument(stream, data->value, data->arguments);
218}
219
Petr Machata94078ec2012-01-05 18:07:02 +0100220static int
221format_struct(FILE *stream, struct value *value, struct value_dict *arguments)
222{
223 int written = 0;
224 if (acc_fprintf(&written, stream, "{ ") < 0)
225 return -1;
Petr Machataf7c46bb2012-11-01 22:15:45 +0100226
227 int need_delim = 0;
Petr Machata94078ec2012-01-05 18:07:02 +0100228 size_t i;
229 for (i = 0; i < type_struct_size(value->type); ++i) {
Petr Machata94078ec2012-01-05 18:07:02 +0100230 struct value element;
231 if (value_init_element(&element, value, i) < 0)
232 return -1;
Petr Machataf7c46bb2012-11-01 22:15:45 +0100233
234 struct format_argument_data data = { &element, arguments };
235 int o = delim_output(stream, &need_delim,
236 format_argument_cb, &data);
Petr Machata8904cdc2012-10-30 17:27:20 +0100237 value_destroy(&element);
Petr Machata94078ec2012-01-05 18:07:02 +0100238 if (o < 0)
239 return -1;
Petr Machataf7c46bb2012-11-01 22:15:45 +0100240
Petr Machata94078ec2012-01-05 18:07:02 +0100241 written += o;
242 }
243 if (acc_fprintf(&written, stream, " }") < 0)
244 return -1;
245 return written;
246}
247
248int
249format_pointer(FILE *stream, struct value *value, struct value_dict *arguments)
250{
Petr Machata26c0c942012-11-19 00:14:51 +0100251 if (value_is_zero(value, arguments))
252 return fprintf(stream, "nil");
253
Petr Machata307b90b2012-11-19 00:35:38 +0100254 /* The following is for detecting recursion. We keep track of
255 * the values that were already displayed. Each time a
256 * pointer should be dereferenced, we compare its value to the
257 * value of each of the pointers dereferenced so far. If one
258 * of them matches, instead of recursing, we just printf which
259 * superstructure this pointer recurses to. */
260 static struct vect pointers = {};
261 if (pointers.elt_size == 0)
262 VECT_INIT(&pointers, struct value *);
263
Petr Machata6248a0a2012-11-19 01:00:54 +0100264 /* Trim number of expanded structures of the same type. Even
265 * for non-recursive structure, we don't want to expand all of
266 * it if it's huge. */
Petr Machata307b90b2012-11-19 00:35:38 +0100267 size_t i;
Petr Machata6248a0a2012-11-19 01:00:54 +0100268 size_t len = vect_size(&pointers);
269 assert(value->type->type == ARGTYPE_POINTER);
270 struct arg_type_info *pointee = value->type->u.ptr_info.info;
271 if (pointee->type == ARGTYPE_STRUCT) {
272 size_t depth = 0;
273 for (i = 0; i < len; ++i) {
274 struct value *old
275 = *VECT_ELEMENT(&pointers, struct value *, i);
276 assert(old->type->type == ARGTYPE_POINTER);
277 struct arg_type_info *old_pointee
278 = old->type->u.ptr_info.info;
279 if (old_pointee == pointee)
280 depth++;
281 }
282 if (depth >= options.arraylen)
283 return fprintf(stream, "...");
284 }
285
Petr Machata307b90b2012-11-19 00:35:38 +0100286 for (i = len; i-- > 0 ;) {
287 struct value **old = VECT_ELEMENT(&pointers, struct value *, i);
288 int rc = value_equal(value, *old, arguments);
289 if (rc < 0)
290 return -1;
291 if (rc > 0) {
292 size_t reclevel = len - i - 1;
293 char buf[reclevel + 1];
294 memset(buf, '^', sizeof buf);
295 buf[reclevel] = 0;
296 return fprintf(stream, "recurse%s", buf);
297 }
298 }
299
300 /* OK, not a recursion. Remember this value for tracking. */
301 if (VECT_PUSHBACK(&pointers, &value) < 0)
302 return -1;
303
Petr Machata94078ec2012-01-05 18:07:02 +0100304 struct value element;
Petr Machata26c0c942012-11-19 00:14:51 +0100305 int o;
306 if (value_init_deref(&element, value) < 0) {
307 o = -1;
308 goto done;
309 }
310 o = format_argument(stream, &element, arguments);
Petr Machata8904cdc2012-10-30 17:27:20 +0100311 value_destroy(&element);
Petr Machata26c0c942012-11-19 00:14:51 +0100312
313done:
Petr Machata307b90b2012-11-19 00:35:38 +0100314 vect_popback(&pointers);
Petr Machata8904cdc2012-10-30 17:27:20 +0100315 return o;
Steve Fink1150bc42006-08-07 06:04:43 +0200316}
317
318/*
Petr Machata94078ec2012-01-05 18:07:02 +0100319 * LENGTH is an expression whose evaluation will yield the actual
320 * length of the array.
Steve Fink1150bc42006-08-07 06:04:43 +0200321 *
Petr Machata94078ec2012-01-05 18:07:02 +0100322 * MAXLEN is the actual maximum length that we care about
323 *
324 * BEFORE if LENGTH>MAXLEN, we display ellipsis. We display it before
325 * the closing parenthesis if BEFORE, otherwise after it.
326 *
327 * OPEN, CLOSE, DELIM are opening and closing parenthesis and element
328 * delimiter.
Steve Fink1150bc42006-08-07 06:04:43 +0200329 */
Juan Cespedesf1350522008-12-16 18:19:58 +0100330int
Petr Machata94078ec2012-01-05 18:07:02 +0100331format_array(FILE *stream, struct value *value, struct value_dict *arguments,
332 struct expr_node *length, size_t maxlen, int before,
333 const char *open, const char *close, const char *delim)
Petr Machata000e3112012-01-03 17:03:39 +0100334{
Petr Machata94078ec2012-01-05 18:07:02 +0100335 /* We need "long" to be long enough to cover the whole address
336 * space. */
337 typedef char assert__long_enough_long[-(sizeof(long) < sizeof(void *))];
Petr Machata31af32c2012-01-08 02:36:50 +0100338 long l;
Petr Machatad7b22922012-01-06 18:34:22 +0100339 if (expr_eval_word(length, value, arguments, &l) < 0)
340 return -1;
Petr Machata94078ec2012-01-05 18:07:02 +0100341 size_t len = (size_t)l;
Steve Fink7bafff02006-08-07 04:50:42 +0200342
Petr Machata94078ec2012-01-05 18:07:02 +0100343 int written = 0;
344 if (acc_fprintf(&written, stream, "%s", open) < 0)
345 return -1;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100346
Zachary T Welchba6aca22010-12-08 18:55:09 -0800347 size_t i;
Petr Machata94078ec2012-01-05 18:07:02 +0100348 for (i = 0; i < len && i <= maxlen; ++i) {
349 if (i == maxlen) {
350 if (before && acc_fprintf(&written, stream, "...") < 0)
351 return -1;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100352 break;
353 }
Petr Machata94078ec2012-01-05 18:07:02 +0100354
355 if (i > 0 && acc_fprintf(&written, stream, "%s", delim) < 0)
356 return -1;
357
358 struct value element;
359 if (value_init_element(&element, value, i) < 0)
360 return -1;
Petr Machataf6ec08a2012-01-06 16:58:54 +0100361 int o = format_argument(stream, &element, arguments);
Petr Machata8904cdc2012-10-30 17:27:20 +0100362 value_destroy(&element);
Petr Machata94078ec2012-01-05 18:07:02 +0100363 if (o < 0)
364 return -1;
365 written += o;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100366 }
Petr Machata94078ec2012-01-05 18:07:02 +0100367 if (acc_fprintf(&written, stream, "%s", close) < 0)
368 return -1;
369 if (i == maxlen && !before && acc_fprintf(&written, stream, "...") < 0)
370 return -1;
371
372 return written;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100373}
374
Petr Machata31af32c2012-01-08 02:36:50 +0100375static int
376toplevel_format_lens(struct lens *lens, FILE *stream,
Petr Machatace034982012-01-09 04:25:31 +0100377 struct value *value, struct value_dict *arguments,
378 enum int_fmt_t int_fmt)
Petr Machata94078ec2012-01-05 18:07:02 +0100379{
Petr Machata94078ec2012-01-05 18:07:02 +0100380 switch (value->type->type) {
381 case ARGTYPE_VOID:
382 return fprintf(stream, "<void>");
383
Petr Machata94078ec2012-01-05 18:07:02 +0100384 case ARGTYPE_SHORT:
385 case ARGTYPE_INT:
386 case ARGTYPE_LONG:
Petr Machatace034982012-01-09 04:25:31 +0100387 return format_integer(stream, value, int_fmt, arguments);
Petr Machata94078ec2012-01-05 18:07:02 +0100388
389 case ARGTYPE_USHORT:
390 case ARGTYPE_UINT:
391 case ARGTYPE_ULONG:
Petr Machatae773f632012-11-09 18:52:53 +0100392 if (int_fmt == INT_FMT_i || int_fmt == INT_FMT_default)
Petr Machatace034982012-01-09 04:25:31 +0100393 int_fmt = INT_FMT_u;
394 return format_integer(stream, value, int_fmt, arguments);
Petr Machata94078ec2012-01-05 18:07:02 +0100395
396 case ARGTYPE_CHAR:
Petr Machatae773f632012-11-09 18:52:53 +0100397 if (int_fmt == INT_FMT_default)
398 return format_naked_char(stream, value, arguments);
399 return format_integer(stream, value, int_fmt, arguments);
Petr Machata94078ec2012-01-05 18:07:02 +0100400
401 case ARGTYPE_FLOAT:
402 case ARGTYPE_DOUBLE:
403 return format_floating(stream, value, arguments);
404
405 case ARGTYPE_STRUCT:
406 return format_struct(stream, value, arguments);
407
408 case ARGTYPE_POINTER:
409 if (value->type->u.array_info.elt_type->type != ARGTYPE_VOID)
410 return format_pointer(stream, value, arguments);
Petr Machata94078ec2012-01-05 18:07:02 +0100411 return format_integer(stream, value, INT_FMT_x, arguments);
412
413 case ARGTYPE_ARRAY:
Petr Machata94078ec2012-01-05 18:07:02 +0100414 return format_array(stream, value, arguments,
415 value->type->u.array_info.length,
Petr Machatae3f4a982012-01-09 04:27:26 +0100416 options.arraylen, 1, "[ ", " ]", ", ");
Petr Machata94078ec2012-01-05 18:07:02 +0100417 }
418 abort();
419}
Petr Machata31af32c2012-01-08 02:36:50 +0100420
421static int
422default_lens_format_cb(struct lens *lens, FILE *stream,
423 struct value *value, struct value_dict *arguments)
424{
Petr Machatae773f632012-11-09 18:52:53 +0100425 return toplevel_format_lens(lens, stream, value, arguments,
426 INT_FMT_default);
Petr Machata31af32c2012-01-08 02:36:50 +0100427}
428
429struct lens default_lens = {
430 .format_cb = default_lens_format_cb,
431};
Petr Machatace034982012-01-09 04:25:31 +0100432
433
434static int
435blind_lens_format_cb(struct lens *lens, FILE *stream,
436 struct value *value, struct value_dict *arguments)
437{
438 return 0;
439}
440
441struct lens blind_lens = {
442 .format_cb = blind_lens_format_cb,
443};
444
445
446static int
447octal_lens_format_cb(struct lens *lens, FILE *stream,
448 struct value *value, struct value_dict *arguments)
449{
450 return toplevel_format_lens(lens, stream, value, arguments, INT_FMT_o);
451}
452
453struct lens octal_lens = {
454 .format_cb = octal_lens_format_cb,
455};
456
457
458static int
459hex_lens_format_cb(struct lens *lens, FILE *stream,
460 struct value *value, struct value_dict *arguments)
461{
462 return toplevel_format_lens(lens, stream, value, arguments, INT_FMT_x);
463}
464
465struct lens hex_lens = {
466 .format_cb = hex_lens_format_cb,
467};
Petr Machatab7819162012-01-09 04:26:15 +0100468
469
470static int
471guess_lens_format_cb(struct lens *lens, FILE *stream,
472 struct value *value, struct value_dict *arguments)
473{
474 return toplevel_format_lens(lens, stream, value, arguments,
475 INT_FMT_unknown);
476}
477
478struct lens guess_lens = {
479 .format_cb = guess_lens_format_cb,
480};
Petr Machatae3f4a982012-01-09 04:27:26 +0100481
482
483static int
Petr Machata38fb49b2012-01-09 04:28:46 +0100484bool_lens_format_cb(struct lens *lens, FILE *stream,
485 struct value *value, struct value_dict *arguments)
486{
487 switch (value->type->type) {
488 case ARGTYPE_VOID:
489 case ARGTYPE_FLOAT:
490 case ARGTYPE_DOUBLE:
491 case ARGTYPE_STRUCT:
492 case ARGTYPE_POINTER:
493 case ARGTYPE_ARRAY:
494 return toplevel_format_lens(lens, stream, value,
Petr Machatae773f632012-11-09 18:52:53 +0100495 arguments, INT_FMT_default);
Petr Machata38fb49b2012-01-09 04:28:46 +0100496
497 int zero;
Petr Machata38fb49b2012-01-09 04:28:46 +0100498 case ARGTYPE_SHORT:
499 case ARGTYPE_INT:
500 case ARGTYPE_LONG:
501 case ARGTYPE_USHORT:
502 case ARGTYPE_UINT:
503 case ARGTYPE_ULONG:
504 case ARGTYPE_CHAR:
505 if ((zero = value_is_zero(value, arguments)) < 0)
506 return -1;
507 if (zero)
508 return fprintf(stream, "false");
509 else
510 return fprintf(stream, "true");
511 }
512 abort();
513}
514
515struct lens bool_lens = {
516 .format_cb = bool_lens_format_cb,
517};
518
519
520static int
Petr Machatae3f4a982012-01-09 04:27:26 +0100521string_lens_format_cb(struct lens *lens, FILE *stream,
522 struct value *value, struct value_dict *arguments)
523{
524 switch (value->type->type) {
525 case ARGTYPE_POINTER:
526 /* This should really be written as either "string",
527 * or, if lens, then string(array(char, zero)*). But
528 * I suspect people are so used to the char * C idiom,
529 * that string(char *) might actually turn up. So
530 * let's just support it. */
531 if (value->type->u.ptr_info.info->type == ARGTYPE_CHAR) {
532 struct arg_type_info info[2];
533 type_init_array(&info[1],
534 value->type->u.ptr_info.info, 0,
535 expr_node_zero(), 0);
536 type_init_pointer(&info[0], &info[1], 0);
537 info->lens = lens;
538 info->own_lens = 0;
539 struct value tmp;
540 if (value_clone(&tmp, value) < 0)
541 return -1;
542 value_set_type(&tmp, info, 0);
543 int ret = string_lens_format_cb(lens, stream, &tmp,
544 arguments);
545 type_destroy(&info[0]);
546 type_destroy(&info[1]);
547 value_destroy(&tmp);
548 return ret;
549 }
550
551 /* fall-through */
552 case ARGTYPE_VOID:
553 case ARGTYPE_FLOAT:
554 case ARGTYPE_DOUBLE:
555 case ARGTYPE_STRUCT:
556 case ARGTYPE_SHORT:
557 case ARGTYPE_INT:
558 case ARGTYPE_LONG:
559 case ARGTYPE_USHORT:
560 case ARGTYPE_UINT:
561 case ARGTYPE_ULONG:
Petr Machatae3f4a982012-01-09 04:27:26 +0100562 return toplevel_format_lens(lens, stream, value,
Petr Machatae773f632012-11-09 18:52:53 +0100563 arguments, INT_FMT_default);
Petr Machatae3f4a982012-01-09 04:27:26 +0100564
565 case ARGTYPE_CHAR:
566 return format_char(stream, value, arguments);
567
568 case ARGTYPE_ARRAY:
569 return format_array(stream, value, arguments,
570 value->type->u.array_info.length,
571 options.strlen, 0, "\"", "\"", "");
572 }
573 abort();
574}
575
576struct lens string_lens = {
577 .format_cb = string_lens_format_cb,
578};