aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-04-04objdump/opcodes: add syntax highlighting to disassembler outputAndrew Burgess8-40/+371
This commit adds the _option_ of having disassembler output syntax highlighted in objdump. This option is _off_ by default. The new command line options are: --disassembler-color=off # The default. --disassembler-color=color --disassembler-color=extended-color I have implemented two colour modes, using the same option names as we use of --visualize-jumps, a basic 8-color mode ("color"), and an extended 8bit color mode ("extended-color"). The syntax highlighting requires that each targets disassembler be updated; each time the disassembler produces some output we now pass through an additional parameter indicating what style should be applied to the text. As updating all target disassemblers is a large task, the old API is maintained. And so, a user of the disassembler (i.e. objdump, gdb) must provide two functions, the current non-styled print function, and a new, styled print function. I don't currently have a plan for converting every single target disassembler, my hope is that interested folk will update the disassemblers they are interested in. But it is possible some might never get updated. In this initial series I intend to convert the RISC-V disassembler completely, and also do a partial conversion of the x86 disassembler. Hopefully having the x86 disassembler at least partial converted will allow more people to try this out easily and provide feedback. In this commit I have focused on objdump. The changes to GDB at this point are the bare minimum required to get things compiling, GDB makes no use of the styling information to provide any colors, that will come later, if this commit is accepted. This first commit in the series doesn't convert any target disassemblers at all (the next two commits will update some targets), so after this commit, the only color you will see in the disassembler output, is that produced from objdump itself, e.g. from objdump_print_addr_with_sym, where we print an address and a symbol name, these are now printed with styling information, and so will have colors applied (if the option is on). Finally, my ability to pick "good" colors is ... well, terrible. I'm in no way committed to the colors I've picked here, so I encourage people to suggest new colors, or wait for this commit to land, and then patch the choice of colors. I do have an idea about using possibly an environment variable to allow the objdump colors to be customised, but I haven't done anything like that in this commit, the color choices are just fixed in the code for now. binutils/ChangeLog: * NEWS: Mention new feature. * doc/binutils.texi (objdump): Describe --disassembler-color option. * objdump.c (disassembler_color): New global. (disassembler_extended_color): Likewise. (disassembler_in_comment): Likewise. (usage): Mention --disassembler-color option. (long_options): Add --disassembler-color option. (objdump_print_value): Use fprintf_styled_func instead of fprintf_func. (objdump_print_symname): Likewise. (objdump_print_addr_with_sym): Likewise. (objdump_color_for_disassembler_style): New function. (objdump_styled_sprintf): New function. (fprintf_styled): New function. (disassemble_jumps): Use disassemble_set_printf, and reset disassembler_in_comment. (null_styled_print): New function. (disassemble_bytes): Use disassemble_set_printf, and reset disassembler_in_comment. (disassemble_data): Update init_disassemble_info call. (main): Handle --disassembler-color option. include/ChangeLog: * dis-asm.h (enum disassembler_style): New enum. (struct disassemble_info): Add fprintf_styled_func field, and created_styled_output field. (disassemble_set_printf): Declare. (init_disassemble_info): Add additional parameter. (INIT_DISASSEMBLE_INFO): Add additional parameter. opcodes/ChangeLog: * dis-init.c (init_disassemble_info): Take extra parameter, initialize the new fprintf_styled_func and created_styled_output fields. * disassembler.c (disassemble_set_printf): New function definition.
2022-04-04Remove more Python 2 codeTom Tromey1-10/+1
I found another more place that still had a workaround for Python 2. This patch removes it.
2022-04-04[gdb/testsuite] Fix KPASS in gdb.ada/arrayptr.expTom de Vries1-16/+45
On openSUSE Leap 15.3 I run into: ... KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all \ (PRMS minimal encodings) KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3) \ (PRMS minimal encodings) KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3) \ (PRMS minimal encodings) ... The test-case KFAILs some tests. However, the analysis in the corresponding PR talks of a compiler problem, so it should use XFAILs instead. The KFAILs are setup for pre-gcc-12, but apparantly the fix has been backported to system compiler 7.5.0, hence the KPASS. Fix this by: - using an XFAIL instead of a KFAIL - matching the specific gdb output that corresponds to the XFAILs (reproduced on Fedora 34). Tested on x86_64-linux, specifically openSUSE Leap 15.3 and Fedora 34.
2022-04-04Automatic date update in version.inGDB Administrator1-1/+1
2022-04-03gdb: add support for Fortran's ASSUMED RANK arraysrupothar5-15/+263
This patch adds a new dynamic property DYN_PROP_RANK, this property is read from the DW_AT_rank attribute and stored within the type just like other dynamic properties. As arrays with dynamic ranks make use of a single DW_TAG_generic_subrange to represent all ranks of the array, support for this tag has been added to dwarf2/read.c. The final piece of this puzzle is to add support in gdbtypes.c so that we can resolve an array type with dynamic rank. To do this the existing resolve_dynamic_array_or_string function is split into two, there's a new resolve_dynamic_array_or_string_1 core that is responsible for resolving each rank of the array, while the now outer resolve_dynamic_array_or_string is responsible for figuring out the array rank (which might require resolving a dynamic property) and then calling the inner core. The resolve_dynamic_range function now takes a rank, which is passed on to the dwarf expression evaluator. This rank will only be used in the case where the array itself has dynamic rank, but we now pass the rank in all cases, this should be harmless if the rank is not needed. The only small nit is that resolve_dynamic_type_internal actually handles resolving dynamic ranges itself, which now obviously requires us to pass a rank value. But what rank value to use? In the end I just passed '1' through here as a sane default, my thinking is that if we are in resolve_dynamic_type_internal to resolve a range, then the range isn't part of an array with dynamic rank, and so the range should actually be using the rank value at all. An alternative approach would be to make the rank value a gdb::optional, however, this ends up adding a bunch of complexity to the code (e.g. having to conditionally build the array to pass to dwarf2_evaluate_property, and handling the 'rank - 1' in resolve_dynamic_array_or_string_1) so I haven't done that, but could, if people think that would be a better approach. Finally, support for assumed rank arrays was only fixed very recently in gcc, so you'll need the latest gcc in order to run the tests for this. Here's an example test program: PROGRAM arank REAL :: a1(10) CALL sub1(a1) CONTAINS SUBROUTINE sub1(a) REAL :: a(..) PRINT *, RANK(a) END SUBROUTINE sub1 END PROGRAM arank Compiler Version: gcc (GCC) 12.0.0 20211122 (experimental) Compilation command: gfortran assumedrank.f90 -gdwarf-5 -o assumedrank Without Patch: gdb -q assumedrank Reading symbols from assumedrank... (gdb) break sub1 Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10. (gdb) run Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank Breakpoint 1, arank::sub1 (a=<unknown type in /home/rupesh/STAGING-BUILD-2787 /bin/assumedrank, CU 0x0, DIE 0xd5>) at assumedrank.f90:10 10 PRINT *, RANK(a) (gdb) print RANK(a) 'a' has unknown type; cast it to its declared type With patch: gdb -q assumedrank Reading symbols from assumedrank... (gdb) break sub1 Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10. (gdb) run Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank Breakpoint 1, arank::sub1 (a=...) at assumedrank.f90:10 10 PRINT *, RANK(a) (gdb) print RANK(a) $1 = 1 (gdb) ptype a type = real(kind=4) (10) (gdb) Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-04-03gdb/dwarf: pass an array of values to the dwarf evaluatorAndrew Burgess4-17/+16
When we need to evaluate a DWARF expression in order to resolve some dynamic property of a type we call the dwarf2_evaluate_property function, which is declared in gdb/dwarf/loc.h and defined in gdb/dwarf/loc.c. Currently, this function takes (amongst other things) an argument of type property_addr_info called addr_stack and a boolean called push_initial_value. When push_initial_value then the top value of addr_stack is pushed onto the dwarf expression evaluation stack before the expression is evaluated. So far this has worked fine, as the only two cases we needed to handle are the case the DWARF expression doesn't require the object address (what the top of addr_stack represents), and the case where the DWARF expression does require the address. In the next commit this is going to change. As we add support for Fortran assumed rank arrays, we need to start resolving the dynamic properties of arrays. To do this, we need to push the array rank onto the dwarf expression evaluation stack before the expression is evaluated. This commit is a refactoring commit aimed at making it easier to support Fortran assumed rank arrays. Instead of passing a boolean, and using this to decide if we should push the object address or not, we instead pass an array (view) of values that should be pushed to the dwarf expression evaluation stack. In the couple of places where we previously passed push_initial_value as true (mostly this was defaulting to false), we now have to pass the address from the addr_stack as an item in the array view. In the next commit, when we want to handle passing the array rank, this will easily be supported too. There should be no user visible changes after this commit.
2022-04-03gdb: small simplification in dwarf2_locexpr_baton_evalAndrew Burgess1-9/+9
While examining the dwarf expression evaluator, I noticed that in dwarf2_locexpr_baton_eval, whenever push_initial_value is true, the addr_stack will never be nullptr. This allows for a small cleanup, replacing an if/then/else with an assertion. There should be no user visible changes after this commit.
2022-04-03gdb/testsuite: resolve some duplicate test names in gdb.baseAndrew Burgess1-4/+6
This commit resolves all the duplicate test names that I see in the script: gdb.base/attach-pie-misread.exp The duplicate names all come from a second call to build_executable_own_libs, so in this commit I've places the second call inside a with_test_prefix block. While I was making this change I've also modified the value being passed as the testname for the second build_executable_own_libs call. Previously we used ${test}, however, I think this was likely a mistake, the 'test' variable is setup for the previous test. I suspect that ${testfile} is a better choice - especially now we have a testname prefix. As the testname is only used (after various calls) from within build_executable_from_specs should the build fail, I don't think this change really makes much difference though. There should be no change in what is tested after this commit.
2022-04-03gdb/testsuite: resolve a duplicate test name in a gdb.mi testAndrew Burgess1-1/+1
Solve two duplicate test names in the test script: gdb.mi/mi-catch-cpp-exceptions.exp by moving the call to restart_for_test inside the with_test_prefix block. There should be no difference in what is tested after this commit.
2022-04-03gdb/Makefile.in: move ALLDEPFILES earlier in Makefile.inAndrew Burgess1-218/+229
If I do 'make tags' in the gdb build directory, the tags target does complete, but I see these warnings: ../../src/gdb/arm.c: No such file or directory ../../src/gdb/arm-get-next-pcs.c: No such file or directory ../../src/gdb/arm-linux.c: No such file or directory The reason for this is the ordering of build rules and make variables in gdb/Makefile.in, specifically, the placement of the tags related rules, and the ALLDEPFILES variable. The ordering is like this: TAGFILES_NO_SRCDIR = .... $(ALLDEPFILES) .... TAGS: $(TAGFILES_NO_SRCDIR) .... # Recipe uses $(TAGFILES_NO_SRCDIR) tags: TAGS ALLDEPFILES = ..... When the TAGS rule is parsed TAGFILES_NO_SRCDIR is expanded, which then expands ALLDEPFILES, which, at that point in the Makefile is undefined, and so expands to the empty string. As a result TAGS does not depend on any file listed in ALLDEPFILES. However, when the TAGS recipe is invoked ALLDEPFILES is now defined. As a result, all the files in ALLDEPFILES are passed to the etags program. The ALLDEPFILES references three files, arm.c, arm-get-next-pcs.c, and arm-linux.c, which are actually in the gdb/arch/ directory, but, in ALLDEPFILES these files don't include the arch/ prefix. As a result, the etags program ends up looking for these files in the wrong location. As ALLDEPFILES is only used by the TAGS rule, this mistake was not previously noticed (the TAGS rule itself was broken until a recent commit). In this commit I make two changes, first, I move ALLDEPFILES to be defined before TAGFILES_NO_SRCDIR, this means that the TAGS rule will depend on all the files in ALLDEPFILES. With this change the TAGS rule now breaks complaining that there's no rule to build the 3 files mentioned above. Next, I have added all *.c files in gdb/arch/ to ALLDEPFILES, including their arch/ prefix, and removed the incorrect (missing arch/ prefix) references. With these two changes the TAGS (or tags if you prefer) target now builds without any errors or warnings.
2022-04-03gdb/Makefile.in: fix 'make tags' build targetReuben Thomas1-1/+0
The gdb_select.h file was moved to the gdbsupport directory long ago, but a reference was accident left in gdb/Makefile.in (in the HFILES_NO_SRCDIR variable), this commit removes that reference. Before this commit, if I use 'make tags' here's what I see: $ make tags make: *** No rule to make target 'gdb_select.h', needed by 'TAGS'. Stop. After this commit 'make tags' completes, but I still see these warnings: ../../src/gdb/arm.c: No such file or directory ../../src/gdb/arm-get-next-pcs.c: No such file or directory ../../src/gdb/arm-linux.c: No such file or directory These are caused by a separate issue, and will be addressed in the next commit.
2022-04-03gdb/Makefile.in: remove SOURCES variableAndrew Burgess1-1/+0
The SOURCES variable was added to gdb/Makefile.in as part of commit: commit fb40c20903110ed8af9701ce7c2635abd3770d52 Date: Wed Feb 23 00:25:43 2000 +0000 Add mi/ and testsuite/gdb.mi/ subdirectories. But as far as I can tell was not used at the time it was added, and is not used today. Lets remove it.
2022-04-03gdb/tui: fair split of delta after a resizeAndrew Burgess2-12/+56
Currently, in master gdb, when a tui window is changed in size, the screen delta is mostly just added to the next available window. We do take care to respect the min/max size, but in most cases, these limits are just "the terminal size", and so, we end up placing the whole delta on the next window. Consider these steps in an 80 column, 24 line terminal: (gdb) tui enable (gdb) layout src (gdb) layout split (gdb) info win Name Lines Columns Focus src 8 80 (has focus) asm 8 80 status 1 80 cmd 8 80 (gdb) winheight cmd +2 (gdb) info win Name Lines Columns Focus src 6 80 (has focus) asm 8 80 status 1 80 cmd 10 80 Notice that initially, the windows were balanced, 8 lines each for the major windows. Then, when the cmd window was adjusted, the extra two lines were given to the asm window. I think it would be nicer if the delta was spread more evenly over the available windows. In the example above, after the adjustment the layout now looks like: (gdb) info win Name Lines Columns Focus src 7 80 (has focus) asm 7 80 status 1 80 cmd 10 80 This is achieved within tui_layout_split::set_size, by just handing out the delta in increments of 1 to each window (except for the window the user adjusted), until there's no more delta left. Of course, we continue to respect the min/max window sizes.
2022-04-03gdb/tui: relax restrictions on window max height and widthAndrew Burgess4-11/+5
This commit removes some arbitrary adjustments made in tui_cmd_window::max_height, tui_win_info::max_height, and tui_win_info::max_width. These member functions all subtract some constant from the theoretical maximum height or width. I've looked back through the history a little and can see no real reason why these adjustments should be needed, with these adjustments removed all the existing tui tests still pass. However, retaining these restrictions causes some bugs, consider: (gdb) tui new-layout hsrc {-horizontal src 1 cmd 1} 1 When this layout is selected with current master, gdb will leave a 4 line gap at the bottom of the terminal. The problem is that the maximum height is restricted, for the cmd window, to 4 less than the terminal height. By removing this restriction gdb is able to size the windows to the complete terminal height, and the layout is done correctly. This 4 line restriction is also what prevents this layout from working correctly: (gdb) tui new-layout conly cmd 1 Previously, this layout would present a cmd window only, but there would be a 4 line gap at the bottom of the terminal. This issue was mentioned in an earlier commit in this series (when a different bug was fixed), but with this commit, the above layout now correctly fills the terminal. The associated test is updated. After removing the adjustment in tui_cmd_window::max_height, the implementation is now the same as the implementation in the parent class tui_win_info, so I've completely removed the max_height call from tui_cmd_window.
2022-04-03gdb/testsuite: some additional tests in gdb.tui/scroll.expAndrew Burgess1-0/+4
This commit just adds an extra check of the src window size prior to sending all the commands to gdb. We also set the cmd window height to its existing height, this (obviously) shouldn't change the window layout, which we check. My main motivation was adding the initial window layout check, the winheight and recheck are just extras. All of these test pass both before and after this commit.
2022-04-03gdb/tui: support placing the cmd window into a horizontal layoutAndrew Burgess4-25/+102
This commit allows the user to place the cmd window within horizontal tui layouts. Consider this set of steps, carried out in an 80 columns by 24 lines terminal, using current master gdb: (gdb) tui new-layout hsrc { -horizontal src 1 cmd 1 } 1 status 1 (gdb) tui layout hsrc What you end up with is a full width cmd window with the status bar beneath. Where's the src window gone? We then try: (gdb) info win Name Lines Columns Focus src 23 3 (has focus) cmd 23 80 status 1 80 (gdb) Something weird has gone on, gdb has overlapped the cmd window with the src window. If we trigger the src window to redraw is content, for example, 'list main', then we see corruption in the cmd window as the src window overwrites it. So, what's going on? The problem is some code in tui_layout_split::apply, in tui-layout.c. Within 'Step 1', there is a loop that calculates the min/max window sizes for all windows within a tui_layout_split. However, there's a special case for the cmd window. This special case is trying to have the cmd window retain its current size when a layout is re-applied, or a new layout is applied. This makes sense, consider moving from the 'src' layout to the 'asm' layout, this looks something like this (status window removed): .-------. .-------. | src | | asm | |-------| ====> |-------| | cmd | | cmd | '-------' '-------' If the user has gone to the effort of adjusting the cmd window size, then, the thinking goes, we shouldn't reset the cmd window size when switching layouts like this. The problem though, is that when we do a switch more like this: .-----------. .-----------. | src | | | | |-----------| ====> | asm | cmd | | cmd | | | | '-----------' '-----------' Now retaining the cmd window width makes no sense; the new layout has a completely different placement for the cmd window, instead of sizing by height, we're now sizing by width. The existing code doesn't understand this though, and tried to retain the full width for the cmd window. To solve this problem, I propose we introduce the idea of a layout "fingerprint". The fingerprint tries to capture, in an abstract way, where the cmd window lives within the layout. Only when two layouts have the same fingerprint will we attempt to retain the cmd window size. The fingerprint for a layout is represented as a string, the string is a series of 'V' or 'H' characters, ending with a single 'C' character. The series of 'V' and 'H' characters represent the vertical or horizontal layouts that must be passed through to find the cmd window. Here are a few examples: # This layout is equivalent to the builtin 'src' layout. # Fingerprint: VC tui new-layout example1 src 2 status 0 cmd 1 # This layout is equivalent to the builtin 'split' layout. # Fingerprint: VC tui new-layout example2 src 1 asm 1 status 0 cmd 1 # This is the same layout that was given at the top. # Fingerprint: VHC tui new-layout hsrc { -horizontal src 1 cmd 1 } 1 status 1 And so, when switching between example1 and example2, gdb knows that the cmd window is, basically, in the same sort of position within the layout, and will retain the cmd window size. In contrast, when switching to the hsrc layout, gdb understands that the position of the cmd window is different, and does not try to retain the cmd window size.
2022-04-03gdb/tui: allow cmd window to change size in tui_layout_split::applyAndrew Burgess3-8/+142
When we switch layouts we call the tui_layout_split::apply member function to reapply the layout, and recalculate all the window sizes. One special case is the cmd window, which we try to keep at its existing size. However, in some cases it is not appropriate to keep the cmd window at its existing size. I will describe two such cases here, in one, we want the cmd window to reduce in size, and in the other, we want the cmd window to grow in size. Try these steps in a 80 columns, by 24 lines terminal: (gdb) tui enable (gdb) layout src (gdb) winheight cmd 20 (gdb) layout split You should see that the status window is missing from the new layout, and that the cmd window has been placed over the border of the asm window. The 'info win' output is: (gdb) info win Name Lines Columns Focus src 3 80 (has focus) asm 3 80 status 1 80 cmd 20 80 Notice that gdb has assigned 27 lines of screen space, even with the border overlap between the src and asm windows, this is still 2 lines too many. The problem here is that after switching layouts, gdb has forced the cmd window to retain its 20 line height. Really, we want the cmd window to reduce in height so that the src and asm windows can occupy their minimum required space. This commit allows this (details on how are below). After this commit, in the above situation, we now see the status window displayed correctly, and the 'info win' output is: (gdb) info win Name Lines Columns Focus src 3 80 (has focus) asm 3 80 status 1 80 cmd 18 80 The cmd window has been reduced in size by 2 lines so that everything can fit on the screen. The second example is one which was discussed in a recent commit, consider this case (still in the 80 column, 24 line terminal): (gdb) tui enable (gdb) tui new-layout conly cmd 1 (gdb) layout conly (gdb) info win Name Lines Columns Focus cmd 8 80 (has focus) (gdb) This layout only contains a cmd window, which we would expect to occupy the entire terminal. But instead, the cmd window only occupies the first 8 lines, and the rest of the terminal is unused! The reason is, again, that the cmd window is keeping its previous size (8 lines). After this commit things are slightly different, the 'info win' output is now: (gdb) info win Name Lines Columns Focus cmd 20 80 (has focus) Which is a little better, but why only 20 lines? Turns out there's yet another bug hitting this case. That bug will be addressed in a later commit, so, for now, we're accepting the 20 lines. What this commit does is modify the phase of tui_layout_split::apply that handles any left over space. Usually, in "Step 2", each sub-layout has a size calculated. As the size is an integer, then, when all sizes are calculated we may have some space left over. This extra space is then distributed between all the windows fairly until all the space is used up. When we consider windows minimum size, or fixed size windows, then it is possible that we might try to use more space than is available, this was our first example above. The same code that added extra space to the windows, can also be used to reclaim space (in the over allocation case) to allow all windows to fit. The problem then is the cmd window, which we often force to a fixed size. Inside the loop that handles the allocation of excess space, if we find that we have tried every window, and still have space either left to give, or we need to claim back more space, then, if the cmd window was changed to a fixed size, we can change the cmd window back to a non-fixed-size window, and proceed to either give, or take space from the cmd window as needed.
2022-04-03gdb/tui: fairer distribution of excess space during applyAndrew Burgess5-24/+53
When applying layouts gdb computes the size of each window (or rather, each sub-layout within a layout) using integer arithmetic. As this rounds down the results, then, when all sub-layouts are sized, there is the possibility that we have some space left over. Currently, this space is just assigned to an arbitrary sub-layout. This can result in some unbalanced results. Consider this set of steps with current master: (gdb) tui enable (gdb) layout regs (gdb) info win Name Lines Columns Focus regs 7 80 src 9 80 (has focus) status 1 80 cmd 8 80 Notice the weird split between the src and regs windows, the original layout specification has these windows given equal weight. The problem is that, with rounding, both the regs and src windows are initially sized to 7, the extra 2 lines are then arbitrarily added to the src window. In this commit, rather than add all the extra space to one single window, I instead hand out the extra space 1 line at a time, looping over all the sub-layouts. We take care to respect the min/max sizes, and so, we now get this result: (gdb) tui enable (gdb) layout regs (gdb) info win Name Lines Columns Focus regs 8 80 src 8 80 (has focus) status 1 80 cmd 8 80 This looks more natural to me. This is obviously a change in behaviour, and so, lots of the existing tests need to be updated to take this into account. None of the changes are huge, it's just a line or two (or column for width) moved between windows.
2022-04-03gdb/tui: avoid fp exception when applying layoutsAndrew Burgess2-12/+21
Consider: (gdb) tui enable (gdb) layout src (gdb) tui new-layout conly cmd 1 (gdb) layout conly After this, with current master, gdb crashes with a floating-point exception. The problem is that in tui_layout_split::apply, when we switch from 'src' to 'conly', we will try to retain the cmd window height. As such, the cmd window will become a fixed size window, which decreases the available_size, but doesn't count towards the total_weight. As the cmd window is the only window, the total_weight stays at zero, and, when we move into step 2, where we attempt to size the windows, we perform a divide by zero, and crash. After this commit we avoid the divide by zero, and just directly set the window size based on the fixed size. There is still a problem after this commit, when the conly layout is selected the cmd window retains its original height, which will only be part of the terminal. The rest of the terminal is left unused. This issue will be addressed in a later commit, this commit is just about the floating-point exception.
2022-04-03gdb/tui/testsuite: refactor new-layout.exp testAndrew Burgess1-27/+56
This commit changes the gdb.tui/new-layout.exp test to make use of a list of test descriptions, and a loop to check each description in turn. There's no change to what is actually tested after this commit. In future commits I plan to add additional tests to this file, and this will be easier now that all I have to do is add a new test description to the list.
2022-04-03gdb/tui: add left_boxed_p and right_boxed_p member functionsAndrew Burgess2-16/+18
When I initially saw this code in tui_layout_split::apply, I assumed that this must be a bug: /* Two adjacent boxed windows will share a border, making a bit more size available. */ if (i > 0 && m_splits[i - 1].layout->bottom_boxed_p () && m_splits[i].layout->top_boxed_p ()) ... After all, the apply might be laying out a horizontal layout, right? So checking bottom_boxed_p and top_boxed_p is clearly wrong. Well, it turns on, that due to the implementations of these things, bottom_boxed_p is equivalent to an imagined right_boxed_p, and top_boxed_p is equivalent to an imagined left_boxed_p. In this commit I've renamed both top_boxed_p and bottom_boxed_p to first_edge_has_border_p and last_edge_has_border_p respectively, and extended the comments in tui_layout_base to mention that these methods handle both horizontal and vertical layouts. Now, hopefully, the code shouldn't look like it only applies for vertical layouts. There should be no user visible changes after this commit.
2022-04-03gdb/tui: add a tui debugging flagAndrew Burgess6-11/+168
This commit adds 'set debug tui on|off' and 'show debug tui'. This commit adds the control variable, and the printing macros in tui/tui.h. I've then added some uses of these in tui.c and tui-layout.c. To help produce more useful debug output in tui-layout.c, I've added some helper member functions in the class tui_layout_split, and also moved the size_info struct out of tui_layout_split::apply into the tui_layout_split class. If tui debug is not turned on, then there should be no user visible changes after this commit. One thing to note is that, due to the way that the tui terminal is often cleared, the only way I've found this useful is when I do: (gdb) tui enable (gdb) set logging file /path/to/file (gdb) set logging debugredirect on (gdb) set logging enable on Additionally, gdb has some quirks when it comes to setting up logging redirect and switching interpreters. Thus, the above only really works if the logging is enabled after the tui is enabled, and disabled again before the tui is disabled. Enabling logging and switching interpreters can cause undefined results, including crashes. This is an existing bug in gdb[1], and has nothing directly to do with tui debug, but it is worth mentioning here I think. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=28948
2022-04-03gdb/tui: add new 'tui window width' command and 'winwidth' aliasAndrew Burgess6-16/+209
This commit adds a new command 'tui window width', and an alias 'winwidth'. This command is equivalent to the old 'winheight' command (which was recently renamed 'tui window height'). Even though I recently moved the old tui commands under the tui namespace, and I would strongly encourage all new tui commands to be added as 'tui ....' only (users can create their own top-level aliases if they want), I'm breaking that suggestion here, and adding a 'winwidth' alias. Given that we already have 'winheight' and have done for years, it just didn't seem right to no have the matching 'winwidth'. You might notice in the test that the window resizing doesn't quite work right. I setup a horizontal layout, then grow and shrink the windows. At the end of the test the windows should be back to their original size... ... they are not. This isn't my fault, honest! GDB's window resizing is a little ... temperamental, and is prone to getting things slightly wrong during resizes, off by 1 type things. This is true for height resizing, as well as the new width resizing. Later patches in this series will rework the resizing algorithm, which should improve things in this area. For now, I'm happy that the width resizing is as good as the height resizing, given the existing quirks. For the docs side I include a paragraph that explains how multiple windows are required before the width can be adjusted. For completeness, I've added the same paragraph to the winheight description. With the predefined layouts this extra paragraph is not really needed for winheight, as there are always multiple windows on the screen. However, with custom layouts, this might not be true, so adding the paragraph seems like a good idea. As for the changes in gdb itself, I've mostly just taken the existing height adjustment code, changed the name to make it generic 'size' adjustment, and added a boolean flag to indicate if we are adjusting the width or the height.
2022-04-03gdb/tui: rename tui_layout_split:set_weights_from_heightsAndrew Burgess2-6/+8
In a following commit I'm going to add the ability to change the width of a tui window (when in a horizontal layout). As a result, some of the places where we currently hard-code references to height need to be changed to handle either height, or width, based on whether we are in a vertical, or horizontal layout. This commit renames set_weights_from_heights to set_weights_from_sizes, and makes the function use either the height, or width as appropriate. Currently, the only place that we call this function is from the tui_layout_split::set_height function, in a part of the code we will only reach for vertical layouts, so the new code is not actually being used, but, this small change will help make later patches smaller, so I'm proposing this as a stand alone change. There should be no user visible changes after this commit.
2022-04-03gdb/tui: rename tui_layout_base::adjust_size to ::set_heightAndrew Burgess2-7/+7
Rename tui_layout_base::adjust_size to tui_layout_base::set_height, the new name more accurately reflects what this member function does, and makes it easier for a later commit to add a new tui_layout_base::set_width member function. There should be no user visible changes after this commit.
2022-04-03gdb: move some commands into the tui namespaceAndrew Burgess4-16/+73
There are a lot of tui related commands that live in the top-level command name space, e.g. layout, focus, refresh, winheight. Having them at the top level means less typing for the user, which is good, but, I think, makes command discovery harder. In this commit, I propose moving all of the above mentioned commands into the tui namespace, so 'layout' becomes 'tui layout', etc. But I will then add aliases so that the old commands will still work, e.g. I'll make 'layout' an alias for 'tui layout'. The benefit I see in this work is that tui related commands can be more easily discovered by typing 'tui ' and then tab-completing. Also the "official" command is now a tui-sub-command, this is visible in, for example, the help output, e.g.: (gdb) help layout tui layout, layout Change the layout of windows. Usage: tui layout prev | next | LAYOUT-NAME List of tui layout subcommands: tui layout asm -- Apply the "asm" layout. tui layout next -- Apply the next TUI layout. tui layout prev -- Apply the previous TUI layout. tui layout regs -- Apply the TUI register layout. tui layout split -- Apply the "split" layout. tui layout src -- Apply the "src" layout. Which I think is a good thing, it makes it clearer that this is a tui command. I've added a NEWS entry and updated the docs to mention the new and old command names, with the new name being mentioned first.
2022-04-03gdb: fix gdb_print -> gdb_printf typoSimon Marchi1-1/+1
This caused a build failure with !CXX_STD_THREAD. Change-Id: I30f0c89c43a76f85c0db34809192644fa64a9d18
2022-04-03Move microblaze relax info to target specific dataAlan Modra3-75/+85
Target specific data shouldn't be put in struct bfd_section. * section.c (struct bfd_section): Delete relax and relax_count. (BFD_FAKE_SECTION): Adjust to suit. (struct relax_table): Move to.. * elf32-microblaze.c (struct relax_table): ..here. (struct _microblaze_elf_section_data): New. (microblaze_elf_section_data): Define. (microblaze_elf_new_section_hook): New function. (bfd_elf32_new_section_hook): Define. (calc_fixup): Return a size_t. Adjust to suit new location of relax and relax_count. (microblaze_elf_relax_section): Adjust to suit new location of relax and relax_count. Make some variables size_t. * bfd-in2.h: Regenerate.
2022-04-03Revert commit 240d6706c6a2Alan Modra1-62/+22
PR 28592 PR 15994 PR 15935 * dwarf2.c (lookup_address_in_line_info_table): Return bool rather than a range. (comp_unit_find_nearest_line): Likewise. Return true if function info found without line info. (_bfd_dwarf2_find_nearest_line): Revert range handling code.
2022-04-03Regen bfd po/SRC-POTFILES.inAlan Modra1-2/+0
2022-04-03Automatic date update in version.inGDB Administrator1-1/+1
2022-04-02gdb: rename floatformats_ia64_quad to floatformats_ieee_quadTiezhu Yang16-55/+39
It is better to rename floatformats_ia64_quad to floatformats_ieee_quad to reflect the reality, and then we can clean up the related code. As Tom Tromey said [1]: These files are maintained in gcc and then imported into the binutils-gdb repository, so any changes to them will have to be proposed there first. the related changes have been merged into gcc master now [2], it is time to do it for gdb. [1] https://sourceware.org/pipermail/gdb-patches/2022-March/186569.html [2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b2dff6b2d9d6 Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-04-02Automatic date update in version.inGDB Administrator1-1/+1
2022-04-01Remove unused variable.John Baldwin1-1/+0
2022-04-01gdb/debuginfod-support.c: Always display debuginfod errorsAaron Merey1-3/+3
Errors encountered when downloading files from debuginfod servers are not displayed if debuginfod verbosity is set to 0 (via 'set debuginfod verbose 0'). Tom recommended that these errors always be displayed, regardless of the verbosity setting [1]. Fix this. [1] https://sourceware.org/pipermail/gdb-patches/2022-March/186350.html
2022-04-01Use I386_GSBASE_REGNUM in i386fbsd_get_thread_local_address.John Baldwin1-5/+2
32-bit x86 arches always the I386_*BASE_REGNUM values. Only code that needs to support both 64-bit and 32-bit arches needs to use tdep->fsbase_regnum to compute a segment base register number.
2022-04-01FreeBSD/x86: Read segment base registers from NT_X86_SEGBASES.John Baldwin2-0/+36
FreeBSD kernels recently grew a new register core dump note containing the base addresses of the %fs and %gs segments (corresponding to the %fsbase and %gsbase registers). Parse this note to permit inspecting TLS variables in core dumps. Native processes already supported TLS via older ptrace() operations.
2022-04-01Use pseudosections for NT_FREEBSD_X86_SEGBASES core dump notes.John Baldwin3-0/+25
This includes adding pseudosections when reading a core dump as well as support for writing out a core dump note from a pseudosection. bfd/ChangeLog: * elf-bfd.h (elfcore_write_x86_segbases): New. * elf.c (elfcore_grok_freebsd_note): Add pseudosections for NT_FREEBSD_X86_SEGBASES register notes. (elfcore_write_x86_segbases): New. (elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES register notes.
2022-04-01Recognize FreeBSD core dump note for x86 segment base registers.John Baldwin4-0/+12
This core dump note contains the value of the base address of the %fs and %gs segments for both i386 and amd64 core dumps. It is primarily useful in resolving the address of TLS variables in core dumps. binutils/ChangeLog: * readelf.c (get_freebsd_elfcore_note_type): Handle NT_FREEBSD_X86_SEGBASES. include/ChangeLog: * elf/common.h (NT_FREEBSD_X86_SEGBASES): Define.
2022-04-01elfcore_grok_freebsd_note: Remove checks of note->namesz.John Baldwin2-8/+6
This function is only called if the note name is "FreeBSD", so checking the name size is unnecessary. bfd/ChangeLog: * elf.c (elfcore_grok_freebsd_note): Remove checks for namesz.
2022-04-01gdb/testing/tui: add new _csi_{L,S,T}Andrew Burgess2-0/+180
This patch was original part of this series: https://sourceware.org/pipermail/gdb-patches/2022-March/186429.html https://sourceware.org/pipermail/gdb-patches/2022-March/186433.html I've pulled this out as it might be useful ahead of the bigger series being merged. This commit adds: _csi_L - insert line _csi_S - pan down _csi_T - pan up
2022-03-31x86: Remove bfd_arch_l1om and bfd_arch_k1omH.J. Lu14-243/+17
Remove bfd_arch_l1om and bfd_arch_k1om since L1OM/K1OM support has been removed from gas, ld and opcodes. bfd/ * Makefile.am (ALL_MACHINES): Remove cpu-l1om.lo and cpu-k1om.lo. (ALL_MACHINES_CFILES): Remove cpu-l1om.c and cpu-k1om.c. * archures.c (bfd_mach_l1om): Removed. (bfd_mach_l1om_intel_syntax): Likewise. (bfd_mach_k1om): Likewise. (bfd_mach_k1om_intel_syntax): Likewise. (bfd_k1om_arch): Likewise. (bfd_l1om_arch): Likewise. (bfd_archures_list): Remove bfd_k1om_arch and bfd_l1om_arch references. * config.bfd (targ_selvecs): Remove l1om_elf64_vec. l1om_elf64_fbsd_vec, k1om_elf64_vec and k1om_elf64_fbsd_vec. (targ_archs): Remove bfd_l1om_arch and bfd_k1om_arch. * configure.ac (k1om_elf64_vec): Removed. (k1om_elf64_fbsd_vec): Likewise. (l1om_elf64_vec): Likewise. (l1om_elf64_fbsd_vec): Likewise. * cpu-k1om.c: Removed. * cpu-l1om.c: Likewise. * elf64-x86-64.c (elf64_l1om_elf_object_p): Removed. (elf64_k1om_elf_object_p): Likewise. (l1om_elf64_vec): Removed. (l1om_elf64_fbsd_vec): Likewise. (k1om_elf64_vec): Likewise. (k1om_elf64_fbsd_vec): Likewise. (ELF_TARGET_OS): Undefine. * targets.c (_bfd_target_vector): Remove k1om_elf64_vec, k1om_elf64_fbsd_vec, l1om_elf64_vec and l1om_elf64_fbsd_vec. * Makefile.in: Regenerate. * bfd-in2.h: Likewise. * configure: Likewise. opcodes/ * configure.ac: Remove bfd_arch_l1om/bfd_arch_k1om references. * disassemble.c (disassembler): Likewise. * configure: Regenerate.
2022-03-31gdb/ctf: pass partial symtab's filename to buildsym_compunitSimon Marchi1-1/+1
I noticed that the CTF symbol reader passes the objfile's name to all buildsym_compunit instances it creates. The result is that all compunit_symtabs created have the same name, that of the objfile: { objfile /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ((struct objfile *) 0x613000005d00) { ((struct compunit_symtab *) 0x621000286760) debugformat ctf producer (null) name libbabeltrace2.so.0.0.0 dirname (null) blockvector ((struct blockvector *) 0x6210003911d0) user ((struct compunit_symtab *) (null)) { symtab /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ((struct symtab *) 0x6210003911f0) fullname (null) linetable ((struct linetable *) 0x0) } } { ((struct compunit_symtab *) 0x621000275c10) debugformat ctf producer (null) name libbabeltrace2.so.0.0.0 dirname (null) blockvector ((struct blockvector *) 0x621000286710) user ((struct compunit_symtab *) (null)) { symtab /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ((struct symtab *) 0x621000286730) fullname (null) linetable ((struct linetable *) 0x0) } } Notice the two "name libbabeltrace2.so.0.0.0". Change it to pass the partial_symtab's filename instead. The output becomes: { objfile /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ((struct objfile *) 0x613000005d00) { ((struct compunit_symtab *) 0x621000295610) debugformat ctf producer (null) name libbabeltrace2.so.0.0.0 dirname (null) blockvector ((struct blockvector *) 0x6210003a15d0) user ((struct compunit_symtab *) (null)) { symtab /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ((struct symtab *) 0x6210003a15f0) fullname (null) linetable ((struct linetable *) 0x0) } } { ((struct compunit_symtab *) 0x621000288700) debugformat ctf producer (null) name current-thread.c dirname (null) blockvector ((struct blockvector *) 0x6210002955c0) user ((struct compunit_symtab *) (null)) { symtab /home/simark/src/babeltrace/src/lib/current-thread.c ((struct symtab *) 0x6210002955e0) fullname (null) linetable ((struct linetable *) 0x0) } } Note that the first compunit_symtab still has libbabeltrace2.so.0.0.0 as its name. This is because the CTF symbol reader really creates a partial symtab named like this. It appears to be because the debug info contains information that has been factored out of all CUs and is at the "top-level" of the objfile, outside any real CU. So it creates a partial symtab and an artificial CU that's named after the objfile. Change-Id: I576316bab2a3668adf87b4e6cebda900a8159b1b
2022-03-31gdb: print compunit_symtab name in "maint info symtabs"Simon Marchi1-0/+1
I think it would make sense to print a compunit_symtab's name in "maint info symtabs". If you are looking for a given CU in the list, that's probably the field you will be looking at. As the doc of compunit_symtab::name says, it is not meant to be a reliable file name, it is for debugging purposes (and "maint info symtabs" exists for debugging purposes). Sample output with the new field: (gdb) maintenance info symtabs { objfile /home/simark/build/binutils-gdb-one-target/gdb/a.out ((struct objfile *) 0x613000005d00) { ((struct compunit_symtab *) 0x621000131630) debugformat DWARF 5 producer GNU C17 11.2.0 -mtune=generic -march=x86-64 -g3 -O0 name test.c dirname /home/simark/build/binutils-gdb-one-target/gdb blockvector ((struct blockvector *) 0x621000131d10) user ((struct compunit_symtab *) (null)) { symtab test.c ((struct symtab *) 0x6210001316b0) fullname (null) linetable ((struct linetable *) 0x621000131d40) } { symtab /home/simark/build/binutils-gdb-one-target/gdb/test.h ((struct symtab *) 0x6210001316e0) fullname (null) linetable ((struct linetable *) 0x0) } { symtab /usr/include/stdc-predef.h ((struct symtab *) 0x621000131710) fullname (null) linetable ((struct linetable *) 0x0) } } { ((struct compunit_symtab *) 0x6210001170a0) debugformat DWARF 5 producer GNU C17 11.2.0 -mtune=generic -march=x86-64 -g3 -O0 name foo.c dirname /home/simark/build/binutils-gdb-one-target/gdb blockvector ((struct blockvector *) 0x621000131580) user ((struct compunit_symtab *) (null)) { symtab foo.c ((struct symtab *) 0x621000117120) fullname (null) linetable ((struct linetable *) 0x6210001315b0) } { symtab /usr/include/stdc-predef.h ((struct symtab *) 0x621000117150) fullname (null) linetable ((struct linetable *) 0x0) } } } Change-Id: I17b87adfac2f6551cb5bda30d59f6c6882789211
2022-03-31gdb/ctf: don't create a buildsym_compunit when building partial symbolsSimon Marchi1-19/+1
I am trying to do some changes to buildsym_compunit, so I am auditing the current uses. Something seems odd with this use of buildsym_compunit (that this patch removes). A buildsym_compunit is normally used when building a compunit_symtab. That is, when expanding a partial symtab into a full compunit symtab. In ctfread.c, a buildsym_compunit is created in ctf_start_archive, which is only used when creating partial symtabs. At this moment, I don't see how that's useful. ctf_start_archive creates a new buildsym_compunit and starts a subfile. But that buildsym_compunit is never used again. It's just overriden in ctf_start_symtab, which means we leak the old buildsym_compunit, I suppose. Remove ctf_start_archive completely. Add an assert in ctf_start_symtab to verify that we are not overwriting an existing buildsym_compunit (meaning we'd leak the existing one). This assert triggers without the other part of the fix. When doing: $ ./gdb --data-directory=data-directory /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ... (gdb) maintenance expand-symtabs /home/simark/src/binutils-gdb/gdb/ctfread.c:1255: internal-error: ctf_start_symtab: Assertion `!ccp->builder' failed. Change-Id: I666d146454a019f08e7305f3a1c4a974d27b4592
2022-03-31Style URLs in GDB outputTom Tromey6-15/+40
I noticed that GDB will display URLs in a few spots. This changes them to be styled. Originally I thought I'd introduce a new "url" style, but there aren't many places to use this, so I just reused filename styling instead. This patch also changes the debuginfod URL list to be printed one URL per line. I think this is probably a bit easier to read.
2022-04-01Automatic date update in version.inGDB Administrator1-1/+1
2022-03-31gdb: initialize ctf_context::builder in create_partial_symtabSimon Marchi1-0/+1
I built a random project with -gctf, in order to test the CTF support in GDB. With my ASan/UBSan/etc-enabled build of GDB, I get: $ ./gdb --data-directory=data-directory /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0 ... Reading symbols from /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0... /home/simark/src/binutils-gdb/gdb/ctfread.c:1545:31: runtime error: member call on misaligned address 0xbebebebebebebebe for type 'struct buildsym_compunit', which requires 8 byte alignment 0xbebebebebebebebe: note: pointer points here The 0xbebebebebebebebe value is a sign that the ctf_context::builder field is uninitialized. The problem probably goes under the radar if the field happens to be zero-initialized, because ctf_start_archive contains this code: if (ccx->builder == nullptr) { ccx->builder = new buildsym_compunit (of, of->original_name, nullptr, language_c, 0); If the field was zero-initialized (by chance), this will create a new buildsym_compunit. But if the field was purposely filled with random bytes by one of the sanitizers, we won't create a buildsym_compunit here and we'll continue with ccx->builder equal to 0xbebebebebebebebe. Fix this the easy way by initializing ccx->builder where the other ctf_context fields are initialized (yeah, this code could be made nicer C++, but I am going for the obvious fix here). With this patch, this passes cleanly on my system: $ make check TESTS="gdb.ctf/*.exp" RUNTESTFLAGS="CC_FOR_TARGET=/opt/gcc/git/bin/gcc" # of expected passes 40 ... where /opt/gcc/git/bin/gcc is a gcc with CTF support, given my system gcc does not have it. Change-Id: Idea1b0cf3e3708b72ecb16b1b60222439160f9b9
2022-03-31Remove dbx modeTom Tromey13-503/+24
This patch removes gdb's dbx mode. Regression tested on x86-64 Fedora 34.
2022-03-31gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xmlH.J. Lu8-38/+12
1. Since 32bit-pkeys.xml and 64bit-pkeys.xml are identical, consolidate them into a single keys.xml. 2. Enable PKU for x32 to fix: $ gdbserver :123456 x32-program ... .../gdbserver/regcache.cc:255: A problem internal to GDBserver has been detected . Unknown register pkru requested on Tiger Lake.