1// Copyright 2016 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#pragma once 6 7#include <stddef.h> 8#include <zircon/types.h> 9 10#define MAX_BUILDID_SIZE 64 11 12namespace inspector { 13 14extern int verbosity_level; 15 16extern void do_print_error(const char* file, int line, const char* fmt, ...); 17 18extern void do_print_zx_error(const char* file, int line, const char* what, zx_status_t status); 19 20#define print_error(fmt...) \ 21 do { \ 22 ::inspector::do_print_error(__FILE__, __LINE__, fmt); \ 23 } while (0) 24 25#define print_zx_error(what, status) \ 26 do { \ 27 ::inspector::do_print_zx_error(__FILE__, __LINE__, \ 28 (what), static_cast<zx_status_t>(status)); \ 29 } while (0) 30 31extern void do_print_debug(const char* file, int line, const char* func, const char* fmt, ...); 32 33#define debugf(level, fmt...) \ 34 do { \ 35 if (::inspector::verbosity_level >= (level)) { \ 36 ::inspector::do_print_debug (__FILE__, __LINE__, __func__, fmt); \ 37 } \ 38 } while (0) 39 40extern const char* path_basename(const char* path); 41 42extern zx_status_t read_mem(zx_handle_t h, zx_vaddr_t vaddr, void* ptr, size_t len); 43 44extern zx_status_t fetch_string(zx_handle_t h, zx_vaddr_t vaddr, char* ptr, size_t max); 45 46extern zx_status_t fetch_build_id(zx_handle_t h, zx_vaddr_t base, char* buf, size_t buf_size); 47 48} // namespace inspector 49