binutils-gdb.git
7 years ago'make check-headers' for c++ header
Yao Qi [Fri, 13 Jan 2017 14:40:11 +0000 (14:40 +0000)]
'make check-headers' for c++ header

If I run 'make check-headers', I get these errors,
....
In file included from ../../binutils-gdb/gdb/common/common-defs.h:78:0,
                 from ../../binutils-gdb/gdb/defs.h:28,
                 from <command-line>:0:
../../binutils-gdb/gdb/common/common-utils.h:23:18: fatal error: string: No such file or directory
 #include <string>
                  ^

because we still parse headers as c file with a c compiler, which is no
longer true after we moved to C++.  This patch changes it to use C++
compiler and parse headers as c++ headers.

gdb:

2017-01-13  Yao Qi  <yao.qi@linaro.org>

* Makefile.in (checker-headers): Use CXX and CXX_DIALET instead
of CC.  Pass "-x c++-header" instead of "-x c".

7 years agoReturn -1 on memory error in print_insn_m68k
Yao Qi [Fri, 13 Jan 2017 12:27:39 +0000 (12:27 +0000)]
Return -1 on memory error in print_insn_m68k

m68k-dis.c:print_insn_m68k doesn't return -1 on memory error, but GDB
expects it returning -1 on memory error.

opcodes:

2017-01-13  Yao Qi  <yao.qi@linaro.org>

* m68k-dis.c (match_insn_m68k): Extend comments.  Return -1
if FETCH_DATA returns 0.
(m68k_scan_mask): Likewise.
(print_insn_m68k): Update code to handle -1 return value.

7 years agoRemove magic numbers in m68k-dis.c:print_insn_arg
Yao Qi [Fri, 13 Jan 2017 12:21:22 +0000 (12:21 +0000)]
Remove magic numbers in m68k-dis.c:print_insn_arg

When I inspect the return values of disassmblers, I happen to see
various -1/-2/-3 magic numbers are used in m68k-dis.c.  This patch
is to replace them with enum.

-1 and -2 is "clearly documented" in print_ins_arg's comments, but
-3 isn't.  In fact, -3 is returned when FETCH_DATA returns false,
which means memory error (because fetch_data return 0 on memory
error).  So I name enum PRINT_INSN_ARG_MEMORY_ERROR for -3.

This patch is a refactor patch, doesn't affect any functionality.

opcodes:

2017-01-13  Yao Qi  <yao.qi@linaro.org>

* m68k-dis.c (enum print_insn_arg_error): New.
(NEXTBYTE): Replace -3 with
PRINT_INSN_ARG_MEMORY_ERROR.
(NEXTULONG): Likewise.
(NEXTSINGLE): Likewise.
(NEXTDOUBLE): Likewise.
(NEXTDOUBLE): Likewise.
(NEXTPACKED): Likewise.
(FETCH_ARG): Likewise.
(FETCH_DATA): Update comments.
(print_insn_arg): Update comments. Replace magic numbers with
enum.
(match_insn_m68k): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 13 Jan 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix incorrect byte counts.
Cary Coutant [Thu, 12 Jan 2017 19:51:18 +0000 (11:51 -0800)]
Fix incorrect byte counts.

gold/
* object.cc (Sized_relobj_file): Fix byte counts for calls to memmem.

7 years agox86-64: Also generate unwind info for .plt.bnd
H.J. Lu [Thu, 12 Jan 2017 18:30:56 +0000 (10:30 -0800)]
x86-64: Also generate unwind info for .plt.bnd

Also generate unwind info for the .plt.bnd section.  Sine it is the same
as unwind info for the .plt.got section, we use unwind info for the
.plt.got section to cover the the .plt.bnd section.

bfd/

PR ld/21038
* elf64-x86-64.c (elf_x86_64_link_hash_table): Add
plt_bnd_eh_frame.
(elf_x86_64_check_relocs): Create .eh_frame section for the
.plt.bnd section.
(elf_x86_64_size_dynamic_sections): Allocate and initialize
.eh_frame section for the .plt.bnd section.
(elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section
for the .plt.bnd section.

ld/

PR ld/21038
* testsuite/ld-x86-64/pr21038b.d: Updated.
* testsuite/ld-x86-64/pr21038c.d: New file.
* testsuite/ld-x86-64/pr21038c.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr21038c.

7 years agoAdd support for locating separate debug info files via the build-id method.
Nick Clifton [Thu, 12 Jan 2017 16:56:54 +0000 (16:56 +0000)]
Add support for locating separate debug info files via the build-id method.

PR binutils/20876
bfd * opncls.c (find_separate_debug_file): Add include_dirs
parameter.  Only include the directory part of the bfd's filename
in search paths if include_dirs is true.  Add a couple of extra
locations for looking for debug files.
( bfd_follow_gnu_debuglink): Update invocation of
find_separate_debug_file.
(bfd_follow_gnu_debugaltlink): Likewise.
(get_build_id): New function: Finds the build-id of the given bfd.
(get_build_id_name): New function: Computes the name of the
separate debug info file for a bfd, based upon its build-id.
(check_build_id_file): New function: Checks to see if a separate
debug info file exists at the given location, and that its
build-id matches that of the original bfd.
(bfd_follow_build_id_debuglink): New function: Finds a separate
debug info file for a given bfd by using the build-id method.
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Try using the build-id
method of locating a separate debug info file before using the
debuglink method.
* bfd-in2.h: Regenerate.

binutils * NEWS: Mention the new feature.
* testsuite/binutils-all/objdump.exp (test_build_id_debuglink):
New proc to test the location of separate debug info files using
the build-id method.

7 years agoEnable Intel AVX512_VPOPCNTDQ instructions
Igor Tsimbalist [Thu, 12 Jan 2017 16:42:17 +0000 (08:42 -0800)]
Enable Intel AVX512_VPOPCNTDQ instructions

gas/

2017-01-12  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>

* config/tc-i386.c (cpu_arch): Add .avx512_vpopcntdq.
(cpu_noarch): Add noavx512_vpopcntdq.
* doc/c-i386.texi: Document avx512_vpopcntdq, noavx512_vpopcntdq.
* testsuite/gas/i386/i386.exp: Run AVX512_VPOPCNTDQ tests.
* testsuite/gas/i386/avx512_vpopcntdqd-intel.d: New file.
* testsuite/gas/i386/avx512_vpopcntdqd.d: Ditto.
* testsuite/gas/i386/avx512_vpopcntdqd.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdqd-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdqd.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdqd.s: Ditto.

opcodes/

2017-01-12  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>

* i386-dis.c (enum): Add PREFIX_EVEX_0F3855, EVEX_W_0F3855_P_2.
* i386-dis-evex.h (evex_table): Updated.
* i386-gen.c (cpu_flag_init): Add CPU_AVX512_VPOPCNTDQ_FLAGS,
CPU_ANY_AVX512_VPOPCNTDQ_FLAGS. Update CPU_ANY_AVX512F_FLAGS.
(cpu_flags): Add CpuAVX512_VPOPCNTDQ.
* i386-opc.h (enum): (AVX512_VPOPCNTDQ): New.
(i386_cpu_flags): Add cpuavx512_vpopcntdq.
* i386-opc.tbl: Add Intel AVX512_VPOPCNTDQ instructions.
* i386-init.h: Regenerate.
* i386-tbl.h: Ditto.

7 years agoUpdate comment in remote_can_async_p
Simon Marchi [Thu, 12 Jan 2017 16:15:01 +0000 (11:15 -0500)]
Update comment in remote_can_async_p

I find this comment counter intuitive, and it probably predates the
always-target-async change.  AFAIK, remote will always be async, unless
the user explicitly prevents it with "maint set target-async off".

gdb/ChangeLog:

* remote.c (remote_can_async_p): Update comment.

7 years agoUpdate comment in linux_nat_can_async_p
Simon Marchi [Thu, 12 Jan 2017 16:04:53 +0000 (11:04 -0500)]
Update comment in linux_nat_can_async_p

I think this comment is outdated.  Nowadays, linux-nat is always async,
unless the user has explictly turned it off with
"maint set target-async off".

gdb/ChangeLog:

* linux-nat.c (linux_nat_can_async_p): Update comment.

7 years agoRemove dead serial_interface_lookup calls
Simon Marchi [Thu, 12 Jan 2017 15:39:35 +0000 (10:39 -0500)]
Remove dead serial_interface_lookup calls

By inspecting the serial_add_interface calls, I found that the serial
interface names that we have today are:

 - hardwire
 - terminal
 - pipe
 - tcp
 - event

 The calls to serial_interface_lookup with any other names are most
 likely leftovers which can be removed since these serial interfaces
 don't exist anymore.  The commits that removed the "pc" and "parallel"
 interfaces are respectively:

  cb2a4ac5dae478fcd9d6e772530c3aba0576fc7a

and

  e386d4d2fb55042f77d0557a0849ed2464aee7b3

gdb/ChangeLog:

* serial.c (serial_open): Forget about "pc" and "lpt" serial interface.

7 years agoPrevent internal assembler errors if a stabs creation function builds an badly format...
Nick Clifton [Thu, 12 Jan 2017 14:56:13 +0000 (14:56 +0000)]
Prevent internal assembler errors if a stabs creation function builds an badly formatted input string.

* read.c (temp_ilp): New function.  Installs a temporary input
line pointer.
(restore_ilp): New function.  Restores the original input line
pointer.
* read.h (temp_ilp): Prototype.
(restore_ilp): Prototype.
* stabs.c (dot_func_p): Use bfd_boolean type.
(generate_asm_file): Use temp_ilp and restore_ilp.
(stabs_generate_asm_lineno): Likewise.
(stabs_generate_asm_endfunc): Likewise.

7 years agoReturn -1 on memory error in print_insn_msp430
Yao Qi [Thu, 12 Jan 2017 09:40:41 +0000 (09:40 +0000)]
Return -1 on memory error in print_insn_msp430

Disassemblers in opcodes return -1 on memory error, but msp430 doesn't
follow this convention.  If I change GDB not to throw exception in
disassemble_info.memory_error_func and rely on the return value of
disassembler, I'll get the following output.

(gdb) disassemble 0x0,+8
Dump of assembler code from 0x0 to 0x8:
   0x00000000:  .word   0xffff; ????
   0x00000002:  .word   0xffff; ????
   0x00000004:  .word   0xffff; ????
   0x00000006:  .word   0xffff; ????
End of assembler dump.

This patch teaches print_insn_msp430 and its callees to return -1
on memory error.

opcodes:

2017-01-12  Yao Qi  <yao.qi@linaro.org>

* msp430-dis.c (msp430_singleoperand): Return -1 if
msp430dis_opcode_signed returns false.
(msp430_doubleoperand): Likewise.
(msp430_branchinstr): Return -1 if
msp430dis_opcode_unsigned returns false.
(msp430x_calla_instr): Likewise.
(print_insn_msp430): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 12 Jan 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix more compile errors with GCC 4.2.
Cary Coutant [Wed, 11 Jan 2017 21:42:24 +0000 (13:42 -0800)]
Fix more compile errors with GCC 4.2.

gold/
PR gold/21040
* x86_64.cc (Output_data_plt_x86_64_bnd::do_fill_first_plt_entry):
Remove unnecessary 'typename' keyword.
(Output_data_plt_x86_64_bnd::do_fill_plt_entry): Likewise.
(Output_data_plt_x86_64_bnd::fill_aplt_entry): Likewise.
(Output_data_plt_x86_64_bnd::do_fill_tlsdesc_entry): Likewise.
(Output_data_plt_x86_64_bnd::do_write): Likewise.

7 years agoFix compile errors with GCC 4.2.
Cary Coutant [Wed, 11 Jan 2017 19:47:27 +0000 (11:47 -0800)]
Fix compile errors with GCC 4.2.

gold/
PR gold/21040
* x86_64.cc (Output_data_plt_x86_64_bnd::do_fill_first_plt_entry):
Remove unnecessary 'typename' keyword.
(Output_data_plt_x86_64_bnd::do_fill_plt_entry): Likewise.
(Output_data_plt_x86_64_bnd::do_fill_tlsdesc_entry): Likewise.
(Output_data_plt_x86_64_bnd::fill_aplt_entry): Likewise.
* testsuite/copy_test_relro_1.cc (p, b, c, q): Add separate extern
declarations.

7 years agoFix test cases to work for i386.
Cary Coutant [Wed, 11 Jan 2017 19:26:26 +0000 (11:26 -0800)]
Fix test cases to work for i386.

gold/
PR gold/21039
* testsuite/script_test_13.sh: Adjust patterns to work for i386.
* testsuite/script_test_15a.sh: Likewise.
* testsuite/script_test_15b.sh: Likewise.
* testsuite/script_test_15c.sh: Likewise.

7 years agox86-64: Correct unwind info for the BND PLT
H.J. Lu [Wed, 11 Jan 2017 17:16:44 +0000 (09:16 -0800)]
x86-64: Correct unwind info for the BND PLT

Since the BND PLT has

 230: 68 00 00 00 00        pushq  $0x0
 235: f2 e9 e5 ff ff ff     bnd jmpq 220 <.plt>
 23b: 0f 1f 44 00 00        nopl   0x0(%rax,%rax,1)

instead of

 230: ff 25 e2 0d 20 00     jmpq   *0x200de2(%rip)        # 201018
<func>
 236: 68 00 00 00 00        pushq  $0x0
 23b: e9 e0 ff ff ff        jmpq   220 <.plt>

its unwind info should be

DW_CFA_def_cfa_expression (DW_OP_breg7 (rsp): 8; DW_OP_breg16 (rip): 0;
DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl;
DW_OP_plus)

bfd/

PR ld/21038
* elf64-x86-64.c (elf_x86_64_eh_frame_bnd_plt): New.
(elf_x86_64_bnd_arch_bed): Use elf_x86_64_eh_frame_bnd_plt and
elf_x86_64_eh_frame_plt_got.
(elf_x86_64_size_dynamic_sections): Get unwind info from
elf_x86_64_bnd_arch_bed for the BND PLT.

ld/

PR ld/21038
* testsuite/ld-x86-64/pr21038a.d: New file.
* testsuite/ld-x86-64/pr21038a.s: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr21038a and pr21038b.

7 years agoFix typo in lookup_cmd_1 comment
Simon Marchi [Wed, 11 Jan 2017 16:15:26 +0000 (11:15 -0500)]
Fix typo in lookup_cmd_1 comment

gdb/ChangeLog:

* cli/cli-decode.c (lookup_cmd_1): Fix typo in comment.

7 years agoAdd support for x86/64 redox target.
Jeremy Soller [Wed, 11 Jan 2017 15:05:53 +0000 (15:05 +0000)]
Add support for x86/64 redox target.

bfd * config.bfd: Add entries for i686-redox and x86_64-redox.

gas * configure.tgt: Add entry for i386-redox.

ld * configure.tgt: Add entries for x86-redox and x86_64-redox.

7 years agoAdd constructor and destructor to demangle_parse_info
Tom Tromey [Tue, 29 Nov 2016 04:39:47 +0000 (21:39 -0700)]
Add constructor and destructor to demangle_parse_info

This adds a constructor and destructor to demangle_parse_info, and
then changes all the users to use them.  This removes
make_cleanup_cp_demangled_name_parse_free and its single use.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-type.c (typy_legacy_template_argument): Update.
* cp-support.h (struct demangle_parse_info) (demangle_parse_info,
~demangle_parse_info): Declare new members.
(cp_demangled_name_to_comp): Return unique_ptr.
(cp_demangled_name_parse_free)
(make_cleanup_cp_demangled_name_parse_free)
(cp_new_demangle_parse_info): Remove.
* cp-support.c (do_demangled_name_parse_free_cleanup)
(make_cleanup_cp_demangled_name_parse_free): Remove.
(inspect_type, cp_canonicalize_string_full)
(cp_canonicalize_string): Update.
(mangled_name_to_comp): Change return type.
(cp_class_name_from_physname, method_name_from_physname)
(cp_func_name, cp_remove_params): Update.
* cp-name-parser.y (demangle_parse_info): New constructor, from
cp_new_demangle_parse_info.
(~demangle_parse_info): New destructor, from
cp_demangled_name_parse_free.
(cp_merge_demangle_parse_infos): Update.
(cp_demangled_name_to_comp): Change return type.

7 years agoRemove cleanups from execute_gdb_command
Tom Tromey [Tue, 29 Nov 2016 04:11:53 +0000 (21:11 -0700)]
Remove cleanups from execute_gdb_command

This replaces a cleanup in execute_gdb_command with an instance of
std::string.

Testing showed that this originally missed a cleanup that was returned
by prevent_dont_repeat.  This version of the patch changes
prevent_dont_repeat to return a scoped_restore rather than a cleanup.

2017-01-10  Tom Tromey  <tom@tromey.com>

* top.c (prevent_dont_repeat): Change return type.
* python/python.c (execute_gdb_command): Use std::string.
Update.
* guile/guile.c (gdbscm_execute_gdb_command): Update.
* command.h (prevent_dont_repeat): Change return type.
* breakpoint.c (bpstat_do_actions_1): Update.

7 years agoUse scoped_value_mark in dwarf2_evaluate_loc_desc_full
Tom Tromey [Tue, 22 Nov 2016 04:04:59 +0000 (21:04 -0700)]
Use scoped_value_mark in dwarf2_evaluate_loc_desc_full

This changes dwarf2_evaluate_loc_desc_full to use scoped_value_mark.

Note that this function previously called do_cleanup using the same
cleanup multiple times.  I had thought this was buggy, but re-reading
make_my_cleanup2 indicates that it is not.  Nevertheless it is
surprising, and at least one of the calls (the one that is completely
removed in this patch) seems to have been done under the assumption
that it would still have some effect.

2017-01-10  Tom Tromey  <tom@tromey.com>

* value.h (scoped_value_mark::~scoped_value_mark): Call
free_to_mark.
(scoped_value_mark::free_to_mark): New method.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use
scoped_value_mark.

7 years agoAdd scoped_value_mark
Tom Tromey [Tue, 22 Nov 2016 01:02:11 +0000 (18:02 -0700)]
Add scoped_value_mark

This adds a scoped_value_mark class, that records the value mark in
the constructor and then calls value_free_to_mark in the destructor.
It then updates various spots in gdb to use this class, rather than a
cleanup.

It would be better overall to replace "struct value *" with a
shared_ptr, maybe eliminating the need for this class (watchpoints
would perhaps need some new mechanism as well).  However, that's
difficult to do.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-value.c (valpy_dereference, valpy_referenced_value)
(valpy_reference_value, valpy_const_value, valpy_get_address)
(valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
(valpy_getitem, valpy_call, valpy_binop_throw, valpy_negative)
(valpy_absolute, valpy_richcompare_throw): Use scoped_value_mark.
* dwarf2loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
scoped_value_mark.
* dwarf2-frame.c (execute_stack_op): Use scoped_value_mark.
* value.h (scoped_value_mark): New class.

7 years agoRemove make_cleanup_discard_psymtabs
Tom Tromey [Mon, 21 Nov 2016 23:50:20 +0000 (16:50 -0700)]
Remove make_cleanup_discard_psymtabs

This removes make_cleanup_discard_psymtabs in favor of a new class.

2017-01-10  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_build_psymtabs): Use psymtab_discarder.
* psympriv.h (make_cleanup_discard_psymtabs): Don't declare.
* psymtab.c (discard_psymtabs_upto): Remove.
(make_cleanup_discard_psymtabs): Remove.
(struct psymtab_state): Remove.

7 years agoIntroduce and use gdb::unlinker
Tom Tromey [Mon, 21 Nov 2016 23:26:20 +0000 (16:26 -0700)]
Introduce and use gdb::unlinker

This introduces a new class, gdb::unlinker, that unlinks a file in the
destructor.  The user of this class has the option to preserve the
file instead, by calling the "keep" method.

This patch then changes the spots in gdb that use unlink in a cleanup
to use this class instead.  In one spot I went ahead and removed all
the cleanups from the function.

This fixes one latent bug -- do_bfd_delete_cleanup could refer to
freed memory, by decref'ing the BFD before using its filename.

2017-01-10  Tom Tromey  <tom@tromey.com>

* record-full.c (record_full_save_cleanups): Remove.
(record_full_save): Use gdb::unlinker.
* gcore.c (do_bfd_delete_cleanup): Remove.
(gcore_command): Use gdb::unlinker, unique_xmalloc_ptr.  Remove
cleanups.
* dwarf2read.c (unlink_if_set): Remove.
(write_psymtabs_to_index): Use gdb::unlinker.
* common/gdb_unlinker.h: New file.

7 years agoUse class to manage BFD reference counts
Tom Tromey [Mon, 21 Nov 2016 18:12:23 +0000 (11:12 -0700)]
Use class to manage BFD reference counts

This introduces a new specialization of gdb::ref_ptr that can be used
to manage BFD reference counts.  Then it changes most places in gdb to
use this new class, rather than explicit reference-counting or
cleanups.  This patch removes make_cleanup_bfd_unref.

If you look you will see a couple of spots using "release" where a use
of gdb_bfd_ref_ptr would be cleaner.  These will be fixed in the next
patch.

I think this patch fixes some latent bugs.  For example, it seems to
me that previously objfpy_add_separate_debug_file leaked a BFD.

I'm not 100% certain that the macho_symfile_read_all_oso change is
correct.  The existing code here is hard for me to follow.  One goal
of this sort of automated reference counting, though, is to make it
more difficult to make logic errors; so hopefully the code is clear
now.

2017-01-10  Tom Tromey  <tom@tromey.com>

* windows-tdep.c (windows_xfer_shared_library): Update.
* windows-nat.c (windows_make_so): Update.
* utils.h (make_cleanup_bfd_unref): Remove.
* utils.c (do_bfd_close_cleanup, make_cleanup_bfd_unref): Remove.
* symfile.h (symfile_bfd_open)
(find_separate_debug_file_in_section): Return gdb_bfd_ref_ptr.
* symfile.c (read_symbols, symbol_file_add)
(separate_debug_file_exists): Update.
(symfile_bfd_open): Return gdb_bfd_ref_ptr.
(generic_load, reread_symbols): Update.
* symfile-mem.c (symbol_file_add_from_memory): Update.
* spu-linux-nat.c (spu_bfd_open): Return gdb_bfd_ref_ptr.
(spu_symbol_file_add_from_memory): Update.
* solist.h (struct target_so_ops) <bfd_open>: Return
gdb_bfd_ref_ptr.
(solib_bfd_fopen, solib_bfd_open): Return gdb_bfd_ref_ptr.
* solib.c (solib_bfd_fopen, solib_bfd_open): Return
gdb_bfd_ref_ptr.
(solib_map_sections, reload_shared_libraries_1): Update.
* solib-svr4.c (enable_break): Update.
* solib-spu.c (spu_bfd_fopen): Return gdb_bfd_ref_ptr.
* solib-frv.c (enable_break2): Update.
* solib-dsbt.c (enable_break): Update.
* solib-darwin.c (gdb_bfd_mach_o_fat_extract): Return
gdb_bfd_ref_ptr.
(darwin_solib_get_all_image_info_addr_at_init): Update.
(darwin_bfd_open): Return gdb_bfd_ref_ptr.
* solib-aix.c (solib_aix_bfd_open): Return gdb_bfd_ref_ptr.
* record-full.c (record_full_save): Update.
* python/py-objfile.c (objfpy_add_separate_debug_file): Update.
* procfs.c (insert_dbx_link_bpt_in_file): Update.
* minidebug.c (find_separate_debug_file_in_section): Return
gdb_bfd_ref_ptr.
* machoread.c (macho_add_oso_symfile): Change abfd to
gdb_bfd_ref_ptr.
(macho_symfile_read_all_oso): Update.
(macho_check_dsym): Return gdb_bfd_ref_ptr.
(macho_symfile_read): Update.
* jit.c (bfd_open_from_target_memory): Return gdb_bfd_ref_ptr.
(jit_bfd_try_read_symtab): Update.
* gdb_bfd.h (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
(gdb_bfd_ref_policy): New struct.
(gdb_bfd_ref_ptr): New typedef.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
* gcore.h (create_gcore_bfd): Return gdb_bfd_ref_ptr.
* gcore.c (create_gcore_bfd): Return gdb_bfd_ref_ptr.
(gcore_command): Update.
* exec.c (exec_file_attach): Update.
* elfread.c (elf_symfile_read): Update.
* dwarf2read.c (dwarf2_get_dwz_file): Update.
(try_open_dwop_file, open_dwo_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwo_file): Update.
(open_dwp_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwp_file): Update.
* corelow.c (core_open): Update.
* compile/compile-object-load.c (compile_object_load): Update.
* common/gdb_ref_ptr.h (ref_ptr::operator->): New operator.
* coffread.c (coff_symfile_read): Update.
* cli/cli-dump.c (bfd_openr_or_error, bfd_openw_or_error): Return
gdb_bfd_ref_ptr.  Rename.
(dump_bfd_file, restore_command): Update.
* build-id.h (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
* build-id.c (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
(find_separate_debug_file_by_buildid): Update.

7 years agoAdd gdb_ref_ptr.h
Tom Tromey [Mon, 21 Nov 2016 00:48:31 +0000 (17:48 -0700)]
Add gdb_ref_ptr.h

This adds a new gdb_ref_ptr.h, that implements a reference-counting
smart pointer class, where the user of the class supplies a
reference-counting policy object.

This class will be used in the next patch, which changes most explicit
BFD reference counts to use this new type.  Meanwhile, this patch
changes gdbpy_ref to be a specialization of this new class.

This change required adding new nullptr_t overloads some operators in
gdb_ref_ptr.h.  I suspect this was needed because some Python header
redefines NULL, but I'm not certain.

2017-01-10  Tom Tromey  <tom@tromey.com>

* common/gdb_ref_ptr.h: New file.
* python/py-ref.h (struct gdbpy_ref_policy): New.
(gdbpy_ref): Now a typedef.

7 years agoRemove make_cleanup_htab_delete
Tom Tromey [Sun, 20 Nov 2016 20:20:32 +0000 (13:20 -0700)]
Remove make_cleanup_htab_delete

This removes make_cleanup_htab_delete in favor of destructors,
building on an earlier patch that added the htab_up typedef.

Testing revealed that more cleanup-removal work was needed in
dwarf2loc.c, so this version of the patch changes code there to use
unordered_set and vector, removing some more cleanups.

2017-01-10  Tom Tromey  <tom@tromey.com>

* utils.h (make_cleanup_htab_delete): Don't declare.
* utils.c (do_htab_delete_cleanup, make_cleanup_htab_delete):
Remove.
* linespec.c (decode_compound_collector): Add constructor,
destructor.
(lookup_prefix_sym): Remove cleanup.
(symtab_collector): Add constructor, destructor.
(collect_symtabs_from_filename): Remove cleanup.
* disasm.c (do_mixed_source_and_assembly): Use htab_up.
* compile/compile-c-symbols.c (generate_c_for_variable_locations):
Use htab_up.
* gnu-v3-abi.c (gnuv3_print_vtable): Use htab_up.
* dwarf2read.c (dw2_expand_symtabs_matching)
(dw2_map_symbol_filenames, dwarf_decode_macros)
(write_psymtabs_to_index): Use htab_up.
* dwarf2loc.c (func_verify_no_selftailcall)
(call_site_find_chain_1, func_verify_no_selftailcall)
(chain_candidate, call_site_find_chain_1): Use std::unordered_set,
std::vector, gdb::unique_xmalloc_ptr.
(call_sitep): Remove typedef.
(dwarf2_locexpr_baton_eval): Remove unused variable.

7 years agoRemove make_cleanup_py_decref and make_cleanup_py_xdecref
Tom Tromey [Sun, 20 Nov 2016 18:16:41 +0000 (11:16 -0700)]
Remove make_cleanup_py_decref and make_cleanup_py_xdecref

make_cleanup_py_decref and make_cleanup_py_xdecref are now unused, so
this patch removes themm.  Future Python changes should use gdbpy_ref
instead.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python-internal.h (make_cleanup_py_decref)
(make_cleanup_py_xdecref): Don't declare.
* python/py-utils.c (py_decref, make_cleanup_py_decref)
(py_xdecref, make_cleanup_py_xdecref): Remove.

7 years agoUse gdbpy_ref rather than make_cleanup_py_decref
Tom Tromey [Sun, 20 Nov 2016 18:04:40 +0000 (11:04 -0700)]
Use gdbpy_ref rather than make_cleanup_py_decref

This changes some spots in py-framefilter.c to use gdbpy_ref rather
than make_cleanup_py_decref or make_cleanup_py_xdecref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (py_mi_print_variables): Use gdbpy_ref.
(py_print_locals, enumerate_locals, py_print_args): Use gdbpy_ref.

7 years agoUse gdbpy_ref in enumerate_args
Tom Tromey [Sun, 20 Nov 2016 17:57:28 +0000 (10:57 -0700)]
Use gdbpy_ref in enumerate_args

This changes enumerate_args to use gdbpy_ref, and gets rid of many
gotos.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (enumerate_args): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-utils.c
Tom Tromey [Sun, 20 Nov 2016 17:52:25 +0000 (10:52 -0700)]
Use gdbpy_ref in py-utils.c

This changes more places in py-utils.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-utils.c (unicode_to_encoded_string)
(python_string_to_target_string)
(python_string_to_target_python_string)
(python_string_to_host_string, gdbpy_obj_to_string)
(get_addr_from_python): Use gdbpy_ref.

7 years agoUse gdbpy_ref in pyuw_object_attribute_to_pointer
Tom Tromey [Sun, 20 Nov 2016 17:48:51 +0000 (10:48 -0700)]
Use gdbpy_ref in pyuw_object_attribute_to_pointer

This changes pyuw_object_attribute_to_pointer to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-unwind.c (pyuw_object_attribute_to_pointer): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in python.c
Tom Tromey [Sun, 20 Nov 2016 17:46:23 +0000 (10:46 -0700)]
Use gdbpy_ref in python.c

This changes more places in python.c to use gdbpy_ref.

Additionally, previously gdbpy_apply_type_printers would return
EXT_LANG_RC_ERROR if a type printer returned None.  However, that
doesn't seem correct to me; this patch changes it to return
EXT_LANG_RC_NOP in this case.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (eval_python_command, gdbpy_decode_line)
(gdbpy_run_events, gdbpy_start_type_printers)
(gdbpy_apply_type_printers): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-param.c
Tom Tromey [Sun, 20 Nov 2016 17:34:34 +0000 (10:34 -0700)]
Use gdbpy_ref in py-param.c

This changes py-param.c to use gdbpy_ref in a couple more spots.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-param.c (get_doc_string, compute_enum_values): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in py-inferior.c
Tom Tromey [Sun, 20 Nov 2016 17:31:17 +0000 (10:31 -0700)]
Use gdbpy_ref in py-inferior.c

This changes py-inferior.c to use gdbpy_ref in more places.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-inferior.c (find_thread_object, build_inferior_list):
Use gdbpy_ref.

7 years agoUse gdbpy_ref in py_print_frame
Tom Tromey [Sun, 20 Nov 2016 17:27:59 +0000 (10:27 -0700)]
Use gdbpy_ref in py_print_frame

This changes py_print_frame to use gdbpy_ref in more places.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (py_print_frame): Use gdbpy_ref.

7 years agoUse gdbpy_ref in bpfinishpy_out_of_scope
Tom Tromey [Sun, 20 Nov 2016 17:25:29 +0000 (10:25 -0700)]
Use gdbpy_ref in bpfinishpy_out_of_scope

This changes bpfinishpy_out_of_scope to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-finishbreakpoint.c (bpfinishpy_out_of_scope): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in py-cmd.c
Tom Tromey [Sun, 20 Nov 2016 17:23:08 +0000 (10:23 -0700)]
Use gdbpy_ref in py-cmd.c

This changes py-cmd.c to use gdbpy_ref in more places.  This also
fixes a latent memory leak in cmdpy_completer_helper, which
unnecessarily increfs the result of PyObject_CallMethodObjArgs.  This
is not needed because that function returns a new reference.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (cmdpy_completer_helper): Use gdbpy_ref.  Remove
extra incref.
(cmdpy_completer_handle_brkchars, cmdpy_completer, cmdpy_init):
Use gdbpy_ref.

7 years agoUse gdbpy_ref in gdbpy_breakpoint_cond_says_stop
Tom Tromey [Sun, 20 Nov 2016 17:13:31 +0000 (10:13 -0700)]
Use gdbpy_ref in gdbpy_breakpoint_cond_says_stop

This changes gdbpy_breakpoint_cond_says_stop to use gdbpy_ref rather
than explicit reference management.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in archpy_disassemble
Tom Tromey [Sun, 20 Nov 2016 17:10:58 +0000 (10:10 -0700)]
Use gdbpy_ref in archpy_disassemble

This changes archpy_disassemble to use gdbpy_ref.  It also fixes a
latent bug where archpy_disassemble was decref'ing the results of a
all to PyArg_ParseTupleAndKeywords.  This is incorrect because
PyArg_ParseTupleAndKeywords returns borrowed references.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-arch.c (archpy_disassemble): Use gdbpy_ref.  Don't
decref results of PyArg_ParseTupleAndKeywords.

7 years agoChange python_run_simple_file to use gdbpy_ref
Tom Tromey [Sat, 12 Nov 2016 19:08:17 +0000 (12:08 -0700)]
Change python_run_simple_file to use gdbpy_ref

This changes python_run_simple_file to use gdbpy_ref and
unique_xmalloc_ptr.  Thi fixes a latent bug in this function, where
the error path previously ran the cleanups and then referred to one of
the objects just freed.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (python_run_simple_file): Use
unique_xmalloc_ptr, gdbpy_ref.

7 years agoUse gdbpy_ref in py-prettyprint.c
Tom Tromey [Sat, 12 Nov 2016 19:07:16 +0000 (12:07 -0700)]
Use gdbpy_ref in py-prettyprint.c

This changes some spots in py-prettyprint.c to use gdbpy_ref.  It also
changes push_dummy_python_frame to be a class, rather than having it
create a cleanup.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-prettyprint.c (print_stack_unless_memory_error)
(print_string_repr, print_children): Use gdbpy_ref.
(dummy_python_frame): New class.
(dummy_python_frame::dummy_python_frame): Rename from
push_dummy_python_frame.
(py_restore_tstate): Remove.

7 years agoUse gdbpy_ref in py_print_frame
Tom Tromey [Sat, 12 Nov 2016 18:57:45 +0000 (11:57 -0700)]
Use gdbpy_ref in py_print_frame

This changes py_print_frame to use gdbpy_ref in a few spots.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (py_print_frame): Use gdbpy_ref.

7 years agoRemove ensure_python_env
Tom Tromey [Sat, 12 Nov 2016 18:53:50 +0000 (11:53 -0700)]
Remove ensure_python_env

All of gdb has been converted away from ensure_python_env and
varobj_ensure_python_env now; so remove them.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (ensure_python_env, restore_python_env):
Remove.
* python/python-internal.h (ensure_python_env): Don't declare.
* varobj.h (varobj_ensure_python_env): Don't declare.
* varobj.c (varobj_ensure_python_env): Remove.

7 years agoUse gdbpy_enter_varobj in varobj_value_get_print_value
Tom Tromey [Sat, 12 Nov 2016 18:51:59 +0000 (11:51 -0700)]
Use gdbpy_enter_varobj in varobj_value_get_print_value

This changes the last function in varobj.c to use gdbpy_enter_varobj.

2017-01-10  Tom Tromey  <tom@tromey.com>

* varobj.c (varobj_value_get_print_value): Use
gdbpy_enter_varobj.

7 years agoChange type of encoding argument to gdbpy_extract_lazy_string
Tom Tromey [Sat, 12 Nov 2016 18:48:48 +0000 (11:48 -0700)]
Change type of encoding argument to gdbpy_extract_lazy_string

This changes gdbpy_extract_lazy_string's "encoding" argument to be a
unique_xmalloc_ptr.  I chose this rather than std::string because it
can sometimes be NULL.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-prettyprint.c (print_string_repr, print_children):
Update.
* python/py-lazy-string.c (gdbpy_extract_lazy_string): Change type
of "encoding".
* varobj.c (varobj_value_get_print_value): Update.
* python/python-internal.h (gdbpy_extract_lazy_string): Update.

7 years agoUse gdbpy_enter_varobj in more of varobj.c
Tom Tromey [Sat, 12 Nov 2016 18:37:52 +0000 (11:37 -0700)]
Use gdbpy_enter_varobj in more of varobj.c

This converts most of the remaining functions in varobj.c to use
gdbpy_enter_varobj.

2017-01-10  Tom Tromey  <tom@tromey.com>

* varobj.c (varobj_get_display_hint)
(dynamic_varobj_has_child_method, install_new_value_visualizer)
(varobj_set_visualizer, free_variable): Use
gdbpy_enter_varobj.

7 years agoUse gdbpy_enter in python.c
Tom Tromey [Sat, 12 Nov 2016 18:32:05 +0000 (11:32 -0700)]
Use gdbpy_enter in python.c

This changes the last functions in python.c to use gdbpy_enter.  I
split gdbpy_finish_initialization into two functions in order to avoid
some "goto"s.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (python_command): Use gdbpy_enter, gdbpy_ref.
(do_finish_initialization): New function.  Use gdbpy_ref.
(gdbpy_finish_initialization): Use gdbpy_enter.  Call
do_finish_initialization.

7 years agoUse gdbpy_enter in py-param.c
Tom Tromey [Sat, 12 Nov 2016 18:23:36 +0000 (11:23 -0700)]
Use gdbpy_enter in py-param.c

This converts the remaining functions in py-param.c to use
gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-param.c (get_set_value, get_show_value): Use
gdbpy_enter, gdbpy_ref.

7 years agoUse gdbpy_enter in fnpy_call
Tom Tromey [Sat, 12 Nov 2016 18:15:46 +0000 (11:15 -0700)]
Use gdbpy_enter in fnpy_call

This changes fnpy_call to use gdbpy_enter and gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-function.c (fnpy_call): Use gdbpy_enter, gdbpy_ref.

7 years agoUse gdbpy_enter in cmdpy_function
Tom Tromey [Sat, 12 Nov 2016 18:12:41 +0000 (11:12 -0700)]
Use gdbpy_enter in cmdpy_function

This changes cmdpy_function to use gdbpy_enter and gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (cmdpy_function): Use gdbpy_enter, gdbpy_ref.

7 years agoUse gdbpy_enter_varobj in py-varobj.c
Tom Tromey [Wed, 9 Nov 2016 03:14:32 +0000 (20:14 -0700)]
Use gdbpy_enter_varobj in py-varobj.c

This converts the remaining functions in py-varobj.c to use
gdbpy_enter_varobj.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-varobj.c (py_varobj_iter_dtor, py_varobj_iter_next):
Use gdbpy_enter_varobj.

7 years agoIntroduce gdbpy_enter_varobj and use it
Tom Tromey [Tue, 8 Nov 2016 23:18:24 +0000 (16:18 -0700)]
Introduce gdbpy_enter_varobj and use it

This introduces gdbpy_enter_varobj, a subclass of gdbpy_enter; then
changes one function in py-varobj.c to use it.  gdbpy_enter_varobj
takes a varobj as an argument, similar to varobj_ensure_python_env.

2017-01-10  Tom Tromey  <tom@tromey.com>

* varobj.c (gdbpy_enter_varobj): New constructor.
* python/python-internal.h (gdbpy_enter_varobj): New class.
* python/py-varobj.c (py_varobj_get_iterator): Use
gdbpy_enter_varobj.

7 years agoUse gdbpy_enter in py-xmethod.c
Tom Tromey [Tue, 8 Nov 2016 22:47:39 +0000 (15:47 -0700)]
Use gdbpy_enter in py-xmethod.c

This changes the remaining functions in py-xmethod.c to use
gdbpy_enter; using gdbpy_ref and unique_xmalloc_ptr as
appropriate.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-xmethods.c (gdbpy_get_xmethod_result_type): Use
gdbpy_enter, gdbpy_ref, unique_xmalloc_ptr.
(gdbpy_invoke_xmethod): Use gdbpy_ref, gdbpy_enter.
(gdbpy_get_xmethod_arg_types): Use gdbpy_ref,
unique_xmalloc_ptr.
(gdbpy_get_xmethod_arg_types): Use gdbpy_ref, gdbpy_enter.

7 years agoUse gdbpy_ref in invoke_match_method
Tom Tromey [Tue, 8 Nov 2016 22:35:24 +0000 (15:35 -0700)]
Use gdbpy_ref in invoke_match_method

Change invoke_match_method to use gdbpy_ref.
I neglected to convert this function in my earlier series.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-xmethods.c (invoke_match_method): Use
gdbpy_ref.

7 years agoUse gdbpy_enter in gdbpy_get_matching_xmethod_workers
Tom Tromey [Tue, 8 Nov 2016 22:34:55 +0000 (15:34 -0700)]
Use gdbpy_enter in gdbpy_get_matching_xmethod_workers

Change gdbpy_get_matching_xmethod_workers to use gdbpy_enter and
gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): use
gdbpy_enter, gdbpy_ref.

7 years agoUse gdbpy_enter in python_interactive_command
Tom Tromey [Tue, 8 Nov 2016 22:15:01 +0000 (15:15 -0700)]
Use gdbpy_enter in python_interactive_command

This changes python_interactive_command to use gdbpy_enter.
Previously this function was leaving a dangling cleanup -- this is
sort of ok in a command function, but IMO it's still better to clean
up.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (python_interactive_command): Use gdbpy_enter.

7 years agoUse gdbpy_enter in gdbpy_before_prompt_hook
Tom Tromey [Tue, 8 Nov 2016 22:13:49 +0000 (15:13 -0700)]
Use gdbpy_enter in gdbpy_before_prompt_hook

Change gdbpy_before_prompt_hook to use gdbpy_enter and gdbpy_ref.
This also rearranges the function a tiny bit to make it more clear.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_before_prompt_hook): Use gdbpy_enter,
gdbpy_ref.

7 years agoUse gdbpy_enter in py-prettyprint.c
Tom Tromey [Tue, 8 Nov 2016 18:38:22 +0000 (11:38 -0700)]
Use gdbpy_enter in py-prettyprint.c

Change py-prettyprint.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Use
gdbpy_enter, gdbpy_ref, unique_xmalloc_ptr.

7 years agoIntroduce htab_up and use gdbpy_enter in py-framefilter.c
Tom Tromey [Tue, 8 Nov 2016 18:11:55 +0000 (11:11 -0700)]
Introduce htab_up and use gdbpy_enter in py-framefilter.c

This introduces a new "htab_up" typedef, which is a std::unique_ptr
that can call htab_delete.  Then it changes some code in
py-framefilter.c to use both gdbpy_enter and the new htab_up.

2017-01-10  Tom Tromey  <tom@tromey.com>

* utils.h (htab_deleter): New struct.
(htab_up): New typedef.
* python/py-framefilter.c (gdbpy_apply_frame_filter): Use
gdbpy_enter, gdbpy_ref, htab_up.

7 years agoUse gdbpy_enter in py-unwind.c
Tom Tromey [Tue, 8 Nov 2016 03:41:50 +0000 (20:41 -0700)]
Use gdbpy_enter in py-unwind.c

Change py-unwind.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-unwind.c (pending_frame_invalidate): Remove.
(pyuw_sniffer): Use gdbpy_enter and gdbpy_ref.

7 years agoUse gdbpy_enter in py-xmethods.c
Tom Tromey [Mon, 7 Nov 2016 23:13:40 +0000 (16:13 -0700)]
Use gdbpy_enter in py-xmethods.c

Change the simple parts of py-xmethods.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-xmethods.c (gdbpy_free_xmethod_worker_data)
(gdbpy_clone_xmethod_worker_data): Use gdbpy_enter.

7 years agoUse gdbpy_enter in py-type.c
Tom Tromey [Mon, 7 Nov 2016 23:12:17 +0000 (16:12 -0700)]
Use gdbpy_enter in py-type.c

Change py-type.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-type.c (save_objfile_types): Use gdbpy_enter.

7 years agoUse gdbpy_enter in python.c
Tom Tromey [Mon, 7 Nov 2016 23:11:37 +0000 (16:11 -0700)]
Use gdbpy_enter in python.c

Change the simple parts of python.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_eval_from_control_command)
(gdbpy_source_script, gdbpy_run_events)
(gdbpy_source_objfile_script, gdbpy_execute_objfile_script)
(gdbpy_free_type_printers, gdbpy_finish_initialization): Use
gdbpy_enter.

7 years agoUse gdbpy_enter in py-progspace.c
Tom Tromey [Mon, 7 Nov 2016 23:08:36 +0000 (16:08 -0700)]
Use gdbpy_enter in py-progspace.c

Change py-progspace.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-progspace.c (py_free_pspace): Use gdbpy_enter.

7 years agoUse gdbpy_enter in py-objfile.c
Tom Tromey [Mon, 7 Nov 2016 23:07:53 +0000 (16:07 -0700)]
Use gdbpy_enter in py-objfile.c

Change py-objfile.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-objfile.c (py_free_objfile): Use gdbpy_enter.

7 years agoUse gdbpy_enter in py-inferior.c
Tom Tromey [Mon, 7 Nov 2016 23:06:26 +0000 (16:06 -0700)]
Use gdbpy_enter in py-inferior.c

Change py-inferior.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-inferior.c (python_on_normal_stop, python_on_resume)
(python_on_inferior_call_pre, python_on_inferior_call_post)
(python_on_memory_change, python_on_register_change)
(python_inferior_exit, python_new_objfile, add_thread_object)
(delete_thread_object, py_free_inferior): Use gdbpy_enter.

7 years agoUse gdbpy_enter in py-finishbreakpoint.c
Tom Tromey [Mon, 7 Nov 2016 23:03:10 +0000 (16:03 -0700)]
Use gdbpy_enter in py-finishbreakpoint.c

Change py-finishbreakpoint.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-finishbreakpoint.c (bpfinishpy_handle_stop)
(bpfinishpy_handle_exit): Use gdbpy_enter.

7 years agoUse gdbpy_enter in py-cmd.c
Tom Tromey [Mon, 7 Nov 2016 23:02:16 +0000 (16:02 -0700)]
Use gdbpy_enter in py-cmd.c

Change py-cmd.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (cmdpy_destroyer)
(cmdpy_completer_handle_brkchars, cmdpy_completer): Use
gdbpy_enter.

7 years agoUse gdbpy_enter in py-breakpoint.c
Tom Tromey [Mon, 7 Nov 2016 22:59:41 +0000 (15:59 -0700)]
Use gdbpy_enter in py-breakpoint.c

Change py-breakpoint.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
gdbpy_enter.
(gdbpy_breakpoint_has_cond): Likewise.

7 years agoIntroduce gdbpy_enter
Tom Tromey [Mon, 7 Nov 2016 22:56:57 +0000 (15:56 -0700)]
Introduce gdbpy_enter

This introduces gdbpy_enter, a class that can be used to acquire and
release the Python GIL, and also set other Python-related globals used
by gdb.  ensure_python_env is rewritten in terms of this new class.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_enter): New constructor.
(~gdbpy_enter): New destructor.
(restore_python_env, ensure_python_env): Rewrite.
* python/python-internal.h (gdbpy_enter): New class.

7 years agoUse gdbpy_ref in gdbpy_lookup_symbol
Tom Tromey [Mon, 7 Nov 2016 04:51:20 +0000 (21:51 -0700)]
Use gdbpy_ref in gdbpy_lookup_symbol

This changes gdbpy_lookup_symbol to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-symbol.c (gdbpy_lookup_symbol): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-value.c
Tom Tromey [Mon, 7 Nov 2016 04:50:36 +0000 (21:50 -0700)]
Use gdbpy_ref in py-value.c

This changes a few functions in py-value.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-value.c (value_has_field, get_field_flag)
(get_field_type, valpy_getitem, convert_value_from_python): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in python.c
Tom Tromey [Mon, 7 Nov 2016 04:49:34 +0000 (21:49 -0700)]
Use gdbpy_ref in python.c

This changes a couple of functions in python.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_progspaces, gdbpy_objfiles): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in py-prettyprint.c
Tom Tromey [Mon, 7 Nov 2016 04:37:01 +0000 (21:37 -0700)]
Use gdbpy_ref in py-prettyprint.c

This changes several functions in py-prettyprint.c to use
gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-prettyprint.c (search_pp_list)
(find_pretty_printer_from_objfiles)
(find_pretty_printer_from_progspace)
(find_pretty_printer_from_gdb, find_pretty_printer)
(gdbpy_get_display_hint, gdbpy_get_varobj_pretty_printer): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in call_doc_function
Tom Tromey [Mon, 7 Nov 2016 04:29:12 +0000 (21:29 -0700)]
Use gdbpy_ref in call_doc_function

This changes call_doc_function to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-param.c (call_doc_function): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-linetable.c
Tom Tromey [Mon, 7 Nov 2016 04:25:34 +0000 (21:25 -0700)]
Use gdbpy_ref in py-linetable.c

This changes some code in py-linetable.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-linetable.c (build_line_table_tuple_from_pcs)
(ltpy_get_all_source_lines): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-framefilter.c
Tom Tromey [Mon, 7 Nov 2016 04:25:31 +0000 (21:25 -0700)]
Use gdbpy_ref in py-framefilter.c

This changes some code in py-framefilter.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (extract_sym, extract_value)
(get_py_iter_from_func, bootstrap_python_frame_filters): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in gdbpy_breakpoints
Tom Tromey [Mon, 7 Nov 2016 04:25:22 +0000 (21:25 -0700)]
Use gdbpy_ref in gdbpy_breakpoints

This changes gdbpy_breakpoints to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_ref.

7 years agoUse gdbpy_ref in gdbpy_inferiors
Tom Tromey [Mon, 7 Nov 2016 04:23:31 +0000 (21:23 -0700)]
Use gdbpy_ref in gdbpy_inferiors

This changes gdbpy_inferiors to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-inferior.c (gdbpy_inferiors): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-function.c
Tom Tromey [Mon, 7 Nov 2016 04:21:14 +0000 (21:21 -0700)]
Use gdbpy_ref in py-function.c

This changes some code in py-function.c to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-function.c (convert_values_to_python, fnpy_init): Use
gdbpy_ref.

7 years agoUse gdbpy_ref in gdbpy_string_to_argv
Tom Tromey [Mon, 7 Nov 2016 04:10:18 +0000 (21:10 -0700)]
Use gdbpy_ref in gdbpy_string_to_argv

This chanes gdbpy_string_to_argv to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (gdbpy_string_to_argv): Use gdbpy_ref.

7 years agoUse gdbpy_ref in py-type.c
Tom Tromey [Mon, 7 Nov 2016 03:59:51 +0000 (20:59 -0700)]
Use gdbpy_ref in py-type.c

This changes py-type.c to use gdbpy_ref.
This results in simpler logic and the removal of "goto"s.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-type.c (convert_field, make_fielditem, typy_fields)
(typy_range): Use gdbpy_ref.

7 years agoChange event code to use gdbpy_ref
Tom Tromey [Mon, 7 Nov 2016 03:42:32 +0000 (20:42 -0700)]
Change event code to use gdbpy_ref

This changes the event code in the Python layer to use
gdbpy_ref, simplifying the logic in many places.

It also changes evpy_emit_event not to steal a reference to its
argument.  This is simpler to do now that gdbpy_ref is in use;
it's also a reasonable cleanup in its own right.  While doing this I
realized that evpy_emit_event should not be calling gdbpy_print_stack
(all the outermost callers do this if needed), so I removed this as
well.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-threadevent.c (create_thread_event_object): Use
gdbpy_ref.
* python/py-stopevent.c (create_stop_event_object): Simplify.
(emit_stop_event): Use gdbpy_ref.
* python/py-signalevent.c (create_signal_event_object): Use
gdbpy_ref.
* python/py-newobjfileevent.c (create_new_objfile_event_object)
(emit_new_objfile_event, create_clear_objfiles_event_object)
(emit_clear_objfiles_event): Use gdbpy_ref.
* python/py-infevents.c (create_inferior_call_event_object)
(create_register_changed_event_object)
(create_memory_changed_event_object, emit_inferior_call_event)
(emit_memory_changed_event, emit_register_changed_event): Use
gdbpy_ref.
* python/py-exitedevent.c (create_exited_event_object)
(emit_exited_event): Use gdbpy_ref.
* python/py-event.h (evpy_emit_event): Remove
CPYCHECKER_STEALS_REFERENCE_TO_ARG annotation.
* python/py-event.c (evpy_emit_event): Use gdbpy_ref.
* python/py-continueevent.c (emit_continue_event): Use
gdbpy_ref.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted, gdbpy_breakpoint_modified): Use
gdbpy_ref.
* python/py-bpevent.c (create_breakpoint_event_object): Use
gdbpy_ref.

7 years agoIntroduce py-ref.h
Tom Tromey [Sat, 5 Nov 2016 19:43:23 +0000 (13:43 -0600)]
Introduce py-ref.h

This patch introduces class gdbpy_ref, which is a sort of smart
pointer that owns a single Python reference to a PyObject.  This class
acts a bit like unique_ptr, but also a bit like shared_ptr (in that
copies do what you might expect); I considered going solely with
unique_ptr but it seemed quite strange to have a unique_ptr that
actually manages a shared resource.

Subsequent patches use this new class to simplify logic in the Python
layer.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-ref.h: New file.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 11 Jan 2017 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoi386/x32: Align .eh_frame section to 4 bytes
H.J. Lu [Tue, 10 Jan 2017 22:18:11 +0000 (14:18 -0800)]
i386/x32: Align .eh_frame section to 4 bytes

.eh_frame section covering PLT sections should be aligned to 4 bytes
for i386 and x32.

bfd/

* elf32-i386.c (elf_i386_check_relocs): Align .eh_frame section
to 4 bytes.
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Align
.eh_frame section to 4 bytes for x32.
(elf_x86_64_check_relocs): Likewise.

ld/

* testsuite/ld-x86-64/pr20830b.d: Updated.

7 years agoX32: Place .plt.got section after .plt section
H.J. Lu [Tue, 10 Jan 2017 21:57:39 +0000 (13:57 -0800)]
X32: Place .plt.got section after .plt section

This patch places .plt.got section after .plt section for x32.

* emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): New.
* testsuite/ld-x86-64/pr20830.d: Renamed to ...
* testsuite/ld-x86-64/pr20830a.d: This.  Updated.
* testsuite/ld-x86-64/pr20830b.d: New file.
* testsuite/ld-x86-64/x86-64.exp: Rename pr20830 to pr20830a.
Run pr20830b.

7 years agoi386/x86-64: Add unwind info for .plt.got section
H.J. Lu [Tue, 10 Jan 2017 21:31:59 +0000 (13:31 -0800)]
i386/x86-64: Add unwind info for .plt.got section

When there are both PLT and GOT references to the same function symbol,
linker combines GOTPLT and GOT slots into a single GOT slot and create
an entry in .plt.got section for PLT access via the GOT slot.  This
patch adds unwind info for .plt.got section.

bfd/

PR ld/20830
* elf32-i386.c (elf_i386_eh_frame_plt_got): New.
(PLT_GOT_FDE_LENGTH): Likewise.
(elf_i386_plt_layout): Add eh_frame_plt_got and
eh_frame_plt_got_size.
(elf_i386_plt): Updated.
(elf_i386_link_hash_table): Add plt_got_eh_frame.
(elf_i386_check_relocs): Create .eh_frame section for .plt.got.
(elf_i386_size_dynamic_sections): Allocate and initialize
.eh_frame section for .plt.got.
(elf_i386_finish_dynamic_sections): Adjust .eh_frame section for
.plt.got.
(elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and
eh_frame_plt_got_size.
* elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New.
(PLT_GOT_FDE_LENGTH): Likewise.
(elf_x86_64_backend_data): Add eh_frame_plt_got and
eh_frame_plt_got_size.
(elf_x86_64_arch_bed): Updated.
(elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and
eh_frame_plt_got_size.
(elf_x86_64_nacl_arch_bed): Likewise.
(elf_x86_64_link_hash_table): Add plt_got_eh_frame.
(elf_x86_64_check_relocs): Create .eh_frame section for .plt.got.
(elf_x86_64_size_dynamic_sections): Allocate and initialize
.eh_frame section for .plt.got.
(elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section
for .plt.got.

ld/

PR ld/20830
* testsuite/ld-i386/i386.exp: Run pr20830.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr20830.d: New file.
* testsuite/ld-i386/pr20830.s: Likewise.
* testsuite/ld-x86-64/pr20830.d: Likewise.
* testsuite/ld-x86-64/pr20830.s: Likewise.

7 years ago[GOLD] PowerPC64 TOC indirect to TOC relative code editing
Alan Modra [Tue, 10 Jan 2017 21:11:53 +0000 (07:41 +1030)]
[GOLD] PowerPC64 TOC indirect to TOC relative code editing

Doesn't yet trim off the unused TOC entries.

* powerpc.cc (class Powerpc_copy_relocs): New.
(Powerpc_copy_relocs::emit): New function.
(Powerpc_relobj::relatoc_, toc_, no_toc_opt_): New variables.
(Powerpc_relobj::toc_shndx, set_no_toc_opt, no_toc_opt): New inlines.
(Powerpc_relobj::do_relocate_sections): New function.
(Powerpc_relobj::make_toc_relative): Likewise.
(Powerpc_relobj::do_find_special_sections): Stash away .rela.toc
and .toc too.
(ok_lo_toc_insn): Move earlier, and handle more insns.
(Target_powerpc::Scan::local): If optimizing toc accesses, set
no_toc_opt for entries we can't edit.  Check insn validity.
Emit "toc optimization is not supported" warning, downgraded
from error.
(Target_powerpc::Scan::global): Likewise.
(Target_powerpc::Relocate::relocate): Edit TOC indirect code
to TOC relative.  Don't emit "toc optimization is not supported"
error here.

7 years agoDon't use elf_i386_eh_frame_plt directly
H.J. Lu [Tue, 10 Jan 2017 19:30:25 +0000 (11:30 -0800)]
Don't use elf_i386_eh_frame_plt directly

Use eh_frame_plt_size and eh_frame_plt from elf_i386_plt_layout for
.eh_frame covering the .plt section.

* elf32-i386.c (elf_i386_size_dynamic_sections): Set
plt_eh_frame->size to eh_frame_plt_size and use eh_frame_plt.

7 years agoi386: Pass -Wl,-R,tmpdir/-Wl --as-needed to $CC
H.J. Lu [Tue, 10 Jan 2017 18:54:39 +0000 (10:54 -0800)]
i386: Pass -Wl,-R,tmpdir/-Wl --as-needed to $CC

Since linker tests were changed to use $CC, instead of $LD, we need
to pass -Wl,-R,tmpdir and -Wl,--as-needed to $CC.

* testsuite/ld-i386/i386.exp: Pass -Wl,-R,tmpdir to GCC driver.
* testsuite/ld-i386/tls.exp: Likewise.

7 years agoChange return type of ui_out redirect to void
Simon Marchi [Tue, 10 Jan 2017 16:30:47 +0000 (11:30 -0500)]
Change return type of ui_out redirect to void

All implementations of redirect/do_redirect in the ui_out subsystem
always return 0 (success).  We can therefore clean it up and make them
return void.

gdb/ChangeLog:

* cli-out.c (cli_ui_out::do_redirect): Change return type to
void.
* cli-out.h (cli_ui_out::do_redirect): Likewise.
* mi/mi-out.c (mi_ui_out::do_redirect): Likewise.
* mi/mi-out.h (mi_ui_out::do_redirect): Likewise.
* ui-out.c (ui_out::redirect): Likewise.
* ui-out.h (ui_out::redirect, ui_out::do_redirect): Likewise.
* cli/cli-logging.c (set_logging_redirect): Update call site of
ui_out::redirect.
(handle_redirections): Likewise.
* scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* top.c (execute_command_to_string): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.

7 years agoRefactor Sized_relobj_file::do_relocate_sections.
Cary Coutant [Tue, 10 Jan 2017 15:46:30 +0000 (07:46 -0800)]
Refactor Sized_relobj_file::do_relocate_sections.

gold/
* aarch64.cc (AArch64_relobj::do_relocate_sections): Call
Sized_relobj_file::relocate_section_range().
* arm.cc (Arm_relobj::do_relocate_sections): Likewise.
* object.h (Sized_relobj_file::relocate_section_range): New method.
* reloc.cc (Sized_relobj_file::do_relocate_sections): Move
implementation...
(Sized_relobj_file::relocate_section_range): ...to new method.

7 years agoUpdate help of the "frame" command
Simon Marchi [Tue, 10 Jan 2017 15:16:26 +0000 (10:16 -0500)]
Update help of the "frame" command

The help message of the "frame" command states that nothing is printed
if the command is executed from the command file or user-defined
command.  My testing leads me to think that this is not true (at least
today).

  (gdb) bt
  #0  bar (n=17) at test.c:9
  #1  0x00000000004006e0 in foo (v=17) at test.c:13
  #2  0x00000000004006f0 in main () at test.c:21
  (gdb) frame
  #0  bar (n=17) at test.c:9
  9     baz(n);
  (gdb) define foo
  Type commands for definition of "foo".
  End with a line saying just "end".
  >frame 1
  >end
  (gdb) foo
  #1  0x00000000004006e0 in foo (v=17) at test.c:13
  13     bar(v);

This patch simply removes that bit from the help message.  I didn't find
anything corresponding to this in the documentation that needs to be
fixed.

The behavior change corresponding to this documentation change was done
in commit b00771232fab861fb31e42dfd5f6643ba1b43cc9.

gdb/ChangeLog:

* stack.c (_initialize_stack): Update "frame" command help message.

7 years agoFix sleb128-8 regressions.
Tristan Gingold [Tue, 10 Jan 2017 13:43:01 +0000 (14:43 +0100)]
Fix sleb128-8 regressions.

gas/
* testsuite/gas/all/sleb128-8.d: Adjust test.
* testsuite/gas/all/gas.exp (test_cond): Likewise.

7 years agoFix compile time warning about pointer comparison.
Nick Clifton [Tue, 10 Jan 2017 11:45:12 +0000 (11:45 +0000)]
Fix compile time warning about pointer comparison.

PR 21034
* stabs.c (parse_stab_members): Fix thinko checking for g++
version 1 stabs information.

7 years agoUpdated Swedish translations for GAS and LD
Nick Clifton [Tue, 10 Jan 2017 11:28:36 +0000 (11:28 +0000)]
Updated Swedish translations for GAS and LD