Skip to content

Commit

Permalink
Add Set_Command to apply some configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
stcarrez committed May 2, 2021
1 parent 31fa5d2 commit 8aacd3b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions mat/src/mat-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ with Util.Log.Loggers;

with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with Ada.Strings.Fixed;
with Ada.Exceptions;
with Ada.IO_Exceptions;
with Ada.Strings.Unbounded;
Expand Down Expand Up @@ -61,6 +62,8 @@ package body MAT.Commands is
Args : in String);
procedure Exit_Command (Target : in out MAT.Targets.Target_Type'Class;
Args : in String);
procedure Set_Command (Target : in out MAT.Targets.Target_Type'Class;
Args : in String);
procedure Open_Command (Target : in out MAT.Targets.Target_Type'Class;
Args : in String);
procedure Help_Command (Target : in out MAT.Targets.Target_Type'Class;
Expand Down Expand Up @@ -952,6 +955,34 @@ package body MAT.Commands is
Console.Error ("Cannot open symbol file '" & Args & "'");
end Symbol_Command;

-- ------------------------------
-- Set command.
-- ------------------------------
procedure Set_Command (Target : in out MAT.Targets.Target_Type'Class;
Args : in String) is
use Ada.Strings;

Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process;
Console : constant MAT.Consoles.Console_Access := Target.Console;
Trimmed_Args : constant String := Fixed.Trim (Args, Both);
Pos : constant Natural := Util.Strings.Index (Trimmed_Args, ' ');
begin
if Pos = 0 then
Console.Error ("Usage: set <name> <value>");
return;
end if;

declare
Name : constant String := Trimmed_Args (Trimmed_Args'First .. Pos - 1);
Value : constant String := Trimmed_Args (Pos + 1 .. Trimmed_Args'Last);
begin
if Name = "demangle" then
Process.Symbols.Value.Use_Demangle := Value = "on";
return;
end if;
end;
end Set_Command;

-- ------------------------------
-- Exit command.
-- ------------------------------
Expand Down Expand Up @@ -1126,4 +1157,5 @@ begin
Commands.Insert ("maps", Maps_Command'Access);
Commands.Insert ("info", Info_Command'Access);
Commands.Insert ("addr", Addr_Command'Access);
Commands.Insert ("set", Set_Command'Access);
end MAT.Commands;

0 comments on commit 8aacd3b

Please sign in to comment.