blob: 8c549395bec616ccbddfde8c7593fa6abc6913e6 [file] [log] [blame]
<html lang="en">
<head>
<title>Writing JIT Debug Info Readers - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Custom-Debug-Info.html#Custom-Debug-Info" title="Custom Debug Info">
<link rel="prev" href="Using-JIT-Debug-Info-Readers.html#Using-JIT-Debug-Info-Readers" title="Using JIT Debug Info Readers">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Writing-JIT-Debug-Info-Readers"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Using-JIT-Debug-Info-Readers.html#Using-JIT-Debug-Info-Readers">Using JIT Debug Info Readers</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Custom-Debug-Info.html#Custom-Debug-Info">Custom Debug Info</a>
<hr>
</div>
<h4 class="subsection">29.4.2 Writing JIT Debug Info Readers</h4>
<p><a name="index-writing-JIT-debug-info-readers-3156"></a>
As mentioned, a reader is essentially a shared object conforming to a
certain ABI. This ABI is described in <samp><span class="file">jit-reader.h</span></samp>.
<p><samp><span class="file">jit-reader.h</span></samp> defines the structures, macros and functions
required to write a reader. It is installed (along with
<span class="sc">gdb</span>), in <samp><var>includedir</var><span class="file">/gdb</span></samp> where <var>includedir</var> is
the system include directory.
<p>Readers need to be released under a GPL compatible license. A reader
can be declared as released under such a license by placing the macro
<code>GDB_DECLARE_GPL_COMPATIBLE_READER</code> in a source file.
<p>The entry point for readers is the symbol <code>gdb_init_reader</code>,
which is expected to be a function with the prototype
<p><a name="index-gdb_005finit_005freader-3157"></a>
<pre class="smallexample"> extern struct gdb_reader_funcs *gdb_init_reader (void);
</pre>
<p><a name="index-g_t_0040code_007bstruct-gdb_005freader_005ffuncs_007d-3158"></a>
<code>struct gdb_reader_funcs</code> contains a set of pointers to callback
functions. These functions are executed to read the debug info
generated by the JIT compiler (<code>read</code>), to unwind stack frames
(<code>unwind</code>) and to create canonical frame IDs
(<code>get_Frame_id</code>). It also has a callback that is called when the
reader is being unloaded (<code>destroy</code>). The struct looks like this
<pre class="smallexample"> struct gdb_reader_funcs
{
/* Must be set to GDB_READER_INTERFACE_VERSION. */
int reader_version;
/* For use by the reader. */
void *priv_data;
gdb_read_debug_info *read;
gdb_unwind_frame *unwind;
gdb_get_frame_id *get_frame_id;
gdb_destroy_reader *destroy;
};
</pre>
<p><a name="index-g_t_0040code_007bstruct-gdb_005fsymbol_005fcallbacks_007d-3159"></a><a name="index-g_t_0040code_007bstruct-gdb_005funwind_005fcallbacks_007d-3160"></a>
The callbacks are provided with another set of callbacks by
<span class="sc">gdb</span> to do their job. For <code>read</code>, these callbacks are
passed in a <code>struct gdb_symbol_callbacks</code> and for <code>unwind</code>
and <code>get_frame_id</code>, in a <code>struct gdb_unwind_callbacks</code>.
<code>struct gdb_symbol_callbacks</code> has callbacks to create new object
files and new symbol tables inside those object files. <code>struct
gdb_unwind_callbacks</code> has callbacks to read registers off the current
frame and to write out the values of the registers in the previous
frame. Both have a callback (<code>target_read</code>) to read bytes off the
target's address space.
</body></html>