Bug 13808 - Get `<unavailable>' when printing variables in gdb.trace/ftrace.exp
Summary: Get `<unavailable>' when printing variables in gdb.trace/ftrace.exp
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Marcin Kościelnicki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-05 15:23 UTC by Yao Qi
Modified: 2023-12-31 13:49 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yao Qi 2012-03-05 15:23:13 UTC
Run gdb.trace/ftrace.exp with board file "native-gdbserver.exp",

print globvar^M
$2 = <unavailable>^M
(gdb) FAIL: gdb.trace/ftrace.exp: print globvar
....
print anarg^M
$3 = <unavailable>^M
(gdb) FAIL: gdb.trace/ftrace.exp: print anarg
Comment 1 Jan Kratochvil 2012-10-24 13:27:14 UTC
On Fedora 18 x86_64:
KPASS: gdb.trace/ftrace.exp: print globvar (PRMS gdb/13808)
Why KFAIL, on which OS?
Comment 2 Yao Qi 2012-11-08 03:25:54 UTC
(In reply to comment #1)
> On Fedora 18 x86_64:
> KPASS: gdb.trace/ftrace.exp: print globvar (PRMS gdb/13808)
> Why KFAIL, on which OS?

There are still two kfails on RHEL 6.1

Running ../../../gdb/gdb/testsuite/gdb.trace/ftrace.exp ...

		=== gdb Summary ===

# of expected passes		10
# of known failures		2

$ cat /etc/redhat-release 
Red Hat Enterprise Linux Workstation release 6.1 (Santiago)
$ gcc --version
gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
Comment 3 Marcin Kościelnicki 2016-02-19 12:19:55 UTC
Whatever it is, it happens on s390 and s390x too.
Comment 4 Marcin Kościelnicki 2016-02-19 13:27:14 UTC
Ugh.  The problem comes from mismatched tdesc between gdbserver (which uses amd64_avx or whatever) and IPA (which always uses plain amd64).  This results in shorter R chunks in trace records coming from fast tracepoints.  Since R size is declared globally by gdbserver, this results in corrupted records and inability to read M chunks after the affected R chunk.

My suggestion: have gdbserver pass its tdesc idx/name/whatever to IPA when it loads, and use it in IPA.  I'll try implementing that one.
Comment 5 Pedro Alves 2016-02-19 20:30:09 UTC
Sounds good, thanks for taking this.
Comment 6 Marcin Kościelnicki 2016-02-21 21:39:57 UTC
Patch at https://sourceware.org/ml/gdb-patches/2016-02/msg00632.html - fixes one of the failures (the other now fails due to an unrelated reason, which I haven't debugged yet).
Comment 7 Sourceware Commits 2016-02-25 16:58:37 UTC
The master branch has been updated by Marcin Ko&#347;cielnicki <mwk@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ae91f6253926e4dadebcae90772f4f5a5bd06056

commit ae91f6253926e4dadebcae90772f4f5a5bd06056
Author: Marcin Kościelnicki <koriakin@0x04.net>
Date:   Sun Feb 21 21:44:48 2016 +0100

    [PR gdb/13808] gdb.trace: Pass tdesc selected in gdbserver to IPA.
    
    If gdbserver and IPA are using different tdesc, they will disagree
    about 'R' trace packet size.  This results in mangled traces.
    
    To make sure they pick the same tdesc, gdbserver pokes the tdesc
    (specified as an index in a target-specific list) into a global
    variable in IPA.  In theory, IPA could find out the tdesc on its
    own, but that may be complex (in particular, I don't know how to
    tell whether we have LAST_BREAK on s390 without messing with ptrace),
    and we'd have to duplicate the logic.
    
    Tested on i386 and x86_64.  On i386, it fixes two FAILs in ftrace.exp.
    On x86_64, these failures have been KFAILed - one of them works now,
    but the other now fails due to an unrelated reason (ugh).
    
    gdb/gdbserver/ChangeLog:
    
    	PR gdb/13808
    	* Makefile.in: Add i386-*-linux-ipa.o and amd64-*-linux-ipa.o.
    	* configure.srv: Ditto.
    	* linux-aarch64-ipa.c (get_ipa_tdesc): New function.
    	(initialize_low_tracepoint): Remove ipa_tdesc assignment.
    	* linux-amd64-ipa.c: Add "linux-x86-tdesc.h" include.
    	(init_registers_amd64_linux): Remove prototype.
    	(tdesc_amd64_linux): Remove declaration.
    	(get_ipa_tdesc): New function.
    	(initialize_low_tracepoint): Remove ipa_tdesc assignment,
    	initialize remaining tdescs.
    	* linux-i386-ipa.c: Add "linux-x86-tdesc.h" include.
    	(init_registers_i386_linux): Remove prototype.
    	(tdesc_i386_linux): Remove declaration.
    	(get_ipa_tdesc): New function.
    	(initialize_low_tracepoint): Remove ipa_tdesc assignment,
    	initialize remaining tdescs.
    	* linux-low.c (linux_get_ipa_tdesc_idx): New function.
    	(linux_target_ops): wire in linux_get_ipa_tdesc_idx.
    	* linux-low.h (struct linux_target_ops): Add get_ipa_tdesc_idx.
    	* linux-x86-low.c: Move tdesc declarations to linux-x86-tdesc.h.
    	(x86_get_ipa_tdesc_idx): New function.
    	(the_low_target): Wire in x86_get_ipa_tdesc_idx.
    	* linux-x86-tdesc.h: New file.
    	* target.h (struct target_ops): Add get_ipa_tdesc_idx.
    	(target_get_ipa_tdesc_idx): New macro.
    	* tracepoint.c (ipa_tdesc_idx): New macro.
    	(struct ipa_sym_addresses): Add addr_ipa_tdesc_idx.
    	(symbol_list): Add ipa_tdesc_idx.
    	(cmd_qtstart): Write ipa_tdesc_idx in the target.
    	(ipa_tdesc): Remove.
    	(ipa_tdesc_idx): New variable.
    	(get_context_regcache): Use get_ipa_tdesc.
    	(gdb_collect): Ditto.
    	(gdb_probe): Ditto.
    	* tracepoint.h (get_ipa_tdesc): New prototype.
    	(ipa_tdesc): Remove.
    
    gdb/testsuite/ChangeLog:
    
    	PR gdb/13808
    	* gdb.trace/ftrace.exp (test_fast_tracepoints): Remove kfail.
Comment 8 Hannes Domani 2023-12-31 13:49:12 UTC
(In reply to Sourceware Commits from comment #7)
> The master branch has been updated by Marcin Ko&#347;cielnicki
> <mwk@sourceware.org>:
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=ae91f6253926e4dadebcae90772f4f5a5bd06056
> 
> commit ae91f6253926e4dadebcae90772f4f5a5bd06056
> Author: Marcin Kościelnicki <koriakin@0x04.net>
> Date:   Sun Feb 21 21:44:48 2016 +0100
> 
>     [PR gdb/13808] gdb.trace: Pass tdesc selected in gdbserver to IPA.
>     
>     If gdbserver and IPA are using different tdesc, they will disagree
>     about 'R' trace packet size.  This results in mangled traces.
>     
>     To make sure they pick the same tdesc, gdbserver pokes the tdesc
>     (specified as an index in a target-specific list) into a global
>     variable in IPA.  In theory, IPA could find out the tdesc on its
>     own, but that may be complex (in particular, I don't know how to
>     tell whether we have LAST_BREAK on s390 without messing with ptrace),
>     and we'd have to duplicate the logic.
>     
>     Tested on i386 and x86_64.  On i386, it fixes two FAILs in ftrace.exp.
>     On x86_64, these failures have been KFAILed - one of them works now,
>     but the other now fails due to an unrelated reason (ugh).
>     
>     gdb/gdbserver/ChangeLog:
>     
>     	PR gdb/13808
>     	* Makefile.in: Add i386-*-linux-ipa.o and amd64-*-linux-ipa.o.
>     	* configure.srv: Ditto.
>     	* linux-aarch64-ipa.c (get_ipa_tdesc): New function.
>     	(initialize_low_tracepoint): Remove ipa_tdesc assignment.
>     	* linux-amd64-ipa.c: Add "linux-x86-tdesc.h" include.
>     	(init_registers_amd64_linux): Remove prototype.
>     	(tdesc_amd64_linux): Remove declaration.
>     	(get_ipa_tdesc): New function.
>     	(initialize_low_tracepoint): Remove ipa_tdesc assignment,
>     	initialize remaining tdescs.
>     	* linux-i386-ipa.c: Add "linux-x86-tdesc.h" include.
>     	(init_registers_i386_linux): Remove prototype.
>     	(tdesc_i386_linux): Remove declaration.
>     	(get_ipa_tdesc): New function.
>     	(initialize_low_tracepoint): Remove ipa_tdesc assignment,
>     	initialize remaining tdescs.
>     	* linux-low.c (linux_get_ipa_tdesc_idx): New function.
>     	(linux_target_ops): wire in linux_get_ipa_tdesc_idx.
>     	* linux-low.h (struct linux_target_ops): Add get_ipa_tdesc_idx.
>     	* linux-x86-low.c: Move tdesc declarations to linux-x86-tdesc.h.
>     	(x86_get_ipa_tdesc_idx): New function.
>     	(the_low_target): Wire in x86_get_ipa_tdesc_idx.
>     	* linux-x86-tdesc.h: New file.
>     	* target.h (struct target_ops): Add get_ipa_tdesc_idx.
>     	(target_get_ipa_tdesc_idx): New macro.
>     	* tracepoint.c (ipa_tdesc_idx): New macro.
>     	(struct ipa_sym_addresses): Add addr_ipa_tdesc_idx.
>     	(symbol_list): Add ipa_tdesc_idx.
>     	(cmd_qtstart): Write ipa_tdesc_idx in the target.
>     	(ipa_tdesc): Remove.
>     	(ipa_tdesc_idx): New variable.
>     	(get_context_regcache): Use get_ipa_tdesc.
>     	(gdb_collect): Ditto.
>     	(gdb_probe): Ditto.
>     	* tracepoint.h (get_ipa_tdesc): New prototype.
>     	(ipa_tdesc): Remove.
>     
>     gdb/testsuite/ChangeLog:
>     
>     	PR gdb/13808
>     	* gdb.trace/ftrace.exp (test_fast_tracepoints): Remove kfail.

Can this be closed now?