Age | Commit message (Collapse) | Author | Files | Lines |
|
'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race:
(gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited
layout ^G
asm next prev regs split src
(gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion
Quit
(gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input
focus ^G
cmd next prev src
(gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion
Quit
This is caused by expecting "$gdb_prompt layout $".
gdb_test_multiple's internal prompt regexp can match first if expect's
internal buffer is filled with partial output. Fix that by splitting
the gdb_test_multiple in question in two. Since the same problem/code
appears twice in the file, factor out a common procedure.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.tui/tui-completion.exp (test_tab_completion): New procedure,
factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in a single gdb_test_multiple.
|
|
gdb.server/ext-{attach, restart, ext-run}.exp
This commit fixes this same problem in several places:
(gdb) PASS: gdb.multi/multi-attach.exp: backtrace 2
kill
Kill the program being debugged? (y or n) y
(gdb) FAIL: gdb.multi/multi-attach.exp: kill inferior 2 (got interactive prompt)
This is just another case of the gdb_test_multiple's internal "got
interactive prompt" pattern matching because the testcase misses
matching enough.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.multi/multi-attach.exp ("kill" test): Match the whole query
output.
* gdb.server/ext-attach.exp ("kill" test): Likewise.
* gdb.server/ext-restart.exp ("kill" test): Likewise.
* gdb.server/ext-run.exp ("kill" test): Likewise.
* gdb.server/ext-wrapper.exp ("kill" test): Likewise.
|
|
With:
$ make check-read1 TESTS="gdb.cp/cpcompletion.exp"
we get (from gdb.log):
(gdb) complete break Foo::
break Foo::Foo()
break Foo::Foofoo()
break Foo::get_foo()
break Foo::set_foo(int)
break Foo::~Foo()
(gdb) FAIL: gdb.cp/cpcompletion.exp: complete class methods (Foo not found)
The problem is that the
"break ${class}::\[A-Za-z0-9_~\]+"
regexp patches partial input, like:
break Foo::F
break Foo::Fo
break Foo::Foo
etc.
Fix that by expecting each whole line.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.cp/cpcompletion.exp (test_class_complete): Tighten regex to
match till end of line.
|
|
Testing with:
$ make check-read1 TESTS="gdb.base/memattr.exp"
Exposes a testcase bug that can result in racy fails:
info mem
Using user-defined memory regions.
Num Enb Low Addr High Addr Attrs
1 y 0x0000000000601060 0x0000000000601160 wo nocache
2 y 0x0000000000601180 0x0000000000601280 ro nocache
4 y 0x0000000000601280 0x0000000000601380 rw nocache
3 y 0x0000000000601380 0x0000000000601480 rw nocache
5 y 0x0000000000601480 0x0000000000601580 rw nocache
(gdb) FAIL: gdb.base/memattr.exp: info mem (1)
The problem is that:
"Attrs\[^\n\r]*.."
matches:
"Attrs \r"
when the output buffer is filled with partial output like this:
"info mem\r\nUsing user-defined memory regions.\r\nNum Enb Low Addr High Addr Attrs \r"
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/memattr.exp: Tighten regexes to match the end line.
|
|
Testing with:
$ make check-read1 TESTS="gdb.base/completion.exp"
Exposes a testcase bug that can result in racy fails:
FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
ERROR: Undefined command "".
FAIL: gdb.base/completion.exp: symbol-name completion limiting using tab character
FAIL: gdb.base/completion.exp: symbol-name completion limiting using complete command
testsuite/gdb.log shows:
(gdb) PASS: gdb.base/completion.exp: set max-completions 5
p^G
passcount path print print-object printf
*** List may be truncated, max-completions reached. ***
(gdb) FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
pcomplete p
Undefined command: "pcomplete". Try "help".
(gdb) ERROR: Undefined command "".
The problem is that the expect buffer can get filled with partial
output that ends in the gdb prompt, and so the default FAIL inside
gdb_test_multiple matches.
Fix that by splitting the gdb_test_multiple in two stages. Since that
is done in more than one place in the testcase, move the otherwise
duplicate code to helper procedures.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp (ignore_and_resync, test_tab_complete):
New procedures, factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in one go.
|
|
Testing with:
$ make check-read1 TESTS="gdb.asm/asm-source.exp"
Exposes a testcase bug that can result in racy fails:
(gdb) PASS: gdb.asm/asm-source.exp: next over foo3
return
Make selected stack frame return now? (y or n) y
n
#0 main () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.asm/asmsrc1.s:53
53 gdbasm_exit0
(gdb) FAIL: gdb.asm/asm-source.exp: return from foo2 (got interactive prompt)
n
The problem is that the "return now\?.*" regex can match partial
output like this:
"Make selected stack frame return no"
and then we send the 'y' too early, and then the next time around we
hit gdb_test_multiple's internal "got interactive prompt" regex.
Also, note we match "return no" instead of "return now" because the
regex is missing one quote level.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp ("kill" test): Match the whole query
output. Fix '?' match.
|
|
When debugging an Ada program, and inserting a watchpoint tracking
a local variable, the watchpoint doesn't get automatically deleted
upon leaving that variable's scope. This watchpoint then starts
creating problems later on, when trying to resume the program's
execution from a location outside of the watchpoint's scope:
(gdb) c
Continuing.
Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7
7 Do_Nothing (Val);
(gdb) n
No frame is currently executing in block pck.get_val.
Command aborted.
(gdb) c
Continuing.
No frame is currently executing in block pck.get_val.
Command aborted.
The expected output is the following:
- The program's execution after the first continue should stop
as soon as we reach the end of the watchpoint's scope, and
the debugger should be deleting it.
- Then we can continue until reaching breakpoint 2 above;
- After which we should be able to do next/continue as usual.
The reason the watchpoint is not automatically deleted at scope exit
is because the watchpoint is not marked as being scope-specific
(b->exp_valid_block is equal NULL), and this is because the
symbol lookup for our local variable failed to set the innermost_block
global variable during the lookup.
More precisely, if we look at watch_command_1, we do the following:
innermost_block = NULL;
[...]
exp = parse_exp_1 (&arg, 0, 0, 0);
[...]
exp_valid_block = innermost_block;
Currently, innermost_block stays NULL after the call to parse_exp_1.
Digging further, this innermost_block is typically set during symbol
lookup when the symbol is considered to have a frame-relative address.
For instance, in c-exp.y, we see some code like the following:
if (symbol_read_needs_frame (sym.symbol))
{
if (innermost_block == 0
|| contained_in (sym.block,
innermost_block))
innermost_block = sym.block;
}
We actually have the exact same mechanism in ada-exp.y, except
that it vhas accidently been turned off. See write_var_from_sym,
where we start with:
if (orig_left_context == NULL && symbol_read_needs_frame (sym))
{
if (innermost_block == 0
|| contained_in (block, innermost_block))
innermost_block = block;
}
In this case, orig_left_context is a parameter, and looking at
the point of call in write_var_or_type, we see:
if (nsyms == 1)
{
write_var_from_sym (par_state, block, syms[0].block,
syms[0].symbol);
In the call above, the paramater we are interested in is "block",
which is a parameter for write_var_or_type as well, except we
explicitly override its value at the beginning when found to be NULL:
if (block == NULL)
block = expression_context_block;
So the block we pass to write_var_from_sym is not NULL, and
we therefore don't set innermost_block, which leads to the watchpoint
no longer being marked as scope-specific.
The handling of orig_left_context in write_var_from_sym was there
to handle the case where a user writes an expression where the symbol
is qualified with a scope (Eg: "function::variable"). But it appears
that handling this is specifically here is no longer necessary,
so this patch simply removes that parameter and the associated check,
and then updates all the points of calls.
Interestingly, this also affects GDB/MI, and in particular varobjs,
because local variables are now properly reported as having a block,
which causes the associated varob to have a "thread-id" field.
This patch also adjusts a couple of Ada/gdb-mi tests.
gdb/ChangeLog:
* ada-exp.y (write_var_from_sym): Remove parameter
"orig_left_context". Update all callers.
gdb/testsuite/ChangeLog:
* gdb.ada/scoped_watch: New testcase.
* gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior
which is actually correct.
* gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj.
* gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
|
|
Running perf on "gdb -nx -readnow -batch gdb", I'm seeing a lot of
time (24%.75!) spent in gettext, via complaints. 'perf report -g' shows:
- 86.23% 0.00% gdb gdb [.] gdb_main
- gdb_main
- 85.60% catch_command_errors
symbol_file_add_main_adapter
symbol_file_add_main
symbol_file_add_main_1
symbol_file_add
- symbol_file_add_with_addrs
- 84.31% dw2_expand_all_symtabs
- dw2_instantiate_symtab
- 83.79% dw2_do_instantiate_symtab
- 70.85% process_die
- 41.11% dwarf_decode_macros
- 41.09% dwarf_decode_macro_bytes
- 39.74% dwarf_decode_macro_bytes
>>>>>>>>>>>>>>>>>>>>>>> + 24.75% __dcigettext <<<<<<<
+ 7.37% macro_define_object_internal
+ 3.16% macro_define_function
0.77% splay_tree_insert
+ 0.76% savestring
+ 0.58% free
0.53% read_indirect_string_at_offset_from
0.54% macro_define_object_internal
0.51% macro_start_file
+ 25.57% process_die
+ 4.07% dwarf_decode_lines
+ 4.28% compute_delayed_physnames
+ 3.85% end_symtab_from_static_block
+ 3.38% load_cu
+ 1.29% end_symtab_get_static_block
+ 0.52% do_my_cleanups
+ 1.29% read_symbols
+ 0.54% gdb_init
The problem is that we're always computing the arguments to pass to
complaint, including passing the format strings through gettext, even
when complaints are disabled. As seen above, gettext can be quite
expensive.
Fix this by wrapping complaint in a macro that skips the real
complaint call when complaints are disabled.
This improves "gdb -nx -readnow -batch gdb" from
~11.0s => ~7.8s with -O2 -g3, and
~6.0s => ~5.3s with -O2 -g.
w/ gcc 5.3.1, on x86_64, for me.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* complaints.c (stop_whining): Make extern.
(complaint): Rename to ...
(complaint_internal): ... this.
* complaints.h (complaint): Rename to ...
(complaint_internal): ... this.
(complaint): Reimplement as macro around complaint_internal.
gdb/testsuite/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* gdb.gdb/complaints.exp (test_initial_complaints)
(test_serial_complaints, test_short_complaints): Call
complaint_internal instead of complaint.
|
|
A correct PID is needed by `libthread_db' library supplied with
glibc repository revisions before commit c579f48edba8 ("Remove
cached PID/TID in clone") or versions before 2.25 release for
GDB to fetch value of TLS variable from core file. On MIPS
platforms it was omitted and fetching value of TLS variable was not
available.
This adds a new test in order to be sure if GDB on native platforms
can successfully fetch value of TLS variable.
gdb/testsuite:
* gdb.threads/tls-core.c: New file.
* gdb.threads/tls-core.exp: Likewise.
|
|
Summary:
- This is preparation for supporting wild name matching on C++ too.
- This is also preparation for TAB-completion fixes.
- Makes symbol name matching (think strcmp_iw) be based on a per-language method.
- Merges completion and non-completion name comparison (think
language_ops::la_get_symbol_name_cmp generalized).
- Avoid re-hashing lookup name multiple times
- Centralizes preparing a name for lookup (Ada name encoding / C++ Demangling),
both completion and non-completion.
- Fixes Ada latent bug with verbatim name matches in expressions
- Makes ada-lang.c use common|symtab.c completion code a bit more.
Ada's wild matching basically means that
"(gdb) break foo"
will find all methods named "foo" in all packages. Translating to
C++, it's roughly the same as saying that "break klass::method" sets
breakpoints on all "klass::method" methods of all classes, no matter
the namespace. A following patch will teach GDB about fullname vs
wild matching for C++ too. This patch is preparatory work to get
there.
Another idea here is to do symbol name matching based on the symbol
language's algorithm. I.e., avoid dependency on current language set.
This allows for example doing
(gdb) b foo::bar< int > (<tab>
and having gdb name match the C++ symbols correctly even if the
current language is C or Assembly (or Rust, or Ada, or ...), which can
easily happen if you step into an Assembly/C runtime library frame.
By encapsulating all the information related to a lookup name in a
class, we can also cache hash computation for a given language in the
lookup name object, to avoid recomputing it over and over.
Similarly, because we don't really know upfront which languages the
lookup name will be matched against, for each language we store the
lookup name transformed into a search name. E.g., for C++, that means
demangling the name. But for Ada, it means encoding the name. This
actually forces us to centralize all the different lookup name
encoding in a central place, resulting in clearer code, IMO. See
e.g., the new ada_lookup_name_info class.
The lookup name -> symbol search name computation is also done only
once per language.
The old language->la_get_symbol_name_cmp / symbol_name_cmp_ftype are
generalized to work with both completion, and normal symbol look up.
At some point early on, I had separate completion vs non-completion
language vector entry points, but a single method ends up being better
IMO for simplifying things -- the more we merge the completion /
non-completion name lookup code paths, the less changes for bugs
causing completion vs normal lookup finding different symbols.
The ada-lex.l change is necessary because when doing
(gdb) p <UpperCase>
then the name that is passed to write_ write_var_or_type ->
ada_lookup_symbol_list misses the "<>", i.e., it's just "UpperCase",
and we end up doing a wild match against "UpperCase" lowercased by
ada_lookup_name_info's constructor. I.e., "uppercase" wouldn't ever
match "UpperCase", and the symbol lookup fails.
This wouldn't cause any regression in the testsuite, but I added a new
test that would pass before the patch and fail after, if it weren't
for that fix.
This is latent bug that happens to go unnoticed because that
particular path was inconsistent with the rest of Ada symbol lookup by
not lowercasing the lookup name.
Ada's symbol_completion_add is deleted, replaced by using common
code's completion_list_add_name. To make the latter work for Ada, we
needed to add a new output parameter, because Ada wants to return back
a custom completion candidates that are not the symbol name.
With this patch, minimal symbol demangled name hashing is made
consistent with regular symbol hashing. I.e., it now goes via the
language vector's search_name_hash method too, as I had suggested in a
previous patch.
dw2_expand_symtabs_matching / .gdb_index symbol names were a
challenge. The problem is that we have no way to telling what is the
language of each symbol name found in the index, until we expand the
corresponding full symbol, which is off course what we're trying to
avoid. Language information is simply not considered in the index
format... Since the symbol name hashing and comparison routines are
per-language, we now have a problem. The patch sorts this out by
matching each name against all languages. This is inneficient, and
indeed slows down completion several times. E.g., with:
$ cat script.cmd
set pagination off
set $count = 0
while $count < 400
complete b string_prin
printf "count = %d\n", $count
set $count = $count + 1
end
$ time gdb --batch -q ./gdb-with-index -ex "source script-string_printf.cmd"
I get, before patch (-O2, x86-64):
real 0m1.773s
user 0m1.737s
sys 0m0.040s
While after patch (-O2, x86-64):
real 0m9.843s
user 0m9.482s
sys 0m0.034s
However, the following patch will optimize this, and will actually
make this use case faster compared to the "before patch" above:
real 0m1.321s
user 0m1.285s
sys 0m0.039s
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_encode): Rename to ..
(ada_encode_1): ... this. Add throw_errors parameter and handle
it.
(ada_encode): Reimplement.
(match_name): Delete, folded into full_name.
(resolve_subexp): No longer pass the encoded name to
ada_lookup_symbol_list.
(should_use_wild_match): Delete.
(name_match_type_from_name): New.
(ada_lookup_simple_minsym): Use lookup_name_info and the
language's symbol_name_matcher_ftype.
(add_symbols_from_enclosing_procs, ada_add_local_symbols)
(ada_add_block_renamings): Adjust to use lookup_name_info.
(ada_lookup_name): New.
(add_nonlocal_symbols, ada_add_all_symbols)
(ada_lookup_symbol_list_worker, ada_lookup_symbol_list)
(ada_iterate_over_symbols): Adjust to use lookup_name_info.
(ada_name_for_lookup): Delete.
(ada_lookup_encoded_symbol): Construct a verbatim name.
(wild_match): Reverse sense of return type. Use bool.
(full_match): Reverse sense of return type. Inline bits of old
match_name here.
(ada_add_block_symbols): Adjust to use lookup_name_info.
(symbol_completion_match): Delete, folded into...
(ada_lookup_name_info::matches): ... .this new method.
(symbol_completion_add): Delete.
(ada_collect_symbol_completion_matches): Add name_match_type
parameter. Adjust to use lookup_name_info and
completion_list_add_name.
(get_var_value, ada_add_global_exceptions): Adjust to use
lookup_name_info.
(ada_get_symbol_name_cmp): Delete.
(do_wild_match, do_full_match): New functions.
(ada_lookup_name_info::ada_lookup_name_info): New method.
(ada_symbol_name_matches, ada_get_symbol_name_matcher): New
functions.
(ada_language_defn): Install ada_get_symbol_name_matcher.
* ada-lex.l (processId): If name starts with '<', copy it
verbatim.
* block.c (block_iter_match_step, block_iter_match_first)
(block_iter_match_next, block_lookup_symbol)
(block_lookup_symbol_primary, block_find_symbol): Adjust to use
lookup_name_info.
* block.h (block_iter_match_first, block_iter_match_next)
(ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use lookup_name_info.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust comments to
refer to la_get_symbol_name_matcher.
* completer.c (complete_files_symbols)
(collect_explicit_location_matches, symbol_completer): Pass a
symbol_name_match_type down.
* completer.h (class completion_match, completion_match_result):
New classes.
(completion_tracker::reset_completion_match_result): New method.
(completion_tracker::m_completion_match_result): New field.
* cp-support.c (make_symbol_overload_list_block): Adjust to use
lookup_name_info.
(cp_fq_symbol_name_matches, cp_get_symbol_name_matcher): New
functions.
* cp-support.h (cp_get_symbol_name_matcher): New declaration.
* d-lang.c: Adjust comments to refer to
la_get_symbol_name_matcher.
* dictionary.c (dict_vector) <iter_match_first, iter_match_next>:
Adjust to use lookup_name_info.
(dict_iter_match_first, dict_iter_match_next)
(iter_match_first_hashed, iter_match_next_hashed)
(iter_match_first_linear, iter_match_next_linear): Adjust to work
with a lookup_name_info.
* dictionary.h (dict_iter_match_first, dict_iter_match_next):
Likewise.
* dwarf2read.c (dw2_lookup_symbol): Adjust to use lookup_name_info.
(dw2_map_matching_symbols): Adjust to use symbol_name_match_type.
(gdb_index_symbol_name_matcher): New class.
(dw2_expand_symtabs_matching) Adjust to use lookup_name_info and
gdb_index_symbol_name_matcher. Accept a NULL symbol_matcher.
* f-lang.c (f_collect_symbol_completion_matches): Adjust to work
with a symbol_name_match_type.
(f_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* go-lang.c (go_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* language.c (default_symbol_name_matcher)
(language_get_symbol_name_matcher): New functions.
(unknown_language_defn, auto_language_defn): Adjust comments to
refer to la_get_symbol_name_matcher.
* language.h (symbol_name_cmp_ftype): Delete.
(language_defn) <la_collect_symbol_completion_matches>: Add match
type parameter.
<la_get_symbol_name_cmp>: Delete field.
<la_get_symbol_name_matcher>: New field.
<la_iterate_over_symbols>: Adjust to use lookup_name_info.
(default_symbol_name_matcher, language_get_symbol_name_matcher):
Declare.
* linespec.c (iterate_over_all_matching_symtabs)
(iterate_over_file_blocks): Adjust to use lookup_name_info.
(find_methods): Add language parameter, and use lookup_name_info
and the language's symbol_name_matcher_ftype.
(linespec_complete_function): Adjust.
(lookup_prefix_sym): Use lookup_name_info.
(add_all_symbol_names_from_pspace): Adjust.
(find_superclass_methods): Add language parameter and pass it
down.
(find_method): Pass symbol language down.
(find_linespec_symbols): Don't demangle or Ada encode here.
(search_minsyms_for_name): Add lookup_name_info parameter.
(add_matching_symbols_to_info): Add name_match_type parameter.
Use lookup_name_info.
* m2-lang.c (m2_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* minsyms.c: Include <algorithm>.
(add_minsym_to_demangled_hash_table): Remove table parameter and
add objfile parameter. Use search_name_hash, and add language to
demangled languages vector.
(struct found_minimal_symbols): New struct.
(lookup_minimal_symbol_mangled, lookup_minimal_symbol_demangled):
New functions.
(lookup_minimal_symbol): Adjust to use them. Don't canonicalize
input names here. Use lookup_name_info instead. Lookup up
demangled names once for each language in the demangled names
vector.
(iterate_over_minimal_symbols): Use lookup_name_info. Lookup up
demangled names once for each language in the demangled names
vector.
(build_minimal_symbol_hash_tables): Adjust.
* minsyms.h (iterate_over_minimal_symbols): Adjust to pass down a
lookup_name_info.
* objc-lang.c (objc_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* objfiles.h: Include <vector>.
(objfile_per_bfd_storage) <demangled_hash_languages>: New field.
* opencl-lang.c (opencl_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* p-lang.c (pascal_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* psymtab.c (psym_lookup_symbol): Use lookup_name_info.
(match_partial_symbol): Use symbol_name_match_type,
lookup_name_info and psymbol_name_matches.
(lookup_partial_symbol): Use lookup_name_info.
(map_block): Use symbol_name_match_type and lookup_name_info.
(psym_map_matching_symbols): Use symbol_name_match_type.
(psymbol_name_matches): New.
(recursively_search_psymtabs): Use lookup_name_info and
psymbol_name_matches. Rename 'kind' parameter to 'domain'.
(psym_expand_symtabs_matching): Use lookup_name_info. Rename
'kind' parameter to 'domain'.
* rust-lang.c (rust_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* symfile-debug.c (debug_qf_map_matching_symbols)
(debug_qf_map_matching_symbols): Use symbol_name_match_type.
(debug_qf_expand_symtabs_matching): Use lookup_name_info.
* symfile.c (expand_symtabs_matching): Use lookup_name_info.
* symfile.h (quick_symbol_functions) <map_matching_symbols>:
Adjust to use symbol_name_match_type.
<expand_symtabs_matching>: Adjust to use lookup_name_info.
(expand_symtabs_matching): Adjust to use lookup_name_info.
* symmisc.c (maintenance_expand_symtabs): Use
lookup_name_info::match_any ().
* symtab.c (symbol_matches_search_name): New.
(eq_symbol_entry): Adjust to use lookup_name_info and the
language's matcher.
(demangle_for_lookup_info::demangle_for_lookup_info): New.
(lookup_name_info::match_any): New.
(iterate_over_symbols, search_symbols): Use lookup_name_info.
(compare_symbol_name): Add language, lookup_name_info and
completion_match_result parameters, and use them.
(completion_list_add_name): Make extern. Add language and
lookup_name_info parameters. Use them.
(completion_list_add_symbol, completion_list_add_msymbol)
(completion_list_objc_symbol): Add lookup_name_info parameters and
adjust. Pass down language.
(completion_list_add_fields): Add lookup_name_info parameters and
adjust. Pass down language.
(add_symtab_completions): Add lookup_name_info parameters and
adjust.
(default_collect_symbol_completion_matches_break_on): Add
name_match_type parameter, and use it. Use lookup_name_info.
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches): Add name_match_type
parameter, and pass it down.
(collect_symbol_completion_matches_type): Adjust.
(collect_file_symbol_completion_matches): Add name_match_type
parameter, and use lookup_name_info.
* symtab.h: Include <string> and "common/gdb_optional.h".
(enum class symbol_name_match_type): New.
(class ada_lookup_name_info): New.
(struct demangle_for_lookup_info): New.
(class lookup_name_info): New.
(symbol_name_matcher_ftype): New.
(SYMBOL_MATCHES_SEARCH_NAME): Use symbol_matches_search_name.
(symbol_matches_search_name): Declare.
(MSYMBOL_MATCHES_SEARCH_NAME): Delete.
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_file_symbol_completion_matches): Add name_match_type
parameter.
(iterate_over_symbols): Use lookup_name_info.
(completion_list_add_name): Declare.
* utils.c (enum class strncmp_iw_mode): Moved to utils.h.
(strncmp_iw_with_mode): Now extern.
* utils.h (enum class strncmp_iw_mode): Moved from utils.c.
(strncmp_iw_with_mode): Declare.
gdb/testsuite/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* gdb.ada/complete.exp (p <Exported_Capitalized>): New test.
(p Exported_Capitalized): New test.
(p exported_capitalized): New test.
|
|
Some extra thoroughness tests that I had over here.
gdb/testsuite/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* gdb.cp/ena-dis-br-range.exp: Add more tests.
|
|
... and also make GDB catch a few more cases of invalid input.
This fixes the inconsistency in GDB's output (e.g., "bad" vs "Bad")
exposed by the new tests added in the previous commit.
Also, makes the "0-0" and "inverted range" cases be loud errors.
Also makes GDB reject negative breakpoint number in ranges. We
already rejected negative number literals, but you could still subvert
that via convenience variables, like:
(gdb) set $bp -1
(gdb) disable $bp.1-2
The change to get_number_trailer fixes a bug exposed by the new tests.
The function did not handle parsing "-$num". [This wasn't visible in
the gdb.multi/tids.exp (which has similar tests) because the TID range
parsing is implemented differently.]
gdb/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* breakpoint.c (extract_bp_kind): New enum.
(extract_bp_num, extract_bp_or_bp_range): New functions, partially
factored out from ...
(extract_bp_number_and_location): ... here.
* cli/cli-utils.c (get_number_trailer): Handle '-$variable'.
gdb/testsuite/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* gdb.base/ena-dis-br.exp (test_ena_dis_br): Adjust test.
* gdb.cp/ena-dis-br-range.exp: Adjust tests.
(disable_invalid, disable_inverted, disable_negative): New
procedures.
("bad numbers"): New set of tests.
|
|
This adds tests that exercise the "bad breakpoint number" paths.
Specifically:
- malformed ranges
- use of explicit 0 as bp/loc number.
- inverted ranges
I'm adding this as a baseline to improve. This shows that there's a
lot of inconsistency in GDB's output (e.g., "bad" vs "Bad").
Also, IMO, the "0-0" and inverted range cases should be loud errors.
That and more will all be addressed in the next patch.
gdb/testsuite/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* gdb.cp/ena-dis-br-range.exp: Add tests.
|
|
It's odd that when parsing a breakpoint or location number, we error out
in most cases, but warn in others.
(gdb) disable 1-
bad breakpoint number at or near: '1-'
(gdb) disable -1
bad breakpoint number at or near: '-1'
(gdb) disable .foo
bad breakpoint number at or near: '.foo'
(gdb) disable foo.1
Bad breakpoint number 'foo.1'
(gdb) disable 1.foo
warning: bad breakpoint number at or near '1.foo'
This changes GDB to always error out. It required touching one testcase
that expected the warning.
gdb/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* breakpoint.c (extract_bp_number_and_location): Change return
type to void. Throw error instead of warning.
(enable_disable_command): Adjust.
gdb/testsuite/ChangeLog:
2017-11-07 Pedro Alves <palves@redhat.com>
* gdb.base/ena-dis-br.exp: Don't expect "warning:".
|
|
When a breakpoint has multiple locations, like e.g.:
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x080486a2 in void foo<int>()...
1.2 y 0x080486ca in void foo<double>()...
[....]
1.5 y 0x080487fa in void foo<long>()...
it's possible to enable/disable the individual locations using the
'<breakpoint_number>.<location_number>' syntax, like e.g.:
(gdb) disable 1.2 1.3 1.4 1.5
That's inconvenient when you have a long list of locations to disable,
however.
This patch adds shorthand for the above, by making it possible to
specify a range of locations with the following syntax (similar to
thread id ranges):
<breakpoint_number>.<first_location_number>-<last_location_number>
For example, the command above can now be simplified to:
(gdb) disable 1.2-5
gdb/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (map_breakpoint_number_range): New, factored out
from ...
(map_breakpoint_numbers): ... here.
(find_location_by_number): Change parameters from string to
breakpoint number and location.
(extract_bp_number_and_location): New function.
(enable_disable_bp_num_loc)
(enable_disable_breakpoint_location_range)
(enable_disable_command): New functions, factored out ...
(enable_command, disable_command): ... these functions, and
adjusted to support ranges.
* NEWS: Document enable/disable breakpoint location range feature.
gdb/doc/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* gdb.texinfo (Set Breaks): Document support for breakpoint
location ranges in the enable/disable commands.
gdb/testsuite/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* gdb.base/ena-dis-br.exp: Add reference to
gdb.cp/ena-dis-br-range.exp.
* gdb.cp/ena-dis-br-range.exp: New file.
* gdb.cp/ena-dis-br-range.cc: New file.
|
|
The patch at
<https://sourceware.org/ml/gdb-patches/2017-11/msg00039.html> was
proposing to add an assertion to child_terminal_init that turns out
would fail if you tried to attach to a process that isn't a process
group leader.
Since the testsuite failed to catch the problem, this commit adds a
new testcase that would catch it, like:
(gdb) attach 12415
Attaching to program: build/gdb/testsuite/outputs/gdb.base/attach-non-pgrp-leader/attach-non-pgrp-leader, process 12415
src/gdb/inflow.c:180: internal-error: void child_terminal_init(target_ops*): Assertion `getpgid (inf->pid) == inf->pid' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.base/attach-non-pgrp-leader.exp: child: attach to child (GDB internal error)
gdb/testsuite/ChangeLog:
2017-11-06 Pedro Alves <palves@redhat.com>
* gdb.base/attach-non-pgrp-leader.c: New.
* gdb.base/attach-non-pgrp-leader.exp: New.
|
|
This commit garbage collects the termio and sgtty support.
GDB's terminal handling code still has support for the old termio and
sgtty interfaces in addition to termios. However, I think it's pretty
safe to assume that for a long, long time, Unix-like systems provide
termios. GNU/Linux, Solaris, Cygwin, AIX, DJGPP, macOS and the BSDs
all have had termios.h for many years. Looking around the web, I
found discussions about FreeBSD folks trying to get rid of old sgtty.h
a decade ago:
https://lists.freebsd.org/pipermail/freebsd-hackers/2007-March/019983.html
So I think support for termio and sgtty in GDB is just dead code that
is never compiled anywhere and is just getting in the way. For
example, serial_noflush_set_tty_state and the raw<->cooked concerns
mentioned in inflow.c only exist because of sgtty (see
hardwire_noflush_set_tty_state).
Regtested on GNU/Linux.
Confirmed that I can still build Solaris, DJGPP and AIX GDB and that
the resulting GDBs still include the termios.h-guarded code.
Confirmed mingw-w64 GDB still builds and skips the termios.h-guarded
code.
gdb/ChangeLog:
2017-11-06 Pedro Alves <palves@redhat.com>
* Makefile.in (SER_HARDWIRE): Update comment.
(HFILES_NO_SRCDIR): Remove gdb_termios.h.
* common/gdb_termios.h: Delete file.
* common/job-control.c: Include termios.h and unistd.h instead of
gdb_termios.h.
(gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor
check.
(have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
Remove sgtty code.
* configure.ac: No longer check for termio.h and sgtty.h.
* configure: Regenerate.
* inflow.c: Include termios.h instead of gdb_termios.h. Replace
PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout.
Replace PROCESS_GROUP_TYPE references with pid_t references
throughout.
(gdb_getpgrp): Delete.
(set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp.
(child_terminal_inferior): Remove comment. Remove sgtty code.
(child_terminal_ours_1): Use tcgetpgrp directly instead of
gdb_getpgrp. Use serial_set_tty_state instead aof
serial_noflush_set_tty_state. Remove sgtty code.
* inflow.h: Include unistd.h instead of gdb_termios.h. Replace
PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check.
(inferior_process_group): Now returns pid_t.
* ser-base.c (ser_base_noflush_set_tty_state): Delete.
* ser-base.h (ser_base_noflush_set_tty_state): Delete.
* ser-event.c (serial_event_ops): Update.
* ser-go32.c (dos_noflush_set_tty_state): Delete.
(dos_ops): Update.
* ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update.
* ser-pipe.c (pipe_ops): Update.
* ser-tcp.c (tcp_ops): Update.
* ser-unix.c: Include termios.h instead of gdb_termios.h. Remove
HAVE_TERMIOS checks.
[HAVE_TERMIO] (struct hardwire_ttystate): Delete.
[HAVE_SGTTY] (struct hardwire_ttystate): Delete.
(get_tty_state, set_tty_state): Drop termio and sgtty code, and
assume termios.
(hardwire_noflush_set_tty_state): Delete.
(hardwire_print_tty_state, hardwire_drain_output)
(hardwire_flush_output, hardwire_flush_input)
(hardwire_send_break, hardwire_raw, hardwire_setbaudrate)
(hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty
code, and assume termios.
(hardwire_ops): Update.
(_initialize_ser_hardwire): Remove HAVE_TERMIOS check.
* serial.c (serial_noflush_set_tty_state): Delete.
* serial.h (serial_noflush_set_tty_state): Delete.
(serial_ops::noflush_set_tty_state): Delete.
gdb/gdbserver/ChangeLog:
2017-11-06 Pedro Alves <palves@redhat.com>
* configure.ac: No longer check for termio.h and sgtty.h.
* configure: Regenerate.
* remote-utils.c: Include termios.h instead of gdb_termios.h.
(remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
Remove termio and sgtty code.
|
|
I see the following test fail in gdb (configured --with-expat=no),
-list-thread-groups --available^M
&"warning: Can not parse XML OS data; XML support was disabled at compile time\n"^M
^error,msg="Can not fetch data now."^M
(gdb) ^M
FAIL: gdb.mi/list-thread-groups-available.exp: list available thread groups (unexpected output)
This patch skips it if XML parsing in GDB is disabled, like what you did
in gdb.mi/mi-info-os.exp.
gdb/testsuite:
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.mi/list-thread-groups-available.exp: Skip it if XML parsing
in GDB is disabled.
|
|
gdb/testsuite:
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.python/py-thrhandle.exp: Skip it if python is not
enabled.
|
|
As reported here
https://sourceware.org/ml/gdb/2017-10/msg00020.html
the output of certain commands, like backtrace, doesn't appear anywhere
when it is run as a breakpoint command and when using MI.
The reason is that the current_uiout is set to the mi_ui_out while these
commands run, whereas we want the output as CLI output. Some commands
like "print" work, because they use printf_filtered (gdb_stdout, ...)
directly, bypassing the current ui_out.
The fix I did is to force setting the cli_uiout as the current_uiout
when calling execute_control_command. I am not sure if this is the
right way to fix the problem, comments about the approach would be
appreciated.
I enhanced gdb.mi/mi-break.exp to test the backtrace command.
Regtested on the buildbot.
gdb/ChangeLog:
* cli/cli-script.c (execute_control_command): Rename to ...
(execute_control_command_1): ... this.
(execute_control_command): New function.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-break.exp (test_breakpoint_commands): Test backtrace
as a breakpoint command.
|
|
thpy_get_inferior function should return a new reference to the
existing inferior object, and therefore should increment its refcount.
Fixed bug looks like this.
If multiple time call gdb.selected_thread ().inferior, gdb throws exception:
(gdb) pi gdb.selected_thread().inferior
<gdb.Inferior object at 0x7f1952bea698>
(gdb) pi gdb.selected_thread().inferior
Python Exception <type 'exceptions.AttributeError'> 'NoneType' object
has no attribute 'inferior':
Error while executing Python code.
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in
|
|
Currently, "info break" can show some (perhaps) unexpected results when
setting a breakpoint on an inlined function:
(gdb) list
1 #include <stdio.h>
2
3 static inline void foo()
4 {
5 printf("Hello world\n");
6 }
7
8 int main()
9 {
10 foo();
11 return 0;
12 }
13
(gdb) b foo
Breakpoint 1 at 0x400434: file foo.c, line 5.
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400434 in main at foo.c:5
GDB reported that we understood what "foo" was, but we then report that the
breakpoint is actually set in main. While that is literally true, we can
do a little better.
This is accomplished by copying the symbol for which the breakpoint was set
into the bp_location. From there, print_breakpoint_location can use this
information to print out symbol information (if available) instead of calling
find_pc_sect_function.
With the patch installed,
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400434 in foo at foo.c:5
gdb/ChangeLog:
* breakpoint.c (print_breakpoint_location): Use the symbol saved
in the bp_location, falling back to find_pc_sect_function when
needed.
(add_location_to_breakpoint): Save sal->symbol.
* breakpoint.h (struct bp_location) <symbol>: New field.
* symtab.c (find_function_start_sal): Save the symbol into the SaL.
* symtab.h (struct symtab_and_line) <symbol>: New field.
gdb/testsuite/ChangeLog:
* gdb.opt/inline-break.exp (break_info_1): New procedure.
Test "info break" for every inlined function breakpoint.
|
|
LR is a caller-save register, so, if inline asm does BL (which touches
LR), we should mark LR clobbered.
gdb/testsuite:
2017-10-27 Yao Qi <yao.qi@linaro.org>
* gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.
|
|
Recursion detection for static members was broken. The implementation
uses a growing (and shrinking) obstack object to simulate a stack of
addresses (CORE_ADDR). Pushing addresses is implemented by calling
obstack_grow(), while popping is implemented by calling obstack_free().
The latter is problematic because obstack_free() expects a pointer to
the base of an object. When popping elements of the stack however,
obstack_free() was called with the new top, which potentially is not the
same as the base of the stack. This is unintended use and the effect is
that obstack->next_free and obstack->object_base members are assigned
the value of the new top, which equals an empty stack. Summary: popping
elements would always result in an empty stack, which breaks the
recursion detection.
The fix shrinks the stack using obstack_blank_fast() with a negative
value as described at the bottom of this page:
https://gcc.gnu.org/onlinedocs/libiberty/Extra-Fast-Growing.html "You
can use obstack_blank_fast with a “negative” size argument to make the
current object smaller. Just don’t try to shrink it beyond zero
length—there’s no telling what will happen if you do that. Earlier
versions of obstacks allowed you to use obstack_blank to shrink objects.
This will no longer work."
The reproducer is added to gdb.cp/classes.exp, which fails without this
patch.
gdb/ChangeLog:
* cp-valprint.c (cp_print_value_fields): Use obstack_blank_fast
to rewind obstack.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.exp (test_static_members): Test printing
Outer::instance.
* gdb.cp/classes.c (struct Inner, struct Outer): New.
(Inner::instance, Outer::instance): New.
|
|
I noticed gdb.base/new-ui.exp failing once here with:
FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)
FAIL: gdb.base/new-ui.exp: do_test: main console: next causes no spurious output on other console
FAIL: gdb.base/new-ui.exp: do_test: main console: breakpoint hit reported on other console
The problem is 100% reproducible with check-read1:
$ make check-read1 TESTS="gdb.*/new-ui.exp"
testsuite/gdb.log shows:
delete
Delete all breakpoints? (y or n) [answered Y; input not from terminal]
(gdb) FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)
This commit fixes the problem.
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.base/new-ui.exp (do_test): Split "delete all breakpoints on
extra console" test in two stages.
|
|
A previous patch removed one nesting level.
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.threads/attach-into-signal.exp (corefunc): Reindent.
|
|
I noticed that the 'with_test_prefix "stoppedtry $stoppedtry"' prefix
in this testcase is unnecessary, because inside that block there are
no pass/fail calls. In fact the block includes a comment saying:
# No PASS message as we may be looping in multiple
# attempts.
but looking deeper at this I noticed a few odd things with this code
block:
1. This code is assuming that the second line in the /proc/PID/status
files is the "State:" line, which may have been true when this was
originally written, but is not true on my machine at least (Linux
4.8.13).
$ cat /proc/self/status
Name: cat
Umask: 0002
State: R (running)
So nowadays, that 'string match "*(stopped)*"' is running against
the "Umask:" line and thus always returns false, meaning the loop
always breaks on $stoppedtry == 0.
2. The loop seems to be waiting for the process to become "(stopped)",
but if so then that 'if {![string match]}' check is reversed, it
should be checking 'if {[string match]}' instead, because "string
match" returns true if the string matches, not 0.
3. But if we fixed all that, we'd still run into the simple fact that
nothing is actually stopping the test's inferior process before GDB
attaches... The top of the testcase says:
# This test was created by modifying attach-stopped.exp.
... and attach-stopped.exp does have:
# Stop the program
remote_exec build "kill -s STOP ${testpid}"
but then attach-stopped.exp doesn't have an equivalent
/proc/PID/status poll loop... (Maybe it could.)
So remove this whole loop as useless.
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.threads/attach-into-signal.exp: Remove whole "stoppedtry"
loop.
|
|
Currently, if you diff testsuite/gdb.sum of two testsuite runs you'll
often see spurious hunks like these:
-PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attempt 2: attach (pass 2), pending signal catch
+PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attempt 1: attach (pass 2), pending signal catch
PASS: gdb.threads/attach-into-signal.exp: successfully compiled posix threads test case
PASS: gdb.threads/attach-into-signal.exp: threaded: handle SIGALRM stop print pass
-PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 1: attach (pass 1), pending signal catch
-PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 1: attach (pass 2), pending signal catch
+PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 2: attach (pass 1), pending signal catch
+PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 4: attach (pass 2), pending signal catch
Fix this by removing the "attempt $attempt" test prefix. The attempt
number can be retrieved from gdb.log instead, since the testcase is
already using "verbose -log" to that effect.
(The 'with_test_prefix "stoppedtry $stoppedtry"' prefix is unnecessary
too, because inside that block there are no pass/fail calls. In fact
the block includes a comment saying:
# No PASS message as we may be looping in multiple
# attempts.
but I'll drop that whole loop in the next patch instead.)
After this commit we'll show:
PASS: gdb.threads/attach-into-signal.exp: nonthreaded: handle SIGALRM stop print pass
PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attach (pass 1), pending signal catch
PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attach (pass 2), pending signal catch
PASS: gdb.threads/attach-into-signal.exp: successfully compiled posix threads test case
PASS: gdb.threads/attach-into-signal.exp: threaded: handle SIGALRM stop print pass
PASS: gdb.threads/attach-into-signal.exp: threaded: attach (pass 1), pending signal catch
PASS: gdb.threads/attach-into-signal.exp: threaded: attach (pass 2), pending signal catch
(I've avoided reindenting to make the patch easier to maintain/read.
I'll reindent the blocks after this is in.)
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.threads/attach-into-signal.exp (corefunc): Remove "attach
$attempt" test prefix.
|
|
Currently, if you diff testsuite/gdb.sum of different builds you see
this spurious hunk:
-PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id" (6a0bfcab663f9810ccff33c756afdebb940037d4)
+PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id" (1f5531c657c57777b05fc95baa0025fd1d115c3b)
Fix this by syncing get_python_valueof with get_integer_valueof, which
stopped outputting the value in commit 2f20e312aad6
("get_integer_valueof: Don't output value in test name").
After this commit we'll show:
PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id"
As the comment explicitly says get_python_valueof is modeled on
get_integer_valueof, I went ahead and also added the optional 'test'
parameter while at it.
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* lib/gdb-python.exp (get_python_valueof): Add 'test' optional
parameter and handle it. Don't output read value in test name.
|
|
Currently, if you diff testsuite/gdb.sum of two builds built from different
source directories you see this spurious hunk:
-PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions /home/pedro/gdb1/src/gdb/testsuite/../features
+PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions /home/pedro/gdb2/src/gdb/testsuite/../features
After this commit we'll show instead:
PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions ${srcdir}/../features
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.gdb/unittest.exp ('maintenance check xml-descriptions'): Use
custom test name.
|
|
Currently, if you diff testsuite/gdb.sum of two builds in different
directories you see these spurious hunks:
-PASS: gdb.base/startup-with-shell.exp: touch /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/unique-file.unique-extension
+PASS: gdb.base/startup-with-shell.exp: touch /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/unique-file.unique-extension
-PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
+PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
-PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
+PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
Since the run_args arguments are already shown in the test prefix, we
can change the "set args" test name to literally "set args $run_args".
I.e., after this commit we'll show:
PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args $run_args
PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args $run_args
PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = $TEST: set args $run_args
PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = $TEST: set args $run_args
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.base/startup-with-shell.exp ('touch $unique_file'): Don't
include the unstable output directory name in the test's name.
(initial_setup_simple) <'set args'>: Use custom test name.
|
|
Currently if you diff testsuite/gdb.sum of two builds built from
different source trees you see this spurious hunk:
-PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb1/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml
+PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb2/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml
After this commit we'll show this instead in gdb.sum:
PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename $srcdir/gdb.arch/arc-tdesc-cpu.xml
gdb/testsuite/ChangeLog:
2017-10-24 Pedro Alves <palves@redhat.com>
* gdb.arch/arc-tdesc-cpu.exp ('set tdesc filename'): Use gdb_test
with explicit test name.
|
|
The [wait -i $gdb_spawn_id] in the test is dangerous in the sense that
it won't be subject to timeout logic. So if GDB fails quiting, this
testcase hangs forever, hanging the test run with it. See:
https://sourceware.org/ml/gdb-patches/2016-10/msg00728.html
Instead of 'wait'ing directly, use gdb_test_multiple and expect 'eof'.
Tested that the testcase no longer hangs by hacking the test to send
"info threads" instead of "quit".
Tested with
--target_board={unix, native-gdbserver,native-extended-gdbserver}
and tested with
--host_board=local-remote-host
as well.
gdb/testsuite/ChangeLog:
2017-10-20 Pedro Alves <palves@redhat.com>
* gdb.base/quit.exp: Use gdb_test_multiple and expect 'eof' before
'wait -i'. Use gdb_assert and remote_close.
|
|
Removes the use of a hard-coded line number from a test.
gdb/testsuite/ChangeLog:
* gdb.linespec/ls-errs.exp (do_test): Update comment, use line
number from variable rather than hard-coded.
|
|
Comparing test results between
--target_board=native-gdbserver
--target_board=native-stdio-gdbserver
I noticed that gdb.base/bigcore.exp is failing with native-stdio-gdbserver:
Running src/gdb/testsuite/gdb.base/bigcore.exp ...
FAIL: gdb.base/bigcore.exp: continue (timeout)
...
The problem is that:
1. When debugging with "target remote | CMD", the inferior's
stdout/stderr streams are connected to a pipe.
2. The bigcore.c program prints a lot to the screen before it
reaches the breakpoint location that the "continue" shown above
wants to reach.
3. GDB is not flushing the inferior's output pipe while the inferior
is running.
4. The pipe becomes full.
5. The inferior thus deadlocks.
The bug is #3 above, which is what this commit fixes. A new test is
added, that specifically exercises this scenario. The test fails
before the fix, and passes after, and gdb.base/bigcore.exp also starts
passing.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* ser-base.c (ser_base_read_error_fd): Delete the file handler if
async.
(handle_error_fd): New function.
(ser_base_async): Add/delete an event loop file handler for
error_fd.
gdb/testsuite/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* gdb.base/long-inferior-output.c: New file.
* gdb.base/long-inferior-output.exp: New file.
|
|
Consider a conversion operator such as:
operator foo const* const* ();
There are two small parser problems, highlighted by this test:
(gdb) p operator foo const* const*
There is no field named operatorfoo const* const *
GDB is looking up the symbol "operatorfoo const* const*" -- it is missing a
space between the keyword "operator" and the type name "foo const* const*".
Additionally, this input of the user-defined type needs to be canonicalized
so that different "spellings" of the type are recognized:
(gdb) p operator const foo* const *
There is no field named operator const foo* const *
gdb/ChangeLog:
* c-exp.y (oper): Canonicalize conversion operators of user-defined
types.
Add whitespace to front of type name.
gdb/testsuite/ChangeLog:
* gdb.cp/cpexprs.cc (base) <operator fluff const* const*>: New
method.
(main): Call it.
* gdb.cp/cpexprs.exp: Add new conversion operator to test matrix.
Add additional user-defined conversion operator tests.
|
|
I've noticed now that due to a last-minute change, commit 739b3f1d8ff7
("Make native gdbserver boards no longer be "remote" (in DejaGnu
terms)") managed to miss loading "local-board" in the
native-stdio-gdbserver board...
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* boards/native-stdio-gdbserver.exp: Load "local-board".
|
|
In my multi-target branch, I had managed to break GDB exiting
successfuly in response to "quit" or SIGHUP/SIGTERM when:
- you're debugging with "target extended-remote",
- have more than one inferior loaded in gdb, some running, and at
least one not running, and,
- quit gdb with the inferior that is not running yet selected.
The testsuite still passed cleanly anyway. I only noticed because I
was left with a bunch of core dumps in the gdb/testsuite/ directory --
the testsuite infrastructure closes GDB's pty after running each
testcase, which results in GDB getting a SIGHUP and should make GDB
exit gracefully. If GDB crashes at that point though, there's no
indication about it in gdb.sum/gdb.log.
This commit adds a multitude of tests exercising quitting GDB with
live inferiors, some of which would have caught the problem.
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/quit-live.c: New file.
* gdb.base/quit-live.exp: New file.
|
|
|
|
We currently do not record access information for typedefs defined inside
classes. Consider:
struct foo
{
typedef int PUBLIC;
private:
typedef int PRIVATE;
PRIVATE b;
};
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
typedef int PUBLIC;
}
This patch fixes this:
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
public:
typedef int PUBLIC;
}
gdb/ChangeLog:
* c-typeprint.c (enum access_specifier): Moved here from
c_type_print_base.
(output_access_specifier): New function.
(c_type_print_base): Consider typedefs when assessing
whether access labels are needed.
Use output_access_specifier as needed.
Output access specifier for typedefs, if needed.
* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
fields.
(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
accessor macros.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
(class_with_protected_typedef, class_with_private_typedef)
(struct_with_public_typedef, struct_with_protected_typedef)
(struct_with_private_typedef): New classes/structs.
* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
typedefs and access specifiers.
|
|
This commit finally clears the "isremote" flag in the native-gdbserver
and native-stdio-gdbserver boards. The goal is to make all "native"
boards be considered not remote in DejaGnu terms, like the
native-extended-gdbserver board is too.
DejaGnu automatically considers boards remote if their names don't
match the local hostname. That means that native-gdbserver and
native-extended-gdbserver are considered remote by default by DejaGnu,
even though they run locally. native-extended-gdbserver, however,
overrides its isremote flag to force it to be not remote. So we are
in that weird state where native-gdbserver is considered remote, and
native-extended-gdbserver is considered not remote.
A recent set of commits fixed all the problems (and some more) exposed
by testing with --target_board=native-gdbserver and
--target_board=native-stdio-gdbserver with isremote forced off on
x86-64 GNU/Linux. I believe we're good to go now.
The native-stdio-gdbserver.exp/remote-stdio-gdbserver.exp boards
required deep non-obvious modifications unfortunately... The problem
is that if a board is not remote, then DejaGnu doesn't call
${board}_spawn / ${board}_exec at all, and the
native-stdio-gdbserver.exp board relies on those procedures being
called. To fix that, this commit redesigns how the stdio boards hook
into the testing framework to spawn gdbserver. IMO, this is a good
change anyway, because the way its done currently is a bit of a hack,
and the result turns out to be simpler, even. With this commit, they
now no longer load the "gdbserver" generic config, and hook at the
mi_gdb_target_load/gdb_reload level instead, making them more like
traditional board files.
To share code between native-stdio-gdbserver.exp and
remote-stdio-gdbserver.exp, a new shared stdio-gdbserver-base.exp file
is created.
Instead of having each native board clear isremote manually, boards
source the new "local-board.exp" file.
This also adds a new section to testsuite/README file discussing
local/remote/native, so that we can easily refer to it.
gdb/testsuite/ChangeLog:
2017-10-16 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* README (Local vs Remote vs Native): New section.
* boards/local-board.exp: New file, with bits factored out from
...
* boards/native-extended-gdbserver.exp: ... here. Load
"local-board".
* boards/native-gdbserver.exp: Load "local-board".
(${board}_spawn, ${board}_exec): Delete.
* boards/native-stdio-gdbserver.exp: Most contents factored out to
...
* boards/stdio-gdbserver-base.exp: ... this new file.
* boards/native-stdio-gdbserver.exp: Reimplement, by loading
"stdio-gdbserver-base" and defining a get_target_remote_pipe_cmd
procedure.
* boards/remote-stdio-gdbserver.exp: Load stdio-gdbserver-base
instead of native-stdio-gdbserver. Don't set gdb_server_prog nor
stdio_gdbserver_command.
(${board}_get_remote_address, ${board}_get_comm_port)
(${board}_download, ${board}_upload): Delete.
(get_target_remote_pipe_cmd): New.
|
|
Use proc_with_prefix to avoid having to call with_test_prefix with a
duplicate of the proc name. The diff is mostly lines being re-indented.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.exp (test_bkpt_basic,
test_bkpt_deletion, test_bkpt_cond_and_cmds,
test_bkpt_invisible, test_watchpoints, test_bkpt_internal,
test_bkpt_eval_funcs, test_bkpt_temporary, test_bkpt_address,
test_bkpt_pending, test_bkpt_events): Use proc_with_prefix,
remove with_test_prefix.
|
|
These tests want to use raw "run", so skip them on targets that can't
do that.
Also adds a small utility procedure that clearly conveys intent instead of
explicitly checking use_gdb_stub in the testcases.
This makes sure these testcases continue to be skipped with
--target_board=native-gdbserver once that board stops setting
is_remote.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (target_can_use_run_cmd): New procedure.
* gdb.base/annota1.exp: Use it instead of is_remote.
* gdb.base/annota3.exp: Use it instead of is_remote.
* gdb.cp/annota2.exp: Use it instead of is_remote.
* gdb.cp/annota3.exp: Use it instead of is_remote.
* gdb.multi/bkpt-multi-exec.exp: Use it instead of is_remote.
|
|
Currently we get:
Running ..../src/gdb/testsuite/gdb.base/testenv.exp ...
FAIL: gdb.base/testenv.exp: test no TEST_GDB var
FAIL: gdb.base/testenv.exp: test with one TEST_GDB var
FAIL: gdb.base/testenv.exp: test with two TEST_GDB var
FAIL: gdb.base/testenv.exp: test with one TEST_GDB var, after unset
FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL
FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL unset
The problem is that the testcase relies on stdio. While we could fix
this for gdbserver by read output from inferior_spawn_id, a better fix
it to not rely on stdio at all. That's what this commit does.
Instead, it reads variables off of the inferior to extract the
necessary information.
Along the way, most of the .exp file is reimplemented/cleaned up using
more modern mechanisms. E.g., with_test_prefix, proc_with_prefix,
save_vars, etc. Also, a missing check for "is_remote host" is added.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/testenv.exp: Check use_gdb_stub instead of is_remote.
(test_num_test_vars, run_and_count_vars, find_env)
(test_set_unset_env, test_inherit_env_var): New procedures.
(top level): Use them.
|
|
If we make the native-gdbserver board be !is_remote, then the few
tests that use the selftest-support.exp routines to debug gdb itself
start running, and fail, with something like:
Running ..../src/gdb/testsuite/gdb.gdb/selftest.exp ...
ERROR: tcl error sourcing ..../src/gdb/testsuite/gdb.gdb/selftest.exp.
ERROR: gdbserver does not support run [....] without extended-remote
while executing
"error "gdbserver does not support $command without extended-remote""
(procedure "gdb_test_multiple" line 25)
invoked from within
"gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
-re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb..."
(procedure "selftest_setup" line 45)
This commit makes sure those tests continue to be skipped.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Extend comments, and
also skip on stub-like targets.
|
|
Currently, with --target_board=native-extended-gdbserver, we get:
Running .../src/gdb/testsuite/gdb.base/find-unmapped.exp ...
FAIL: gdb.base/find-unmapped.exp: find global_var_0, global_var_2, 0xff
FAIL: gdb.base/find-unmapped.exp: find global_var_1, global_var_2, 0xff
FAIL: gdb.base/find-unmapped.exp: find global_var_2, (global_var_2 + 16), 0xff
This commit makes the test pass there, and also enables in on
--target_board=native-gdbserver, and other remote targets.
I've filed PR gdb/22293 to track the missing-warning problem.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
PR gdb/22293
* gdb.base/find-unmapped.exp: Don't skip if is_remote target.
(top level): Move some tests to ...
(test_not_found): ... this new procedure.
(top level): Call it.
|
|
With --target_board=native-extended-gdbserver, we get:
Running .../src/gdb/testsuite/gdb.base/term.exp ...
FAIL: gdb.base/term.exp: info terminal at breakpoint
(gdb) info terminal
No saved terminal information.
Fix it by running the test everywhere, and expecting different output
on non-native targets.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/term.exp: Don't skip if is_remote target. Instead,
expect different "info terminal" output if testing with a
non-native target.
|
|
This testcase works fine with gdbserver nowadays. So remove the
kfail.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
PR python/12966
* gdb.python/py-evthreads.exp: Remove is_remote target kfail.
|
|
Fixes:
Running ..../src/gdb/testsuite/gdb.python/py-evthreads.exp ...
FAIL: gdb.python/py-evthreads.exp: run to breakpoint 1
FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2
FAIL: gdb.python/py-evthreads.exp: thread 2
FAIL: gdb.python/py-evthreads.exp: reached breakpoint 3
FAIL: gdb.python/py-evthreads.exp: thread 3
FAIL: gdb.python/py-evthreads.exp: continue thread 1
[... cascading time outs ...]
By following the usual pattern that makes sure that non-stop is enabled
before connecting to gdbserver.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.python/py-evthreads.exp: Start GDB with "set non-stop on"
already.
|
|
Fixes, with --target_board=native-extended-gdbserver:
Running ..../src/gdb/testsuite/gdb.python/py-evsignal.exp ...
FAIL: gdb.python/py-evsignal.exp: signal Thread 3
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.python/py-evsignal.exp: Check gdb_protocol instead of
is_remote.
|