Bug 677681 - inline parameter poor debuginfo: cannot resolve context_switch parameters
Summary: inline parameter poor debuginfo: cannot resolve context_switch parameters
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 852126 1173076
TreeView+ depends on / blocked
 
Reported: 2011-02-15 15:15 UTC by Josh Boyer
Modified: 2015-12-02 16:02 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 852126 1173076 (view as bug list)
Environment:
Last Closed: 2015-12-02 02:34:21 UTC
Type: ---


Attachments (Terms of Use)
preprocessed sched.c (1.76 MB, text/plain)
2011-02-16 02:20 UTC, Josh Boyer
no flags Details
sched.s (2.79 MB, text/plain)
2011-02-16 02:20 UTC, Josh Boyer
no flags Details

Description Josh Boyer 2011-02-15 15:15:46 UTC
Description of problem:

If you try to run the semok/thirtynine.stp tapset, it errors out.

Version-Release number of selected component (if applicable):

[root@r2d2 testsuite]# rpm -qa | grep systemtap
systemtap-runtime-1.4-2.fc14.i686
systemtap-testsuite-1.4-2.fc14.i686
systemtap-1.4-2.fc14.i686
systemtap-sdt-devel-1.4-2.fc14.i686
[root@r2d2 testsuite]# 

(from updates-testing)

How reproducible:

Always

Steps to Reproduce:
1. cd /usr/share/systemtap/testsuite/
2. stap -v semok/thirtynine.stp
3. see error
  
Actual results:

[root@r2d2 testsuite]# stap -v semok/thirtynine.stp 
Pass 1: parsed user script and 76 library script(s) using 22820virt/13432res/2432shr kb, in 590usr/60sys/688real ms.
semantic error: not accessible at this address (0xc07a61a4, dieoffset: 0x586a2b): identifier '$prev' at semok/thirtynine.stp:6:40
        source:   printf("switch from=0x%x to=0x%x\n", $prev, $next)
                                                       ^
Pass 2: analyzed script: 1 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 181336virt/102872res/75504shr kb, in 1740usr/1530sys/5073real ms.
Pass 2: analysis failed.  Try again with another '--vp 01' option.

Expected results:

probe works

Additional info:

This seems very much related to systemtap PR 1155, but the final comment there says that with gcc 4.5 or RH gcc 4.4.* it should be resolved.  Maybe this is a regression?

http://sourceware.org/bugzilla/show_bug.cgi?id=1155

Comment 1 Frank Ch. Eigler 2011-02-15 15:26:35 UTC
Thank you for your report, Josh.
Indeed, gcc has dramatically improved its dwarf debuginfo quality since
4.4, but it's not perfect.  When we encounter cases like this, we
report them as bugs to gcc maintainers (see bug #668489 for example),
but they need preprocessed source code & CFLAGS.

Are you in a position to try to rpmbuild a kernel to gather such
information?

Comment 2 Josh Boyer 2011-02-15 18:17:28 UTC
(In reply to comment #1)
> Thank you for your report, Josh.
> Indeed, gcc has dramatically improved its dwarf debuginfo quality since
> 4.4, but it's not perfect.  When we encounter cases like this, we
> report them as bugs to gcc maintainers (see bug #668489 for example),
> but they need preprocessed source code & CFLAGS.
> 
> Are you in a position to try to rpmbuild a kernel to gather such
> information?

Yes.  Do you have some specific data you'd like me to gather?

Comment 3 Frank Ch. Eigler 2011-02-15 18:23:29 UTC
I think an rpmbuild -bp or perhaps -ba,
then make -C RPMBUILD/BUILD V=1 EXTRA_CFLAGS=-save-temps kernel/sched.o
then find the new .i file, and attach it to this bug; paste the CFLAGS used,
then reassign to component gcc (suckers! :-),
That's about it.

Comment 4 Josh Boyer 2011-02-16 02:19:01 UTC
This happens on x86_64 too, and that machine is much faster than the ATOM based i686 box I originally reported this on.  Here is the build output of the kernel and I'll attach the .i file shortly.

[jwboyer@hansolo linux-2.6.35.x86_64]$ make V=1 EXTRA_CFLAGS=-save-temps kernel/sched.o
make -f /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/Makefile silentoldconfig
make -f scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
mkdir -p include/linux include/config
make -f scripts/Makefile.build obj=scripts/kconfig silentoldconfig
mkdir -p include/generated
scripts/kconfig/conf -s arch/x86/Kconfig
rm -f include/config/kernel.release
echo "2.6.35.11$(/bin/sh /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/scripts/setlocalversion /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64)" > include/config/kernel.release
set -e; : '  CHK     include/linux/version.h'; mkdir -p include/linux/; 	(echo \#define LINUX_VERSION_CODE 132643; echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) < /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/Makefile > include/linux/version.h.tmp; if [ -r include/linux/version.h ] && cmp -s include/linux/version.h include/linux/version.h.tmp; then rm -f include/linux/version.h.tmp; else : '  UPD     include/linux/version.h'; mv -f include/linux/version.h.tmp include/linux/version.h; fi
set -e; : '  CHK     include/generated/utsrelease.h'; mkdir -p include/generated/; 	if [ `echo -n "2.6.35.11" | wc -c ` -gt 64 ]; then echo '"2.6.35.11" exceeds 64 characters' >&2; exit 1; fi; (echo \#define UTS_RELEASE \"2.6.35.11\";) < include/config/kernel.release > include/generated/utsrelease.h.tmp; if [ -r include/generated/utsrelease.h ] && cmp -s include/generated/utsrelease.h include/generated/utsrelease.h.tmp; then rm -f include/generated/utsrelease.h.tmp; else : '  UPD     include/generated/utsrelease.h'; mv -f include/generated/utsrelease.h.tmp include/generated/utsrelease.h; fi
mkdir -p .tmp_versions 
make -f scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f scripts/Makefile.build obj=.
mkdir -p kernel/
  gcc -Wp,-MD,kernel/.bounds.s.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include -I/home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -save-temps   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(bounds)"  -D"KBUILD_MODNAME=KBUILD_STR(bounds)" -D"DEBUG_HASH=49" -D"DEBUG_HASH2=5" -fverbose-asm -S -o kernel/bounds.s kernel/bounds.c
gcc: warning: -pipe ignored because -save-temps specified
mkdir -p include/generated/
  	(set -e; echo "#ifndef __LINUX_BOUNDS_H__"; echo "#define __LINUX_BOUNDS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " *"; echo " */"; echo ""; sed -ne 	"/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" kernel/bounds.s; echo ""; echo "#endif" ) > include/generated/bounds.h
mkdir -p arch/x86/kernel/
  gcc -Wp,-MD,arch/x86/kernel/.asm-offsets.s.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include -I/home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -save-temps   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(asm_offsets)"  -D"KBUILD_MODNAME=KBUILD_STR(asm_offsets)" -D"DEBUG_HASH=16" -D"DEBUG_HASH2=7" -fverbose-asm -S -o arch/x86/kernel/asm-offsets.s arch/x86/kernel/asm-offsets.c
gcc: warning: -pipe ignored because -save-temps specified
  	(set -e; echo "#ifndef __ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " *"; echo " */"; echo ""; sed -ne 	"/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" arch/x86/kernel/asm-offsets.s; echo ""; echo "#endif" ) > include/generated/asm-offsets.h
make -f scripts/Makefile.build obj=. missing-syscalls
  /bin/sh scripts/checksyscalls.sh gcc -Wp,-MD,./.missing-syscalls.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include -I/home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -save-temps   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(missing_syscalls)"  -D"KBUILD_MODNAME=KBUILD_STR(missing_syscalls)" -D"DEBUG_HASH=8" -D"DEBUG_HASH2=54"
gcc: warning: -pipe ignored because -save-temps specified
make -f scripts/Makefile.build obj=scripts
make -f scripts/Makefile.build obj=scripts/mod
  gcc -Wp,-MD,scripts/mod/.empty.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include -I/home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -save-temps   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(empty)"  -D"KBUILD_MODNAME=KBUILD_STR(empty)" -D"DEBUG_HASH=43" -D"DEBUG_HASH2=50" -c -o scripts/mod/empty.o scripts/mod/empty.c
gcc: warning: -pipe ignored because -save-temps specified
  set -e ; perl /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/scripts/recordmcount.pl "x86_64" "little" "64" "objdump" "objcopy" "gcc" "ld" "nm" "" "" "0" "scripts/mod/empty.o";
  gcc -Wp,-MD,scripts/mod/.mk_elfconfig.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -o scripts/mod/mk_elfconfig scripts/mod/mk_elfconfig.c  
  scripts/mod/mk_elfconfig < scripts/mod/empty.o > scripts/mod/elfconfig.h
  gcc -Wp,-MD,scripts/mod/.file2alias.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -c -o scripts/mod/file2alias.o scripts/mod/file2alias.c
  gcc -Wp,-MD,scripts/mod/.modpost.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -c -o scripts/mod/modpost.o scripts/mod/modpost.c
  gcc -Wp,-MD,scripts/mod/.sumversion.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -c -o scripts/mod/sumversion.o scripts/mod/sumversion.c
  gcc  -o scripts/mod/modpost scripts/mod/modpost.o scripts/mod/file2alias.o scripts/mod/sumversion.o  
make -f scripts/Makefile.build obj=scripts/selinux
make -f scripts/Makefile.build obj=scripts/selinux/genheaders
  gcc -Wp,-MD,scripts/selinux/genheaders/.genheaders.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -Isecurity/selinux/include  -o scripts/selinux/genheaders/genheaders scripts/selinux/genheaders/genheaders.c  
make -f scripts/Makefile.build obj=scripts/selinux/mdp
  gcc -Wp,-MD,scripts/selinux/mdp/.mdp.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -Isecurity/selinux/include  -o scripts/selinux/mdp/mdp scripts/selinux/mdp/mdp.c  
  gcc -Wp,-MD,scripts/.kallsyms.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -o scripts/kallsyms scripts/kallsyms.c  
  gcc -Wp,-MD,scripts/.pnmtologo.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -o scripts/pnmtologo scripts/pnmtologo.c  
  gcc -Wp,-MD,scripts/.conmakehash.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer     -o scripts/conmakehash scripts/conmakehash.c  
make -f scripts/Makefile.build obj=kernel kernel/sched.o
  gcc -Wp,-MD,kernel/.sched.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include -I/home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -save-temps   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(sched)"  -D"KBUILD_MODNAME=KBUILD_STR(sched)" -D"DEBUG_HASH=13" -D"DEBUG_HASH2=16" -c -o kernel/sched.o kernel/sched.c
gcc: warning: -pipe ignored because -save-temps specified
  set -e ; perl /home/jwboyer/rpm/BUILD/kernel-2.6.35.fc14/linux-2.6.35.x86_64/scripts/recordmcount.pl "x86_64" "little" "64" "objdump" "objcopy" "gcc" "ld" "nm" "" "" "0" "kernel/sched.o";
[jwboyer@hansolo linux-2.6.35.x86_64]$

Comment 5 Josh Boyer 2011-02-16 02:20:07 UTC
Created attachment 479005 [details]
preprocessed sched.c

Comment 6 Josh Boyer 2011-02-16 02:20:44 UTC
Created attachment 479006 [details]
sched.s

Comment 7 Josh Boyer 2011-02-16 02:23:24 UTC
And just to show it really does happen on x86_64:

[root@hansolo testsuite]# stap -v semok/thirtynine.stp 
Pass 1: parsed user script and 76 library script(s) using 96880virt/22496res/2844shr kb, in 180usr/20sys/200real ms.
semantic error: not accessible at this address (0xffffffff814683d8, dieoffset: 0x62431f): identifier '$prev' at semok/thirtynine.stp:6:40
        source:   printf("switch from=0x%x to=0x%x\n", $prev, $next)
                                                       ^
Pass 2: analyzed script: 1 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 244668virt/124020res/78572shr kb, in 660usr/40sys/707real ms.
Pass 2: analysis failed.  Try again with another '--vp 01' option.
[root@hansolo testsuite]# rpm -qa | systemtap
-bash: systemtap: command not found
[root@hansolo testsuite]#
[root@hansolo testsuite]# rpm -qa | grep systemtap
systemtap-1.4-2.fc14.x86_64
systemtap-testsuite-1.4-2.fc14.x86_64
systemtap-runtime-1.4-2.fc14.x86_64
systemtap-sdt-devel-1.4-2.fc14.x86_64
[root@hansolo testsuite]# rpm -qa | grep gcc
gcc-c++-4.5.1-4.fc14.x86_64
libgcc-4.5.1-4.fc14.i686
libgcc-4.5.1-4.fc14.x86_64
gcc-4.5.1-4.fc14.x86_64
[root@hansolo testsuite]# uname -a
Linux hansolo.jdub.homelinux.org 2.6.35.11-83.fc14.x86_64 #1 SMP Mon Feb 7 07:06:44 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@hansolo testsuite]#

Comment 8 Josh Boyer 2011-02-16 02:25:25 UTC
Reassigning to gcc, per Frank.

(Sorry)

Comment 9 Frank Ch. Eigler 2011-02-16 02:40:47 UTC
Thanks for the data gathering, Josh.

By the way, that version of the kernel probably has an nearly-equivalent
tracepoint that systemtap can attach to:  

  probe kernel.trace("sched_switch") { println($$parms$) }

Comment 10 Jakub Jelinek 2011-02-23 12:21:30 UTC
I don't see here details on where exactly you inspect the variables/parameters, there are many prev and next variables or parameters.

Comment 11 Frank Ch. Eigler 2011-02-23 12:37:25 UTC
Jakub, the function in question here is "context_switch".

Comment 12 Jakub Jelinek 2011-02-23 12:42:24 UTC
That is not precise enough, context_switch is an inline function.
Ideally I'd like to know on which pc you are inspecting the vars, mapped back to the assembly in #c6 (e.g. which line there or say copy a short snippet of the assembly around and say where it is, or objdump -dr around assuming you are looking at the same kernel as the assembly.

Comment 13 Frank Ch. Eigler 2011-02-23 12:51:50 UTC
Ideally, *all* inlined copies of context_switch should have those variables
resolvable.  In my f13 kernel, there appears to be only one such inlined
instance; how many do you see?

This stap invocation should give a PC value:
      stap -p2 -vv -e 'probe kernel.function("context_switch") {}'
and                                                            {println($next)}
should resolve the parameter.

Comment 14 Jakub Jelinek 2011-02-23 17:40:34 UTC
This is scheduler moving one insn from the inline fn ahead of the rest, while debug_insns for the inline fn stay right before the rest of the insns.

Simplified testcase (with today's gcc trunk on x86_64-linux):

/* { dg-options "-Os -mtune=generic -fno-omit-frame-pointer -g -dA" } */
struct task_struct;
struct thread_info { int preempt_count; };
struct hlist_node;
struct hlist_head { struct hlist_node *first; };
struct hlist_node { struct hlist_node *next, **pprev; };
struct preempt_notifier;
struct preempt_ops { void (*sched_out) (struct preempt_notifier *notifier, struct task_struct *next); };
struct preempt_notifier { struct hlist_node link; struct preempt_ops *ops; };
struct task_struct { volatile long state; struct hlist_head preempt_notifiers; };
struct rq { unsigned int skip_clock_update; unsigned long long nr_switches; struct task_struct *curr; };
struct rq *volatile rrq;
struct task_struct *volatile vnext;
struct thread_info *current_thread_info (void);

static void
fire_sched_out_preempt_notifiers (struct task_struct *curr, struct task_struct *next)
{
  struct preempt_notifier *notifier;
  struct hlist_node *node;
  for (node = curr->preempt_notifiers.first; node; node = node->next)
    {
      notifier = (__typeof (*notifier) *) node;
      notifier->ops->sched_out (notifier, next);
    }
}

static inline void
context_switch (struct rq *rq, struct task_struct *myprev, struct task_struct *mynext)
{
  fire_sched_out_preempt_notifiers (myprev, mynext);
  unsigned long __edi = __edi, __esi = __esi, __edx = __edx, __ecx = __ecx, __eax = __eax;
  asm volatile ("" : "=D" (__edi), "=S" (__esi), "=d" (__edx), "=c" (__ecx)
                   : "D" ((unsigned long)(myprev)) : "memory", "rax", "r8", "r9", "r10", "r11");
  asm volatile ("" : "=a" (myprev) : "S" (mynext), "D" (myprev)
                   : "memory", "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15");
}

void
schedule (void)
{
  struct task_struct *prev, *next;
  struct rq *rq;
  rq = rrq;
  prev = rq->curr;
  if (prev->state && !((current_thread_info ()->preempt_count) & 0x10000000))
    {
      if (prev->state & 1)
        prev->state = 0;
    }
  next = vnext;
  rq->skip_clock_update = 0;
  if (prev != next)
    {
      rq->nr_switches++;
      rq->curr = next;
      context_switch (rq, prev, next);
    }
}

context_switch fn has a two entry ranges, but .debug_loc range for myprev/mynext (renamed from prev/next to avoid confusion with schedule's prev/next) covers just the second range.  In *.split4 it still looks correct and the memory load is after the debug_insns, but sched2 moves it earlier.

Alex, is there anything that could be done about it?

Comment 15 Alexandre Oliva 2011-02-24 13:07:07 UTC
The proper fix is to implement SFN (my GCC Summit paper last year) in GCC and GDB.

The only short-term work-around I can think of is to disable the artificial dependency of debug insns on their immediate predecessors, but this may have devastating consequences to debug info, in the absence of SFN, and per the comments right before the change, it would likely cause codegen differences (compare-debug failures).

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 7293fc3..823d608 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -2816,7 +2816,7 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx insn)
 	 additional analysis can modify the generated code.  */
       prev = PREV_INSN (insn);
 
-      if (prev && NONDEBUG_INSN_P (prev))
+      if (0 && prev && NONDEBUG_INSN_P (prev))
 	add_dependence (insn, prev, REG_DEP_ANTI);
     }
   else

Comment 16 Mark Wielaard 2011-02-24 13:16:58 UTC
(In reply to comment #15)
> The proper fix is to implement SFN (my GCC Summit paper last year) in GCC and
> GDB.

Since I had to look it up anyway, SFN stands for Statement Frontier Annotations.
The gcc paper can be found at http://www.lsd.ic.unicamp.br/~oliva/papers/sfn/

Comment 17 Jakub Jelinek 2011-02-24 13:47:00 UTC
I meant something more conservative, roughly if an insn after some debug insn
is scheduled ahead of that debug insn, but the debug insn decl is not in the scope for any of the real insns it is being moved across (and obviously the second arguments of var_location allow such a move), then the debug insn can be moved together.  That is exactly what happens here, all the debug_insns refer to the inline fns vars/parameters, which isn't in scope of the real insns in between.  In that case IMHO the transformation shouldn't make debug info worse.
But, as I said, I'm not familiar with VTA stuff in the scheduler enough to know where and how something like that could be implementable.

Comment 18 Aravind vijayan 2011-12-28 04:54:17 UTC
    Thank you for your bug report. 

    We are sorry, but the Fedora Project is no longer releasing bug fixes or any other updates for this version of Fedora. This bug will be set to CLOSED:WONTFIX to reflect this, but please reopen it if the problem persists after upgrading to the latest version of Fedora, which is available from: 

    http://fedoraproject.org/get-fedora 



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 19 Frank Ch. Eigler 2011-12-28 12:02:26 UTC
Still affects rawhide / gcc 4.6.2.

Comment 20 Mark Wielaard 2012-08-12 20:15:09 UTC
Here is another example against GNU C 4.7.0 20120507 (Red Hat 4.7.0-5)

Found by Roman:

bash-4.2.37-2.fc17.x86_64 (current bash package for f17)

$ stap -e 'probe process("bash").function("execute_select_command"){print("%p\n", $select_command)}'
semantic error: not accessible at this address (0x4326c4, dieoffset: 0x202be): identifier '$select_command' at <input>:1:72
        source: probe process("bash").function("execute_select_command"){print("%p\n", $select_command)}
                                                                                       ^

Analysis from Jan:

 <4><202a6>: Abbrev Number: 64 (DW_TAG_inlined_subroutine)
    <202ab>   DW_AT_entry_pc    : 0x4326c4
 <5><202be>: Abbrev Number: 63 (DW_TAG_formal_parameter)
    <202c3>   DW_AT_location    : 0x21d01	(location list)
    00021d01 00000000004326d2 00000000004326d6 (DW_OP_reg1 (rdx))

/usr/src/debug/bash-4.2/execute_cmd.c:830
  4326c0:	49 8b 57 18             mov    0x18(%r15),%rdx
### %rdx is already valid here.
execute_select_command():
/usr/src/debug/bash-4.2/execute_cmd.c:2920
### This is the inlined function start PC.
  4326c4:	be 01 00 00 00          mov    $0x1,%esi
  4326c9:	48 8b 7a 08             mov    0x8(%rdx),%rdi
execute_command_internal():
/usr/src/debug/bash-4.2/execute_cmd.c:830
  4326cd:	48 89 54 24 50          mov    %rdx,0x50(%rsp)
execute_select_command():
/usr/src/debug/bash-4.2/execute_cmd.c:2920
### Here GCC only makes the %rdx value visible to debuggers.
  4326d2:	e8 49 77 ff ff          callq  429e20 <check_identifier>

Comment 21 Fedora End Of Life 2013-04-03 19:22:53 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 22 Frank Ch. Eigler 2014-12-11 12:06:43 UTC
This problem still exists as of f21:

% uname -a
Linux very.elastic.org 3.17.4-301.fc21.x86_64 #1 SMP Thu Nov 27 19:09:10 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

% stap -p2 -e 'probe kernel.function("context_switch") { println ($prev) }'
semantic error: not accessible at this address (pc: 0xffffffff8174192d) [man error::dwarf]: identifier '$prev' at <input>:1:52
        dieoffset: 0xbc6e1c from unknown debug file for kernel
        function: sched_info_switch at kernel/sched/stats.h:149 inlined by prepare_task_switch at kernel/sched/core.c:2186 inlined by context_switch at kernel/sched/core.c:2312 inlined by __schedule at kernel/sched/core.c:2821
        alternative locations: [0xffffffff81741a8c,0xffffffff81741aa3]
        source: probe kernel.function("context_switch") { println ($prev) }

Comment 23 Fedora End Of Life 2015-11-04 15:47:46 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 24 Josh Stone 2015-11-04 19:09:29 UTC
FWIW, comment 22 works on kernel-4.2.3-300.fc23.x86_64.

But comment 20 still fails on bash-4.3.42-1.fc23.x86_64.

Comment 25 Fedora End Of Life 2015-12-02 02:34:33 UTC
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.