Debug loading lfm file lazarus / 12-Debugger ---------------------------------------------------------------------- timppl · 2012-07-05 08:15 I am using latest svn versions of lazarus and fpc ( updated every day with fpcup ) on Mandriva  linux, and revisiting a library which compiled OK a few weeks ago I found that when trying to load a form with F12 I get a dialogue about an access violation. The dialogue text is QuoteStream=TDATEditForm: Root=:TDATEditForm Component Class: TRzSplitter Access violation Stream position: 16384 TRzSplitter is a component I wrote myself so the fault is almost certainly there, but I dont know how to find out where in the lmf file the offending line is. I assume it is something to do with the Stream Position item. Can anyone help? TIA Tim ---------------------------------------------------------------------- Martin_fr · 2012-07-05 09:59 Well I can't help you with the stream reader itself. But if you want to debug things.... Depends on how far you want to go. Some of the stream reader is in unit classes (RTL belongs to FPC, not Lazarus). To debug that, you must recompile FPC with debug info. I don't know fpup, but since it works on SVN (doesn't it?) it should do the build for you. just add -g (or if you prefer -gw for stabs, but then you should build all with stabs) Same for the IDE (and packages). The IDE you can also build from the Tools menu in the IDE. The lazarus.lpr/lpi are in the folder ide/ (You do not need them for building, but for running). Open lazarus as project and press F9. This will run a 2nd Lazarus, being debugged by the first. The rest is getting he error and debugging... ---------------------------------------------------------------------- BigChimp · 2012-07-05 10:55 Quote from: Martin_fr on July 05, 2012, 11:59:11 amI don't know fpup, but since it works on SVN (doesn't it?) it should do the build for you. just add -g (or if you prefer -gw for stabs, but then you should build all with stabs) Same for the IDE (and packages). The IDE you can also build from the Tools menu in the IDE. Yep, fpcup uses svn. You can pass compiler options for FPC like this: Code: [Select]--fpcopt='-g' and Lazarus like this: Code: [Select]--lazopt='-g' You can use multiple options, e.g. Code: [Select]'-gh -gw -O' ---------------------------------------------------------------------- Martin_fr · 2012-07-05 11:04 Quote from: BigChimp on July 05, 2012, 12:55:27 pmYou can use multiple options, e.g. Code: [Select]'-gh -gw -O' Better make that last  Code: [Select]-O- so any previous -O* will be cancelled out (you can also do -O-1 ) ---------------------------------------------------------------------- timppl · 2012-07-06 06:58 Thanks guys. I am using both fpc and lazarus compiled for debugging, but there does not seem to be any support for finding out what part of the lfm file is causing the problem. I have tried google but cant find any information on how the stream position relates to lines in the lfm  .  ATM it seem I will have to; 1) check there are no properties in the lfm file that have incorrect values; 2) delete lines from the lfm file and see if it makes any difference; FYI  the easiest way to do 2) is to open the lfm file in the source code editor in lazarus and in an external editor. Make changes in the external editor and then when lazarus gets focus again it will ask to reload the file. This makes sure any changes are in the executable to test ---------------------------------------------------------------------- wp · 2012-07-06 07:52 When I have such problems with my own components I first create a run- time only projekt. Let's say the component to be debugged is TRzSplitter as mentioned in the first posting. (1) Don't install it into the IDE at first (2) Create a new project and add the components that TRzSplitter needs to work. (3) In the private section of the form, add the declaration of the new component. In the FormCreate event handler create the new component by code. If the component needs event handlers assign them manually. Code: [Select]type   TForm1 = class(TForm)     // ....     procedure FormCreate(Sender: TObject);   private     RzSplitter : TRzSplitter;     procedure SplitterClick(Sender: TObject);   end;     procedure TForm1.FormCreate(Sender: TObject); begin   RzSplitter := TRzSplitter.Create(self);   with RzSplitter do begin     Parent := self;  // or the Panel or whatever where the Splitter sits in     NewProperty := 100;  // this is an example of a new property of your component that you can set here.     OnClick := @SplitterClick;  // example of a manually assigned event handler   end; end; procedure TForm1.SplitterClick(Sender: TObject); begin   // do something... end; (4) Run this project. Most probably Lazarus will immediately point you to the code that is wrong - with me it is usually dereferencing nil pointers. Or at least, you can debug your component code without fiddling around with the IDE. (5) Only after you do not find any more errors install the component. ---------------------------------------------------------------------- timppl · 2012-07-06 10:33 Thanks. Seems an excellent suggestion.  I had sort of partially got there creating a test project, but it did not occur to me to use an uninstalled component in a runtime only project. I shall play with this for my other components as well  Regards Tim ---------------------------------------------------------------------- Martin_fr · 2012-07-06 10:51 Ox, i am not exactly sure what you are looking for... But first (something else): I have NOT looked at TReader and related recently, but the stream position usually is in bytes. However, that should not matter, the code needs to read from the stream, and then the name of the current property will be in a string that you can inspect. (See also conditional breakpoints): http://wiki.lazarus.freep ascal.org/IDE_Window:Breakpoints#Breakpoint_properties ) That said the TReader stuff is a lot of code to get into.... Anyway back to the question: What is your problem? Why do you look for it in the reader classes? If you have a property that does not exist, the IDE does deal with it., So I *GUESS* you have a problem with a property value? Tat is I *ASSUME* you get the error, when opening your component in the IDE? Is that so? But it may be an exception in your class, and TReader catches it/ creates a new one (the one you get to see). If you run in the debugger, it should tell you about such an error... It seems you do not know the exact property that causes the issue. So I would suggest to remove all of them from the LFM, and see if the error disappears. - Then add them one by one, until the error happens. - Then remove all but the last (in case it is a combination...) And so on. Then play with the values. That way you can learn, what properties are involved. You can also set breakpoints on the setter of each published property...