Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: gdb/remote.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/remote.h ('k') | gdb/remote-fileio.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* Remote target communications for serial-line targets in custom GDB protocol 1 /* Remote target communications for serial-line targets in custom GDB protocol
2 2
3 Copyright (C) 1988-2012 Free Software Foundation, Inc. 3 Copyright (C) 1988-2013 Free Software Foundation, Inc.
4 4
5 This file is part of GDB. 5 This file is part of GDB.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 /* See the GDB User Guide for details of the GDB remote protocol. */ 20 /* See the GDB User Guide for details of the GDB remote protocol. */
21 21
22 #include "defs.h" 22 #include "defs.h"
23 #include "gdb_string.h" 23 #include <string.h>
24 #include <ctype.h> 24 #include <ctype.h>
25 #include <fcntl.h> 25 #include <fcntl.h>
26 #include "inferior.h" 26 #include "inferior.h"
27 #include "bfd.h" 27 #include "bfd.h"
28 #include "symfile.h" 28 #include "symfile.h"
29 #include "exceptions.h" 29 #include "exceptions.h"
30 #include "target.h" 30 #include "target.h"
31 /*#include "terminal.h" */ 31 /*#include "terminal.h" */
32 #include "gdbcmd.h" 32 #include "gdbcmd.h"
33 #include "objfiles.h" 33 #include "objfiles.h"
34 #include "gdb-stabs.h" 34 #include "gdb-stabs.h"
35 #include "gdbthread.h" 35 #include "gdbthread.h"
36 #include "remote.h" 36 #include "remote.h"
37 #include "remote-notif.h"
37 #include "regcache.h" 38 #include "regcache.h"
38 #include "value.h" 39 #include "value.h"
39 #include "gdb_assert.h" 40 #include "gdb_assert.h"
40 #include "observer.h" 41 #include "observer.h"
41 #include "solib.h" 42 #include "solib.h"
42 #include "cli/cli-decode.h" 43 #include "cli/cli-decode.h"
43 #include "cli/cli-setshow.h" 44 #include "cli/cli-setshow.h"
44 #include "target-descriptions.h" 45 #include "target-descriptions.h"
46 #include "gdb_bfd.h"
47 #include "filestuff.h"
45 48
46 #include <ctype.h> 49 #include <ctype.h>
47 #include <sys/time.h> 50 #include <sys/time.h>
48 51
49 #include "event-loop.h" 52 #include "event-loop.h"
50 #include "event-top.h" 53 #include "event-top.h"
51 #include "inf-loop.h" 54 #include "inf-loop.h"
52 55
53 #include <signal.h> 56 #include <signal.h>
54 #include "serial.h" 57 #include "serial.h"
55 58
56 #include "gdbcore.h" /* for exec_bfd */ 59 #include "gdbcore.h" /* for exec_bfd */
57 60
58 #include "remote-fileio.h" 61 #include "remote-fileio.h"
59 #include "gdb/fileio.h" 62 #include "gdb/fileio.h"
60 #include "gdb_stat.h" 63 #include <sys/stat.h>
61 #include "xml-support.h" 64 #include "xml-support.h"
62 65
63 #include "memory-map.h" 66 #include "memory-map.h"
64 67
65 #include "tracepoint.h" 68 #include "tracepoint.h"
66 #include "ax.h" 69 #include "ax.h"
67 #include "ax-gdb.h" 70 #include "ax-gdb.h"
68 #include "agent.h" 71 #include "agent.h"
72 #include "btrace.h"
69 73
70 /* Temp hacks for tracepoint encoding migration. */ 74 /* Temp hacks for tracepoint encoding migration. */
71 static char *target_buf; 75 static char *target_buf;
72 static long target_buf_size; 76 static long target_buf_size;
73 77
74 /* The size to align memory write packets, when practical. The protocol 78 /* The size to align memory write packets, when practical. The protocol
75 does not guarantee any alignment, and gdb will generate short 79 does not guarantee any alignment, and gdb will generate short
76 writes and unaligned writes, but even as a best-effort attempt this 80 writes and unaligned writes, but even as a best-effort attempt this
77 can improve bulk transfers. For instance, if a write is misaligned 81 can improve bulk transfers. For instance, if a write is misaligned
78 relative to the target's data bus, the stub may need to make an extra 82 relative to the target's data bus, the stub may need to make an extra
79 round trip fetching data from the target. This doesn't make a 83 round trip fetching data from the target. This doesn't make a
80 huge difference, but it's easy to do, so we try to be helpful. 84 huge difference, but it's easy to do, so we try to be helpful.
81 85
82 The alignment chosen is arbitrary; usually data bus width is 86 The alignment chosen is arbitrary; usually data bus width is
83 important here, not the possibly larger cache line size. */ 87 important here, not the possibly larger cache line size. */
84 enum { REMOTE_ALIGN_WRITES = 16 }; 88 enum { REMOTE_ALIGN_WRITES = 16 };
85 89
86 /* Prototypes for local functions. */ 90 /* Prototypes for local functions. */
87 static void cleanup_sigint_signal_handler (void *dummy); 91 static void async_cleanup_sigint_signal_handler (void *dummy);
88 static void initialize_sigint_signal_handler (void);
89 static int getpkt_sane (char **buf, long *sizeof_buf, int forever); 92 static int getpkt_sane (char **buf, long *sizeof_buf, int forever);
90 static int getpkt_or_notif_sane (char **buf, long *sizeof_buf, 93 static int getpkt_or_notif_sane (char **buf, long *sizeof_buf,
91 » » » » int forever); 94 » » » » int forever, int *is_notif);
92 95
93 static void handle_remote_sigint (int); 96 static void async_handle_remote_sigint (int);
94 static void handle_remote_sigint_twice (int); 97 static void async_handle_remote_sigint_twice (int);
95 static void async_remote_interrupt (gdb_client_data);
96 void async_remote_interrupt_twice (gdb_client_data);
97 98
98 static void remote_files_info (struct target_ops *ignore); 99 static void remote_files_info (struct target_ops *ignore);
99 100
100 static void remote_prepare_to_store (struct regcache *regcache); 101 static void remote_prepare_to_store (struct regcache *regcache);
101 102
102 static void remote_open (char *name, int from_tty); 103 static void remote_open (char *name, int from_tty);
103 104
104 static void extended_remote_open (char *name, int from_tty); 105 static void extended_remote_open (char *name, int from_tty);
105 106
106 static void remote_open_1 (char *, int, struct target_ops *, int extended_p); 107 static void remote_open_1 (char *, int, struct target_ops *, int extended_p);
107 108
108 static void remote_close (int quitting); 109 static void remote_close (void);
109 110
110 static void remote_mourn (struct target_ops *ops); 111 static void remote_mourn (struct target_ops *ops);
111 112
112 static void extended_remote_restart (void); 113 static void extended_remote_restart (void);
113 114
114 static void extended_remote_mourn (struct target_ops *); 115 static void extended_remote_mourn (struct target_ops *);
115 116
116 static void remote_mourn_1 (struct target_ops *); 117 static void remote_mourn_1 (struct target_ops *);
117 118
118 static void remote_send (char **buf, long *sizeof_buf_p); 119 static void remote_send (char **buf, long *sizeof_buf_p);
119 120
120 static int readchar (int timeout); 121 static int readchar (int timeout);
121 122
123 static void remote_serial_write (const char *str, int len);
124
122 static void remote_kill (struct target_ops *ops); 125 static void remote_kill (struct target_ops *ops);
123 126
124 static int tohex (int nib); 127 static int tohex (int nib);
125 128
126 static int remote_can_async_p (void); 129 static int remote_can_async_p (void);
127 130
128 static int remote_is_async_p (void); 131 static int remote_is_async_p (void);
129 132
130 static void remote_async (void (*callback) (enum inferior_event_type event_type, 133 static void remote_async (void (*callback) (enum inferior_event_type event_type,
131 void *context), void *context); 134 void *context), void *context);
132 135
133 static void remote_detach (struct target_ops *ops, char *args, int from_tty); 136 static void sync_remote_interrupt_twice (int signo);
134
135 static void remote_interrupt (int signo);
136
137 static void remote_interrupt_twice (int signo);
138 137
139 static void interrupt_query (void); 138 static void interrupt_query (void);
140 139
141 static void set_general_thread (struct ptid ptid); 140 static void set_general_thread (struct ptid ptid);
142 static void set_continue_thread (struct ptid ptid); 141 static void set_continue_thread (struct ptid ptid);
143 142
144 static void get_offsets (void); 143 static void get_offsets (void);
145 144
146 static void skip_frame (void); 145 static void skip_frame (void);
147 146
(...skipping 22 matching lines...) Expand all
170 static void compare_sections_command (char *, int); 169 static void compare_sections_command (char *, int);
171 170
172 static void packet_command (char *, int); 171 static void packet_command (char *, int);
173 172
174 static int stub_unpack_int (char *buff, int fieldlength); 173 static int stub_unpack_int (char *buff, int fieldlength);
175 174
176 static ptid_t remote_current_thread (ptid_t oldptid); 175 static ptid_t remote_current_thread (ptid_t oldptid);
177 176
178 static void remote_find_new_threads (void); 177 static void remote_find_new_threads (void);
179 178
180 static void record_currthread (ptid_t currthread);
181
182 static int fromhex (int a); 179 static int fromhex (int a);
183 180
184 extern int hex2bin (const char *hex, gdb_byte *bin, int count);
185
186 extern int bin2hex (const gdb_byte *bin, char *hex, int count);
187
188 static int putpkt_binary (char *buf, int cnt); 181 static int putpkt_binary (char *buf, int cnt);
189 182
190 static void check_binary_download (CORE_ADDR addr); 183 static void check_binary_download (CORE_ADDR addr);
191 184
192 struct packet_config; 185 struct packet_config;
193 186
194 static void show_packet_config_cmd (struct packet_config *config); 187 static void show_packet_config_cmd (struct packet_config *config);
195 188
196 static void update_packet_config (struct packet_config *config); 189 static void update_packet_config (struct packet_config *config);
197 190
(...skipping 12 matching lines...) Expand all
210 203
211 struct remote_state; 204 struct remote_state;
212 static int remote_get_trace_status (struct trace_status *ts); 205 static int remote_get_trace_status (struct trace_status *ts);
213 206
214 static int remote_upload_tracepoints (struct uploaded_tp **utpp); 207 static int remote_upload_tracepoints (struct uploaded_tp **utpp);
215 208
216 static int remote_upload_trace_state_variables (struct uploaded_tsv **utsvp); 209 static int remote_upload_trace_state_variables (struct uploaded_tsv **utsvp);
217 210
218 static void remote_query_supported (void); 211 static void remote_query_supported (void);
219 212
220 static void remote_check_symbols (struct objfile *objfile); 213 static void remote_check_symbols (void);
221 214
222 void _initialize_remote (void); 215 void _initialize_remote (void);
223 216
224 struct stop_reply; 217 struct stop_reply;
225 static struct stop_reply *stop_reply_xmalloc (void);
226 static void stop_reply_xfree (struct stop_reply *); 218 static void stop_reply_xfree (struct stop_reply *);
227 static void do_stop_reply_xfree (void *arg); 219 static void remote_parse_stop_reply (char *, struct stop_reply *);
228 static void remote_parse_stop_reply (char *buf, struct stop_reply *);
229 static void push_stop_reply (struct stop_reply *); 220 static void push_stop_reply (struct stop_reply *);
230 static void remote_get_pending_stop_replies (void); 221 static void discard_pending_stop_replies_in_queue (struct remote_state *);
231 static void discard_pending_stop_replies (int pid);
232 static int peek_stop_reply (ptid_t ptid); 222 static int peek_stop_reply (ptid_t ptid);
233 223
234 static void remote_async_inferior_event_handler (gdb_client_data); 224 static void remote_async_inferior_event_handler (gdb_client_data);
235 static void remote_async_get_pending_events_handler (gdb_client_data);
236 225
237 static void remote_terminal_ours (void); 226 static void remote_terminal_ours (void);
238 227
239 static int remote_read_description_p (struct target_ops *target); 228 static int remote_read_description_p (struct target_ops *target);
240 229
241 static void remote_console_output (char *msg); 230 static void remote_console_output (char *msg);
242 231
243 static int remote_supports_cond_breakpoints (void); 232 static int remote_supports_cond_breakpoints (void);
244 233
245 static int remote_can_run_breakpoint_commands (void); 234 static int remote_can_run_breakpoint_commands (void);
246 235
247 /* The non-stop remote protocol provisions for one pending stop reply.
248 This is where we keep it until it is acknowledged. */
249
250 static struct stop_reply *pending_stop_reply = NULL;
251
252 /* For "remote". */ 236 /* For "remote". */
253 237
254 static struct cmd_list_element *remote_cmdlist; 238 static struct cmd_list_element *remote_cmdlist;
255 239
256 /* For "set remote" and "show remote". */ 240 /* For "set remote" and "show remote". */
257 241
258 static struct cmd_list_element *remote_set_cmdlist; 242 static struct cmd_list_element *remote_set_cmdlist;
259 static struct cmd_list_element *remote_show_cmdlist; 243 static struct cmd_list_element *remote_show_cmdlist;
260 244
245 /* Stub vCont actions support.
246
247 Each field is a boolean flag indicating whether the stub reports
248 support for the corresponding action. */
249
250 struct vCont_action_support
251 {
252 /* vCont;t */
253 int t;
254
255 /* vCont;r */
256 int r;
257 };
258
259 /* Controls whether GDB is willing to use range stepping. */
260
261 static int use_range_stepping = 1;
262
263 #define OPAQUETHREADBYTES 8
264
265 /* a 64 bit opaque identifier */
266 typedef unsigned char threadref[OPAQUETHREADBYTES];
267
268 /* About this many threadisds fit in a packet. */
269
270 #define MAXTHREADLISTRESULTS 32
271
261 /* Description of the remote protocol state for the currently 272 /* Description of the remote protocol state for the currently
262 connected target. This is per-target state, and independent of the 273 connected target. This is per-target state, and independent of the
263 selected architecture. */ 274 selected architecture. */
264 275
265 struct remote_state 276 struct remote_state
266 { 277 {
267 /* A buffer to use for incoming packets, and its current size. The 278 /* A buffer to use for incoming packets, and its current size. The
268 buffer is grown dynamically for larger incoming packets. 279 buffer is grown dynamically for larger incoming packets.
269 Outgoing packets may also be constructed in this buffer. 280 Outgoing packets may also be constructed in this buffer.
270 BUF_SIZE is always at least REMOTE_PACKET_SIZE; 281 BUF_SIZE is always at least REMOTE_PACKET_SIZE;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 stop. In the mean time, we can't start another command/query. 319 stop. In the mean time, we can't start another command/query.
309 The remote server wouldn't be ready to process it, so we'd 320 The remote server wouldn't be ready to process it, so we'd
310 timeout waiting for a reply that would never come and eventually 321 timeout waiting for a reply that would never come and eventually
311 we'd close the connection. This can happen in asynchronous mode 322 we'd close the connection. This can happen in asynchronous mode
312 because we allow GDB commands while the target is running. */ 323 because we allow GDB commands while the target is running. */
313 int waiting_for_stop_reply; 324 int waiting_for_stop_reply;
314 325
315 /* True if the stub reports support for non-stop mode. */ 326 /* True if the stub reports support for non-stop mode. */
316 int non_stop_aware; 327 int non_stop_aware;
317 328
318 /* True if the stub reports support for vCont;t. */ 329 /* The status of the stub support for the various vCont actions. */
319 int support_vCont_t; 330 struct vCont_action_support supports_vCont;
320 331
321 /* True if the stub reports support for conditional tracepoints. */ 332 /* True if the stub reports support for conditional tracepoints. */
322 int cond_tracepoints; 333 int cond_tracepoints;
323 334
324 /* True if the stub reports support for target-side breakpoint 335 /* True if the stub reports support for target-side breakpoint
325 conditions. */ 336 conditions. */
326 int cond_breakpoints; 337 int cond_breakpoints;
327 338
328 /* True if the stub reports support for target-side breakpoint 339 /* True if the stub reports support for target-side breakpoint
329 commands. */ 340 commands. */
(...skipping 13 matching lines...) Expand all
343 disconnected. */ 354 disconnected. */
344 int disconnected_tracing; 355 int disconnected_tracing;
345 356
346 /* True if the stub reports support for enabling and disabling 357 /* True if the stub reports support for enabling and disabling
347 tracepoints while a trace experiment is running. */ 358 tracepoints while a trace experiment is running. */
348 int enable_disable_tracepoints; 359 int enable_disable_tracepoints;
349 360
350 /* True if the stub can collect strings using tracenz bytecode. */ 361 /* True if the stub can collect strings using tracenz bytecode. */
351 int string_tracing; 362 int string_tracing;
352 363
364 /* True if the stub supports qXfer:libraries-svr4:read with a
365 non-empty annex. */
366 int augmented_libraries_svr4_read;
367
353 /* Nonzero if the user has pressed Ctrl-C, but the target hasn't 368 /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
354 responded to that. */ 369 responded to that. */
355 int ctrlc_pending_p; 370 int ctrlc_pending_p;
371
372 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
373 remote_open knows that we don't have a file open when the program
374 starts. */
375 struct serial *remote_desc;
376
377 /* These are the threads which we last sent to the remote system. The
378 TID member will be -1 for all or -2 for not sent yet. */
379 ptid_t general_thread;
380 ptid_t continue_thread;
381
382 /* This is the traceframe which we last selected on the remote system.
383 It will be -1 if no traceframe is selected. */
384 int remote_traceframe_number;
385
386 char *last_pass_packet;
387
388 /* The last QProgramSignals packet sent to the target. We bypass
389 sending a new program signals list down to the target if the new
390 packet is exactly the same as the last we sent. IOW, we only let
391 the target know about program signals list changes. */
392 char *last_program_signals_packet;
393
394 enum gdb_signal last_sent_signal;
395
396 int last_sent_step;
397
398 char *finished_object;
399 char *finished_annex;
400 ULONGEST finished_offset;
401
402 /* Should we try the 'ThreadInfo' query packet?
403
404 This variable (NOT available to the user: auto-detect only!)
405 determines whether GDB will use the new, simpler "ThreadInfo"
406 query or the older, more complex syntax for thread queries.
407 This is an auto-detect variable (set to true at each connect,
408 and set to false when the target fails to recognize it). */
409 int use_threadinfo_query;
410 int use_threadextra_query;
411
412 void (*async_client_callback) (enum inferior_event_type event_type,
413 void *context);
414 void *async_client_context;
415
416 /* This is set to the data address of the access causing the target
417 to stop for a watchpoint. */
418 CORE_ADDR remote_watch_data_address;
419
420 /* This is non-zero if target stopped for a watchpoint. */
421 int remote_stopped_by_watchpoint_p;
422
423 threadref echo_nextthread;
424 threadref nextthread;
425 threadref resultthreadlist[MAXTHREADLISTRESULTS];
426
427 /* The state of remote notification. */
428 struct remote_notif_state *notif_state;
356 }; 429 };
357 430
358 /* Private data that we'll store in (struct thread_info)->private. */ 431 /* Private data that we'll store in (struct thread_info)->private. */
359 struct private_thread_info 432 struct private_thread_info
360 { 433 {
361 char *extra; 434 char *extra;
362 int core; 435 int core;
363 }; 436 };
364 437
365 static void 438 static void
366 free_private_thread_info (struct private_thread_info *info) 439 free_private_thread_info (struct private_thread_info *info)
367 { 440 {
368 xfree (info->extra); 441 xfree (info->extra);
369 xfree (info); 442 xfree (info);
370 } 443 }
371 444
372 /* Returns true if the multi-process extensions are in effect. */ 445 /* Returns true if the multi-process extensions are in effect. */
373 static int 446 static int
374 remote_multi_process_p (struct remote_state *rs) 447 remote_multi_process_p (struct remote_state *rs)
375 { 448 {
376 return rs->multi_process_aware; 449 return rs->multi_process_aware;
377 } 450 }
378 451
379 /* This data could be associated with a target, but we do not always 452 /* This data could be associated with a target, but we do not always
380 have access to the current target when we need it, so for now it is 453 have access to the current target when we need it, so for now it is
381 static. This will be fine for as long as only one target is in use 454 static. This will be fine for as long as only one target is in use
382 at a time. */ 455 at a time. */
383 static struct remote_state remote_state; 456 static struct remote_state *remote_state;
384 457
385 static struct remote_state * 458 static struct remote_state *
386 get_remote_state_raw (void) 459 get_remote_state_raw (void)
387 { 460 {
388 return &remote_state; 461 return remote_state;
462 }
463
464 /* Allocate a new struct remote_state with xmalloc, initialize it, and
465 return it. */
466
467 static struct remote_state *
468 new_remote_state (void)
469 {
470 struct remote_state *result = XCNEW (struct remote_state);
471
472 /* The default buffer size is unimportant; it will be expanded
473 whenever a larger buffer is needed. */
474 result->buf_size = 400;
475 result->buf = xmalloc (result->buf_size);
476 result->remote_traceframe_number = -1;
477 result->last_sent_signal = GDB_SIGNAL_0;
478
479 return result;
389 } 480 }
390 481
391 /* Description of the remote protocol for a given architecture. */ 482 /* Description of the remote protocol for a given architecture. */
392 483
393 struct packet_reg 484 struct packet_reg
394 { 485 {
395 long offset; /* Offset into G packet. */ 486 long offset; /* Offset into G packet. */
396 long regnum; /* GDB's internal register number. */ 487 long regnum; /* GDB's internal register number. */
397 LONGEST pnum; /* Remote protocol register number. */ 488 LONGEST pnum; /* Remote protocol register number. */
398 int in_g_packet; /* Always part of G packet. */ 489 int in_g_packet; /* Always part of G packet. */
399 /* long size in bytes; == register_size (target_gdbarch, regnum); 490 /* long size in bytes; == register_size (target_gdbarch (), regnum);
400 at present. */ 491 at present. */
401 /* char *name; == gdbarch_register_name (target_gdbarch, regnum); 492 /* char *name; == gdbarch_register_name (target_gdbarch (), regnum);
402 at present. */ 493 at present. */
403 }; 494 };
404 495
405 struct remote_arch_state 496 struct remote_arch_state
406 { 497 {
407 /* Description of the remote protocol registers. */ 498 /* Description of the remote protocol registers. */
408 long sizeof_g_packet; 499 long sizeof_g_packet;
409 500
410 /* Description of the remote protocol registers indexed by REGNUM 501 /* Description of the remote protocol registers indexed by REGNUM
411 (making an array gdbarch_num_regs in size). */ 502 (making an array gdbarch_num_regs in size). */
412 struct packet_reg *regs; 503 struct packet_reg *regs;
413 504
414 /* This is the size (in chars) of the first response to the ``g'' 505 /* This is the size (in chars) of the first response to the ``g''
415 packet. It is used as a heuristic when determining the maximum 506 packet. It is used as a heuristic when determining the maximum
416 size of memory-read and memory-write packets. A target will 507 size of memory-read and memory-write packets. A target will
417 typically only reserve a buffer large enough to hold the ``g'' 508 typically only reserve a buffer large enough to hold the ``g''
418 packet. The size does not include packet overhead (headers and 509 packet. The size does not include packet overhead (headers and
419 trailers). */ 510 trailers). */
420 long actual_register_packet_size; 511 long actual_register_packet_size;
421 512
422 /* This is the maximum size (in chars) of a non read/write packet. 513 /* This is the maximum size (in chars) of a non read/write packet.
423 It is also used as a cap on the size of read/write packets. */ 514 It is also used as a cap on the size of read/write packets. */
424 long remote_packet_size; 515 long remote_packet_size;
425 }; 516 };
426 517
427 long sizeof_pkt = 2000;
428
429 /* Utility: generate error from an incoming stub packet. */ 518 /* Utility: generate error from an incoming stub packet. */
430 static void 519 static void
431 trace_error (char *buf) 520 trace_error (char *buf)
432 { 521 {
433 if (*buf++ != 'E') 522 if (*buf++ != 'E')
434 return; /* not an error msg */ 523 return; /* not an error msg */
435 switch (*buf) 524 switch (*buf)
436 { 525 {
437 case '1': /* malformed packet error */ 526 case '1': /* malformed packet error */
438 if (*++buf == '0') /* general case: */ 527 if (*++buf == '0') /* general case: */
439 error (_("remote.c: error in outgoing packet.")); 528 error (_("remote.c: error in outgoing packet."));
440 else 529 else
441 error (_("remote.c: error in outgoing packet at field #%ld."), 530 error (_("remote.c: error in outgoing packet at field #%ld."),
442 strtol (buf, NULL, 16)); 531 strtol (buf, NULL, 16));
443 case '2':
444 error (_("trace API error 0x%s."), ++buf);
445 default: 532 default:
446 error (_("Target returns error code '%s'."), buf); 533 error (_("Target returns error code '%s'."), buf);
447 } 534 }
448 } 535 }
449 536
450 /* Utility: wait for reply from stub, while accepting "O" packets. */ 537 /* Utility: wait for reply from stub, while accepting "O" packets. */
451 static char * 538 static char *
452 remote_get_noisy_reply (char **buf_p, 539 remote_get_noisy_reply (char **buf_p,
453 long *sizeof_buf) 540 long *sizeof_buf)
454 { 541 {
(...skipping 21 matching lines...) Expand all
476 from = ul; 563 from = ul;
477 564
478 p = pp + 1; 565 p = pp + 1;
479 unpack_varlen_hex (p, &ul); 566 unpack_varlen_hex (p, &ul);
480 to = ul; 567 to = ul;
481 568
482 org_to = to; 569 org_to = to;
483 570
484 TRY_CATCH (ex, RETURN_MASK_ALL) 571 TRY_CATCH (ex, RETURN_MASK_ALL)
485 { 572 {
486 » gdbarch_relocate_instruction (target_gdbarch, &to, from); 573 » gdbarch_relocate_instruction (target_gdbarch (), &to, from);
487 } 574 }
488 if (ex.reason >= 0) 575 if (ex.reason >= 0)
489 { 576 {
490 adjusted_size = to - org_to; 577 adjusted_size = to - org_to;
491 578
492 xsnprintf (buf, *sizeof_buf, "qRelocInsn:%x", adjusted_size); 579 xsnprintf (buf, *sizeof_buf, "qRelocInsn:%x", adjusted_size);
493 putpkt (buf); 580 putpkt (buf);
494 } 581 }
495 else if (ex.reason < 0 && ex.error == MEMORY_ERROR) 582 else if (ex.reason < 0 && ex.error == MEMORY_ERROR)
496 { 583 {
(...skipping 20 matching lines...) Expand all
517 } 604 }
518 while (1); 605 while (1);
519 } 606 }
520 607
521 /* Handle for retreving the remote protocol data from gdbarch. */ 608 /* Handle for retreving the remote protocol data from gdbarch. */
522 static struct gdbarch_data *remote_gdbarch_data_handle; 609 static struct gdbarch_data *remote_gdbarch_data_handle;
523 610
524 static struct remote_arch_state * 611 static struct remote_arch_state *
525 get_remote_arch_state (void) 612 get_remote_arch_state (void)
526 { 613 {
527 return gdbarch_data (target_gdbarch, remote_gdbarch_data_handle); 614 return gdbarch_data (target_gdbarch (), remote_gdbarch_data_handle);
528 } 615 }
529 616
530 /* Fetch the global remote target state. */ 617 /* Fetch the global remote target state. */
531 618
532 static struct remote_state * 619 static struct remote_state *
533 get_remote_state (void) 620 get_remote_state (void)
534 { 621 {
535 /* Make sure that the remote architecture state has been 622 /* Make sure that the remote architecture state has been
536 initialized, because doing so might reallocate rs->buf. Any 623 initialized, because doing so might reallocate rs->buf. Any
537 function which calls getpkt also needs to be mindful of changes 624 function which calls getpkt also needs to be mindful of changes
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 777
691 if (rs->explicit_packet_size) 778 if (rs->explicit_packet_size)
692 return rs->explicit_packet_size; 779 return rs->explicit_packet_size;
693 780
694 return rsa->remote_packet_size; 781 return rsa->remote_packet_size;
695 } 782 }
696 783
697 static struct packet_reg * 784 static struct packet_reg *
698 packet_reg_from_regnum (struct remote_arch_state *rsa, long regnum) 785 packet_reg_from_regnum (struct remote_arch_state *rsa, long regnum)
699 { 786 {
700 if (regnum < 0 && regnum >= gdbarch_num_regs (target_gdbarch)) 787 if (regnum < 0 && regnum >= gdbarch_num_regs (target_gdbarch ()))
701 return NULL; 788 return NULL;
702 else 789 else
703 { 790 {
704 struct packet_reg *r = &rsa->regs[regnum]; 791 struct packet_reg *r = &rsa->regs[regnum];
705 792
706 gdb_assert (r->regnum == regnum); 793 gdb_assert (r->regnum == regnum);
707 return r; 794 return r;
708 } 795 }
709 } 796 }
710 797
711 static struct packet_reg * 798 static struct packet_reg *
712 packet_reg_from_pnum (struct remote_arch_state *rsa, LONGEST pnum) 799 packet_reg_from_pnum (struct remote_arch_state *rsa, LONGEST pnum)
713 { 800 {
714 int i; 801 int i;
715 802
716 for (i = 0; i < gdbarch_num_regs (target_gdbarch); i++) 803 for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
717 { 804 {
718 struct packet_reg *r = &rsa->regs[i]; 805 struct packet_reg *r = &rsa->regs[i];
719 806
720 if (r->pnum == pnum) 807 if (r->pnum == pnum)
721 return r; 808 return r;
722 } 809 }
723 return NULL; 810 return NULL;
724 } 811 }
725 812
726 /* FIXME: graces/2002-08-08: These variables should eventually be
727 bound to an instance of the target object (as in gdbarch-tdep()),
728 when such a thing exists. */
729
730 /* This is set to the data address of the access causing the target
731 to stop for a watchpoint. */
732 static CORE_ADDR remote_watch_data_address;
733
734 /* This is non-zero if target stopped for a watchpoint. */
735 static int remote_stopped_by_watchpoint_p;
736
737 static struct target_ops remote_ops; 813 static struct target_ops remote_ops;
738 814
739 static struct target_ops extended_remote_ops; 815 static struct target_ops extended_remote_ops;
740 816
741 /* FIXME: cagney/1999-09-23: Even though getpkt was called with 817 /* FIXME: cagney/1999-09-23: Even though getpkt was called with
742 ``forever'' still use the normal timeout mechanism. This is 818 ``forever'' still use the normal timeout mechanism. This is
743 currently used by the ASYNC code to guarentee that target reads 819 currently used by the ASYNC code to guarentee that target reads
744 during the initial connect always time-out. Once getpkt has been 820 during the initial connect always time-out. Once getpkt has been
745 modified to return a timeout indication and, in turn 821 modified to return a timeout indication and, in turn
746 remote_wait()/wait_for_inferior() have gained a timeout parameter 822 remote_wait()/wait_for_inferior() have gained a timeout parameter
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 interrupt_sequence_mode = interrupt_sequence_control_c; 886 interrupt_sequence_mode = interrupt_sequence_control_c;
811 } 887 }
812 888
813 static void 889 static void
814 show_remotebreak (struct ui_file *file, int from_tty, 890 show_remotebreak (struct ui_file *file, int from_tty,
815 struct cmd_list_element *c, 891 struct cmd_list_element *c,
816 const char *value) 892 const char *value)
817 { 893 {
818 } 894 }
819 895
820 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
821 remote_open knows that we don't have a file open when the program
822 starts. */
823 static struct serial *remote_desc = NULL;
824
825 /* This variable sets the number of bits in an address that are to be 896 /* This variable sets the number of bits in an address that are to be
826 sent in a memory ("M" or "m") packet. Normally, after stripping 897 sent in a memory ("M" or "m") packet. Normally, after stripping
827 leading zeros, the entire address would be sent. This variable 898 leading zeros, the entire address would be sent. This variable
828 restricts the address to REMOTE_ADDRESS_SIZE bits. HISTORY: The 899 restricts the address to REMOTE_ADDRESS_SIZE bits. HISTORY: The
829 initial implementation of remote.c restricted the address sent in 900 initial implementation of remote.c restricted the address sent in
830 memory packets to ``host::sizeof long'' bytes - (typically 32 901 memory packets to ``host::sizeof long'' bytes - (typically 32
831 bits). Consequently, for 64 bit targets, the upper 32 bits of an 902 bits). Consequently, for 64 bit targets, the upper 32 bits of an
832 address was never sent. Since fixing this bug may cause a break in 903 address was never sent. Since fixing this bug may cause a break in
833 some remote targets this variable is principly provided to 904 some remote targets this variable is principly provided to
834 facilitate backward compatibility. */ 905 facilitate backward compatibility. */
835 906
836 static int remote_address_size; 907 static unsigned int remote_address_size;
837 908
838 /* Temporary to track who currently owns the terminal. See 909 /* Temporary to track who currently owns the terminal. See
839 remote_terminal_* for more details. */ 910 remote_terminal_* for more details. */
840 911
841 static int remote_async_terminal_ours_p; 912 static int remote_async_terminal_ours_p;
842 913
843 /* The executable file to use for "run" on the remote side. */ 914 /* The executable file to use for "run" on the remote side. */
844 915
845 static char *remote_exec_file = ""; 916 static char *remote_exec_file = "";
846 917
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 PACKET_qXfer_auxv, 1329 PACKET_qXfer_auxv,
1259 PACKET_qXfer_features, 1330 PACKET_qXfer_features,
1260 PACKET_qXfer_libraries, 1331 PACKET_qXfer_libraries,
1261 PACKET_qXfer_libraries_svr4, 1332 PACKET_qXfer_libraries_svr4,
1262 PACKET_qXfer_memory_map, 1333 PACKET_qXfer_memory_map,
1263 PACKET_qXfer_spu_read, 1334 PACKET_qXfer_spu_read,
1264 PACKET_qXfer_spu_write, 1335 PACKET_qXfer_spu_write,
1265 PACKET_qXfer_osdata, 1336 PACKET_qXfer_osdata,
1266 PACKET_qXfer_threads, 1337 PACKET_qXfer_threads,
1267 PACKET_qXfer_statictrace_read, 1338 PACKET_qXfer_statictrace_read,

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/remote.h ('k') | gdb/remote-fileio.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698