Sign in Join

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

Mailing lists / fpc-devel / 2004-08

Issues with GDB on Mac OS X with mixed case file names

13 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Dr. Rolf Jansen

The following smal pascal program is stored in file named TestProgram.pas in the current working directory.

program TestProgamm;
    var
       i : Integer;
begin
    for i := 1 to 5 do
       writeln('Test');
end.

It compiles successfully with:

fpc -g TestProgram.pas

An object file named TestProgram.o and an executable named TestProgram is produced in the cwd.

Invoking GDB with

gdb TestProgram

yields:

GNU gdb 5.3-20030128 (Apple version gdb-330.1) (Fri Jul 16 21:42:28 GMT
2004) ...BLAH...BLAH...
(gdb)

That is fine so far. But here is the issue:

(gdb) break TestProgram.pas:6

gives the error message:

No source file named TestProgram.pas.

while

(gdb) break testprogram.pas:6

gives the success confirmation:

Breakpoint 1 at 0x1fc08: file testprogram.pas, line 6.

(gdb) run
Starting program:
/Users/Rolf/Programmieren/Xcode/Pascal/TestProgram/TestProgram Reading symbols for shared libraries . done

Breakpoint 1, P$TESTPROGAMM_main () at testprogram.pas:6
6          for i := 1 to 5 do

This is not a really big issue when using GDB from the command line. I simply have to remember to input the filenames in lower case letters for setting breakpoints.

However, setting breakpoints that do work by the way of Xcodes GUI is not possible, because Xcode insists on using the original mixed case file name. I searched for hours to no avail to tell either Xcode to use lower case letters or to say GDB to ignore the case ("set case-sensitive off" in GDB does NOT do the trick).

The lowercase filename comes into the .stabs of the TestProgram due to the routine TGNUAssembler.WriteFileLineInfo of aggas.pas at line 237 of the fpc compiler. If I change that line from:

AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+

to

AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+

and compile fpc first and then again my TestProgram, then GDB happily accepts the mixed case file name for seting breakpoints, and all the features of Xcode can be used to source level debug fpc programs.

So, PLEASE, PLEASE, PLEASE, can someone change line 237 in aggas.pas as indicated. It would be OK, to make the change conditional for the target Darwin.

Just for my curiosity, how does this work with case sensitive filesystems. My understanding of what´s going on tells me that setting breakpoints in mixed case files e.g. in Linux does´t work even when using lower case letters for the breakpoint, as long as line 237 of aggas.pas is not changed.

Best regards

Rolf

__ InstantWare ______________________________________________________ Dr. Rolf Jansen * Stephanienstraße 19 * D-76133 Karlsruhe * Germany

http://InstantWare.bei.t-online.de/
_____________________________________________________________________

Reply by email

Florian Klaempfl
to Dr. Rolf Jansen
Dr. Rolf Jansen wrote 92 lines
The following smal pascal program is stored in file named TestProgram.pas in the current working directory. program TestProgamm; var i : Integer; begin for i := 1 to 5 do writeln('Test'); end. It compiles successfully with: fpc -g TestProgram.pas An object file named TestProgram.o and an executable named TestProgram is produced in the cwd. Invoking GDB with gdb TestProgram yields: GNU gdb 5.3-20030128 (Apple version gdb-330.1) (Fri Jul 16 21:42:28 GMT 2004) ...BLAH...BLAH... (gdb) That is fine so far. But here is the issue: (gdb) break TestProgram.pas:6 gives the error message: No source file named TestProgram.pas. while (gdb) break testprogram.pas:6 gives the success confirmation: Breakpoint 1 at 0x1fc08: file testprogram.pas, line 6. (gdb) run Starting program: /Users/Rolf/Programmieren/Xcode/Pascal/TestProgram/TestProgram Reading symbols for shared libraries . done Breakpoint 1, P$TESTPROGAMM_main () at testprogram.pas:6 6 for i := 1 to 5 do This is not a really big issue when using GDB from the command line. I simply have to remember to input the filenames in lower case letters for setting breakpoints. However, setting breakpoints that do work by the way of Xcodes GUI is not possible, because Xcode insists on using the original mixed case file name. I searched for hours to no avail to tell either Xcode to use lower case letters or to say GDB to ignore the case ("set case-sensitive off" in GDB does NOT do the trick). The lowercase filename comes into the .stabs of the TestProgram due to the routine TGNUAssembler.WriteFileLineInfo of aggas.pas at line 237 of the fpc compiler. If I change that line from: AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+ to AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+ and compile fpc first and then again my TestProgram, then GDB happily accepts the mixed case file name for seting breakpoints, and all the features of Xcode can be used to source level debug fpc programs. So, PLEASE, PLEASE, PLEASE, can someone change line 237 in aggas.pas as indicated. It would be OK, to make the change conditional for the target Darwin. Just for my curiosity, how does this work with case sensitive filesystems. My understanding of what´s going on tells me that setting breakpoints in mixed case files e.g. in Linux does´t work even when using lower case letters for the breakpoint, as long as line 237 of aggas.pas is not changed. Best regards

We simply decided for fpc that on case sensitive systems, all source names should be lower case else you get case sensitiveness into the pascal language when working with units.

MyUnit.pas:
unit MyUnit;
...
end.

test.pas:
uses
MyUnit; <--- case sensitive identifier in pascal; myunit wouldn't be found and being case sensitive here would cause a lot of trouble.

Reply by email

Dr. Rolf Jansen
to Florian Klaempfl
Florian Klaempfl wrote 36 lines
Dr. Rolf Jansen wrote: > ...<SNIP> > The lowercase filename comes into the .stabs of the TestProgram due > to the routine TGNUAssembler.WriteFileLineInfo of aggas.pas at line > 237 of the fpc compiler. If I change that line from: > AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+ > to > AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+ > and compile fpc first and then again my TestProgram, then GDB happily > accepts the mixed case file name for seting breakpoints, and all the > features of Xcode can be used to source level debug fpc programs. > So, PLEASE, PLEASE, PLEASE, can someone change line 237 in aggas.pas > as indicated. It would be OK, to make the change conditional for the > target Darwin. > Just for my curiosity, how does this work with case sensitive > filesystems. My understanding of what´s going on tells me that > setting breakpoints in mixed case files e.g. in Linux does´t work > even when using lower case letters for the breakpoint, as long as > line 237 of aggas.pas is not changed. > Best regards We simply decided for fpc that on case sensitive systems, all source names should be lower case else you get case sensitiveness into the pascal language when working with units. MyUnit.pas: unit MyUnit; ... end. test.pas: uses MyUnit; <--- case sensitive identifier in pascal; myunit wouldn't be found and being case sensitive here would cause a lot of trouble.
That is fine. If all file names are lower case anyway, then line 237 of
aggas.pas can safely be changed from:
       AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+

to:

AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+

since, the lower function has nothing to do there.

Reply by email

Peter Vreman
to Dr. Rolf Jansen
you wrote 14 lines
Am 26.08.2004 um 15:45 schrieb Florian Klaempfl: >Dr. Rolf Jansen wrote: > >>...<SNIP> >>The lowercase filename comes into the .stabs of the TestProgram due to >>the routine TGNUAssembler.WriteFileLineInfo of aggas.pas at line 237 of >>the fpc compiler. If I change that line from: >> AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+ >>to >> AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+ >>and compile fpc first and then again my TestProgram, then GDB happily >>accepts the mixed case file name for seting breakpoints, and all the >>features of Xcode can be

Fixed, Thanks

Peter

Reply by email

Dr. Rolf Jansen
to Peter Vreman
Peter Vreman wrote 17 lines
At 16:43 26-8-2004, you wrote: > Am 26.08.2004 um 15:45 schrieb Florian Klaempfl: > >> Dr. Rolf Jansen wrote: >> >>> ...<SNIP> >>> The lowercase filename comes into the .stabs of the TestProgram due >>> to the routine TGNUAssembler.WriteFileLineInfo of aggas.pas at line >>> 237 of the fpc compiler. If I change that line from: >>> AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+ >>> to >>> AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+ >>> and compile fpc first and then again my TestProgram, then GDB >>> happily accepts the mixed case file name for seting breakpoints, >>> and all the features of Xcode can be Fixed, Thanks

Peter,

Many thanks for the fix. Unfortunately, I discovered too late, that this enables GDB support on Mac OS X only for the main program file. In unit files it still includes the lowercase filenames into the .stabs.

However, I found the problem and a possible solution. In globals.pas there are three FindFile routines, namely: TSearchPathList.FindFile, FindFile, and FindFilePchar.

All routines contain roughly the same code snippet:

           {
             Search order for case sensitive systems:
              1. lowercase
              2. NormalCase
              3. UPPERCASE
             None case sensitive only lowercase
           }
           FoundFile:=p.Str+Lower(f);
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
{$ifdef UNIX}
           FoundFile:=p.Str+f;
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
           FoundFile:=p.Str+Upper(f);
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
{$endif UNIX}

On Mac OS X and on other none case sensitive file systems the sequence exits always after the first search for the lowercase filename and it returns this lowercase name which then makes its way into the .stab.

I suggest to change the search order as follows:

           {
             Search order for case sensitive systems:
              1. NormalCase
              2. lowercase
              3. UPPERCASE
           }
           FoundFile:=p.Str+f;
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
           FoundFile:=p.Str+Lower(f);
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
{$ifdef UNIX}
           FoundFile:=p.Str+Upper(f);
           If FileExists(FoundFile) then
            begin
              FindFile:=true;
              exit;
            end;
{$endif UNIX}

I changed it that way on my local copy, and now everything works really fine. There should be also a little performance gain on case sensitive file systems by this way, if lots of mixed case filenames are present.

Finally, I am unsure about the effects of the following at line 216 in file assembler.pas in the routine TAssembler.Create

         name:=Lower(current_module.modulename^);

For testing purposes I removed the Lower(), but it made no obvious difference, so I switched it back to the line given above.

Best regards

Rolf

Reply by email

Peter Vreman
to Dr. Rolf Jansen
Show quoted text 9 lines
Many thanks for the fix. Unfortunately, I discovered too late, that this enables GDB support on Mac OS X only for the main program file. In unit files it still includes the lowercase filenames into the .stabs. However, I found the problem and a possible solution. In globals.pas there are three FindFile routines, namely: TSearchPathList.FindFile, FindFile, and FindFilePchar. All routines contain roughly the same code snippet:

Fixed

Reply by email

Dr. Rolf Jansen
to Peter Vreman
Peter Vreman wrote 12 lines
> Many thanks for the fix. Unfortunately, I discovered too late, that > this enables GDB support on Mac OS X only for the main program file. > In > unit files it still includes the lowercase filenames into the .stabs. > > However, I found the problem and a possible solution. In globals.pas > there are three FindFile routines, namely: TSearchPathList.FindFile, > FindFile, and FindFilePchar. > > All routines contain roughly the same code snippet: Fixed

Everything is fine now. Thank you very much!

Rolf

Reply by email

Vincent Snijders
to Peter Vreman: Fixed
Show quoted text 7 lines
> However, I found the problem and a possible solution. In globals.pas > there are three FindFile routines, namely: TSearchPathList.FindFile, > FindFile, and FindFilePchar. > > All routines contain roughly the same code snippet: Fixed

Does this mean the folowing is not true anymore?
// FPC searches first lowercase, then keeping case, then uppercase FYI: This is a comment for the lazarus/main.pp.

Vincent.

Reply by email

Peter Vreman
to Vincent Snijders
you wrote 13 lines
On Sat, 28 Aug 2004 22:26:08 +0200 (CEST) Peter Vreman wrote: > > However, I found the problem and a possible solution. In globals.pas > > there are three FindFile routines, namely: TSearchPathList.FindFile, > > FindFile, and FindFilePchar. > > > > All routines contain roughly the same code snippet: > > Fixed Does this mean the folowing is not true anymore? // FPC searches first lowercase, then keeping case, then uppercase FYI: This is a comment for the lazarus/main.pp.

Below is the mail i wrote for updating the fpc docs:

I've updated the search order of files. It is now:

For case sensitive systems (and windows):

NormalCase
lowercase
UPPERCASE

For non-case sensitive systems

lowercase

What does this mean. When you have a 'uses Hello' the compiler will first look for a Hello.pp/.pas file. When the file HEllo.pas exists it will not be found. So for the mixed case the uses line will be case-sensitive. This is Kylix compatible.

Peter

Reply by email

Unknown author
to Peter Vreman

One other topic: Why there are *.pp files? The handling is always very nonpractical and boring. Should we rename them to *.pas?

Peter Vreman wrote 47 lines
At 14:00 29-8-2004, you wrote: > On Sat, 28 Aug 2004 22:26:08 +0200 (CEST) > Peter Vreman wrote: > > > > However, I found the problem and a possible solution. In globals.pas > > > there are three FindFile routines, namely: TSearchPathList.FindFile, > > > FindFile, and FindFilePchar. > > > > > > All routines contain roughly the same code snippet: > > > > Fixed > Does this mean the folowing is not true anymore? > // FPC searches first lowercase, then keeping case, then uppercase > FYI: This is a comment for the lazarus/main.pp. Below is the mail i wrote for updating the fpc docs: I've updated the search order of files. It is now: For case sensitive systems (and windows): NormalCase lowercase UPPERCASE For non-case sensitive systems lowercase What does this mean. When you have a 'uses Hello' the compiler will first look for a Hello.pp/.pas file. When the file HEllo.pas exists it will not be found. So for the mixed case the uses line will be case-sensitive. This is Kylix compatible. Peter _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Peter Vreman
to Unknown author
One other topic: Why there are *.pp files? The handling is always very nonpractical and boring. Should we rename them to *.pas?

I don't see problems. You rename all your sources to *.pas. And you can set highlighting for *.pp also to pascal. Under linux a lot of editors already support *.pp for pascal sources.

*.pp are fpc specific (objfpc) sources
*.pas is for comaptiblity with tp7 and delphi

Reply by email