2 * This file is part of ltrace.
3 * Copyright (C) 2012 Petr Machata, Red Hat Inc.
4 * Copyright (C) 2003,2008,2009 Juan Cespedes
5 * Copyright (C) 2006 Ian Wienand
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
30 debug_(int level, const char *file, int line, const char *fmt, ...) {
34 if (!(options.debug & level)) {
38 vsnprintf(buf, 1024, fmt, args);
41 output_line(NULL, "DEBUG: %s:%d: %s", file, line, buf);
42 fflush(options.output);
46 xwritedump(long *ptr, arch_addr_t addr, size_t count)
49 for (i = 0; i < count; ++i) {
50 if (fprintf(stderr, "%p->%0*lx\n",
51 addr, 2 * (int)sizeof(long), ptr[i]) < 0)
60 xinfdump(struct process *proc, arch_addr_t addr, size_t length)
62 unsigned char buf[length];
63 size_t got = umovebytes(proc, addr, buf, length);
64 if (got == (size_t)-1)
66 return xwritedump((long *)buf, addr, got / sizeof(long));