D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5585 - bad debug line number info for return statements with enumerator expressions
Summary: bad debug line number info for return statements with enumerator expressions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-02-15 00:19 UTC by Rainer Schuetze
Modified: 2011-07-17 12:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2011-02-15 00:19:07 UTC
When compiled by dmd with debug information, stepping through the following code in a debugger

enum { Success, Failure }

int main()
{
	return Success;
}

makes the debugger jump to the enumerator declaration when the instruction pointer is in fact at the return statement. This can be very annoying because there is no information of the actual line of execution, you have to guess from the disassembly.

This is happening because the line info is taken from the first expression of the return statement, which is the initializer expression of the enum identifier. I suggest forcing the line number to the statement instead.

*** src\s2ir.c 2011-02-14 19:56:09.000000000 +-0100
--- src\s2ir.c 2011-02-07 01:49:13.000000000 +-0100
***************
*** 1287,1298 ****
--- 1287,1299 ----
          else
          {
              e = exp->toElem(irs);
              assert(e);
          }
  
+         elem_setLoc(e, loc);
          block_appendexp(blx->curblock, e);
          block_next(blx, BCretexp, NULL);
      }
      else
          block_next(blx, BCret, NULL);
  }


This is under Windows, but I guess it also applies to other OS supported by dmd.
Comment 1 Rainer Schuetze 2011-07-17 01:47:36 UTC
https://github.com/D-Programming-Language/dmd/pull/258