output.c revision b8f0d8b5859a7d69f6aed4904a87ac6a423285f6
1/* 2 * This file is part of ltrace. 3 * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc. 4 * Copyright (C) 2010 Joe Damato 5 * Copyright (C) 1997,1998,1999,2001,2002,2003,2004,2007,2008,2009 Juan Cespedes 6 * Copyright (C) 2006 Paul Gilliam, IBM Corporation 7 * Copyright (C) 2006 Ian Wienand 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 2 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA 23 */ 24 25#include "config.h" 26 27#include <stdio.h> 28#include <stdlib.h> 29#include <stdarg.h> 30#include <string.h> 31#include <time.h> 32#include <sys/time.h> 33#include <unistd.h> 34#include <errno.h> 35#include <assert.h> 36 37#include "output.h" 38#include "demangle.h" 39#include "fetch.h" 40#include "lens_default.h" 41#include "library.h" 42#include "memstream.h" 43#include "options.h" 44#include "param.h" 45#include "proc.h" 46#include "prototype.h" 47#include "type.h" 48#include "value.h" 49#include "value_dict.h" 50 51/* TODO FIXME XXX: include in common.h: */ 52extern struct timeval current_time_spent; 53 54struct dict *dict_opt_c = NULL; 55 56static struct process *current_proc = 0; 57static size_t current_depth = 0; 58static int current_column = 0; 59 60static void 61output_indent(struct process *proc) 62{ 63 int d = options.indent * (proc->callstack_depth - 1); 64 current_column += fprintf(options.output, "%*s", d, ""); 65} 66 67static void 68begin_of_line(struct process *proc, int is_func, int indent) 69{ 70 current_column = 0; 71 if (!proc) { 72 return; 73 } 74 if ((options.output != stderr) && (opt_p || options.follow)) { 75 current_column += fprintf(options.output, "%u ", proc->pid); 76 } else if (options.follow) { 77 current_column += fprintf(options.output, "[pid %u] ", proc->pid); 78 } 79 if (opt_r) { 80 struct timeval tv; 81 static struct timeval old_tv = { 0, 0 }; 82 struct timeval diff; 83 84 gettimeofday(&tv, NULL); 85 86 if (old_tv.tv_sec == 0 && old_tv.tv_usec == 0) { 87 old_tv.tv_sec = tv.tv_sec; 88 old_tv.tv_usec = tv.tv_usec; 89 } 90 diff.tv_sec = tv.tv_sec - old_tv.tv_sec; 91 if (tv.tv_usec >= old_tv.tv_usec) { 92 diff.tv_usec = tv.tv_usec - old_tv.tv_usec; 93 } else { 94 diff.tv_sec--; 95 diff.tv_usec = 1000000 + tv.tv_usec - old_tv.tv_usec; 96 } 97 old_tv.tv_sec = tv.tv_sec; 98 old_tv.tv_usec = tv.tv_usec; 99 current_column += fprintf(options.output, "%3lu.%06d ", 100 (unsigned long)diff.tv_sec, 101 (int)diff.tv_usec); 102 } 103 if (opt_t) { 104 struct timeval tv; 105 gettimeofday(&tv, NULL); 106 if (opt_t > 2) { 107 current_column += fprintf(options.output, "%lu.%06d ", 108 (unsigned long)tv.tv_sec, 109 (int)tv.tv_usec); 110 } else if (opt_t > 1) { 111 struct tm *tmp = localtime(&tv.tv_sec); 112 current_column += 113 fprintf(options.output, "%02d:%02d:%02d.%06d ", 114 tmp->tm_hour, tmp->tm_min, tmp->tm_sec, 115 (int)tv.tv_usec); 116 } else { 117 struct tm *tmp = localtime(&tv.tv_sec); 118 current_column += fprintf(options.output, "%02d:%02d:%02d ", 119 tmp->tm_hour, tmp->tm_min, 120 tmp->tm_sec); 121 } 122 } 123 if (opt_i) { 124 if (is_func) { 125 struct callstack_element *stel 126 = &proc->callstack[proc->callstack_depth - 1]; 127 current_column += fprintf(options.output, "[%p] ", 128 stel->return_addr); 129 } else { 130 current_column += fprintf(options.output, "[%p] ", 131 proc->instruction_pointer); 132 } 133 } 134 if (options.indent > 0 && indent) { 135 output_indent(proc); 136 } 137} 138 139static struct arg_type_info * 140get_unknown_type(void) 141{ 142 static struct arg_type_info *ret = NULL; 143 if (ret != NULL) 144 return ret; 145 146 static struct arg_type_info info; 147 info = *type_get_simple(ARGTYPE_LONG); 148 info.lens = &guess_lens; 149 ret = &info; 150 return ret; 151} 152 153/* The default prototype is: long X(long, long, long, long). */ 154static struct prototype * 155build_default_prototype(void) 156{ 157 static struct prototype *ret = NULL; 158 if (ret != NULL) 159 return ret; 160 161 static struct prototype proto; 162 prototype_init(&proto); 163 164 struct arg_type_info *unknown_type = get_unknown_type(); 165 assert(unknown_type != NULL); 166 proto.return_info = unknown_type; 167 proto.own_return_info = 0; 168 169 struct param unknown_param; 170 param_init_type(&unknown_param, unknown_type, 0); 171 172 size_t i; 173 for (i = 0; i < 4; ++i) 174 if (prototype_push_param(&proto, &unknown_param) < 0) { 175 report_global_error("build_default_prototype: %s", 176 strerror(errno)); 177 prototype_destroy(&proto); 178 return NULL; 179 } 180 181 ret = &proto; 182 return ret; 183} 184 185static struct prototype * 186library_get_prototype(struct library *lib, const char *name) 187{ 188 if (lib->protolib == NULL) 189 lib->protolib = protolib_cache_search(&g_protocache, 190 lib->soname, 0, 1); 191 if (lib->protolib == NULL) 192 return NULL; 193 194 return protolib_lookup_prototype(lib->protolib, name, 195 lib->type != LT_LIBTYPE_SYSCALL); 196} 197 198struct find_proto_data { 199 const char *name; 200 struct prototype *ret; 201}; 202 203static enum callback_status 204find_proto_cb(struct process *proc, struct library *lib, void *d) 205{ 206 struct find_proto_data *data = d; 207 data->ret = library_get_prototype(lib, data->name); 208 return CBS_STOP_IF(data->ret != NULL); 209} 210 211static struct prototype * 212lookup_symbol_prototype(struct process *proc, struct library_symbol *libsym) 213{ 214 if (libsym->proto != NULL) 215 return libsym->proto; 216 217 struct library *lib = libsym->lib; 218 if (lib != NULL) { 219 struct find_proto_data data = { libsym->name }; 220 data.ret = library_get_prototype(lib, libsym->name); 221 if (data.ret == NULL 222 && libsym->plt_type == LS_TOPLT_EXEC) 223 proc_each_library(proc, NULL, find_proto_cb, &data); 224 if (data.ret != NULL) 225 return data.ret; 226 } 227 228 return build_default_prototype(); 229} 230 231void 232output_line(struct process *proc, const char *fmt, ...) 233{ 234 if (options.summary) 235 return; 236 237 if (current_proc != NULL) { 238 if (current_proc->callstack[current_depth].return_addr) 239 fprintf(options.output, " <unfinished ...>\n"); 240 else 241 fprintf(options.output, " <no return ...>\n"); 242 } 243 current_proc = NULL; 244 if (fmt == NULL) 245 return; 246 247 begin_of_line(proc, 0, 0); 248 249 va_list args; 250 va_start(args, fmt); 251 vfprintf(options.output, fmt, args); 252 fprintf(options.output, "\n"); 253 va_end(args); 254 255 current_column = 0; 256} 257 258static void 259tabto(int col) { 260 if (current_column < col) { 261 fprintf(options.output, "%*s", col - current_column, ""); 262 } 263} 264 265static int 266output_error(FILE *stream) 267{ 268 return fprintf(stream, "?"); 269} 270 271static int 272fetch_simple_param(enum tof type, struct process *proc, 273 struct fetch_context *context, 274 struct value_dict *arguments, 275 struct arg_type_info *info, int own, 276 struct value *valuep) 277{ 278 /* Arrays decay into pointers per C standard. We check for 279 * this here, because here we also capture arrays that come 280 * from parameter packs. */ 281 if (info->type == ARGTYPE_ARRAY) { 282 struct arg_type_info *tmp = malloc(sizeof(*tmp)); 283 if (tmp != NULL) { 284 type_init_pointer(tmp, info, own); 285 tmp->lens = info->lens; 286 info = tmp; 287 own = 1; 288 } 289 } 290 291 struct value value; 292 value_init(&value, proc, NULL, info, own); 293 if (fetch_arg_next(context, type, proc, info, &value) < 0) 294 return -1; 295 296 if (val_dict_push_next(arguments, &value) < 0) { 297 value_destroy(&value); 298 return -1; 299 } 300 301 if (valuep != NULL) 302 *valuep = value; 303 304 return 0; 305} 306 307static void 308fetch_param_stop(struct value_dict *arguments, ssize_t *params_leftp) 309{ 310 if (*params_leftp == -1) 311 *params_leftp = val_dict_count(arguments); 312} 313 314static int 315fetch_param_pack(enum tof type, struct process *proc, 316 struct fetch_context *context, 317 struct value_dict *arguments, struct param *param, 318 ssize_t *params_leftp) 319{ 320 struct param_enum *e = param_pack_init(param, arguments); 321 if (e == NULL) 322 return -1; 323 324 int ret = 0; 325 while (1) { 326 int insert_stop = 0; 327 struct arg_type_info *info = malloc(sizeof(*info)); 328 if (info == NULL 329 || param_pack_next(param, e, info, &insert_stop) < 0) { 330 fail: 331 free(info); 332 ret = -1; 333 break; 334 } 335 336 if (insert_stop) 337 fetch_param_stop(arguments, params_leftp); 338 339 if (info->type == ARGTYPE_VOID) { 340 type_destroy(info); 341 free(info); 342 break; 343 } 344 345 struct value val; 346 if (fetch_simple_param(type, proc, context, arguments, 347 info, 1, &val) < 0) 348 goto fail; 349 350 int stop = 0; 351 switch (param_pack_stop(param, e, &val)) { 352 case PPCB_ERR: 353 goto fail; 354 case PPCB_STOP: 355 stop = 1; 356 case PPCB_CONT: 357 break; 358 } 359 360 if (stop) 361 break; 362 } 363 364 param_pack_done(param, e); 365 return ret; 366} 367 368static int 369fetch_one_param(enum tof type, struct process *proc, 370 struct fetch_context *context, 371 struct value_dict *arguments, struct param *param, 372 ssize_t *params_leftp) 373{ 374 switch (param->flavor) { 375 int rc; 376 case PARAM_FLAVOR_TYPE: 377 return fetch_simple_param(type, proc, context, arguments, 378 param->u.type.type, 0, NULL); 379 380 case PARAM_FLAVOR_PACK: 381 if (fetch_param_pack_start(context, 382 param->u.pack.ppflavor) < 0) 383 return -1; 384 rc = fetch_param_pack(type, proc, context, arguments, 385 param, params_leftp); 386 fetch_param_pack_end(context); 387 return rc; 388 389 case PARAM_FLAVOR_STOP: 390 fetch_param_stop(arguments, params_leftp); 391 return 0; 392 } 393 394 assert(!"Invalid param flavor!"); 395 abort(); 396} 397 398struct fetch_one_param_data 399{ 400 struct process *proc; 401 struct fetch_context *context; 402 struct value_dict *arguments; 403 ssize_t *params_leftp; 404 enum tof tof; 405}; 406 407static enum callback_status 408fetch_one_param_cb(struct prototype *proto, struct param *param, void *data) 409{ 410 struct fetch_one_param_data *cb_data = data; 411 return CBS_STOP_IF(fetch_one_param(cb_data->tof, cb_data->proc, 412 cb_data->context, 413 cb_data->arguments, param, 414 cb_data->params_leftp) < 0); 415} 416 417static int 418fetch_params(enum tof type, struct process *proc, 419 struct fetch_context *context, 420 struct value_dict *arguments, struct prototype *func, 421 ssize_t *params_leftp) 422{ 423 struct fetch_one_param_data cb_data 424 = { proc, context, arguments, params_leftp, type }; 425 if (prototype_each_param(func, NULL, 426 &fetch_one_param_cb, &cb_data) != NULL) 427 return -1; 428 429 /* Implicit stop at the end of parameter list. */ 430 fetch_param_stop(arguments, params_leftp); 431 432 return 0; 433} 434 435struct format_argument_data 436{ 437 struct value *value; 438 struct value_dict *arguments; 439}; 440 441static int 442format_argument_cb(FILE *stream, void *ptr) 443{ 444 struct format_argument_data *data = ptr; 445 int o = format_argument(stream, data->value, data->arguments); 446 if (o < 0) 447 o = output_error(stream); 448 return o; 449} 450 451static int 452output_params(struct value_dict *arguments, size_t start, size_t end, 453 int *need_delimp) 454{ 455 size_t i; 456 for (i = start; i < end; ++i) { 457 struct value *value = val_dict_get_num(arguments, i); 458 if (value == NULL) 459 return -1; 460 461 struct format_argument_data data = { value, arguments }; 462 int o = delim_output(options.output, need_delimp, 463 format_argument_cb, &data); 464 if (o < 0) 465 return -1; 466 current_column += o; 467 } 468 return 0; 469} 470 471void 472output_left(enum tof type, struct process *proc, 473 struct library_symbol *libsym) 474{ 475 if (options.summary) { 476 return; 477 } 478 if (current_proc) { 479 fprintf(options.output, " <unfinished ...>\n"); 480 current_column = 0; 481 } 482 current_proc = proc; 483 current_depth = proc->callstack_depth; 484 begin_of_line(proc, type == LT_TOF_FUNCTION, 1); 485 if (!options.hide_caller && libsym->lib != NULL 486 && libsym->plt_type != LS_TOPLT_NONE) 487 /* We don't terribly mind failing this. */ 488 account_output(¤t_column, 489 fprintf(options.output, "%s->", 490 libsym->lib->soname)); 491 492 const char *name = libsym->name; 493#ifdef USE_DEMANGLE 494 if (options.demangle) 495 name = my_demangle(libsym->name); 496#endif 497 if (account_output(¤t_column, 498 fprintf(options.output, "%s", name)) < 0) 499 return; 500 501 if (libsym->lib != NULL 502 && libsym->lib->type != LT_LIBTYPE_MAIN 503 && libsym->plt_type == LS_TOPLT_NONE 504 && account_output(¤t_column, 505 fprintf(options.output, "@%s", 506 libsym->lib->soname)) < 0) 507 /* We do mind failing this though. */ 508 return; 509 510 account_output(¤t_column, fprintf(options.output, "(")); 511 512 struct prototype *func = lookup_symbol_prototype(proc, libsym); 513 if (func == NULL) { 514 fail: 515 account_output(¤t_column, fprintf(options.output, "???")); 516 return; 517 } 518 519 struct fetch_context *context = fetch_arg_init(type, proc, 520 func->return_info); 521 if (context == NULL) 522 goto fail; 523 524 struct value_dict *arguments = malloc(sizeof(*arguments)); 525 if (arguments == NULL) { 526 fetch_arg_done(context); 527 goto fail; 528 } 529 val_dict_init(arguments); 530 531 ssize_t params_left = -1; 532 int need_delim = 0; 533 if (fetch_params(type, proc, context, arguments, func, ¶ms_left) < 0 534 || output_params(arguments, 0, params_left, &need_delim) < 0) { 535 val_dict_destroy(arguments); 536 fetch_arg_done(context); 537 arguments = NULL; 538 context = NULL; 539 } 540 541 struct callstack_element *stel 542 = &proc->callstack[proc->callstack_depth - 1]; 543 stel->fetch_context = context; 544 stel->arguments = arguments; 545 stel->out.params_left = params_left; 546 stel->out.need_delim = need_delim; 547} 548 549static void 550free_stringp_cb(const char **stringp, void *data) 551{ 552 free((char *)*stringp); 553} 554 555void 556output_right(enum tof type, struct process *proc, struct library_symbol *libsym) 557{ 558 struct prototype *func = lookup_symbol_prototype(proc, libsym); 559 if (func == NULL) 560 return; 561 562again: 563 if (options.summary) { 564 if (dict_opt_c == NULL) { 565 dict_opt_c = malloc(sizeof(*dict_opt_c)); 566 if (dict_opt_c == NULL) { 567 oom: 568 fprintf(stderr, 569 "Can't allocate memory for " 570 "keeping track of -c.\n"); 571 free(dict_opt_c); 572 options.summary = 0; 573 goto again; 574 } 575 DICT_INIT(dict_opt_c, char *, struct opt_c_struct, 576 dict_hash_string, dict_eq_string, NULL); 577 } 578 579 struct opt_c_struct *st 580 = DICT_FIND_REF(dict_opt_c, &libsym->name, 581 struct opt_c_struct); 582 if (st == NULL) { 583 const char *na = strdup(libsym->name); 584 struct opt_c_struct new_st = {.count = 0, .tv = {0, 0}}; 585 if (na == NULL 586 || DICT_INSERT(dict_opt_c, &na, &new_st) < 0) { 587 free((char *)na); 588 DICT_DESTROY(dict_opt_c, const char *, 589 struct opt_c_struct, 590 free_stringp_cb, NULL, NULL); 591 goto oom; 592 } 593 st = DICT_FIND_REF(dict_opt_c, &libsym->name, 594 struct opt_c_struct); 595 assert(st != NULL); 596 } 597 598 if (st->tv.tv_usec + current_time_spent.tv_usec > 1000000) { 599 st->tv.tv_usec += current_time_spent.tv_usec - 1000000; 600 st->tv.tv_sec++; 601 } else { 602 st->tv.tv_usec += current_time_spent.tv_usec; 603 } 604 st->count++; 605 st->tv.tv_sec += current_time_spent.tv_sec; 606 return; 607 } 608 609 if (current_proc && (current_proc != proc || 610 current_depth != proc->callstack_depth)) { 611 fprintf(options.output, " <unfinished ...>\n"); 612 current_proc = 0; 613 } 614 if (current_proc != proc) { 615 begin_of_line(proc, type == LT_TOF_FUNCTIONR, 1); 616#ifdef USE_DEMANGLE 617 current_column += 618 fprintf(options.output, "<... %s resumed> ", 619 options.demangle ? my_demangle(libsym->name) 620 : libsym->name); 621#else 622 current_column += 623 fprintf(options.output, "<... %s resumed> ", libsym->name); 624#endif 625 } 626 627 struct callstack_element *stel 628 = &proc->callstack[proc->callstack_depth - 1]; 629 630 struct fetch_context *context = stel->fetch_context; 631 632 /* Fetch & enter into dictionary the retval first, so that 633 * other values can use it in expressions. */ 634 struct value retval; 635 int own_retval = 0; 636 if (context != NULL) { 637 value_init(&retval, proc, NULL, func->return_info, 0); 638 own_retval = 1; 639 if (fetch_retval(context, type, proc, func->return_info, 640 &retval) < 0) 641 value_set_type(&retval, NULL, 0); 642 else if (stel->arguments != NULL 643 && val_dict_push_named(stel->arguments, &retval, 644 "retval", 0) == 0) 645 own_retval = 0; 646 } 647 648 if (stel->arguments != NULL) 649 output_params(stel->arguments, stel->out.params_left, 650 val_dict_count(stel->arguments), 651 &stel->out.need_delim); 652 653 current_column += fprintf(options.output, ") "); 654 tabto(options.align - 1); 655 fprintf(options.output, "= "); 656 657 if (context != NULL && retval.type != NULL) { 658 struct format_argument_data data = { &retval, stel->arguments }; 659 format_argument_cb(options.output, &data); 660 } 661 662 if (own_retval) 663 value_destroy(&retval); 664 665 if (opt_T) { 666 fprintf(options.output, " <%lu.%06d>", 667 (unsigned long)current_time_spent.tv_sec, 668 (int)current_time_spent.tv_usec); 669 } 670 fprintf(options.output, "\n"); 671 672#if defined(HAVE_LIBUNWIND) 673 if (options.bt_depth > 0 674 && proc->unwind_priv != NULL 675 && proc->unwind_as != NULL) { 676 unw_cursor_t cursor; 677 arch_addr_t ip, function_offset; 678 unw_word_t sp; 679 struct library *lib = NULL; 680 int unwind_depth = options.bt_depth; 681 char fn_name[100]; 682 const char *lib_name; 683 size_t distance; 684 685 /* Verify that we can safely cast arch_addr_t* to 686 * unw_word_t*. */ 687 (void)sizeof(char[1 - 2*(sizeof(unw_word_t) 688 != sizeof(arch_addr_t))]); 689 unw_init_remote(&cursor, proc->unwind_as, proc->unwind_priv); 690 while (unwind_depth) { 691 unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip); 692 unw_get_reg(&cursor, UNW_REG_SP, &sp); 693 unw_get_proc_name(&cursor, fn_name, sizeof(fn_name), 694 (unw_word_t *) &function_offset); 695 696 /* We are looking for the library with the base address 697 * closest to the current ip. */ 698 lib_name = "unmapped_area"; 699 distance = (size_t) -1; 700 lib = proc->libraries; 701 while (lib != NULL) { 702 /* N.B.: Assumes sizeof(size_t) == 703 * sizeof(arch_addr_t). 704 * Keyword: double cast. */ 705 if ((ip >= lib->base) && 706 ((size_t)(ip - lib->base) 707 < distance)) { 708 distance = ip - lib->base; 709 lib_name = lib->pathname; 710 } 711 lib = lib->next; 712 } 713 714 fprintf(options.output, " > %s(%s+0x%p) [%p]\n", 715 lib_name, fn_name, function_offset, ip); 716 717 if (unw_step(&cursor) <= 0) 718 break; 719 unwind_depth--; 720 } 721 fprintf(options.output, "\n"); 722 } 723#endif /* defined(HAVE_LIBUNWIND) */ 724 725 current_proc = 0; 726 current_column = 0; 727} 728 729int 730delim_output(FILE *stream, int *need_delimp, 731 int (*writer)(FILE *stream, void *data), 732 void *data) 733{ 734 int o; 735 736 /* If we don't need a delimiter, then we don't need to go 737 * through a temporary stream. It's all the same whether 738 * WRITER emits anything or not. */ 739 if (!*need_delimp) { 740 o = writer(stream, data); 741 742 } else { 743 struct memstream ms; 744 if (memstream_init(&ms) < 0) 745 return -1; 746 o = writer(ms.stream, data); 747 if (memstream_close(&ms) < 0) 748 o = -1; 749 if (o > 0 && ((*need_delimp 750 && account_output(&o, fprintf(stream, ", ")) < 0) 751 || fwrite(ms.buf, 1, ms.size, stream) != ms.size)) 752 o = -1; 753 754 memstream_destroy(&ms); 755 } 756 757 if (o < 0) 758 return -1; 759 760 *need_delimp = *need_delimp || o > 0; 761 return o; 762} 763 764int 765account_output(int *countp, int c) 766{ 767 if (c > 0) 768 *countp += c; 769 return c; 770} 771 772static void 773do_report(const char *filename, unsigned line_no, const char *severity, 774 const char *fmt, va_list args) 775{ 776 char buf[128]; 777 vsnprintf(buf, sizeof(buf), fmt, args); 778 buf[sizeof(buf) - 1] = 0; 779 if (filename != NULL) 780 output_line(0, "%s:%d: %s: %s", 781 filename, line_no, severity, buf); 782 else 783 output_line(0, "%s: %s", severity, buf); 784} 785 786void 787report_error(const char *filename, unsigned line_no, const char *fmt, ...) 788{ 789 va_list args; 790 va_start(args, fmt); 791 do_report(filename, line_no, "error", fmt, args); 792 va_end(args); 793} 794 795void 796report_warning(const char *filename, unsigned line_no, const char *fmt, ...) 797{ 798 va_list args; 799 va_start(args, fmt); 800 do_report(filename, line_no, "warning", fmt, args); 801 va_end(args); 802} 803 804void 805report_global_error(const char *fmt, ...) 806{ 807 va_list args; 808 va_start(args, fmt); 809 do_report(NULL, 0, "error", fmt, args); 810 va_end(args); 811} 812