Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-11

write watch breakpoint to field inside object

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I managed to add a write watch to my variable VarA which is an instance of a class and it works fine following instructions here: http://wiki.freepascal.org/IDE_Window:Breakpoints

But actually I would like to watch when a field inside the class is modified. Any way to do that? I tried setting the variable to watch as VarA.MyField but it doesn't work =/

Is it possible somehow? I wonder how this works, will it stops at all variables which are valled VarA? There is not enough information to establish a particular one, I guess...

I am searching for a memory corruption, so I would like to breakpoint when a code writes into a variable ...

thanks,

Felipe Monteiro de Carvalho

Reply by email

Martin
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 17 lines
Hello, I managed to add a write watch to my variable VarA which is an instance of a class and it works fine following instructions here: http://wiki.freepascal.org/IDE_Window:Breakpoints But actually I would like to watch when a field inside the class is modified. Any way to do that? I tried setting the variable to watch as VarA.MyField but it doesn't work =/ Is it possible somehow? I wonder how this works, will it stops at all variables which are valled VarA? There is not enough information to establish a particular one, I guess... I am searching for a memory corruption, so I would like to breakpoint when a code writes into a variable ...

What type is the field?

It works here.

Couple of points:
- You must use "global" for scope. Unless your object var "VarA" is a global var).
Otherwise "varA" will go out of scope, and gdb has no idea there are other refs to the object.

- You must delete, and create again, after every run. In order to work around gdb scope of VarA the IDE translates the expression to a pointer. That may not be valid on the next re-run

- You can only set the watch, if all vars involved are in scope: e.g the ide can show the value in watches window

Otherwise: logfile please
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

Reply by email

Martin
to Martin
Martin wrote 17 lines
What type is the field? It works here. Couple of points: - You must use "global" for scope. Unless your object var "VarA" is a global var). Otherwise "varA" will go out of scope, and gdb has no idea there are other refs to the object. - You must delete, and create again, after every run. In order to work around gdb scope of VarA the IDE translates the expression to a pointer. That may not be valid on the next re-run - You can only set the watch, if all vars involved are in scope: e.g the ide can show the value in watches window

Also, it may not work, if the fields type is declared inline

   AFoo: array of integer;

because the IDE needs the name of the type for a typecast in the gdb expression generated

Solution: declare a named type

Dynamic Arrays, may only watch the reference, not the data

Show quoted text 11 lines
Otherwise: logfile please http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Felipe Monteiro de Carvalho
to Martin
Also, it may not work, if the fields type is declared inline AFoo: array of integer; because the IDE needs the name of the type for a typecast in the gdb expression generated

It is array of SomeStructure declared inline indeed ... I'll try to change to a named type, thanks.

Felipe Monteiro de Carvalho

Reply by email