1 /* Main code for remote server for GDB.
2 Copyright (C) 1989, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 char ch
, status
, own_buf
[2000], mem_buf
[2000];
29 unsigned int mem_addr
, len
;
33 fprintf(stderr
, "Exiting\n");
38 error("Usage: gdbserver tty prog [args ...]");
40 inferior_pid
= create_inferior (argv
[2], &argv
[2]);
41 fprintf (stderr
, "Process %s created; pid = %d\n", argv
[2], inferior_pid
);
43 signal
= mywait (&status
); /* Wait till we are at 1st instr in prog */
45 /* We are now stopped at the first instruction of the target process */
49 remote_open (argv
[1]);
52 while (getpkt (own_buf
) > 0)
59 prepare_resume_reply (own_buf
, status
, signal
);
62 convert_int_to_ascii (registers
, own_buf
, REGISTER_BYTES
);
65 convert_ascii_to_int (&own_buf
[1], registers
, REGISTER_BYTES
);
66 store_inferior_registers (-1);
70 decode_m_packet (&own_buf
[1], &mem_addr
, &len
);
71 read_inferior_memory (mem_addr
, mem_buf
, len
);
72 convert_int_to_ascii (mem_buf
, own_buf
, len
);
75 decode_M_packet (&own_buf
[1], &mem_addr
, &len
, mem_buf
);
76 if (write_inferior_memory (mem_addr
, mem_buf
, len
) == 0)
83 signal
= mywait (&status
);
84 prepare_resume_reply (own_buf
, status
, signal
);
88 signal
= mywait (&status
);
89 prepare_resume_reply (own_buf
, status
, signal
);
92 fprintf (stderr
, "Killing inferior\n");
94 inferior_pid
= create_inferior (argv
[2], &argv
[2]);
95 fprintf (stderr
, "Process %s created; pid = %d\n", argv
[2],
97 signal
= mywait (&status
); /* Wait till we are at 1st instr in prog */
103 printf ("\nUnknown option chosen by master\n");
111 /* We come here when getpkt fails. Close the connection, and re-open it
112 at the top of the loop. */
114 fprintf (stderr
, "Remote side has terminated connection. GDBserver will reopen the connection.\n");
This page took 0.03184 seconds and 4 git commands to generate.