aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-11-28Partially revert patch for PR 20815 - do not sort the PT_LOAD segments. ↵Nick Clifton2-65/+21
Non-ordered segments are needed by the Linux kernel. PR ld/20815 * elf.c (phdr_sorter): Delete. (assign_file_positions_except_relocs): Do not sort program headers.
2016-11-28X86: Ignore REX_B bit for 32-bit XOP instructionsAmit Pawar6-4/+52
While decoding 32-bit XOP instructions, 64 bit registers names are printed. This patch fixes this by ignoring REX_B bit in 32-bit mode. opcodes/ PR binutils/20637 * i386-dis.c (get_valid_dis386): Ignore REX_B for 32-bit XOP instructions. gas/ PR binutils/20637 * testsuite/gas/i386/xop32reg.d: New file. * testsuite/gas/i386/xop32reg.s: New file. * testsuite/gas/i386/i386.exp: Run new test.
2016-11-28Restrict checking value.lval on using addressYao Qi3-12/+9
With the previous change, value.location.address is only valid for lval_memory. This patch restrict some checking on value.lval on using address. Since we have a check on VALUE_VAL in set_value_address, we need to set VALUE_VAL properly before set_value_address too. gdb: 2016-11-25 Yao Qi <yao.qi@linaro.org> * ada-lang.c (ensure_lval): Call set_value_address after setting VALUE_LVAL. * elfread.c (elf_gnu_ifunc_resolve_addr): Set VALUE_LVAL to lval_memory. (elf_gnu_ifunc_resolver_return_stop): Likewise. * value.c (value_fn_field): Likewise. (value_from_contents_and_address_unresolved): Likewise. (value_from_contents_and_address): Likewise. (value_address): Check value->lval isn't lval_memory. (value_raw_address): Likewise. (set_value_address): Assert value->lval is lval_memory.
2016-11-28Adjust Value.location for lval_registerYao Qi3-29/+18
value.regnum and value.next_frame_id are only used for lval_register, so this patch moves them to union value.location. As a result, when we copy value, only copy location, don't need to copy regnum and next_frame_id. This patch also changes regnum's type to int as there is no space constraint, so update deprecated_value_regnum_hack return type too. gdb: 2016-11-28 Yao Qi <yao.qi@linaro.org> * valops.c (value_slice): Don't set frame id of slice. * value.c (struct value) <regnum, next_frame_id>: Move them to... (struct value) <location>: ... here. Update comments. (allocate_value_lazy): Don't set frame id and regnum. (deprecated_value_next_frame_id_hack): Adjust. (deprecated_value_regnum_hack): Adjust. (value_copy): Don't copy frame id and regnu. (value_primitive_field): Likewise. (value_from_component): Likewise. (deprecated_value_regnum_hack): Return int *. * value.h (deprecated_value_regnum_hack): Update declaration.
2016-11-28Move computed value's frame id to piece_closureYao Qi1-13/+11
Nowadays, we set computed value's frame id, which is a misuse to me. The computed value itself doesn't care about frame id, but function value_computed_funcs (val)->read (or read_pieced_value) cares about which frame the register is relative to, so 'struct piece_closure' is a better place to fit frame id. This patch adds a frame id in 'struct piece_closure', and use it instead of using computed value's frame id. gdb: 2016-11-28 Yao Qi <yao.qi@linaro.org> * dwarf2loc.c (struct piece_closure) <frame_id>: New field. (allocate_piece_closure): Add new parameter 'frame' and set closure's frame_id field accordingly. (read_pieced_value): Get frame from closure instead of value. (dwarf2_evaluate_loc_desc_full): Remove code getting frame id. Don't set value's frame id.
2016-11-28Properly hide hidden versioned symbol in executableH.J. Lu5-28/+46
A hidden versioned symbol in executable should be forced local if it is locally defined, not referenced by shared library and not exported. We must do it before _bfd_elf_link_renumber_dynsyms. bfd/ * elflink.c (_bfd_elf_fix_symbol_flags): Hide hidden versioned symbol in executable. (elf_link_output_extsym): Don't change bind from global to local when linking executable. ld/ * testsuite/ld-elf/indirect.exp: Add a test for PR 18720. * testsuite/ld-elf/pr18720.rd: New file.
2016-11-28Automatic date update in version.inGDB Administrator1-1/+1
2016-11-27Fix powerpc vle test for sorting of program headersAlan Modra2-3/+8
1a9ccd70f changed the order of headers. PR 20815 * testsuite/ld-powerpc/vle-multiseg-5.d: Update.
2016-11-27Fix spelling in comments in .y files (ld)Ambrogino Modigliani2-2/+6
* deffilep.y: Fix spelling in comments.
2016-11-27Fix spelling in comments in .y files (binutils)Ambrogino Modigliani2-1/+5
* arparse.y: Fix spelling in comments.
2016-11-27Fix spelling in comments in .sc files (ld)Ambrogino Modigliani5-6/+13
* scripttempl/ia64vms.sc: Fix spelling in comments. * scripttempl/ip2k.sc: Fix spelling in comments. * scripttempl/v850.sc: Fix spelling in comments. * scripttempl/v850_rh850.sc: Fix spelling in comments.
2016-11-27Fix spelling in comments in .l files (gas)Ambrogino Modigliani2-1/+5
* config/bfin-lex.l: Fix spelling in comments.
2016-11-27Fix spelling in comments in .em files (ld)Ambrogino Modigliani6-6/+14
* emultempl/avrelf.em: Fix spelling in comments. * emultempl/elf32.em: Fix spelling in comments. * emultempl/pe.em: Fix spelling in comments. * emultempl/pep.em: Fix spelling in comments. * emultempl/spuelf.em: Fix spelling in comments.
2016-11-27Fix spelling in comments in .def files (gold)Ambrogino Modigliani2-1/+5
* aarch64-reloc.def: Fix spelling in comments.
2016-11-27Fix spelling in comments in Expect scripts (ld)Ambrogino Modigliani5-4/+11
* testsuite/ld-sh/arch/arch.exp: Fix spelling in comments. * testsuite/ld-sh/rd-sh.exp: Fix spelling in comments. * testsuite/ld-sh/sh64/rd-sh64.exp: Fix spelling in comments. * testsuite/ld-undefined/undefined.exp: Fix spelling in comments.
2016-11-27Fix spelling in comments in Expect scripts (gas)Ambrogino Modigliani8-11/+21
* testsuite/gas/all/gas.exp: Fix spelling in comments. * testsuite/gas/cris/cris.exp: Fix spelling in comments. * testsuite/gas/hppa/basic/basic.exp: Fix spelling in comments. * testsuite/gas/hppa/parse/parse.exp: Fix spelling in comments. * testsuite/gas/hppa/reloc/reloc.exp: Fix spelling in comments. * testsuite/gas/sh/arch/arch.exp: Fix spelling in comments. * testsuite/gas/tic4x/tic4x.exp: Fix spelling in comments.
2016-11-27Fix spelling in comments in Assembler files (ld)Ambrogino Modigliani7-9/+18
* testsuite/ld-arm/stm32l4xx-fix-all.s: Fix spelling in comments. * testsuite/ld-arm/thumb2-b-interwork.s: Fix spelling in comments. * testsuite/ld-arm/thumb2-bl.s: Fix spelling in comments. * testsuite/ld-s390/tlspic1.s: Fix spelling in comments. * testsuite/ld-s390/tlspic1_64.s: Fix spelling in comments. * testsuite/ld-scripts/section-match-1.d: Fix spelling in comments.
2016-11-27Fix spelling in comments in Assembler files (gas)Ambrogino Modigliani13-13/+28
* testsuite/gas/arm/local_function.d: Fix spelling in comments. * testsuite/gas/arm/req.s: Fix spelling in comments. * testsuite/gas/arm/vfp1.s: Fix spelling in comments. * testsuite/gas/arm/vfp1_t2.s: Fix spelling in comments. * testsuite/gas/arm/vfp1xD.s: Fix spelling in comments. * testsuite/gas/arm/vfp1xD_t2.s: Fix spelling in comments. * testsuite/gas/mcore/allinsn.s: Fix spelling in comments. * testsuite/gas/mips/24k-triple-stores-5.s: Fix spelling in comments. * testsuite/gas/mips/delay.d: Fix spelling in comments. * testsuite/gas/mips/nodelay.d: Fix spelling in comments. * testsuite/gas/mips/r5900-full.s: Fix spelling in comments. * testsuite/gas/mips/r5900.s: Fix spelling in comments.
2016-11-27Fix spelling in comments in C source files (ld)Ambrogino Modigliani6-7/+15
* deffile.h: Fix spelling in comments. * ld.h: Fix spelling in comments. * ldlang.c: Fix spelling in comments. * ldmisc.c: Fix spelling in comments. * pe-dll.c: Fix spelling in comments.
2016-11-27Fix spelling in comments in C source files (gprof)Ambrogino Modigliani5-4/+11
* basic_blocks.c: Fix spelling in comments. * cg_arcs.c: Fix spelling in comments. * cg_print.c: Fix spelling in comments. * corefile.c: Fix spelling in comments.
2016-11-27Fix spelling in comments in C source files (gold)Ambrogino Modigliani13-16/+31
* aarch64.cc: Fix spelling in comments. * arm.cc: Fix spelling in comments. * icf.cc: Fix spelling in comments. * layout.cc: Fix spelling in comments. * layout.h: Fix spelling in comments. * mips.cc: Fix spelling in comments. * output.h: Fix spelling in comments. * plugin.h: Fix spelling in comments. * script-sections.h: Fix spelling in comments. * script.h: Fix spelling in comments. * stringpool.h: Fix spelling in comments. * tilegx.cc: Fix spelling in comments.
2016-11-27Fix spelling in comments in C source files (gas)Ambrogino Modigliani45-87/+135
* as.h: Fix spelling in comments. * config/obj-ecoff.c: Fix spelling in comments. * config/obj-macho.c: Fix spelling in comments. * config/tc-aarch64.c: Fix spelling in comments. * config/tc-arc.c: Fix spelling in comments. * config/tc-arm.c: Fix spelling in comments. * config/tc-avr.c: Fix spelling in comments. * config/tc-cr16.c: Fix spelling in comments. * config/tc-epiphany.c: Fix spelling in comments. * config/tc-frv.c: Fix spelling in comments. * config/tc-hppa.c: Fix spelling in comments. * config/tc-hppa.h: Fix spelling in comments. * config/tc-i370.c: Fix spelling in comments. * config/tc-m68hc11.c: Fix spelling in comments. * config/tc-m68k.c: Fix spelling in comments. * config/tc-mcore.c: Fix spelling in comments. * config/tc-mep.c: Fix spelling in comments. * config/tc-metag.c: Fix spelling in comments. * config/tc-mips.c: Fix spelling in comments. * config/tc-mn10200.c: Fix spelling in comments. * config/tc-mn10300.c: Fix spelling in comments. * config/tc-nds32.c: Fix spelling in comments. * config/tc-nios2.c: Fix spelling in comments. * config/tc-ns32k.c: Fix spelling in comments. * config/tc-pdp11.c: Fix spelling in comments. * config/tc-ppc.c: Fix spelling in comments. * config/tc-riscv.c: Fix spelling in comments. * config/tc-rx.c: Fix spelling in comments. * config/tc-score.c: Fix spelling in comments. * config/tc-score7.c: Fix spelling in comments. * config/tc-sparc.c: Fix spelling in comments. * config/tc-tic54x.c: Fix spelling in comments. * config/tc-vax.c: Fix spelling in comments. * config/tc-xgate.h: Fix spelling in comments. * config/tc-xtensa.c: Fix spelling in comments. * config/tc-z80.c: Fix spelling in comments. * dwarf2dbg.c: Fix spelling in comments. * input-file.h: Fix spelling in comments. * itbl-ops.c: Fix spelling in comments. * read.c: Fix spelling in comments. * stabs.c: Fix spelling in comments. * symbols.c: Fix spelling in comments. * write.c: Fix spelling in comments. * testsuite/gas/all/itbl-test.c: Fix spelling in comments. * testsuite/gas/tic4x/opclasses.h: Fix spelling in comments.
2016-11-27Fix spelling in comments in C source files (binutils)Ambrogino Modigliani8-8/+18
* dwarf.c: Fix spelling in comments. * dwarf.h: Fix spelling in comments. * objcopy.c: Fix spelling in comments. * od-macho.c: Fix spelling in comments. * rclex.c: Fix spelling in comments. * readelf.c: Fix spelling in comments. * stabs.c: Fix spelling in comments.
2016-11-26Remove verbosity from ui_out_message and friendsSimon Marchi15-68/+69
That concept is never actually used, so it's just a burden. Removing it facilitates the refactoring in upcoming patches. gdb/ChangeLog: * mi/mi-out.c (mi_message): Remove verbosity argument. * ada-tasks.c (print_ada_task_info, info_task, task_command): Update call. * auto-load.c (auto_load_info_scripts): Likewise. * breakpoint.c (breakpoint_1, watchpoints_info, tracepoints_info): Likewise. * cli-out.c (cli_message): Remove verbosity argument. * inferior.c (print_inferior): Update call. * linux-thread-db.c (info_auto_load_libthread_db): Likewise. * probe.c (info_probes_for_ops): Likewise. * skip.c (skip_info): Likewise. * solib.c (info_sharedlibrary_command): Likewise. * symfile.c (load_progress): Likewise. * thread.c (print_thread_info_1): Likewise. * ui-out.c (uo_message, ui_out_message): Remove verbosity argument. (ui_out_get_verblvl): Remove. * ui-out.h (ui_out_message): Remove verbosity argument. (ui_out_get_verblvl): Remove. (message_ftype): Remove verbosity argument.
2016-11-26Constify wrap_here/wrap_hint code pathSimon Marchi7-11/+21
Constify the data path between ui_out_wrap_hint and the wrap_indent global, because we can. It's clearer that the argument passed to wrap_hint is not intended to be modified by the ui_out implementation. gdb/ChangeLog: * mi/mi-out.c (mi_wrap_hint): Constify argument. * cli-out.c (cli_wrap_hint): Likewise. * ui-out.c (ui_out_wrap_hint, uo_wrap_hint): Likewise. * ui-out.h (ui_out_wrap_hint, wrap_hint_ftype): Likewise. * utils.c (wrap_here): Likewise. (wrap_indent): Constify. * utils.h (wrap_here): Constify argument.
2016-11-26Fix return value of uo_redirectSimon Marchi2-2/+6
The wrapper uo_redirect seems like it should return the return value from of implementation function, since callers rely on it, but it doesn't. gdb/ChangeLog: * ui-out.c (uo_redirect): Return the return value from the implementation function.
2016-11-26Remove ui_out_destroySimon Marchi3-36/+5
It's not actually used, and removing it simplifies the upcoming patches a bit. After the whole series, destroying an ui_out object will be simply "delete uiout", which will call the default destructor. gdb/ChangeLog: * ui-out.c (ui_out_destroy, uo_data_destroy): Remove. * ui-out.h (ui_out_destroy): Remove.
2016-11-26Rename ui_out_data to mi_ui_out_dataSimon Marchi2-2/+7
Just a little cleanup, so the name is more consistent with the naming of the equivalent structures of cli and tui. It goes away in subsequent patches anyway, but it might help follow the changes in those patches... gdb/ChangeLog: * mi/mi-out.c (ui_out_data): Rename to ... (mi_ui_out_data): ... this.
2016-11-26Remove unused functions and declarationsSimon Marchi5-50/+13
gdb/ChangeLog: * ui-out.c (_initialize_ui_out): Remove. (ui_out_set_flags): Remove. (ui_out_clear_flags): Remove. * ui-out.h (ui_out_begin_cleanup_end): Remove. (ui_out_begin_cleanup_end): Remove. (ui_out_set_flags): Remove. (ui_out_clear_flags): Remove. * mi/mi-out.c (_initialize_mi_out): Remove. (mi_out_buffered): Remove. * mi/mi-out.h (mi_out_buffered): Remove.
2016-11-27Automatic date update in version.inGDB Administrator1-1/+1
2016-11-26Remove stale commentsSimon Marchi3-5/+5
The default ui_out is gone since commit 23ff98d2fed4a1eaeb815e18cd4169e5aa7aaa60. gdb/ChangeLog: * ui-out.h (struct ui_out_impl): Remove comment. * ui-out.c (struct ui_out): Remove comment.
2016-11-26Automatic date update in version.inGDB Administrator1-1/+1
2016-11-25Remove check requiring void argument to functions with no parameters.John Baldwin2-10/+4
C++ treats an empty parameter list as no parameters unlike C. gdb/ChangeLog: * contrib/ari/gdb_ari.sh (no parameter function): Remove check.
2016-11-25Fix typo in MakefileSimon Marchi2-1/+5
Fix a typo I made in my previous Makefile cleanup series. Thanks to Patrick Monnerat for reporting. gdb/ChangeLog: * Makefile.in: Fix typo.
2016-11-25Fix typos in commentSimon Marchi2-1/+5
gdb/ChangeLog: * record-full.c (record_full_resume): Fix typos in comment.
2016-11-25Fix typo in commentSimon Marchi2-1/+5
gdb/ChangeLog: * infcmd.c (interrupt_command): Fix typo in comment.
2016-11-25gas: fix CBCOND diagnostics for invalid immediate operands.Jose E. Marchesi5-2/+20
This patch fixes two problems in the SPARC assembler: - The diagnostic message Error: Illegal operands: Immediate value in cbcond is out of range. is incorrectly issued for non-CBCOND instructions that feature a simm5 immediate field, such as MPMUL, MONTMUL, etc. - When an invalid immediate operand is used in a CBCOND instruction, two redundant error messages are issued to the user, the second due to a stale fixup (this happens since commit 85024cd8bcb93f4112470ecdbd6c10fc2aea724f). Some diagnostic tests for the CBCOND instructions are also included in the patch. Tested in both sparc64-linux-gnu and sparcv9-linux-gnu targets. gas/ChangeLog: 2016-11-25 Jose E. Marchesi <jose.marchesi@oracle.com> * config/tc-sparc.c (sparc_ip): Avoid emitting a cbcond error messages for non-cbcond instructions. * testsuite/gas/sparc/cbcond-diag.s: New file. * testsuite/gas/sparc/cbcond-diag.l: Likewise. * testsuite/gas/sparc/sparc.exp (gas_64_check): Run cbcond-diag tests.
2016-11-25Prevent problems with section alignment by not shrinking the .rsrc section.Jon Turney2-20/+8
PR ld/20193 * peXXigen.c (rsrc_process_section): Do not shrink the merged .rsrc section.
2016-11-25Automatic date update in version.inGDB Administrator1-1/+1
2016-11-24Do not use std::move when assigning an anonymous object to a unique_ptr.John Baldwin6-14/+23
Using std::move forces an extra copy of the object. These changes fix -Wpessimizing-move warnings from clang. gdb/ChangeLog: * ada-lang.c (create_excep_cond_exprs): Do not use 'std::move'. * ax-gdb.c (agent_eval_command_one): Likewise. (agent_eval_command_one): Likewise. * breakpoint.c (parse_cond_to_aexpr): Likewise. (parse_cmd_to_aexpr): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * parse.c (parse_expression_for_completion): Likewise.
2016-11-24Add noexcept to custom non-throwing new operators.John Baldwin2-2/+7
Both libc++ and libstdc++ declare non-throwing new operators as noexcept and overloads must also be noexcept. This fixes a -Wmissing-exception-spec warning with clang. gdb/ChangeLog: * common/new-op.c (operator new): Mark 'noexcept'. (operator new[]): Likewise.
2016-11-24Optimize byte-aligned copies in copy_bitwise()Andreas Arnez2-4/+28
The function copy_bitwise used for copying DWARF pieces can potentially be invoked for large chunks of data. For instance, consider a large struct one of whose members is currently located in a register. In this case copy_bitwise would still copy the data bitwise in a loop, which is much slower than necessary. This change uses memcpy for the large part instead, if possible. gdb/ChangeLog: * dwarf2loc.c (copy_bitwise): Use memcpy for the middle part, if it is byte-aligned.
2016-11-24Add unit test for copy_bitwiseAndreas Arnez3-2/+151
This adds a unit test for the copy_bitwise function in dwarf2loc.c. With the old (broken) version of copy_bitwise this test would generate the following failure message: (gdb) maintenance selftest Self test failed: copy_bitwise 11000000 != 10000000 (7+2 -> 0) gdb/ChangeLog: 2016-11-24 Andreas Arnez <arnez@linux.vnet.ibm.com> Pedro Alves <palves@redhat.com> * dwarf2loc.c (bits_to_str, check_copy_bitwise) (copy_bitwise_tests): New functions. (_initialize_dwarf2loc): Register the new function copy_bitwise_tests as a unit test. * selftest.c (run_self_tests): Improve the failure message's wording and formatting.
2016-11-24Fix copy_bitwise()Andreas Arnez4-149/+96
When the user writes or reads a variable whose location is described with DWARF pieces (DW_OP_piece or DW_OP_bit_piece), GDB's helper function copy_bitwise is invoked for each piece. The implementation of this function has a bug that may result in a corrupted copy, depending on alignment and bit size. (Full-byte copies are not affected.) This rewrites copy_bitwise, replacing its algorithm by a fixed version, and adding an appropriate test case. Without the fix the new test case fails, e.g.: print def_t $2 = {a = 0, b = 4177919} (gdb) FAIL: gdb.dwarf2/nonvar-access.exp: print def_t Written in binary, the wrong result above looks like this: 01111111011111111111111 Which means that two zero bits have sneaked into the copy of the original all-one bit pattern. The test uses this simple all-one value in order to avoid another GDB bug that causes the DWARF piece of a DW_OP_stack_value to be taken from the wrong end on big-endian architectures. gdb/ChangeLog: * dwarf2loc.c (extract_bits_primitive): Remove. (extract_bits): Remove. (copy_bitwise): Rewrite. Fixes a possible corruption that may occur for non-byte-aligned copies. gdb/testsuite/ChangeLog: * gdb.dwarf2/nonvar-access.exp: Add a test for accessing non-byte-aligned bit fields.
2016-11-24Fix PR12616 - gdb does not implement DW_AT_data_bit_offsetAndreas Arnez4-0/+119
The DW_AT_data_bit_offset attribute was introduced by DWARF V4 and allows specifying the offset of a data member within its containing entity. But although the new attribute was intended to replace DW_AT_bit_offset for this purpose, GDB ignores it, and thus GCC still emits DW_AT_bit_offset instead. See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71669. This change fixes GDB's lack of support for DW_AT_data_bit_offset and adds an appropriate test case. gdb/ChangeLog: PR gdb/12616 * dwarf2read.c (dwarf2_add_field): Handle the DWARF V4 attribute DW_AT_data_bit_offset. gdb/testsuite/ChangeLog: PR gdb/12616 * gdb.dwarf2/nonvar-access.exp: New testcase. Check that GDB respects the DW_AT_data_bit_offset attribute.
2016-11-24[ARM] Bind defined symbol locally in PIEJiong Wang7-1/+37
bfd/ PR target/20737 * elf32-arm.c (elf32_arm_final_link_relocate): Bind defined symbol locally in PIE. ld/ * testsuite/ld-arm/pie-bind-locally-a.s: New test source. * testsuite/ld-arm/pie-bind-locally-b.s: Likewise. * testsuite/ld-arm/pie-bind-locally.d: New testcase. * testsuite/ld-arm/arm-elf.exp: Run new testcase.
2016-11-24Fix snafu parsing $ORIGIN.Nick Clifton2-1/+8
PR ld/20858 * emultempl/elf32.em (_search_needed): Allow for path separator and terminating NUL byte when allocating space for new $ORIGIN path.
2016-11-24RISC-V/bfd: Fix bitsize of R_RISCV_ADD8.Kuan-Lin Chen2-1/+5
bfd/ChangeLog: * bfd/elfxx-riscv.c (howto_table): Fix bitsize of R_RISCV_ADD8.
2016-11-24Automatic date update in version.inGDB Administrator1-1/+1
2016-11-23gdb: Use C++11 std::chronoPedro Alves16-210/+358
This patch fixes a few problems with GDB's time handling. #1 - It avoids problems with gnulib's C++ namespace support On MinGW, the struct timeval that should be passed to gnulib's gettimeofday replacement is incompatible with libiberty's timeval_sub/timeval_add. That's because gnulib also replaces "struct timeval" with its own definition, while libiberty expects the system's. E.g., in code like this: gettimeofday (&prompt_ended, NULL); timeval_sub (&prompt_delta, &prompt_ended, &prompt_started); timeval_add (&prompt_for_continue_wait_time, &prompt_for_continue_wait_time, &prompt_delta); That's currently handled in gdb by not using gnulib's gettimeofday at all (see common/gdb_sys_time.h), but that #undef hack won't work with if/when we enable gnulib's C++ namespace support, because that mode adds compile time warnings for uses of ::gettimeofday, which are hard errors with -Werror. #2 - But there's an elephant in the room: gettimeofday is not monotonic... We're using it to: a) check how long functions take, for performance analysis b) compute when in the future to fire events in the event-loop c) print debug timestamps But that's exactly what gettimeofday is NOT meant for. Straight from the man page: ~~~ The time returned by gettimeofday() is affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the system time). If you need a monotonically increasing clock, see clock_gettime(2). ~~~ std::chrono (part of the C++11 standard library) has a monotonic clock exactly for such purposes (std::chrono::steady_clock). This commit switches to use that instead of gettimeofday, fixing all the issues mentioned above. gdb/ChangeLog: 2016-11-23 Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add common/run-time-clock.c. (HFILES_NO_SRCDIR): Add common/run-time-clock.h. (COMMON_OBS): Add run-time-clock.o. * common/run-time-clock.c, common/run-time-clock.h: New files. * defs.h (struct timeval, print_transfer_performance): Delete declarations. * event-loop.c (struct gdb_timer) <when>: Now a std::chrono::steady_clock::time_point. (create_timer): use std::chrono::steady_clock instead of gettimeofday. Use new instead of malloc. (delete_timer): Use delete instead of xfree. (duration_cast_timeval): New. (update_wait_timeout): Use std::chrono::steady_clock instead of gettimeofday. * maint.c: Include <chrono> instead of "gdb_sys_time.h", <time.h> and "timeval-utils.h". (scoped_command_stats::~scoped_command_stats) (scoped_command_stats::scoped_command_stats): Use std::chrono::steady_clock instead of gettimeofday. Use user_cpu_time_clock instead of get_run_time. * maint.h: Include "run-time-clock.h" and <chrono>. (scoped_command_stats): <m_start_cpu_time>: Now a user_cpu_time_clock::time_point. <m_start_wall_time>: Now a std::chrono::steady_clock::time_point. * mi/mi-main.c: Include "run-time-clock.h" and <chrono> instead of "gdb_sys_time.h" and <sys/resource.h>. (rusage): Delete. (mi_execute_command): Use new instead of XNEW. (mi_load_progress): Use std::chrono::steady_clock instead of gettimeofday. (timestamp): Rewrite in terms of std::chrono::steady_clock, user_cpu_time_clock and system_cpu_time_clock. (timeval_diff): Delete. (print_diff): Adjust to use std::chrono::steady_clock, user_cpu_time_clock and system_cpu_time_clock. * mi/mi-parse.h: Include "run-time-clock.h" and <chrono> instead of "gdb_sys_time.h". (struct mi_timestamp): Change fields types to std::chrono::steady_clock::time_point, user_cpu_time_clock::time and system_cpu_time_clock::time_point, instead of struct timeval. * symfile.c: Include <chrono> instead of <time.h> and "gdb_sys_time.h". (struct time_range): New. (generic_load): Use std::chrono::steady_clock instead of gettimeofday. (print_transfer_performance): Replace timeval parameters with a std::chrono::steady_clock::duration parameter. Adjust. * utils.c: Include <chrono> instead of "timeval-utils.h", "gdb_sys_time.h", and <time.h>. (prompt_for_continue_wait_time): Now a std::chrono::steady_clock::duration. (defaulted_query, prompt_for_continue): Use std::chrono::steady_clock instead of gettimeofday/timeval_sub/timeval_add. (reset_prompt_for_continue_wait_time): Use std::chrono::steady_clock::duration instead of struct timeval. (get_prompt_for_continue_wait_time): Return a std::chrono::steady_clock::duration instead of struct timeval. (vfprintf_unfiltered): Use std::chrono::steady_clock instead of gettimeofday. Use std::string. Use '.' instead of ':'. * utils.h: Include <chrono>. (get_prompt_for_continue_wait_time): Return a std::chrono::steady_clock::duration instead of struct timeval. gdb/gdbserver/ChangeLog: 2016-11-23 Pedro Alves <palves@redhat.com> * debug.c: Include <chrono> instead of "gdb_sys_time.h". (debug_vprintf): Use std::chrono::steady_clock instead of gettimeofday. Use '.' instead of ':'. * tracepoint.c: Include <chrono> instead of "gdb_sys_time.h". (get_timestamp): Use std::chrono::steady_clock instead of gettimeofday.