From 325fac504a327de9c46a4e5cf9c88ece9d9d7701 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 16 Sep 2016 19:55:17 +0100 Subject: gdb: Use std::min and std::max throughout Otherwise including 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 * defs.h (min, max): Delete. * aarch64-tdep.c: Include 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. --- gdb/btrace.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gdb/btrace.c') diff --git a/gdb/btrace.c b/gdb/btrace.c index f2cb750..d1af128 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -37,6 +37,7 @@ #include #include +#include /* Command lists for btrace maintenance commands. */ static struct cmd_list_element *maint_btrace_cmdlist; @@ -395,7 +396,7 @@ ftrace_new_return (struct btrace_function *prev, We start at the preceding function's level in case this has already been a return for which we have not seen the call. We start at level 0 otherwise, to handle tail calls correctly. */ - bfun->level = min (0, prev->level) - 1; + bfun->level = std::min (0, prev->level) - 1; /* Fix up the call stack for PREV. */ ftrace_fixup_caller (prev, bfun, BFUN_UP_LINKS_TO_RET); @@ -645,7 +646,7 @@ btrace_compute_ftrace_bts (struct thread_info *tp, /* Maintain the function level offset. For all but the last block, we do it here. */ if (blk != 0) - level = min (level, end->level); + level = std::min (level, end->level); size = 0; TRY @@ -691,7 +692,7 @@ btrace_compute_ftrace_bts (struct thread_info *tp, and is not really part of the execution history, it shouldn't affect the level. */ if (blk == 0) - level = min (level, end->level); + level = std::min (level, end->level); } } @@ -801,7 +802,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, } /* Maintain the function level offset. */ - *plevel = min (*plevel, end->level); + *plevel = std::min (*plevel, end->level); btinsn.pc = (CORE_ADDR) insn.ip; btinsn.size = (gdb_byte) insn.size; @@ -1827,7 +1828,7 @@ btrace_insn_next (struct btrace_insn_iterator *it, unsigned int stride) space = end - index; /* Advance the iterator as far as possible within this segment. */ - adv = min (space, stride); + adv = std::min (space, stride); stride -= adv; index += adv; steps += adv; @@ -1906,7 +1907,7 @@ btrace_insn_prev (struct btrace_insn_iterator *it, unsigned int stride) } /* Advance the iterator as far as possible within this segment. */ - adv = min (index, stride); + adv = std::min (index, stride); stride -= adv; index -= adv; -- cgit v1.1