aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-05-08[PR python/18291] Fix printing of "disabled" status of xmethod matchers.Siva Chandra4-2/+16
gdb/ChangeLog: PR python/18291 * python/lib/gdb/command/xmethods.py (print_xm_info): Fix typo. Print xmethod matcher status. gdb/testsuite/ChangeLog: PR python/18291 * gdb.python/py-xmethods.exp: Add tests.
2015-05-08Add -mno-shared to x86 assemblerH.J. Lu7-0/+110
On ELF target, the assembler normally generates code which can go into a shared library where non-weak symbols can be preempted. The -mno-shared option tells the assembler to generate code not for a shared library, where non-weak symbols won't be preempted. The resulting code is slightly smaller. This option mainly affects the handling of branch instructions. gas/ * config/tc-i386.c (no_shared): New. (OPTION_MNO_SHARED): Likewise. (elf_symbol_resolved_in_segment_p): Check no_shared. (md_longopts): Add mno-shared. (md_parse_option): Handle OPTION_MNO_SHARED. (md_show_usage): Add -mno-shared. * doc/c-i386.texi: Document -mno-shared. gas/testsuite/ * gas/i386/i386.exp: Run relax-4 and x86-64-relax-3. * gas/i386/relax-4.d: New file. * gas/i386/x86-64-relax-3.d: Likewise.
2015-05-08Fix PR 18208: update /proc/pid/coredump_filter by c codeYao Qi3-9/+31
Hi, We see some fails in gdb.base/coredump-filter.exp when we do remote gdbserver testing, like what I did for arm/aarch64 linux testing or run it with board file remote-gdbserver-on-localhost $ make check RUNTESTFLAGS='--target_board=remote-gdbserver-on-localhost coredump-filter.exp' we find that this line in the test doesn't work as expected, remote_exec target "sh -c \"echo $filter_flag > /proc/$ipid/coredump_filter\"" although such pattern has been used in gdb testsuite somewhere else, but the special thing here is that we redirect the output to /proc/$ipid/coredump_filter on the remote target. DejaGNU will redirect the output from the remote target to local, and looks tcl gets confused by these two redirection. After trying pass different parameters to remote_exec and hacking remote_exec/rsh_exec/local_exec, I got no success, I decide to give up, and try to update /proc/$ipid/coredump_filter by the c code directly. This patch adds a c function set_coredump_filter to update coredump_filter, and GDB calls it. gdb/testsuite: 2015-05-08 Yao Qi <yao.qi@linaro.org> PR gdb/18208 * gdb.base/coredump-filter.c (set_coredump_filter): New function. * gdb.base/coredump-filter.exp (do_save_core): Call inferior function set_coredump_filter, and remove remote_exec call. Remove argument ipid. Callers update. (top level): Don't get inferior's PID.
2015-05-08[gdbserver] Disable conditional breakpoints on no-hardware-single-step targetsYao Qi8-1/+53
GDBserver steps over breakpoint if the condition is false, but if target doesn't support hardware single step, the step over is very simple, if not incorrect, in linux-arm-low.c: /* We only place breakpoints in empty marker functions, and thread locking is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR arm_reinsert_addr (void) { struct regcache *regcache = get_thread_regcache (current_thread, 1); unsigned long pc; collect_register_by_name (regcache, "lr", &pc); return pc; } and linux-mips-low.c does the same. GDBserver sets a breakpoint at the return address of the current function, resume and wait the program hits the breakpoint in order to achieve "breakpoint step over". What if program hits other user breakponits during this "step over"? It is worse if the arm/thumb interworking is considered. Nowadays, GDBserver arm backend unconditionally inserts arm breakpoint, /* Define an ARM-mode breakpoint; we only set breakpoints in the C library, which is most likely to be ARM. If the kernel supports clone events, we will never insert a breakpoint, so even a Thumb C library will work; so will mixing EABI/non-EABI gdbserver and application. */ (const unsigned char *) &arm_breakpoint, (const unsigned char *) &arm_eabi_breakpoint, note that the comments are no longer valid as C library can be compiled in thumb mode. When GDBserver steps over a breakpoint in arm mode function, which returns to thumb mode, GDBserver will insert arm mode breakpoint by mistake and the program will crash. GDBserver alone is unable to determine the arm/thumb mode given a PC address. See how GDB does it in arm-tdep.c:arm_pc_is_thumb. After thinking about how to teach GDBserver inserting right breakpoint (arm or thumb) for a while, I reconsider it from a different direction that it may be unreasonable to run target-side conditional breakpoint for targets without hardware single step. Pedro also pointed this out here https://sourceware.org/ml/gdb-patches/2015-04/msg00337.html This patch is to add a new target_ops hook supports_conditional_breakpoints, and only reply ";ConditionalBreakpoints+" if it is true. On linux targets, supports_conditional_breakpoints returns true if target has hardware single step, on other targets, (win32, lynx, nto, spu), set it to NULL, because conditional breakpoint is a linux-specific feature. gdb/gdbserver: 2015-05-08 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_supports_conditional_breakpoints): New function. (linux_target_ops): Install new target method. * lynx-low.c (lynx_target_ops): Install NULL hook for supports_conditional_breakpoints. * nto-low.c (nto_target_ops): Likewise. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * server.c (handle_query): Check target_supports_conditional_breakpoints. * target.h (struct target_ops) <supports_conditional_breakpoints>: New field. (target_supports_conditional_breakpoints): New macro.
2015-05-08S390: Fix for inadvertently setting 24-bit mode in fill_gregsetAndreas Arnez2-9/+25
On 64-bit S390 platforms, for programs compiled with -m31, it could happen that GDB inadvertently cleared the inferior's 31-bit addressing mode bit and left the inferior running in 24-bit addressing mode. In particular this occurred with checkpoint.exp, when the "restore" command needed to create a new regcache copy: At the time when the PSWM register was copied over, the addressing mode bit was taken from the PSWA register, which was still zero since it had not been copied yet. And when the PSWA register was copied, the addressing mode was not updated again. The fix affects fill_gregset, where the bits "belonging" to each of the PSWA and PSWM registers are now carefully separated. The addressing mode bit is no longer touched when writing PSWM, and -- more importantly -- it *is* written when writing PSWA. gdb/ChangeLog: * s390-linux-nat.c (fill_gregset): Avoid relying on the PSWA register in the regcache when treating the PSWM register, and vice versa.
2015-05-08Skip watch_thread_num.exp on targets without access watchpointsAndreas Arnez2-1/+8
Since watch_thread_num.exp was changed to use access watchpoints, the test case fails on s390 and s390x, since those targets do not support access watchpoints. This patch skips the test case on such targets. gdb/testsuite/ChangeLog: * gdb.base/watch_thread_num.exp: Skip test on targets without access watchpoints.
2015-05-08Automatic date update in version.inGDB Administrator1-1/+1
2015-05-07Optimize branches to non-weak symbols with visibilityH.J. Lu7-4/+137
Branches to global non-weak symbols defined in the same segment with non-default visibility can be optimized the same way as branches to local symbols. gas/ * config/tc-i386.c (elf_symbol_resolved_in_segment_p): New. (md_estimate_size_before_relax): Use it. gas/testsuite/ * gas/i386/i386.exp: Run relax-3 and x86-64-relax-2. * gas/i386/relax-3.d: New file. * gas/i386/relax-3.s: Likewise. * gas/i386/x86-64-relax-2.d: Likewise.
2015-05-07Remove unused td_ta_map_id2thr codeGary Benson2-6/+6
linux-thread-db.c initializes td_ta_map_id2thr but never uses it. This commit removes this dead code. gdb/ChangeLog: * linux-thread-db.c (struct thread_db_info) <td_ta_map_id2thr_p>: Remove field. (try_thread_db_load_1): Remove initialization for the above.
2015-05-07Remove unused td_thr_validate codeGary Benson2-5/+6
linux-thread-db.c initializes td_thr_validate but never uses it. This commit removes this dead code. gdb/ChangeLog: * linux-thread-db.c (struct thread_db_info) <td_thr_validate_p>: Remove field. (try_thread_db_load_1): Remove initialization for the above.
2015-05-07Automatic date update in version.inGDB Administrator1-1/+1
2015-05-06compile: Support relocation to GNU-IFUNCsJan Kratochvil2-0/+9
Calling memcpy() could fail as memcpy() from libc is GNU-IFUNC. gdb/ChangeLog 2015-05-06 Jan Kratochvil <jan.kratochvil@redhat.com> * compile/compile-object-load.c (compile_object_load): Support mst_text_gnu_ifunc.
2015-05-06Code cleanup: compile: Constify some parametersJan Kratochvil3-7/+19
gdb/ChangeLog 2015-05-06 Jan Kratochvil <jan.kratochvil@redhat.com> * compile/compile.c (compile_to_object): Make the cmd_string parameter const. Use new variables for the const compatibility. (eval_compile_command): Make the cmd_string parameter const. * compile/compile.h (eval_compile_command): Make the cmd_string parameter const.
2015-05-06PR server/18081: gdbserver crashes when providing an unexisting binaryPedro Alves4-0/+75
$ ./gdbserver :1234 blah Process blah created; pid = 16471 Cannot exec blah: No such file or directory. Child exited with status 127 Killing process(es): 16471 ../../../../src/binutils-gdb/gdb/gdbserver/linux-low.c:920: A problem internal to GDBserver has been detected. kill_wait_lwp: Assertion `res > 0' failed. GDBserver shouldn't even be trying to kill that process. GDBserver kills or detaches from all processes on exit, and due to a missing mourn_inferior call, GDBserver tries to kill the process that it had already seen exit. Tested on x86_64 Fedora 20. New test included. I emulated what Windows outputs by hacking an error call in linux_create_inferior. gdb/gdbserver/ChangeLog: 2015-05-06 Pedro Alves <palves@redhat.com> PR server/18081 * server.c (start_inferior): If the process exits, mourn it. gdb/testsuite/ChangeLog: 2015-05-06 Pedro Alves <palves@redhat.com> PR server/18081 * gdb.server/non-existing-program.exp: New file.
2015-05-06Get rid of deprecated_init_ui_hookJoel Brobecker5-22/+11
This hook is no longer used, and can therefore be eliminated. gdb/ChangeLog: * defs.h (deprecated_init_ui_hook): Delete. Remove associated comment. * top.c (deprecated_init_ui_hook): Delete. (gdb_init): Remove handling of deprecated_init_ui_hook. * interps.c (clear_interpreter_hooks): Remove handling of deprecated_init_ui_hook. * main.c (captured_main): Update comment.
2015-05-06Make the "info dll" command available on all platform.Joel Brobecker6-11/+22
The "info dll", an alias of the "info sharedlibrary" command, is currently only defined in windows native versions. This patch makes it universally available by moving the alias declaration to solib.c, and adjusts the documentation accordingly. Making it universally available has two benefits: - Windows users moving to a Unix platforms are still able to use the same command for getting the list of shared libraries; - Unix to Windows cross debuggers now provide that command also. gdb/ChangeLog: * solib.c (_initialize_solib): Add "info dll" alias creation. * windows-nat.c (set_windows_aliases): Delete. (_initialize_windows_nat): Remove deprecated_init_ui_hook assignment. * NEWS: Add news entry about "info dll" now being available on all platforms. gdb/doc/ChangeLog: * gdb.texinfo (Files): Add "info dll" documentation. (Cygwin Native): Remove "info dll" documentation.
2015-05-06gas: typo in comment fixed.Jose E. Marchesi2-1/+5
gas/ChangeLog: 2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com> * config/tc-sparc.c: Typo in comment fixed.
2015-05-06gas: added tests for the sparc natural instructions.Jose E. Marchesi5-5/+53
gas/ChangeLog: 2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com> * gas/sparc/natural-32.d: Test ldn, ldna, stn, stna, slln, srln, sran, casn, casna and clrn. * gas/sparc/natural-32.s: Likewise. * gas/sparc/natural.s: Likewise. * gas/sparc/natural.d: Likewise.
2015-05-06gas: support for the sparc %ncc condition codes register.Jose E. Marchesi9-2/+56
gas/ChangeLog: 2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com> * config/tc-sparc.c (sparc_ip): Support the %ncc "natural" condition codes * doc/c-sparc.texi (Sparc-Regs): Document %ncc. gas/testsuite/ChangeLog: 2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com> * gas/sparc/natural.s: New file. * gas/sparc/natural-32.s: Likewise. * gas/sparc/natural.d: Likewise. * gas/sparc/natural-32.d: Likewise. * gas/sparc/sparc.exp (sparc_elf_setup): Run the tests natural and natural-32.
2015-05-06Skip discarded resource sections when building a PE resource table.Toni Spets2-1/+8
PR ld/18372 * peXXigen.c (rsrc_process_section): Skip discarded resource sections.
2015-05-06Update GAS documentation to note that dollar local labels are only supported ↵Nick Clifton2-15/+23
on some targets. * doc/as.texinfo (Dollar Local Labels): Note that these are only supported on some targets.
2015-05-06[AArch64] Record instruction alignment for .inst directiveRenlin Li5-5/+30
2015-05-06 Renlin Li <renlin.li@arm.com> gas/ * config/tc-aarch64.c (mapping_state): Recording alignment before exit. gas/testsuite/ * gas/aarch64/codealign_1.s: New. * gas/aarch64/codealign_1.d: New.
2015-05-06Automatic date update in version.inGDB Administrator1-1/+1
2015-05-05Further document ada-lang.c::value_assign_to_component & fix whitespaces.Joel Brobecker2-11/+22
This patch improves the documentation of ada-lang.c's value_assign_to_component to publish the fact that it also works with not_lval values. And touching this area of the code showed that there were a number of whitespace issues, as well as a formatting issue of the main comment (no leading '*' on each line). This patch fixes those while at it. No functional change, however. gdb/ChangeLog: * ada-lang.c (value_assign_to_component): Reformat and improve documentation. Remove all trailing spaces.
2015-05-05out of line functions nested inside inline functions.Joel Brobecker4-0/+27
This patch improves the handling of out-of-line functions nested inside functions that have been inlined. Consider for instance a situation where function Foo_O224_021 has a function Child1 declared in it, which itself has a function Child2 nested inside Child1. After compiling the program with optimization on, Child1 gets inlined, but not Child2. After inserting a breakpoint on Child2, and running the program until reaching that breakpoint, we get the following backtrace: % gdb foo_o224_021 (gdb) break foo_o224_021.child1.child2 (gdb) run [...] Breakpoint 1, foo_o224_021 () at foo_o224_021.adb:28 28 Child1; (gdb) bt #0 0x0000000000402400 in foo_o224_021 () at foo_o224_021.adb:28 #1 0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23 #2 0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28 GDB reports the wrong function name for frame #0. We also get the same kind of error in the "Breakpoint 1, foo_o224_021 () [...]" message. In both cases, the function name should be foo_o224_021.child1.child2, and the parameters should be "s=...". What happens is that the inlined frame handling does not handle well the case where an inlined function is calling an out-of-line function which was declared inside the inlined function's scope. In particular, looking first at the inlined-frame sniffer when applying to frame #0: /* Calculate DEPTH, the number of inlined functions at this location. */ depth = 0; cur_block = frame_block; while (BLOCK_SUPERBLOCK (cur_block)) { if (block_inlined_p (cur_block)) depth++; cur_block = BLOCK_SUPERBLOCK (cur_block); } What happens is that cur_block starts as the block associated to child2, which is not inlined. We shoud be stopping here, but instead, we keep walking the superblock chain, which takes us all the way to Foo_O224_021's block, via Child2's block. And since Child1 was inlined, we end up with a depth count of 1, wrongly making GDB think that frame #0 is an inlined frame. Same kind of issue inside skip_inline_frames. The fix is to stop checking for inlined frames as soon as we see a block corresponding to a function which is not inlined. This is the behavior we now obtain: (gdb) run [...] Breakpoint 1, foo_o224_021.child1.child2 (s=...) at foo_o224_021.adb:9 9 function Child2 (S : String) return Boolean is (gdb) bt #0 0x0000000000402400 in foo_o224_021.child1.child2 (s=...) at foo_o224_021.adb:9 #1 0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23 #2 0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28 gdb/ChangeLog: * inline-frame.c (inline_frame_sniffer, skip_inline_frames): Stop counting inlined frames as soon as an out-of-line function is found. gdb/testsuite/ChangeLog: * gdb.ada/out_of_line_in_inlined.exp: Add run and "bt" tests.
2015-05-05DWARF: cannot break on out-of-line function nested inside inlined function.Pierre-Marie de Rodat7-6/+159
Consider the following code, which defines a function, Child2, which is itself nested inside Child1: procedure Foo_O224_021 is O1 : constant Object_Type := Get_Str ("Foo"); procedure Child1 is O2 : constant Object_Type := Get_Str ("Foo"); function Child2 (S : String) return Boolean is -- STOP begin for C of S loop Do_Nothing (C); if C = 'o' then return True; end if; end loop; return False; end Child2; R : Boolean; begin R := Child2 ("Foo"); R := Child2 ("Bar"); R := Child2 ("Foobar"); end Child1; begin Child1; end Foo_O224_021; On x86_64-linux, when compiled at -O2, GDB is unable to insert a breakpoint on Child2: % gnatmake -g -O2 foo_o224_021 % gdb foo_o224_021 (gdb) b child2 Function "child2" not defined. (gdb) b foo_o224_021.child1.child2 Function "foo_o224_021.child1.child2" not defined. The problem is caused by the fact that GDB did not create a symbol for Child2, and this, in turn, is caused by the fact that the compiler decided to inline Child1, but not Child2. The DWARF debugging info first provides an abstract instance tree for Child1... <3><1b7b>: Abbrev Number: 29 (DW_TAG_subprogram) <1b7c> DW_AT_name : (indirect string, offset: 0x23f8): foo_o224_021__child1 <1b82> DW_AT_inline : 1 (inlined) <1b83> DW_AT_sibling : <0x1c01> ... where that subprogram is given the DW_AT_inline attribute. Inside that function there is a lexical block which has no PC range (corresponding to the fact that this is the abstract tree): <4><1b87>: Abbrev Number: 30 (DW_TAG_lexical_block) ... inside which our subprogram Child2 is described: <5><1b92>: Abbrev Number: 32 (DW_TAG_subprogram) <1b93> DW_AT_name : (indirect string, offset: 0x2452): foo_o224_021__child1__child2 <1b99> DW_AT_type : <0x1ab1> <1b9d> DW_AT_low_pc : 0x402300 <1ba5> DW_AT_high_pc : 0x57 [...] Then, later on, we get the concrete instance tree, starting at: <3><1c5e>: Abbrev Number: 41 (DW_TAG_inlined_subroutine) <1c5f> DW_AT_abstract_origin: <0x1b7b> <1c63> DW_AT_entry_pc : 0x4025fd <1c6b> DW_AT_ranges : 0x150 ... which refers to Child1. One of that inlined subroutine children is the concrete instance of the empty lexical block we saw above (in the abstract instance tree), which gives the actual address range for this inlined instance: <5><1c7a>: Abbrev Number: 43 (DW_TAG_lexical_block) <1c7b> DW_AT_abstract_origin: <0x1b87> <1c7f> DW_AT_ranges : 0x180 This is the DIE which provides the context inside which we can record Child2. But unfortunately, GDB does not take the abstract origin into account when handling lexical blocks, causing it to miss the fact that this block contains some symbols described in the abstract instance tree. This is the first half of this patch: modifying GDB to follow DW_AT_abstract_origin attributes for lexical blocks. But this not enough to fix the issue, as we're still unable to break on Child2 with just that change. The second issue can be traced to the way inherit_abstract_dies determines the list of DIEs to inherit from. For that, it iterates over all the DIEs in the concrete instance tree, and finds the list of DIEs from the abstract instance tree that are not referenced from the concrete instance tree. As it happens, there is one type of DIE in the concrete instance tree which does reference Child2's DIE, but in fact does otherwise define a concrete instance of the reference DIE; that's (where <0x1b92> is Child2's DIE): <6><1d3c>: Abbrev Number: 35 (DW_TAG_GNU_call_site) <1d3d> DW_AT_low_pc : 0x4026a4 <1d45> DW_AT_abstract_origin: <0x1b92> So, the second part of the patch is to modify inherit_abstract_dies to ignore DW_TAG_GNU_call_site DIEs when iterating over the concrete instance tree. This patch also includes a testcase which can be used to reproduce the issue. Unfortunately, for it to actually pass, a smal patch in GCC is also necessary to make sure that GCC provides lexical blocks' DW_AT_abstract_origin attributes from the concrete tree back to the abstract tree. We hope to be able to submit and integrate that patch in the GCC tree soon. Meanwhile, a setup_xfail has been added. gdb/ChangeLog: 2014-05-05 Pierre-Marie de Rodat <derodat@adacore.com> * dwarf2read.c (inherit_abstract_dies): Skip DW_TAG_GNU_call_site dies while inheriting children of an abstract DIE into a scope. (read_lexical_block_scope): Inherit abstract DIE's for lexical scopes. gdb/testsuite/ChangeLog: * gdb.ada/out_of_line_in_inlined: New testcase.
2015-05-05compare object sizes before comparing them with value_contents_eqJoel Brobecker3-3/+16
This is an issue which I noticed while working on trying to print an array of variant records. For instance, trying to print "A1", an array of elements whose size is variable, defined as follow (see gdb.ada/var_rec_arr testcase): subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; function Ident (R : Record_Type) return Record_Type; type Array_Type is array (Integer range <>) of Record_Type; A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); The debugger sometimes prints the array as follow: (gdb) print A1 $1 = ((i => 0, s => ""), (i => 0, s => ""), (i => 0, s => "")) The problem happens inside the part of the loop printing the array's elements, while trying to count the number of consecutive elements that have the same value (in order to replace them by the "<repeats nnn times>" message when the number exceeds a threshold). In particular, in ada-valprint.c::val_print_packed_array_elements: elttype = TYPE_TARGET_TYPE (type); eltlen = TYPE_LENGTH (check_typedef (elttype)); while (...) { if (!value_contents_eq (v0, value_embedded_offset (v0), v1, value_embedded_offset (v1), eltlen)) break; The value comparison is performed using value_contents_eq but makes the assumption that elttype is not dynamic, which is not always true. In particular, in the case above, elttype is dynamic and therefore its TYPE_LENGTH changes from element to element. As it happens in this case, the eltlen is zero, which causes the call to value_contents_eq to return true, and therefore GDB thinks all 3 elements of the array are equal. This patch fixes the issue by making sure that both v0 and v1, which are values whose type we expect to be resolved, have identical lengths. If not, then the two elements of the array cannot possibly have the same value and we do not even need to do the binary comparison. Unfortunately, this is still not enough to get GDB to print the correct value for our array, because the assumption that v0 and v1 have a type which has been resolved is actually not met. So, the second part of the patch modifies the function that constructed the values to make sure dynamic types do get resolved. gdb/ChangeLog: * ada-valprint.c (val_print_packed_array_elements): Delete variable "len". Add a type-length check when comparing two consecutive elements of the array. Use the element's actual length in call to value_contents_eq. * ada-lang.c (ada_value_primitive_packed_val): Always return a value whose type has been resolved.
2015-05-05testsuite/gdb.ada/var_rec_arr: New testcase.Joel Brobecker5-0/+144
gdb/testsuite/ChangeLog: * gdb.ada/var_rec_arr: New testcase.
2015-05-05GDB crash trying to subscript array of variant record.Joel Brobecker2-0/+17
Consider the following declarations: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; A2 : Array_Type := (1 => (I => 2, S => "AB"), 2 => (I => 1, S => "A"), 3 => (I => 0, S => <>)); Compiled with -fgnat-encodings=minimal, and trying to print one element of our array, valgrind reports an invalid memory access. On certain GNU/Linux boxes, malloc even reports it as well, and causes GDB to crash. (gdb) print a2(1) *** glibc detected *** /[...]/gdb: malloc(): memory corruption: 0x0a30ba48 *** [crash] The invalid memory access occurs because of a simple buffer overflow in ada_value_primitive_packed_val. When this function is called, it is given a bit_size of 128 (or 16 bytes), which corresponds to the stride of our array. But the actual size of each element depends on its value. In particular, A2(1) is a record whose size is only 6 bytes. What happens in our example is that we start building a new value (v) where the element is to be unpacked, with any of its dynamic properties getting resolved as well. We then unpack the data into this value's buffer: unpacked = (unsigned char *) value_contents (v); [...] nsrc = len; [...] while (nsrc > 0) { [...] unpacked[targ] = accum & ~(~0L << HOST_CHAR_BIT); [...] targ += delta; [...] nsrc -= 1; [...] } In the loop above, targ starts at zero (for LE architectures), and len is 16. With delta being +1, we end up iterating 16 times, writing 16 bytes into a 6-bytes buffer. This patch fixes the issue by adjusting BIT_SIZE and recomputing LEN after having resolved our type if the resolved type turns out to be smaller than bit_size. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Recompute BIT_SIZE and LEN if the size of the resolved type is smaller than BIT_SIZE * HOST_CHAR_BIT.
2015-05-05[Ada] array of variant record subscriptingJoel Brobecker2-2/+8
Consider the following (Ada) array... A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); ... where Array_Type is declared as follow: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; Trying to print the value of each element individually does not always work. Printing the value of the first one does: (gdb) p a1(1) $1 = (i => 0, s => "") But printing the value of the subsequent ones often does not. For instance: (gdb) p a1(2) $2 = (i => 1, s => "") <<<--- s should be "A" (gdb) p a1(3) $3 = (i => 2, s => "") <<<--- s should be "AB" I traced the problem to ada_value_primitive_packed_val, which is trying to perform the array subscripting by extracting the value of the corresponding array element into a buffer where the contents is now byte-aligned. The element type that ada_value_primitive_packed_val gets passed is a dynamic type. As it happens, that dynamic type can get resolved thanks to: v = value_at (type, value_address (obj)); type = value_type (v); However, obj represents the array, so the address given in the call to value_at represents the value of the first element. As a result, the solution of component S's upper bound always gets resolved based on the value of component I in the first element of the array, whose value is 0, thus leading to GDB mistakely resolving the element type where S's upper bound is always 0. The proper fix would be to systematically resolve the element type first. But, this requires us to extract-and-realign the element's value so as to be able to pass it as "valaddr" to resolve_dynamic_type. In the meantime, it's easy to make the situation a little better by passing "value_address (obj) + offset" as the object address. This only works when BIT_OFFSET is nul, but that should be the case when the element type is anything but a scalar, which seems to be the only situation where it seems important to resolve the type now. And we're not that worse off otherwise. But we'll try to find a better solution in a separate patch. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Use a more correct address in call to value_at. Adjust call to value_address accordingly.
2015-05-05[Ada] Resolve dynamic type before trying to print it.Joel Brobecker2-0/+7
This is another required step towards trying to print the value of an array of variant records. For instance: A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); ... where Array_Type is an array of records whose size is variable: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; What happens is that the ada-valprint modules gets passed an array whose element type is not resolved yet (since each element of the array needs to be resolved separately). the module then recurses, and eventually gets called with the first element of the array. But because the element hasn't been resolved yet, we end up having trouble printing its value soon after. This patch fixes the issue by calling resolve_dynamic_type before trying to print it. With this patch, GDB is finally able to print the complete value for variable "A1": (gdb) p a1 $1 = ((i => 0, s => ""), (i => 1, s => "A"), (i => 2, s => "AB")) gdb/ChangeLog: * ada-valprint.c (ada_val_print_1): Resolve TYPE before trying to print it.
2015-05-05Add valaddr support in dynamic property resolution.Joel Brobecker8-11/+45
This is the second part of enhancing the debugger to print the value of arrays of records whose size is variable when only standard DWARF info is available (no GNAT encoding). For instance: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); Currently, GDB prints the following output: (gdb) p a1 $1 = ( The error happens while the ada-valprint module is trying to print the value of an element of our array. Because of the fact that the array's element (type Record_Type) has a variant size, the DWARF info for our array provide the array's stride: <1><749>: Abbrev Number: 10 (DW_TAG_array_type) <74a> DW_AT_name : (indirect string, offset: 0xb6d): pck__T18s <74e> DW_AT_byte_stride : 16 <74f> DW_AT_type : <0x6ea> And because our array has a stride, ada-valprint treats it the same way as packed arrays (see ada-valprint.c::ada_val_print_array): if (TYPE_FIELD_BITSIZE (type, 0) > 0) val_print_packed_array_elements (type, valaddr, offset_aligned, 0, stream, recurse, original_value, options); The first thing that we should notice in the call above is that the "valaddr" buffer and the associated offset (OFFSET_ALIGNED) is passed, but that the corresponding array's address is not. This can be explained by looking inside val_print_packed_array_elements, where we see that the function unpacks each element of our array from the buffer alone (ada_value_primitive_packed_val), and then prints the resulting artificial value instead: v0 = ada_value_primitive_packed_val (NULL, valaddr + offset, (i0 * bitsize) / HOST_CHAR_BIT, (i0 * bitsize) % HOST_CHAR_BIT, bitsize, elttype); [...] val_print (elttype, value_contents_for_printing (v0), value_embedded_offset (v0), 0, stream, recurse + 1, v0, &opts, current_language); Of particular interest, here, is the fact that we call val_print with a null address, which is OK, since we're providing a buffer instead (value_contents_for_printing). Also, providing an address might not always possible, since packing could place elements at boundaries that are not byte-aligned. Things go south when val_print tries to see if there is a pretty-printer that could be applied. In particular, one of the first things that the Python pretty-printer does is to create a value using our buffer, and the given address, which in this case is null (see call to value_from_contents_and_address in gdbpy_apply_val_pretty_printer). value_from_contents_and_address, in turn immediately tries to resolve the type, using the given address, which is null. But, because our array element is a record containing an array whose bound is the value of one of its elements (the "s" component), the debugging info for the array's upper bound is a reference... <3><71a>: Abbrev Number: 7 (DW_TAG_subrange_type) <71b> DW_AT_type : <0x724> <71f> DW_AT_upper_bound : <0x703> ... to component "i" of our record... <2><703>: Abbrev Number: 5 (DW_TAG_member) <704> DW_AT_name : i <706> DW_AT_decl_file : 2 <707> DW_AT_decl_line : 6 <708> DW_AT_type : <0x6d1> <70c> DW_AT_data_member_location: 0 ... where that component is located at offset 0 of the start of the record. dwarf2_evaluate_property correctly determines the offset where to load the value of the bound from, but then tries to read that value from inferior memory using the address that was given, which is null. See case PROP_ADDR_OFFSET in dwarf2_evaluate_property: val = value_at (baton->offset_info.type, pinfo->addr + baton->offset_info.offset); This triggers a memory error, which then causes the printing to terminate. Since there are going to be situations where providing an address alone is not going to be sufficient (packed arrays where array elements are not stored at byte boundaries), this patch fixes the issue by enhancing the type resolution to take both address and data. This follows the same principle as the val_print module, where both address and buffer ("valaddr") can be passed as arguments. If the data has already been fetched from inferior memory (or provided by the debugging info in some form -- Eg a constant), then use that data instead of reading it from inferior memory. Note that this should also be a good step towards being able to handle dynamic types whose value is stored outside of inferior memory (Eg: in a register). With this patch, GDB isn't able to print all of A1, but does perform a little better: (gdb) p a1 $1 = ((i => 0, s => , (i => 1, s => , (i => 2, s => ) There is another issue which is independent of this one, and will therefore be patched separately. gdb/ChangeLog: * dwarf2loc.h (struct property_addr_info): Add "valaddr" field. * dwarf2loc.c (dwarf2_evaluate_property): Add handling of pinfo->valaddr. * gdbtypes.h (resolve_dynamic_type): Add "valaddr" parameter. * gdbtypes.c (resolve_dynamic_struct): Set pinfo.valaddr. (resolve_dynamic_type_internal): Set pinfo.valaddr. Add handling of addr_stack->valaddr. (resolve_dynamic_type): Add "valaddr" parameter. Set pinfo.valaddr field. * ada-lang.c (ada_discrete_type_high_bound): Update call to resolve_dynamic_type. (ada_discrete_type_low_bound): Likewise. * findvar.c (default_read_var_value): Likewise. * value.c (value_from_contents_and_address): Likewise.
2015-05-05preserve the bit stride when resolving an array type.Joel Brobecker2-3/+8
Consider the following (Ada) variable... A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); ... where Array_Type is an array of records whose size is variable: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; Trying to print the value of this array currently results in the following error: (gdb) p a1 Cannot access memory at address 0x61c000 What happens in this case, is that the compiler describes our array as an array with a specific stride (and bounds being static 1..3): <1><749>: Abbrev Number: 10 (DW_TAG_array_type) <74a> DW_AT_name : (indirect string, offset: 0xb6d): pck__T18s <74e> DW_AT_byte_stride : 16 <74f> DW_AT_type : <0x6ea> <2><757>: Abbrev Number: 11 (DW_TAG_subrange_type) <758> DW_AT_type : <0x75e> <75c> DW_AT_upper_bound : 3 This is because we cannot use, in this case, the size of the record to determine that stride, since the size of the record depends on its contents. So the compiler helps us by providing that stride. The problems start when trying to resolve that type. Because the elements contained in that array type are dynamic, the array itself is considered dynamic, and thus we end up creating a resolved version of that array. And during that resolution, we were not handling the case where the array had a stride. See gdbtypes.c::resolve_dynamic_array... return create_array_type (copy_type (type), elt_type, range_type); As a result, we created an array whose stride was based on the size of elt_type, which a record whose size isn't static and irrelevant regardless. This patch fixes is by calling create_array_type_with_stride instead. As it happens, there is another issue for us to be able to print the value of our array, but those are independent of this patch and will be handled separately. For now, the patch allows us to get rid of the first error, and the output is now: (gdb) p a1 $1 = ( gdb/ChangeLog: * gdbtypes.c (resolve_dynamic_array): Use create_array_type_with_stride instead of create_array_type.
2015-05-05[AARCH64] Positively emit symbols for alignmentRenlin Li7-14/+63
2015-05-05 Renlin Li <renlin.li@arm.com> gas/ * config/tc-aarch64.c (aarch64_init_frag): Always generate mapping symbols. gas/testsuite/ * gas/aarch64/mapping_5.d: New. * gas/aarch64/mapping_5.s: New. * gas/aarch64/mapping_6.d: New. * gas/aarch64/mapping_6.s: New.
2015-05-05Add support to the MSP430 linker for the automatic placement of code and ↵Nick Clifton8-16/+369
data into either low or high memory regions. gas * config/tc-msp430.c (MAX_OP_LEN): Increase to 4096. (msp430_make_init_symbols): New function. (msp430_section): Call it. (msp430_frob_section): Likewise. ld * emulparams/msp430elf.sh (TEMPLATE_NAME): Change to msp430. * scripttempl/msp430.sc (.text): Add .lower.text and .either.text. (.data): Add .lower.data and .either.data. (.bss): Add .lower.bss and .either.bss. (.rodata): Add .lower.rodata and .either.rodata. * emultempl/msp430.em: New file. Implements a new orphan placement algorithm that divides sections between lower and upper memory regions. * Makefile.am (emsp430elf.c): Depend upon msp430.em. *emsp430X.c): Likewise. * Makefine.in: Regenerate.
2015-05-05xtensa: optimize trampolines relaxationMax Filippov2-27/+207
Currently every fixup in the current segment is checked when relaxing trampoline frag. This is very expensive. Make a searchable array of fixups pointing at potentially oversized jumps at the beginning of every relaxation pass and only check subset of this cache in the reach of single jump from the trampoline frag currently being relaxed. Original profile: % time self children called name ----------------------------------------- 370.16 593.38 12283048/12283048 relax_segment 98.4 370.16 593.38 12283048 xtensa_relax_frag 58.91 269.26 2691463834/2699602236 xtensa_insnbuf_from_chars 68.35 68.17 811266668/813338977 S_GET_VALUE 36.85 29.51 2684369246/2685538060 xtensa_opcode_decode 28.34 8.84 2684369246/2685538060 xtensa_format_get_slot 12.39 5.94 2691463834/2699775044 xtensa_format_decode 0.03 4.60 4101109/4101109 relax_frag_for_align 0.18 1.76 994617/994617 relax_frag_immed 0.07 0.09 24556277/24851220 new_logical_line 0.06 0.00 12283048/14067410 as_where 0.04 0.00 7094588/15460506 xtensa_format_num_slots 0.00 0.00 1/712477 xtensa_insnbuf_alloc ----------------------------------------- Same data, after optimization: % time self children called name ----------------------------------------- 0.51 7.47 12283048/12283048 relax_segment 58.0 0.51 7.47 12283048 xtensa_relax_frag 0.02 4.08 4101109/4101109 relax_frag_for_align 0.18 1.39 994617/994617 relax_frag_immed 0.01 0.98 555/555 xtensa_cache_relaxable_fixups 0.21 0.25 7094588/16693271 xtensa_insnbuf_from_chars 0.06 0.12 24556277/24851220 new_logical_line 0.06 0.00 7094588/15460506 xtensa_format_num_slots 0.02 0.04 7094588/16866079 xtensa_format_decode 0.05 0.00 12283048/14067410 as_where 0.00 0.00 1/712477 xtensa_insnbuf_alloc 0.00 0.00 93808/93808 xtensa_find_first_cached_fixup ----------------------------------------- 2015-05-02 Max Filippov <jcmvbkbc@gmail.com> gas/ * config/tc-xtensa.c (cached_fixupS, fixup_cacheS): New typedefs. (struct cached_fixup, struct fixup_cache): New structures. (fixup_order, xtensa_make_cached_fixup), (xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups), (xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup), (xtensa_add_cached_fixup): New functions. (xtensa_relax_frag): Cache fixups pointing at potentially oversized jumps at the beginning of every relaxation pass. Only check subset of this cache in the reach of single jump from the trampoline frag currently being relaxed.
2015-05-05Automatic date update in version.inGDB Administrator1-1/+1
2015-05-04Automatic date update in version.inGDB Administrator1-1/+1
2015-05-03Automatic date update in version.inGDB Administrator1-1/+1
2015-05-02Change Section_id type to use Relobj* instead of Object*.Cary Coutant12-43/+80
2015-04-29 Cary Coutant <cary@google.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com> gold/ * gc.h (Garbage_collection::is_section_garbage): Change Object* to Relobj*. (Garbage_collection::add_reference): Likewise. (Garbage_collection::gc_process_relocs): Likewise. Don't push object/shndx pair onto *secvec for dynamic objects. Don't follow relocations pointing to dynamic objects for GC. * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::get_folded_section): Likewise. * icf.h: (Icf::get_folded_section): Likewise. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::section_has_function_pointers): Likewise. (Icf::set_section_has_function_pointers): Likewise. * object.h (Section_id): Likewise. (Const_section_id): Likewise. * output.cc (Output_section::update_section_layout): Likewise. * output.h: (Output_section_lookup_maps::find_relaxed_input_section): Likewise. * plugin.cc (update_section_order): Likewise. (unique_segment_for_sections): Likewise. * powerpc.cc (Powerpc_relobj::add_reference): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. (Target_powerpc::gc_process_relocs): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. * symtab.cc (Symbol_table::is_section_folded): Likewise. (Symbol_table::gc_mark_symbol): Likewise. * symtab.h: (Symbol_table::is_section_folded): Likewise. * target.h: (Sized_target::gc_add_reference): Likewise. (Sized_target::do_gc_add_reference): Likewise.
2015-05-02Automatic date update in version.inGDB Administrator1-1/+1
2015-05-01Fix typos in previous patch.DJ Delorie2-6/+11
* config/rl78-parse.y (MULU): Remove ISA_G14. (MULH, DIVHU, DIVWU, MACHI, MACH): Update error strings.
2015-05-01Sync filenames.h with gccH.J. Lu2-0/+11
Merge with gcc: 2014-11-11 Anthony Brandon <anthony.brandon@gmail.com> Manuel López-Ibáñez <manu@gcc.gnu.org> PR driver/36312 * filenames.h: Add prototype for canonical_filename_eq.
2015-05-01Configure zlib with --enable-host-shared for shared bfdH.J. Lu5-8/+44
When bfd is configured as a shared library, we need to configure zlib with --enable-host-shared since zlib is used by bfd. PR ld/18355 * Makefile.def: Add extra_configure_flags to host zlib. * configure.ac (extra_host_zlib_configure_flags): New. Set to --enable-host-shared When bfd is to be built as shared library. AC_SUBST. * Makefile.in: Regenerated. * configure: Likewise.
2015-05-01Remove i386_elf_emit_arch_noteH.J. Lu7-47/+23
This x86 assembler patch: https://sourceware.org/ml/binutils/2001-11/msg00344.html generates a .note section for .arch directive so that GDB can tell which architecture an i386 binary belongs: https://sourceware.org/ml/binutils/2001-11/msg00271.html However, x86 assembly code can have any instructions. A .note section doesn't help. This patch removes it. gas/ * config/tc-i386.c (i386_elf_emit_arch_note): Removed. * config/tc-i386.h (md_end): Likewise. (i386_elf_emit_arch_note): Likewise. gas/testsuite/ * gas/i386/i386.exp: Run note. * gas/i386/note.d: New file. * gas/i386/note.s: Likewise.
2015-05-01Support ix86-*-elf*H.J. Lu4-2/+10
bfd/ * config.bfd: Support i[3-7]86-*-elf*. gas/ * configure.tgt: Support i386-*-elf*.
2015-05-01Automatic date update in version.inGDB Administrator1-1/+1
2015-04-30Make RL78 disassembler and simulator respect ISA for mul/divDJ Delorie24-467/+706
[gas] * config/rl78-defs.h (rl78_isa_g10): New. (rl78_isa_g13): New. (rl78_isa_g14): New. * config/rl78-parse.y (ISA_G10): New. (ISA_G13): New. (ISA_G14): New. (MULHU, MULH, MULU, DIVHU, DIVWU, MACHU, MACH): Use them. * config/tc-rl78.c (rl78_isa_g10): New. (rl78_isa_g13): New. (rl78_isa_g14): New. [gdb] * rl78-tdep.c (rl78_analyze_prologue): Pass RL78_ISA_DEFAULT to rl78_decode_opcode [include] * dis-asm.h (print_insn_rl78_g10): New. (print_insn_rl78_g13): New. (print_insn_rl78_g14): New. (rl78_get_disassembler): New. * opcode/rl78.h (RL78_Dis_Isa): New. (rl78_decode_opcode): Add ISA parameter. [opcodes] * disassemble.c (disassembler): Choose suitable disassembler based on E_ABI. * rl78-decode.opc (rl78_decode_opcode): Take ISA parameter. Use it to decode mul/div insns. * rl78-decode.c: Regenerate. * rl78-dis.c (print_insn_rl78): Rename to... (print_insn_rl78_common): ...this, take ISA parameter. (print_insn_rl78): New. (print_insn_rl78_g10): New. (print_insn_rl78_g13): New. (print_insn_rl78_g14): New. (rl78_get_disassembler): New. [sim] * rl78/cpu.c (g14_multiply): New. * rl78/cpu.h (g14_multiply): New. * rl78/load.c (rl78_load): Decode ISA completely. * rl78/main.c (main): Expand -M to include other ISAs. * rl78/rl78.c (decode_opcode): Decode based on ISA. * rl78/trace.c (rl78_disasm_fn): New. (sim_disasm_init): Reset it. (sim_disasm_one): Get correct disassembler for ISA.
2015-04-30Use "else if" on cpu_arch_isaH.J. Lu2-1/+6
* config/tc-i386.c (i386_target_format): Use "else if" on cpu_arch_isa.
2015-04-30Fix handling of relocs for the MeP target.Nick Clifton7-19/+53
bfd PR 18317 * elf32-mep.c (MEPREL): Use bfd_elf_generic_reloc instead of mep_reloc. (mep_reloc): Delete unused function. bin * readelf.c (get_machine_flags): Add description of MeP flags. tests * binutils-all/objdump.exp (cpus_expected): Add MeP CPU names.