xref: /freebsd/sys/gdb/gdb.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1fa521b03SWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3497b6b2aSPedro F. Giffuni  *
472d44f31SMarcel Moolenaar  * Copyright (c) 2004 Marcel Moolenaar
572d44f31SMarcel Moolenaar  * All rights reserved.
672d44f31SMarcel Moolenaar  *
772d44f31SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
872d44f31SMarcel Moolenaar  * modification, are permitted provided that the following conditions
972d44f31SMarcel Moolenaar  * are met:
1072d44f31SMarcel Moolenaar  *
1172d44f31SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
1272d44f31SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
1372d44f31SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
1472d44f31SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
1572d44f31SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
1672d44f31SMarcel Moolenaar  *
1772d44f31SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1872d44f31SMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1972d44f31SMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2072d44f31SMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2172d44f31SMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2272d44f31SMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2372d44f31SMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2472d44f31SMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2572d44f31SMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2672d44f31SMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2772d44f31SMarcel Moolenaar  */
2872d44f31SMarcel Moolenaar 
2972d44f31SMarcel Moolenaar #ifndef _GDB_GDB_H_
3072d44f31SMarcel Moolenaar #define	_GDB_GDB_H_
3172d44f31SMarcel Moolenaar 
3272d44f31SMarcel Moolenaar typedef int gdb_checkc_f(void);
3372d44f31SMarcel Moolenaar typedef int gdb_getc_f(void);
3472d44f31SMarcel Moolenaar typedef void gdb_init_f(void);
3572d44f31SMarcel Moolenaar typedef int gdb_probe_f(void);
3672d44f31SMarcel Moolenaar typedef void gdb_putc_f(int);
3772d44f31SMarcel Moolenaar typedef void gdb_term_f(void);
3872d44f31SMarcel Moolenaar 
3972d44f31SMarcel Moolenaar struct gdb_dbgport {
4072d44f31SMarcel Moolenaar 	const char	*gdb_name;
4172d44f31SMarcel Moolenaar 	gdb_getc_f	*gdb_getc;
4272d44f31SMarcel Moolenaar 	gdb_init_f	*gdb_init;
4372d44f31SMarcel Moolenaar 	gdb_probe_f	*gdb_probe;
4472d44f31SMarcel Moolenaar 	gdb_putc_f	*gdb_putc;
4572d44f31SMarcel Moolenaar 	gdb_term_f	*gdb_term;
4672d44f31SMarcel Moolenaar 	int		gdb_active;
47dda17b36SConrad Meyer 	void		(*gdb_sendpacket)(const void *, size_t);
48dda17b36SConrad Meyer 	int		gdb_dbfeatures;
4972d44f31SMarcel Moolenaar };
5072d44f31SMarcel Moolenaar 
51dda17b36SConrad Meyer #define	GDB_DBGP_FEAT_WANTTERM	0x1	/* Want gdb_term() invocation when
52dda17b36SConrad Meyer 					   leaving GDB.  gdb_term has been
53dda17b36SConrad Meyer 					   deadcode and never invoked for so
54dda17b36SConrad Meyer 					   long I don't want to just blindly
55dda17b36SConrad Meyer 					   start invoking it without opt-in. */
566310546dSConrad Meyer #define	GDB_DBGP_FEAT_RELIABLE	0x2	/* The debugport promises it is a
576310546dSConrad Meyer 					   reliable transport, which allows GDB
586310546dSConrad Meyer 					   acks to be turned off. */
59dda17b36SConrad Meyer 
609b188af1SPoul-Henning Kamp #define	GDB_DBGPORT(name, probe, init, term, getc, putc)		\
6172d44f31SMarcel Moolenaar 	static struct gdb_dbgport name##_gdb_dbgport = {		\
6272d44f31SMarcel Moolenaar 		.gdb_name = #name,					\
6372d44f31SMarcel Moolenaar 		.gdb_probe = probe,					\
649b188af1SPoul-Henning Kamp 		.gdb_init = init,					\
659b188af1SPoul-Henning Kamp 		.gdb_term = term,					\
669b188af1SPoul-Henning Kamp 		.gdb_getc = getc,					\
6772d44f31SMarcel Moolenaar 		.gdb_putc = putc,					\
6872d44f31SMarcel Moolenaar 	};								\
6972d44f31SMarcel Moolenaar 	DATA_SET(gdb_dbgport_set, name##_gdb_dbgport)
7072d44f31SMarcel Moolenaar 
7172d44f31SMarcel Moolenaar #endif /* !_GDB_GDB_H_ */
72