mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-31 10:09:16 +08:00
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken. E.g.: In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0, from /opt/gcc/include/c++/7.0.0/string:40, from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68: /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2 min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2 max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ In file included from .../src/gdb/infrun.c:21:0: To the best of my grepping abilities, I believe I adjusted all min/max calls. gdb/ChangeLog: 2016-09-16 Pedro Alves <palves@redhat.com> * defs.h (min, max): Delete. * aarch64-tdep.c: Include <algorithm> and use std::min and std::max throughout. * aarch64-tdep.c: Likewise. * alpha-tdep.c: Likewise. * amd64-tdep.c: Likewise. * amd64-windows-tdep.c: Likewise. * arm-tdep.c: Likewise. * avr-tdep.c: Likewise. * breakpoint.c: Likewise. * btrace.c: Likewise. * ctf.c: Likewise. * disasm.c: Likewise. * doublest.c: Likewise. * dwarf2loc.c: Likewise. * dwarf2read.c: Likewise. * environ.c: Likewise. * exec.c: Likewise. * f-exp.y: Likewise. * findcmd.c: Likewise. * ft32-tdep.c: Likewise. * gcore.c: Likewise. * hppa-tdep.c: Likewise. * i386-darwin-tdep.c: Likewise. * i386-tdep.c: Likewise. * linux-thread-db.c: Likewise. * lm32-tdep.c: Likewise. * m32r-tdep.c: Likewise. * m88k-tdep.c: Likewise. * memrange.c: Likewise. * minidebug.c: Likewise. * mips-tdep.c: Likewise. * moxie-tdep.c: Likewise. * nds32-tdep.c: Likewise. * nios2-tdep.c: Likewise. * nto-procfs.c: Likewise. * parse.c: Likewise. * ppc-sysv-tdep.c: Likewise. * probe.c: Likewise. * record-btrace.c: Likewise. * remote.c: Likewise. * rs6000-tdep.c: Likewise. * rx-tdep.c: Likewise. * s390-linux-nat.c: Likewise. * s390-linux-tdep.c: Likewise. * ser-tcp.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * source.c: Likewise. * sparc-tdep.c: Likewise. * symfile.c: Likewise. * target-memory.c: Likewise. * target.c: Likewise. * tic6x-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * tracefile-tfile.c: Likewise. * tracepoint.c: Likewise. * valprint.c: Likewise. * value.c: Likewise. * xtensa-tdep.c: Likewise. * cli/cli-cmds.c: Likewise. * compile/compile-object-load.c: Likewise.
This commit is contained in:
@ -36,6 +36,7 @@
|
||||
#include "charset.h"
|
||||
#include "typeprint.h"
|
||||
#include <ctype.h>
|
||||
#include <algorithm>
|
||||
|
||||
/* Maximum number of wchars returned from wchar_iterate. */
|
||||
#define MAX_WCHARS 4
|
||||
@ -2178,7 +2179,7 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
|
||||
{
|
||||
/* We want fetchlimit chars, so we might as well read them all in
|
||||
one operation. */
|
||||
unsigned int fetchlen = min (len, fetchlimit);
|
||||
unsigned int fetchlen = std::min ((unsigned) len, fetchlimit);
|
||||
|
||||
*buffer = (gdb_byte *) xmalloc (fetchlen * width);
|
||||
bufptr = *buffer;
|
||||
@ -2202,12 +2203,12 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
|
||||
So we choose the minimum of 8 and fetchlimit. We used to use 200
|
||||
instead of 8 but 200 is way too big for remote debugging over a
|
||||
serial line. */
|
||||
chunksize = min (8, fetchlimit);
|
||||
chunksize = std::min (8u, fetchlimit);
|
||||
|
||||
do
|
||||
{
|
||||
QUIT;
|
||||
nfetch = min (chunksize, fetchlimit - bufsize);
|
||||
nfetch = std::min ((unsigned long) chunksize, fetchlimit - bufsize);
|
||||
|
||||
if (*buffer == NULL)
|
||||
*buffer = (gdb_byte *) xmalloc (nfetch * width);
|
||||
@ -2864,8 +2865,8 @@ val_print_string (struct type *elttype, const char *encoding,
|
||||
because finding the null byte (or available memory) is what actually
|
||||
limits the fetch. */
|
||||
|
||||
fetchlimit = (len == -1 ? options->print_max : min (len,
|
||||
options->print_max));
|
||||
fetchlimit = (len == -1 ? options->print_max : std::min ((unsigned) len,
|
||||
options->print_max));
|
||||
|
||||
err = read_string (addr, len, width, fetchlimit, byte_order,
|
||||
&buffer, &bytes_read);
|
||||
|
Reference in New Issue
Block a user