terran 0 Posted May 16, 2023 (edited) I am debugging a Delphi application, which uses C Object files (.obj). When enters a function, it shows correct Local variables, but when a step-in, it doesn't show correct Local variables. Is it a bug? Before entering function: After entering function: Previous function in stack: Actually, ReadProc is assigned to SeekProc, WriteProc to CloseProc, and SeekProc to SizeProc. Function in delphi: type PTIFF = Pointer; TIFFReadWriteProc = function(Fd: THandle; Buffer: Pointer; Size: tmsize_t): Integer; cdecl; TIFFCloseProc = function(Fd: THandle): Integer; cdecl; TIFFSeekProc = function(Fd: THandle; Off: toff_t; Whence: Integer): toff_t; cdecl; TIFFSizeProc = function(Fd: THandle): toff_t; cdecl; TIFFMapFileProc = function(Fd: THandle; PBase: PPointer; PSize: poff_t): Integer; cdecl; TIFFUnmapFileProc = procedure(Fd: THandle; Base: Pointer; Size: toff_t); cdecl; function _TIFFClientOpenExt(name: PAnsiChar; mode: PAnsiChar; clientdata: THandle; readproc: TIFFReadWriteProc; writeproc: TIFFReadWriteProc; seekproc: TIFFSeekProc; closeproc: TIFFCloseProc; sizeproc: TIFFSizeProc; mapproc: TIFFMapFileProc; unmapproc:TIFFUnmapFileProc; opts: Pointer): PTIFF; cdecl; external; Function in C : typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size); typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size); //////////// TIFF *TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc) { return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc, seekproc, closeproc, sizeproc, mapproc, unmapproc, NULL); } TIFF *TIFFClientOpenExt(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions *opts) Edited May 16, 2023 by terran Share this post Link to post
Fr0sT.Brutal 900 Posted May 17, 2023 Is the function working well? I'd bet on incorrect parameters porting. 1st guess is differing calling convention but it seems valid Share this post Link to post
PeterBelow 238 Posted May 17, 2023 10 hours ago, terran said: When enters a function, it shows correct Local variables, but when a step-in, it doesn't show correct Local variables. Is it a bug? The obj files do not contain debug information so the IDE debugger is unable to work fully while the execution is inside code from the obj file. Share this post Link to post
David Heffernan 2345 Posted May 17, 2023 I didn't even know that Delphi debugger would step into obj files. How did you compile the .obj file? Where is Delphi getting the debug info from? Share this post Link to post
terran 0 Posted May 17, 2023 I compiled it with bcc32c -tM -tR -Od -v (CMake did it for me). The object files compiled with the -v switch are twice as big, and of course contain some "debugging information". But it's not exact. 😄 No, the code doesn't work. It is an old LibTiff library. It worked with a (20 years) old .OBJ files with no sources (and no debugging). I compiled the new object files from .C sources, and with them it doesn't work. The delphi unit to that library is not so much outdated. But it's not exact. 😄 Share this post Link to post
Fr0sT.Brutal 900 Posted May 17, 2023 (edited) What if you try to print arguments from that C function and test at runtime? I too didn't know that Delphi is able to step into OBJ. Probably this feature is buggy Edited May 17, 2023 by Fr0sT.Brutal Share this post Link to post
David Heffernan 2345 Posted May 17, 2023 If I were you I'd compile the code into a DLL and link to that. My experience is that works more reliably. I used to do the .obj dance back in the day but moved away from it. Very happy to have done so. Share this post Link to post