binutils-gdb/gdb/remote.h
Simon Marchi 2189c31265 gdb: add remote_debug_printf
This is the next in the new-style debug macro series.

For this one, I decided to omit the function name from the "Sending packet" /
"Packet received" kind of prints, just because it's not very useful in that
context and hinders readability more than anything else.  This is completely
arbitrary.

This is with:

  [remote] putpkt_binary: Sending packet: $qTStatus#49...
  [remote] getpkt_or_notif_sane_1: Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::

and without:

  [remote] Sending packet: $qTStatus#49...
  [remote] Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::

A difference is that previously, the query packet and its reply would be
printed on the same line, like this:

  Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::

Now, they are printed on two lines, since each remote_debug_printf{,_nofunc}
prints its own complete message including an end of line.  It's probably
a matter of taste, but I prefer the two-line version, it's easier to
follow, especially when the query packet is long.

As a result, lib/range-stepping-support.exp needs to be updated, as it
currently expects the vCont packet and the reply to be on the same line.
I think it's sufficient in that context to just expect the vCont packet
and not the reply, since the goal is just to count how many vCont;r GDB
sends.

gdb/ChangeLog:

	* remote.h (remote_debug_printf): New.
	(remote_debug_printf_nofunc): New.
	(REMOTE_SCOPED_DEBUG_ENTER_EXIT): New.
	* remote.c: Use above macros throughout file.

gdbsupport/ChangeLog:

	* common-debug.h (debug_prefixed_printf_cond_nofunc): New.
	* common-debug.c (debug_prefixed_vprintf): Handle a nullptr
	func.

gdb/testsuite/ChangeLog:

	* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
	Adjust to "set debug remote" changes.

Change-Id: Ica6dead50d3f82e855c7d763f707cef74bed9fee
2021-01-22 12:43:27 -05:00

81 lines
2.9 KiB
C

/* Remote target communications for serial-line targets in custom GDB protocol
Copyright (C) 1999-2021 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef REMOTE_H
#define REMOTE_H
#include "remote-notif.h"
struct target_desc;
struct remote_target;
/* True when printing "remote" debug statements is enabled. */
extern bool remote_debug;
/* Print a "remote" debug statement. */
#define remote_debug_printf(fmt, ...) \
debug_prefixed_printf_cond (remote_debug, "remote", fmt, ##__VA_ARGS__)
/* Same as the above, but don't include the function name. */
#define remote_debug_printf_nofunc(fmt, ...) \
debug_prefixed_printf_cond_nofunc (remote_debug, "remote", \
fmt, ##__VA_ARGS__)
/* Print "remote" enter/exit debug statements. */
#define REMOTE_SCOPED_DEBUG_ENTER_EXIT \
scoped_debug_enter_exit (remote_debug, "remote")
/* Read a packet from the remote machine, with error checking, and
store it in *BUF. Resize *BUF using xrealloc if necessary to hold
the result, and update *SIZEOF_BUF. If FOREVER, wait forever
rather than timing out; this is used (in synchronous mode) to wait
for a target that is is executing user code to stop. */
extern void getpkt (remote_target *remote,
char **buf, long *sizeof_buf, int forever);
/* Send a packet to the remote machine, with error checking. The data
of the packet is in BUF. The string in BUF can be at most PBUFSIZ
- 5 to account for the $, # and checksum, and for a possible /0 if
we are debugging (remote_debug) and want to print the sent packet
as a string. */
extern int putpkt (remote_target *remote, const char *buf);
void register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
const struct target_desc *tdesc);
void register_remote_support_xml (const char *);
void remote_file_put (const char *local_file, const char *remote_file,
int from_tty);
void remote_file_get (const char *remote_file, const char *local_file,
int from_tty);
void remote_file_delete (const char *remote_file, int from_tty);
extern int remote_register_number_and_offset (struct gdbarch *gdbarch,
int regnum, int *pnum,
int *poffset);
extern void remote_notif_get_pending_events (remote_target *remote,
struct notif_client *np);
#endif