* Copyright (c) 2012-2021 Google, Inc. All rights reserved.
* Copyright (c) 2000-2010 VMware, Inc. All rights reserved.
* **********************************************************/
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of VMware, Inc. nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#ifndef _DR_TRACEDUMP_H_
#define _DR_TRACEDUMP_H_ 1
* @file dr_tracedump.h
* @brief Binary trace dump format for the -tracedump_binary option.
*/
* BINARY TRACE DUMP FORMAT
*/
* Binary trace dump format:
* the file starts with a tracedump_file_header_t
* then, for each trace:
struct _tracedump_trace_header
if num_bbs > 0 # tracedump_origins
foreach bb:
app_pc tag;
int bb_code_size;
byte code[bb_code_size];
endif
foreach exit:
struct _tracedump_stub_data
if linkcount_size > 0 # deprecated
linkcount_type_t count; # sizeof == linkcount_size
endif
if separate from body
(i.e., exit_stub < cache_start_pc || exit_stub >= cache_start_pc+code_size):
byte stub_code[15]; # all separate stubs are 15
endif
endfor
byte code[code_size];
</pre>
*/
typedef struct _tracedump_file_header_t {
int version;
bool x64;
int linkcount_size;
} tracedump_file_header_t;
typedef struct _tracedump_trace_header_t {
int frag_id;
app_pc tag;
app_pc cache_start_pc;
int entry_offs;
int num_exits;
int code_size;
uint num_bbs;
bool x64;
} tracedump_trace_header_t;
#define BB_ORIGIN_HEADER_SIZE (sizeof(app_pc) + sizeof(int))
#define SEPARATE_STUB_MAX_SIZE IF_X64_ELSE(23, 15)
typedef struct _tracedump_stub_data {
int cti_offs;
app_pc stub_pc;
app_pc target;
bool linked;
int stub_size;
union {
uint count32;
uint64 count64;
} count;
* the file, which indicates the linkcount size. */
* stub_pc < cache_start_pc ||
* stub_pc >= cache_start_pc+code_size).
* The actual size of the array varies and is indicated by the stub_size field.
*/
byte stub_code[1 ];
} tracedump_stub_data_t;
#define STUB_DATA_FIXED_SIZE (offsetof(tracedump_stub_data_t, count))
#endif