Related
My brand new Delphi XE shows hundreds of errors in 'Structure' panel. It shows errors like 'Undeclared FileExists at line 130' or 'Undeclared Create at line 242'. Even if it shows those errors, the program compiles just fine.
I also see that code insight is not always working. When I move the cursor over a variable, the cursor starts to flicker and no pop-up appears. Other times, it just highlight some units in red and it says the it cannot find them.
There are tricks to fix all these issues?
Update/Pseudo-fix:
I have found that restarting the IDE helps for a while.
I really help that one day Embarcadero will release Delphi ST (from STable).
:)
Yeah, CodeInsight and ErrorInsight are known to have lots of problems. They've gotten a bit better each version for a while now, but there's still a lot to be done. Andreas Hausladen, who's probably the smartest guy in the Delphi community, has done a lot of poking around in the IDE internals, and he says they have race condition-based bugs that probably can't be fixed without a total rewrite.
If these fake errors are giving you trouble, you can probably disable them, as Ken mentioned in his comment.
For me it usually helps to close the project and re-open it; the structure errors disappear.
It appears that much of the Error-Insight problems go away if you keep your library entries up to date.
This is was once pointed out by someone AGES ago on problem report for an earlier Delphi version and no-one seems to have picked up on it. If error-insight encounters a non-existent file in the LIBRARIES list it appears to just stop looking any further - leaving those annoying red-line squiggles everywhere! Trouble was, that problem report had so many entries everyone seems to keep missing that solution!
Go to Tools-Options and find the LIBRARY tab. Go through the lists and eliminate every entry that is ABSOLUTE but INVALID. You probably can and initially should leave any that have variables in them like $(BDSLIB) even if invalid, but definitely start by removing invalid ones that are declared without variables (which is what I mean by absolute). If you are gung-ho and just let Delphi auto-delete the invalid ones, all those with "unfulfilled" variables will disappear too - and that will break many things (this is another Delphi bug discussed elsewhere in this forum I believe). You may also have to repeat this with the Project-Options libraries, but be more circumspect here if the project came from someone else!
If that doesn't do the job immediately, then use the appropriate options tab to toggle the Error-Insight checkbox off and then back on again (closing the options dialog each time). That should get rid of any cached stuff, if such exists.
Deleting just some invalid entries worked for me on Delphi XE4.
We noticed why problems occur.
If there are some invalid invisible chars exist in code, this shows as error. These invalid chars sometime occurs when you copy some text and paste in delphi editor. Then, sometimes delphi paste text with invalid chars!
First you should copy all errored text and paste it on notepad++.
You will see that all text you copied will not be pasted as well.
You will see that corrupted text. You should look at code pasted, determine which code pasted as text. You should look which code could you see on notepad as pasted last char.
here we can see on picture captured: " RoutePatternObject); "
so after these chars some invalid characters occur here but we can not see!
So we select these text area after " ; " character.
Then delete and retype deleted codes again!
All red underline signatures will disappear!
I have had the same errors before and i asked the same question, this was the reply:
From another post:
You did not make a mistake. The problem is that the there are three
compilers in XE2 (like in previous versions of Delphi): the real
compiler (which works fine), the Code Insight compiler (which is
faster), the Error Insight compiler (which must be even more faster),
and the syntax highlighting parser (which is the fastest).
XE2 introduced a number of features that made the normal compiler
slower, and gave the Code Insight and Error Insight compilers a bit of
trouble. First of all, we have the new targets: Win32, Win64 and OSX
which cause the search paths to be different for each target (see
$PLATFORM directive), as well as build configuration, although there
is only one "Library path" for each PLATFORM (and not for the build
configurations).
The second complexing factor is the dotted unit names (scoped unit
names) that were introduced. Windows is no longer Windows, but
Winapi.Windows.
My guess is that these two additional complexing factors cause
problems for the Code Insight and Error Insight compilers. Note that
the real compiler still works. But the Error Insight shows incorrect
errors, and the Code Insight doesn't always work for these units.
You could try to explicitly add them to the project again (in which
case the full path will be used, like you mention in your question on
stack overflow as well).
What I found out was:
99% of the errors are due to edited files not being save right
(including references)
If you add profiles Save your .dpr, .dproj, .pas, .dfm files (save
unit, save project)
If all fails a save + restart will usually fix it
For older projects delete the .res file, it has botched paths,
Delphi will recreate it.
(Sorry for the bad initial post, Just got a Stackoverflow account, was not allowed to edit it. I hope this will suffice)
Copy and pasting the pas file into Notepad, clearing the pas file, saving, closing the IDE, opening the IDE then copying from notepad and pasting back to the pas file worked for me.
From time to time I lose breakpoint functionality in Delphi.
I thought this to be a Delphi 2009 issue but now I have also it in Delphi XE.
In Delphi 2009 by deleting .dproj file I made the breakpoints work again.
In Delphi XE I am not able to make breakopints appear. I have update 1 with all hotfixes applied.
Does anyone have a solution?
Debug info isn't present in the file.
Make sure that you're using the Debug configuration. (Project Manager tree, expand Build Configurations, make sure Debug is bold. If it's not, right click Debug and choose Activate from the context menu.) Make sure you then do a Build of your project, not just a Compile.
If that still doesn't work, go to Project->Options from the IDE's main menu, click on Compiling under Delphi Compiler, and check the Debugging section on the right half of the window. Make sure that Debug Information and Local Symbols are both checked. If you're trying to trace into the VCL's own source, also check Use debug .dcus (you'll want to turn this off and do a full build of your project as soon as you're done, as it gets annoying when you're debugging normally). Again, you'll want to build and not compile.
If all of the above fails, another possibility is that the code unit you have open in the Code Editor isn't the same one being seen by the compiler. Make sure you don't have multiple copies of the file on your computer in a location that the compiler might find first. If you're not sure, delete the .dcu files with that unit name and then do a build of your project, and see if the newly created .dcu is in the location you'd expect.
I found a better way.
From the Project Manager tree, right click on the project and choose "Clean" from the popupmenu.
The breakpoints reappear magically and it is a very fast method.
I suspect this happens when you have done a release build, with debug disabled. Then you switch back to debug configuration and do a compile rather than a build. The files where you can't set breakpoints correspond to those with DCUs produced by a compile with debug disabled.
Simply doing a build to re-generate all DCU files will make your breakpoints work again.
Here's one more reason to misaligned code vs breakpoint markers (blue/red "pill" in the gutter).
The editor recognices three different line endings,
CRLF (Carriage Return - Line Feed pair)
CR only
LF only
Of these, CRLF is the default in the editor.
The compiler however, doesn't seem to consider CR only as a line ending, only CRLF and LF only. Thus if your source file happens to have one or more CR only, the "blue pills" will be offset from the source.
You might have got source files with CR only EOL (end of line) character from e.g. the internet. I recall MAC OS used CR only as EOL.
To verify the EOL's in your file, you can turn on the displaying of EOL's in the editor
( Tools - Options - Editor options - Source options - Show line breaks).
The symbols look weird (see images below), but are just C on top of L for CRLF, C on top of R for CR and L on top of F for LF.
The following images show the normal EOL's (CRLF) and the EOLS's after I forced CR only for one line and LF only for another line in a hex editor. As said above, it is the CR only that offsets the break point markers from the source code.
Normal CRLF EOL's:
One line with CR only and one with LF only:
Fix
To reset all EOL's to CRLF, untick Preserve line ends in Editor Options
( Tools - Options - Editor options),
make a trivial change, so that the file is marked as modified, close the file, save changes to XYZ.pas? YES, and reopen.
Now all line endings are CRLF. Rebuilt the project and all the breakpoint balls will be in the correct locations.
Turning on remote debugging symbols did it for me (nothing else worked). Project > Options > Linking and check Include remote debug symbols.
I had the same problem with XE4. This is why I found this article a couple of hours ago. None of the above solutions worked for me. The correct solution for me - up to now - was to add "remote debug symbols" option. Strange because I don't use remote debugging. Anyway it looks OK now.
It is a bug, restarting Delphi will fix your problem.
Try remote debugging to your local PC.
Why it works: (source)
When you debug Delphi projects locally, RAD Studio does not use your RSM debug file because the compiler holds the symbol tables in memory. However, when you debug Delphi projects remotely, you must generate an RSM debug file that contains those symbol tables; otherwise, RAD Studio does not stop at your breakpoints.
Of course, you must first configure your project's "Linking" option "Map file" to "Detailed" to generate the *.rsm file. See Overview of Remote Debugging for how to get started.
I had a related problem: I lost the breakpoints in a particular file, but the other files were fine. What had happened was that I had renamed that file, but unknown to me the DCU for the old file was still being used because it was being referenced in a "uses" clause somewhere.
The solution is to manually delete all the DCUs (doing a "clean" is not enough because the old file represented by the DCU is no longer in the project) and rebuild. You will get a compile error showing the bad "uses" clauses.
Another reason for not working breakpoint could be (often tested with delphi5):
Too many procedures in a unit.
The solution is to move procedures to another unit
Although this is an old question I can confirm that this is still an issue in the current version of Delphi 10.3 Rio.
The answer above regarding line endings
https://stackoverflow.com/a/53360447/6445054
Solved the issue for me I had imported some very old Delphi code which had CR line endings
in a couple of places, as soon as I started moving code around the debugging broke completely.
The option to turn line endings on has moved slightly in Rio it's now
( Tools - Options - Editor - Source - Show line breaks).
In delphi 7 there seems to be a real bug on setting breakpoints.
I had a unit where many texts are definied in a
const constname : array[0..x] of record-type = (...);
in interface section, where record-type has some AnsiString items.
In the implementation section there are some procedures.
In some particular cases, when I set a breakpoint anywhere within a procedure, delphi does not stop at it!
Remarks: all options for debugging are set properly (as for F7 causes delphi stop at the "begin" of the program, blue dots are visible in the whole unit the line stays red while executing the app) and all DCUs that have according PAS files were deleted from all of my disks and within all folders, before I did a complete build on the whole project. So no wold files should hang around anywhere.
For testing, I renamed the PAS to another name, never ever used before, and surely nowhere else on any disk, then adapted all sources and recompiled, just to be sure that delphi and I are looking at the same PAS file - but the breakpoints did not work either.
But there another, very weird thing happened: the text consts (!) changed within my executable (not within exe file, but obviously within memory)! Those texts were checked for correctness during program start, and sometimes it complained about errors! Display of the texts in a messagebox showed, that there was changed a sinlge character within that texts, that are defined as const. For test, I tried to assign something to that consts within my code, but, as expected, compiler complained, so it cannot be an ordinary assignment that causes the change of the text. Must be a wrong pointer. Weird.
So, hours of testing followed, looking for any source code that might have set up a wrong pointer that later could cause that change in a text const. I placed the messagebox into the initialization section of the first unit within the chain of unit initialization I was able to edit, but the changed char was already there! Must be changed very early during startup of my application, then!
Finally I figured out, that the char that appeared in my texts always was an $CC - which exactly is the assembler code for INT 3, the code that delphi is using for setting a breakpoint. And when moving a breakpoint within that unit a line up or down, the position of the changed character also moves some chars left or right! And the number of characters the wrong one moved just correlated with the estimated amount of assembler coded bytes the concerned lines needed. Setting two breakpoint in lines near each other, suddenly two characters changed! When removing all breakpoints from that unit, the text remained unchanged!
So there's only one conclusion: delphi itself is changing that texts when trying to set a breakpoint and fails to do so. I was unable to get rid of this bug. None of the tips about re-synching delphi's internal bookkeeping of source and object code files did help me out!
As the concerned unit mainly consisted of {$I} lines between multiple {$IFDEF}s, for including some different, but long pascal texts, I considered delphi having problems on too long inclusions or on evaluation of conditional compiler directives. So I removed the includes and put the source text immediately into the unit, and removed the {$IFDEF}s - which compiled without errors, but setting breakpoints also changed my text constants, instead of stopping execution. All the same!
I solved this for now by splitting the unit into two units, one holding just the text consts in it's interface part, and a second one to hold the procedures. And now, without changing any compiler nor linker settings, all breakpoints do work like expected and not text is changed any more!
So, if breakpoints do not work for you, while you are sure they should, possibly delphi is the culprit and fails to set the breakpoints at the correct place. In case of it is changing just some texts, maybe that never gets to your attention. Splitting the unit helped me out, maybe that helps you, too.
If the file you're trying to set breakpoints in is part of a DLL, you need to make that DLL active by double-clicking on it in Project Manager so it turns bold, and then build it. Then the blue circles will show up next to lines where you're allowed to set breakpoints.
I solved my issue by making sure Debug was set to Local:
In my case, I was setting breakpoints in a unit that whilst open in the IDE was not part of the currently active project. Such breakpoints also show as green. IOW I was not on the right page at all.
(I discovered this after trying all of the above .)
If the project group uses packages (BPLs) ensure that none of them have any compiler warnings regarding implicitly imported units. If these exist you will only be able to step through the code via the CPU debug window.
Bit late answer but I stumbled on this problem too.
If I activated the MyPackage.bpl (bold) in the project manager with the debug configuration, then compiled it, I could see the IDE registered the debug information (blue dots on left of editor).
But when I activated my MainProject.exe (the one using MyPackage.bpl), those blue dots would disappear, indicating that the debug information is no longer present. After some head scratching, I realized that I did set up a dependency (right click on MainProject.exe -> Dependencies) on the Release configuration of MyPackage.bpl and not on the Debug configuration.
Each time I compiled MyProject.exe, it would link with the Release configuration, not the debug configuration!
So check your dependency configurations!
I had MSBuild checked under Delphi Compile (we do MS Builds). That was preventing breakpoints from working. Unchecked and it works.
By using F9 to run the app, breakpoints will work as expected. I am using XE4 and I do not know if this will "fix" prior versions of Delphi.
Since this is the best resource I found on this issue when encountering this problem with a new install of Delpi XE on a new laptop, I will just add in one more possible answer for Delphi XE.
If you are using a two monitor setup and the code editor window is on the 2nd monitor, the tooltips will not show. Works fine if the editor window is on the primary monitor. Very frustrating. May be a driver issue.
I'm working with Delphi2010 Enterprise Update 4.
When I'm opening my project in the IDE and displaying the mainform code, there are 2 unit names underline in red.
xxx http://img268.imageshack.us/img268/6475/unitnameunresolved.png.
I have verified that the path to the unit source is in the Library path and in the Browsing path.
Surprisingly, when I'm doing a right-clicking on the unit and selecting Open file at cursor, it works (ie. delphi opens the right unit).
Any idea about that ?
Error Insight which keeps all the error messages into the structure view is quite buggy.
It doesn't understand your code the way the compiler understands it.
There is an IDE Fix Pack developed by Andreas Hausladen which reduces the number of those "Cannot resolve unit xyz" problems.
It doesn't fix the bug, but it makes them less visible by addressing some of the Error Insight's threading problems.
Out of curiosity, is there any code in AdPort and/or AdStatLt that is subject to conditional compilation ?
The parser that underpins Error Insight is I think different (physically and contextually) from the compiler. The compiler may be able to make sense of those conditional compilation areas that Error Insight is not.
This is just speculation on my part, but Error Insight is much improved in Delphi 2010 and typically now only chokes when there are errors in my code that I have yet to resolve.
Just disable Error Insight (Tools -> Options -> Editor Options -> Code Insight, uncheck Error Insight). It works fine for me.
Source: http://codeverge.com/embarcadero.delphi.ide/cannot-resolve-unit-name-forms/1041789
This is a cosmetic issue only, and doesn't affect your application in
any way.
It's caused by a bug in the compiler used for Error Insight (the
functionality that gives you the wavy red lines), which is not the
same compiler used to build your application or to compile from the
command line. The bug has existed since Error Insight was first
introduced. (It has gotten less frequent, though; it used to be that
the first thing I would do when I installed Delphi was to disable
Error Insight, and I haven't had to do that with either D2007 or D2009
as the problem is very infrequent and do esn't seem to last long for
whatever reason.)
Since there really isn't a problem (other than the cosmetic issue),
you can either ignore it or get rid of it by disabling Error Insight (Tools -> Options -> Editor Options -> Code Insight, uncheck Error Insight).
I reset the library path under tools\options\environment options\delphi options\library.
Click the dropdown box, and reselect your os, and it will reset the path to the library. Worked for me.
Closing and reopening a project usually helps to get rid of most of these errors. Try it...
(That doesn't change the fact that nowadays, this is probably my number one annoyance in the IDE...)
I face a very annoying bug in D2007 IDE :
It's the second time I have this problem within one month (on two differents computers, but with the same project), and it is a very annoying bug that causes the IDE to close itself without allowing me to save any changes in the code.
I tried but cannot reproduce the bug, it only appears randomly.
Here's what happen exactly :
i'm changing a line of code then (when I press "enter" to go next line)
the message
"Assertion failed: amount >= dest - startDest, file ek_flbuf.cpp, line 315" appears.
and when I press OK an second message "Abnormal program termination" appears.
Closing this message cause the IDE to quit.
When googling at my problem i found QC 33917 but the status is Closed : Cannot Reproduce
My questions are :
Is there any known workaround to this problem ?
can this problem be caused by third party stuff ? (I'm using GExperts and Delphi SpeedUp)
Does anyone here encountered the problem on a more recent IDE ?
UPDATE :
I remembered the problem occurs the first time (a month ago) within the same Unit.
so maybe the problem is not only project related but unit related.
I've restarted Delphi and returned in the same function where the problem appears today, trying to reproduce the bug only typing some code then deleting it, again and again, like a mad...
just restarting delphi and editing code in the unit (no other actions before), I managed to reproduce the problem a second time today ! but no more, despite many new similar tentatives... :(
...still investigating. (and thank you for the answers, I will now stop trying to reproduce the bug and check the answerers hints.)
The last time I have seen this, is when one of my source files had inconsistent line endings.
Make sure all your lines in all your source files end with CRLF.
--jeroen
When I used 2007 and saw this, it only happened on very long units (10,000+ lines - having that many is an issue for another discussion :p) Usually the IDE would be fine, then typing would become fairly slow - I could see the letters I typed lagging behind in the code editor. Unless I paused and let the editor catch up, I'd get that error.
So, my fix was:
If you're in a large unit and the editor starts lagging, pause, immediately. Let it catch up, and keep going.
This is really annoying, but worked for me.
I also turned off many of the Code Insight features, but I don't know if they affected this particular issue or not. They did help general editing speed. Turning them off was recommended to me in the then-Codegear forums. I can't remember who by, but I have a vague feeling it may even have been one of the Codegear QA staff who was aware of the bug but was trying to see if I could narrow down what affected or caused it. This was a couple of years ago now though, so don't take that as gospel.
Splitting your files into smaller, say <5000 line units may also help. For me it only happened on large and complex files.
The issue seems to have been fixed in RAD Studio 2010. Another way to avoid the error would be to upgrade :) If you do, wait a few days or talk to their salespeople first. The next version, RAD Studio XE, is due out at any moment. I'd recommend upgrading anyway: you'll need to handle Unicode issues, but other than that the 2010 edition is the best version I've used, including its stability, and I've used Delphi since version 1.
The first thing to try is to remove both add-on packages (GExperts and Delphi Speedup). It could be something they are doing.
The second is to do your best to reproduce and submit the issue.
The third is to upgrade to a new version of Delphi and hope that it solves your problems without creating new ones.
If this happens on two separate computers, but the same project on both, then the problem is most likely in the project itself and not the IDE. Of course, you didn't post any of the code that causes the error message to appear, so it's hard to help you find out what the problem is with the code. I find it very unlikely that the problem is the IDE, though, or others would have reported the same problem (D2007 has been out and in use by millions of developers for years now).
If the problem is in the IDE itself, you should be able to reproduce it with a new, empty project. Copy and paste only enough of the code from the old project into the new one to allow the problem line to compile, and then replicate the same change->press Enter to add a new line - does the same assertion failure and then abnormal termination happen?
If you can't reproduce the problem in a new project, the problem is most likely with your code, and without seeing it it's hard to tell what might be causing it.
Debug breakpoint's works fine in all other 38 units of my system. But, in my DataModule, that have +- 10.000 lines, delphi disables then after I launch by F9/F8/F7. In any part of source that unit, even on obrigatory steps like OnCreate, SQLConnection.Active:=true, etc.
Detail: works fine until +- 20 days ago.
I'm using D7 and have all sources of components also.
Thanks
Felipe
Try doing a full build (Shift+F9). If that does not work, then what happens if you simulate a breakpoint in code with the below?
asm int 3 end;
Check for multiple copies of your source file for the datamodule. Sometimes the code you think you're running isn't the code the compiler and debugger are seeing.
Next, make sure you haven't accidentally turned off debugging in your code with {$D-} or {$DEBUGINFO OFF}. This can turn off debugging info for a single unit.
Also, make sure you've turned on Integrated Debugging in Tools|Options|Debugger Options. I know you said you could debug other places, but it can't hurt to make sure that integrated debugging didn't get accidentally turned off somehow.
I discovered this problem. It's a weird behavior in Delphi7 that limits the number of fields in interface class section, between: type TDM=class(TDataModule) and private section. I deleted some fields (DataSet Fields (+-40 fields)) and degub runs again. I add these fields again, and debug not runs. I'm sure that's a limit, because doesn't mather which component fields I deleted. I tried with several fields, from different tables too, adding, testing and deleting. It's a shame, but is true...
Thanks for your help.
I have a vague memory that debugging very large files was buggy in old D7.
Try to break you big unit in several classes and se if you can debug outside your unit.
Another option could be to turn off debuginfo in your big file except the section you want to debug. It is worth a try.
There's a blog post from Steve Trefethen, a while back, explaining some possible reasons, although if you say you can debug other units, I doubt they'll apply.
We had the same issue with a large DataModule in Delphi 5 that wouldn't let us debug it, and kind of put it down to it being too large a file to debug and Delphi not liking it. When we moved to Delphi 2007, we could debug it again. Not sure why, nothing had changed (code wise).
Felipe, is the unit that will not allow you to debug in a dll that is being moved into or out of memory? I've found when debugging dll's that if I do something in the executable that executes code in another dll or unloads the dll that the problem unit is in - Delphi will disable all breakpoints. Usually a restart of Delphi and being sure to keep a single instance of the problem unit's dll in memory is the only solution for this problem.
I doubt size is the issue, as I have a 17k line unit that I debug regularly.