Skip to content

Commit

Permalink
Merge branch 'topic/eng/ide/ada_language_server#1380' into 'master'
Browse files Browse the repository at this point in the history
Create two different traces config files for Ada and GPR

See merge request eng/ide/ada_language_server!1624
  • Loading branch information
AnthonyLeonardoGracio committed Jul 17, 2024
2 parents a5e8901 + 86ee1d6 commit abbc2f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 7 additions & 3 deletions doc/traces.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# ALS Trace File

Default trace file name is `$HOME/.als/traces.cfg`. This file gets automatically created
if not present on the disk. The first line of the traces file
defines the traces output stream (a filename in our case) and the other
Default trace file names are:

* `$HOME/.als/ada_ls_traces.cfg` for the language server spawned for Ada projects/files, which produce `ada_ls_log.<timestamp>.log` log files by default.
* `$HOME/.als/gpr_ls_traces.cfg` for the language server spawned for GPR project files, which produce `gpr_ls_log.<timestamp>.log` log files by default.

These files gets automatically created if not present on the disk. The first line of the
traces files defines the traces output stream (a filename in our case) and the other
lines are used to enable or disable traces.

Note that you can provide another traces file via the `--tracefile=<FILE>` command line option.
Expand Down
20 changes: 12 additions & 8 deletions source/ada/lsp-ada_driver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,6 @@ procedure LSP.Ada_Driver is
GNATdebug : constant Virtual_File := Create_From_Base
(".gnatdebug");

Default_Traces_File_Contents : constant String :=
">als.$T.txt:buffer_size=0" & Ada.Characters.Latin_1.LF
& "ALS.MAIN=yes" & Ada.Characters.Latin_1.LF
& "ALS.IN=no" & Ada.Characters.Latin_1.LF
& "ALS.OUT=no" & Ada.Characters.Latin_1.LF;

Traces_File : Virtual_File;

Trace_File_Option : constant VSS.Command_Line.Value_Option :=
Expand Down Expand Up @@ -350,12 +344,22 @@ begin

Traces_File := Create_From_Dir
(Dir => ALS_Dir,
Base_Name => "traces.cfg");
Base_Name =>
(if VSS.Command_Line.Is_Specified (Language_GPR_Option) then
"gpr_ls" else "ada_ls") & "_traces.cfg");

-- No default traces file found: create one
if not Traces_File.Is_Regular_File then
declare
W_Traces_File : Writable_File;
W_Traces_File : Writable_File;
Default_Traces_File_Contents : constant String :=
">"
& (if VSS.Command_Line.Is_Specified (Language_GPR_Option)
then "gpr_ls" else "ada_ls")
& "_log.$T.log:buffer_size=0" & Ada.Characters.Latin_1.LF
& "ALS.MAIN=yes" & Ada.Characters.Latin_1.LF
& "ALS.IN=no" & Ada.Characters.Latin_1.LF
& "ALS.OUT=no" & Ada.Characters.Latin_1.LF;
begin
W_Traces_File := Traces_File.Write_File;
W_Traces_File.Write (Default_Traces_File_Contents);
Expand Down
File renamed without changes.

0 comments on commit abbc2f4

Please sign in to comment.