119370Spst/* Common definitions for remote server for GDB. 2130803Smarcel Copyright 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004 398944Sobrien Free Software Foundation, Inc. 419370Spst 598944Sobrien This file is part of GDB. 619370Spst 798944Sobrien This program is free software; you can redistribute it and/or modify 898944Sobrien it under the terms of the GNU General Public License as published by 998944Sobrien the Free Software Foundation; either version 2 of the License, or 1098944Sobrien (at your option) any later version. 1119370Spst 1298944Sobrien This program is distributed in the hope that it will be useful, 1398944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1498944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1598944Sobrien GNU General Public License for more details. 1619370Spst 1798944Sobrien You should have received a copy of the GNU General Public License 1898944Sobrien along with this program; if not, write to the Free Software 1998944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 2098944Sobrien Boston, MA 02111-1307, USA. */ 2119370Spst 2298944Sobrien#ifndef SERVER_H 2398944Sobrien#define SERVER_H 2498944Sobrien 2598944Sobrien#include "config.h" 26130803Smarcel 2798944Sobrien#include <stdarg.h> 2898944Sobrien#include <stdio.h> 2998944Sobrien#include <stdlib.h> 3098944Sobrien#include <errno.h> 31130803Smarcel#include <setjmp.h> 3298944Sobrien 33130803Smarcel#ifdef HAVE_STRING_H 34130803Smarcel#include <string.h> 35130803Smarcel#endif 3698944Sobrien 37130803Smarcel#ifdef NEED_DECLARATION_STRERROR 38130803Smarcel#ifndef strerror 39130803Smarcelextern char *strerror (int); /* X3.159-1989 4.11.6.2 */ 40130803Smarcel#endif 41130803Smarcel#endif 42130803Smarcel 43130803Smarcel#ifndef ATTR_NORETURN 44130803Smarcel#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) 45130803Smarcel#define ATTR_NORETURN __attribute__ ((noreturn)) 46130803Smarcel#else 47130803Smarcel#define ATTR_NORETURN /* nothing */ 48130803Smarcel#endif 49130803Smarcel#endif 50130803Smarcel 51130803Smarcel#ifndef ATTR_FORMAT 52130803Smarcel#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4)) 53130803Smarcel#define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y))) 54130803Smarcel#else 55130803Smarcel#define ATTR_FORMAT(type, x, y) /* nothing */ 56130803Smarcel#endif 57130803Smarcel#endif 58130803Smarcel 59130803Smarcel/* FIXME: This should probably be autoconf'd for. It's an integer type at 60130803Smarcel least the size of a (void *). */ 6198944Sobrientypedef long long CORE_ADDR; 6298944Sobrien 63130803Smarcel/* Generic information for tracking a list of ``inferiors'' - threads, 64130803Smarcel processes, etc. */ 65130803Smarcelstruct inferior_list 66130803Smarcel{ 67130803Smarcel struct inferior_list_entry *head; 68130803Smarcel struct inferior_list_entry *tail; 69130803Smarcel}; 70130803Smarcelstruct inferior_list_entry 71130803Smarcel{ 72130803Smarcel int id; 73130803Smarcel struct inferior_list_entry *next; 74130803Smarcel}; 75130803Smarcel 76130803Smarcel/* Opaque type for user-visible threads. */ 77130803Smarcelstruct thread_info; 78130803Smarcel 7998944Sobrien#include "regcache.h" 8098944Sobrien#include "gdb/signals.h" 8198944Sobrien 82130803Smarcel#include "target.h" 83130803Smarcel#include "mem-break.h" 8419370Spst 8546283Sdfr/* Target-specific functions */ 8646283Sdfr 8798944Sobrienvoid initialize_low (); 8819370Spst 89130803Smarcel/* From inferiors.c. */ 9046283Sdfr 91130803Smarcelextern struct inferior_list all_threads; 92130803Smarcelvoid add_inferior_to_list (struct inferior_list *list, 93130803Smarcel struct inferior_list_entry *new_inferior); 94130803Smarcelvoid for_each_inferior (struct inferior_list *list, 95130803Smarcel void (*action) (struct inferior_list_entry *)); 96130803Smarcelextern struct thread_info *current_inferior; 97130803Smarcelvoid remove_inferior (struct inferior_list *list, 98130803Smarcel struct inferior_list_entry *entry); 99130803Smarcelvoid remove_thread (struct thread_info *thread); 100130803Smarcelvoid add_thread (int thread_id, void *target_data); 101130803Smarcelvoid clear_inferiors (void); 102130803Smarcelstruct inferior_list_entry *find_inferior 103130803Smarcel (struct inferior_list *, 104130803Smarcel int (*func) (struct inferior_list_entry *, 105130803Smarcel void *), 106130803Smarcel void *arg); 107130803Smarcelstruct inferior_list_entry *find_inferior_id (struct inferior_list *list, 108130803Smarcel int id); 109130803Smarcelvoid *inferior_target_data (struct thread_info *); 110130803Smarcelvoid set_inferior_target_data (struct thread_info *, void *); 111130803Smarcelvoid *inferior_regcache_data (struct thread_info *); 112130803Smarcelvoid set_inferior_regcache_data (struct thread_info *, void *); 113130803Smarcelvoid change_inferior_id (struct inferior_list *list, 114130803Smarcel int new_id); 11546283Sdfr 11646283Sdfr/* Public variables in server.c */ 11746283Sdfr 11819370Spstextern int cont_thread; 11919370Spstextern int general_thread; 120130803Smarcelextern int step_thread; 12119370Spstextern int thread_from_wait; 12219370Spstextern int old_thread_from_wait; 123130803Smarcelextern int server_waiting; 12419370Spst 12546283Sdfrextern jmp_buf toplevel; 12619370Spst 12746283Sdfr/* Functions from remote-utils.c */ 12819370Spst 12998944Sobrienint putpkt (char *buf); 13098944Sobrienint getpkt (char *buf); 13198944Sobrienvoid remote_open (char *name); 13298944Sobrienvoid remote_close (void); 13398944Sobrienvoid write_ok (char *buf); 13498944Sobrienvoid write_enn (char *buf); 13598944Sobrienvoid enable_async_io (void); 13698944Sobrienvoid disable_async_io (void); 137130803Smarcelvoid unblock_async_io (void); 138130803Smarcelvoid block_async_io (void); 13998944Sobrienvoid convert_ascii_to_int (char *from, char *to, int n); 14098944Sobrienvoid convert_int_to_ascii (char *from, char *to, int n); 141130803Smarcelvoid new_thread_notify (int id); 142130803Smarcelvoid dead_thread_notify (int id); 14398944Sobrienvoid prepare_resume_reply (char *buf, char status, unsigned char sig); 14446283Sdfr 14598944Sobrienvoid decode_m_packet (char *from, CORE_ADDR * mem_addr_ptr, 14698944Sobrien unsigned int *len_ptr); 14798944Sobrienvoid decode_M_packet (char *from, CORE_ADDR * mem_addr_ptr, 14898944Sobrien unsigned int *len_ptr, char *to); 14946283Sdfr 150130803Smarcelint unhexify (char *bin, const char *hex, int count); 151130803Smarcelint hexify (char *hex, const char *bin, int count); 152130803Smarcel 153130803Smarcelint look_up_one_symbol (const char *name, CORE_ADDR *addrp); 154130803Smarcel 15598944Sobrien/* Functions from ``signals.c''. */ 15698944Sobrienenum target_signal target_signal_from_host (int hostsig); 15798944Sobrienint target_signal_to_host_p (enum target_signal oursig); 15898944Sobrienint target_signal_to_host (enum target_signal oursig); 15946283Sdfr 16046283Sdfr/* Functions from utils.c */ 16146283Sdfr 16298944Sobrienvoid perror_with_name (char *string); 163130803Smarcelvoid error (const char *string,...) ATTR_NORETURN; 164130803Smarcelvoid fatal (const char *string,...) ATTR_NORETURN; 16598944Sobrienvoid warning (const char *string,...); 16698944Sobrien 167130803Smarcel/* Functions from the register cache definition. */ 16898944Sobrien 169130803Smarcelvoid init_registers (void); 17098944Sobrien 17198944Sobrien/* Maximum number of bytes to read/write at once. The value here 17298944Sobrien is chosen to fill up a packet (the headers account for the 32). */ 17398944Sobrien#define MAXBUFBYTES(N) (((N)-32)/2) 17498944Sobrien 17598944Sobrien/* Buffer sizes for transferring memory, registers, etc. Round up PBUFSIZ to 17698944Sobrien hold all the registers, at least. */ 17798944Sobrien#define PBUFSIZ ((registers_length () + 32 > 2000) \ 17898944Sobrien ? (registers_length () + 32) \ 17998944Sobrien : 2000) 18098944Sobrien 18198944Sobrien#endif /* SERVER_H */ 182