15389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copyright (C) 2007-2010 The Android Open Source Project 25389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** 35389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** This software is licensed under the terms of the GNU General Public 45389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** License version 2, as published by the Free Software Foundation, and 55389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** may be copied, distributed, and modified under those terms. 65389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** 75389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** This program is distributed in the hope that it will be useful, 85389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** but WITHOUT ANY WARRANTY; without even the implied warranty of 95389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 105389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine** GNU General Public License for more details. 115389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine*/ 125389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 135389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* 145389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Contains declarations of utility routines for memchecker framework. 155389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 165389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 175389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#ifndef QEMU_MEMCHECK_MEMCHECK_UTIL_H 185389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#define QEMU_MEMCHECK_MEMCHECK_UTIL_H 195389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 205389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#include "memcheck_common.h" 214e024bb4f5c8aa8b07459f7fbd65c35122127fd1David 'Digit' Turner#include "elff/elff_api.h" 225285864985be9077e58e42235af6582dee72e841David 'Digit' Turner#include "exec.h" 235389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 245389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#ifdef __cplusplus 255389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkineextern "C" { 265389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#endif 275389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 285389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 295389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// Transfering data between guest and emulator address spaces. 305389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 315389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 325389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies buffer residing in the guest's virtual address space to a buffer 335389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * in the emulator's address space. 345389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 355389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Address of the bufer in guest's virtual address space. 365389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Address of the bufer in the emulator's address space. 375389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * buffer_size - Byte size of the guest's buffer. 385389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 395389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_get_guest_buffer(void* qemu_address, 405389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_address, 415389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine size_t buffer_size); 425389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 435389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies buffer residing in the emulator's address space to a buffer in the 445389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest's virtual address space. 455389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 465389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Address of the bufer in the emulator's address space. 475389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Address of the bufer in guest's virtual address space. 485389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * buffer_size - Byte size of the emualtor's buffer. 495389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 505389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_set_guest_buffer(target_ulong guest_address, 515389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine const void* qemu_address, 525389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine size_t buffer_size); 535389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 545389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies zero-terminated string residing in the guest's virtual address space 555389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * to a string buffer in emulator's address space. 565389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 575389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_str - Address of the string bufer in the emulator's address space. 585389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_str - Address of the string in guest's virtual address space. 595389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_buffer_size - Size of the emulator's string buffer. 605389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Return 615389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Length of the string that has been copied. 625389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 635389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinesize_t memcheck_get_guest_string(char* qemu_str, 645389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_str, 655389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine size_t qemu_buffer_size); 665389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 675389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies zero-terminated string residing in the guest's kernel address space 685389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * to a string buffer in emulator's address space. 695389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 705389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_str - Address of the string bufer in the emulator's address space. 715389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_str - Address of the string in guest's kernel address space. 725389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_buffer_size - Size of the emulator's string buffer. 735389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Return 745389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Length of the string that has been copied. 755389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 765389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinesize_t memcheck_get_guest_kernel_string(char* qemu_str, 775389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_str, 785389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine size_t qemu_buffer_size); 795389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 805389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 815389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// Helpers for transfering memory allocation information. 825389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 835389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 845389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies memory allocation descriptor from the guest's address space to the 855389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * emulator's memory. 865389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 875389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Descriptor address in the emulator's address space where to 885389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * copy descriptor. 895389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Descriptor address in the guest's address space. 905389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 915389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinestatic inline void 925389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinememcheck_get_malloc_descriptor(MallocDesc* qemu_address, 935389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_address) 945389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine{ 955389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine memcheck_get_guest_buffer(qemu_address, guest_address, sizeof(MallocDesc)); 965389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine} 975389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 985389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies memory allocation descriptor from the emulator's memory to the guest's 995389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * address space. 1005389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1015389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Descriptor address in the guest's address space. 1025389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Descriptor address in the emulator's address space where to 1035389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * copy descriptor. 1045389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1055389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinestatic inline void 1065389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinememcheck_set_malloc_descriptor(target_ulong guest_address, 1075389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine const MallocDesc* qemu_address) 1085389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine{ 1095389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine memcheck_set_guest_buffer(guest_address, qemu_address, sizeof(MallocDesc)); 1105389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine} 1115389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1125389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies memory free descriptor from the guest's address space to the 1135389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * emulator's memory. 1145389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1155389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Descriptor address in the emulator's address space where to 1165389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * copy descriptor. 1175389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Descriptor address in the guest's address space. 1185389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1195389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinestatic inline void 1205389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinememcheck_get_free_descriptor(MallocFree* qemu_address, 1215389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_address) 1225389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine{ 1235389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine memcheck_get_guest_buffer(qemu_address, guest_address, sizeof(MallocFree)); 1245389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine} 1255389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1265389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Copies memory allocation query descriptor from the guest's address space to 1275389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * the emulator's memory. 1285389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1295389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Descriptor address in the guest's address space. 1305389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * qemu_address - Descriptor address in the emulator's address space where to 1315389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * copy descriptor. 1325389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1335389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinestatic inline void 1345389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinememcheck_get_query_descriptor(MallocDescQuery* qemu_address, 1355389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine target_ulong guest_address) 1365389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine{ 1375389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine memcheck_get_guest_buffer(qemu_address, guest_address, 1385389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine sizeof(MallocDescQuery)); 1395389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine} 1405389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1415389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Fails allocation request (TRACE_DEV_REG_MALLOC event). 1425389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Allocation request failure is reported by zeroing 'libc_pid' filed in the 1435389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * allocation descriptor in the guest's address space. 1445389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1455389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Allocation descriptor address in the guest's address space, 1465389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * where to record failure. 1475389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1485389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_fail_alloc(target_ulong guest_address); 1495389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1505389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Fails free request (TRACE_DEV_REG_FREE_PTR event). 1515389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Free request failure is reported by zeroing 'libc_pid' filed in the free 1525389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * descriptor in the guest's address space. 1535389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1545389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Free descriptor address in the guest's address space, where 1555389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * to record failure. 1565389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1575389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_fail_free(target_ulong guest_address); 1585389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1595389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Fails memory allocation query request (TRACE_DEV_REG_QUERY_MALLOC event). 1605389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Query request failure is reported by zeroing 'libc_pid' filed in the query 1615389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * descriptor in the guest's address space. 1625389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1635389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * guest_address - Query descriptor address in the guest's address space, where 1645389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * to record failure. 1655389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1665389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_fail_query(target_ulong guest_address); 1675389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1685389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 1695389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// Misc. utility routines. 1705389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine// ============================================================================= 1715389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1725389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Converts PC address in the translated block to a corresponded PC address in 1735389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * the guest address space. 1745389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1755389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * tb_pc - PC address in the translated block. 1765389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Return: 1775389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Corresponded PC address in the guest address space on success, or NULL if 1785389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * conversion has failed. 1795389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1805389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinestatic inline target_ulong 1815389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinememcheck_tpc_to_gpc(target_ulong tb_pc) 1825389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine{ 1835389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine const TranslationBlock* tb = tb_find_pc(tb_pc); 1845389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine return tb != NULL ? tb_search_guest_pc_from_tb_pc(tb, tb_pc) : 0; 1855389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine} 1865389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1875389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Invalidates TLB table pages that contain given memory range. 1885389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * This routine is called after new entry is inserted into allocation map, so 1895389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * every access to the allocated block will cause __ld/__stx_mmu to be called. 1905389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 1915389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * start - Beginning of the allocated block to invalidate pages for. 1925389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * end - End of (past one byte after) the allocated block to invalidate pages 1935389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * for. 1945389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 1955389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid invalidate_tlb_cache(target_ulong start, target_ulong end); 1965389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 1975389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Gets routine, file path and line number information for a PC address in the 1985389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * given module. 1995389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param: 2005389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * abs_pc - PC address. 2015389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * rdesc - Mapped memory range descriptor for the module containing abs_pc. 2025389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * info - Upon successful return will contain routine, file path and line 2035389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * information for the given PC address in the given module. 2045389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * NOTE: Pathnames, saved into this structure are contained in mapped 2055389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * sections of the symbols file for the module addressed by module_path. 2065389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Thus, pathnames are accessible only while elff_handle returned from this 2075389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * routine remains opened. 2085389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * NOTE: each successful call to this routine requires the caller to call 2095389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * elff_free_pc_address_info for Elf_AddressInfo structure. 2105389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * elff_handle - Upon successful return will contain a handle to the ELFF API 2115389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * that wraps symbols file for the module, addressed by module_path. The 2125389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * handle must remain opened for as long as pathnames in the info structure 2135389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * are accessed, and must be eventually closed via call to elff_close. 2145389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Return: 2155389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * 0 on success, 1, if symbols file for the module has not been found, or -1 on 2165389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * other failures. If a failure is returned from this routine content of info 2175389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * and elff_handle parameters is undefined. 2185389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 2195389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkineint memcheck_get_address_info(target_ulong abs_pc, 2205389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine const MMRangeDesc* rdesc, 2215389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine Elf_AddressInfo* info, 2225389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine ELFF_HANDLE* elff_handle); 2235389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 2245389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine/* Dumps content of an allocation descriptor to stdout. 2255389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * Param desc - Allocation descriptor to dump. 2265389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * print_flags - If 1, flags field of the descriptor will be dumped to stdout. 2275389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * If 0, flags filed will not be dumped. 2285389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * print_proc_info - If 1, allocator's process information for the descriptor 2295389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * will be dumped to stdout. If 0, allocator's process information will 2305389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine * not be dumped. 2315389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine */ 2325389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkinevoid memcheck_dump_malloc_desc(const MallocDescEx* desc, 2335389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine int print_flags, 2345389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine int print_proc_info); 2355389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 2365389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#ifdef __cplusplus 2375389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine}; /* end of extern "C" */ 2385389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#endif 2395389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine 2405389aa19033153c09556d1362a8b8a56abccb8f5Vladimir Chtchetkine#endif // QEMU_MEMCHECK_MEMCHECK_UTIL_H 241