Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][debug] Scope of the contained subroutine is not correct. #96314

Closed
abidh opened this issue Jun 21, 2024 · 2 comments · Fixed by #99531
Closed

[flang][debug] Scope of the contained subroutine is not correct. #96314

abidh opened this issue Jun 21, 2024 · 2 comments · Fixed by #99531
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir

Comments

@abidh
Copy link
Contributor

abidh commented Jun 21, 2024

If the following program is compiled with flang, the scope of sub1 is not the parent function that contains it. As a result, when control is stopped in sub1, debugger fails to evaluate the variable in parent function (e.g.i) .

with gfortran

Breakpoint 1, test::sub1 (m=2) at ../../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
$1 = 2

With flang

Breakpoint 1, sub1 (m=2) at ../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
No symbol "i" in current context.
program test
  integer i
  i = 2
  call sub1(i)
  i = i + 1
  call sub2(5)
  print *, i
contains
  subroutine sub1(m)
    integer m
    print *, "sub1: ", m
  end subroutine sub1
end program test

subroutine sub2(n)
    integer n
    print *, "sub2: ", n
end subroutine sub2
@abidh abidh self-assigned this Jun 21, 2024
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Jun 21, 2024
@EugeneZelenko EugeneZelenko added flang:ir and removed flang Flang issues not falling into any other category labels Jun 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2024

@llvm/issue-subscribers-flang-ir

Author: Abid Qadeer (abidh)

If the following program is compiled with flang, the scope of `sub1` is not the parent function that contains it. As a result, when control is stopped in `sub1`, debugger fails to evaluate the variable in parent function (e.g.`i`) .

with gfortran

Breakpoint 1, test::sub1 (m=2) at ../../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
$1 = 2

With flang

Breakpoint 1, sub1 (m=2) at ../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
No symbol "i" in current context.
program test
  integer i
  i = 2
  call sub1(i)
  i = i + 1
  call sub2(5)
  print *, i
contains
  subroutine sub1(m)
    integer m
    print *, "sub1: ", m
  end subroutine sub1
end program test

subroutine sub2(n)
    integer n
    print *, "sub2: ", n
end subroutine sub2

@psteinfeld psteinfeld added the bug Indicates an unexpected problem or unintended behavior label Jun 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2024

@llvm/issue-subscribers-bug

Author: Abid Qadeer (abidh)

If the following program is compiled with flang, the scope of `sub1` is not the parent function that contains it. As a result, when control is stopped in `sub1`, debugger fails to evaluate the variable in parent function (e.g.`i`) .

with gfortran

Breakpoint 1, test::sub1 (m=2) at ../../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
$1 = 2

With flang

Breakpoint 1, sub1 (m=2) at ../test1.f90:11
11          print *, "sub1: ", m
(gdb) p i
No symbol "i" in current context.
program test
  integer i
  i = 2
  call sub1(i)
  i = i + 1
  call sub2(5)
  print *, i
contains
  subroutine sub1(m)
    integer m
    print *, "sub1: ", m
  end subroutine sub1
end program test

subroutine sub2(n)
    integer n
    print *, "sub2: ", n
end subroutine sub2

abidh added a commit to abidh/llvm-project that referenced this issue Jul 18, 2024
The functions internal to subroutine should have the scope set to the
parent function. This allows to evaluate variable in parent when control
is stopped in the child.

Fixes llvm#96314
abidh added a commit to abidh/llvm-project that referenced this issue Jul 24, 2024
The functions internal to subroutine should have the scope set to the
parent function. This allows to evaluate variable in parent when control
is stopped in the child.

Fixes llvm#96314
abidh added a commit that referenced this issue Jul 25, 2024
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.

Fixes #96314
yuxuanchen1997 pushed a commit that referenced this issue Jul 25, 2024
Summary:
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.

Fixes #96314

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250527
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Jul 26, 2024
Summary:
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.

Fixes llvm#96314

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: https://phabricator.intern.facebook.com/D60250527

(cherry picked from commit 626022b)
tru pushed a commit to llvmbot/llvm-project that referenced this issue Jul 26, 2024
Summary:
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.

Fixes llvm#96314

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: https://phabricator.intern.facebook.com/D60250527

(cherry picked from commit 626022b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants