Cmajor debugger

The Cmajor debugger, cmdb, is a command-line debugger for Windows, Linux and Windows subsystem for Linux. It is integrated in Cmajor Code, a graphical editor and development environment written in Cmajor. The cmdb reads a debugging information file that is generated by the Cmajor compiler with C++ backend, cppcmc. The debug information file contains line number information and information about types and variables of a Cmajor program. The cmdb uses it to drive the GNU debugger GDB.

Table of contents

1 Requirements
2 Running the debugger
    2.1 Command-line options
3 Debugger commands
    3.1 List command
          3.1.1 Syntax
          3.1.2 Examples
          3.1.3 Result
    3.2 Break command
          3.2.1 Syntax
          3.2.2 Examples
          3.2.3 Result
    3.3 Delete command
          3.3.1 Syntax
          3.3.2 Examples
          3.3.3 Result
    3.4 Show breakpoint command
          3.4.1 Syntax
          3.4.2 Examples
          3.4.3 Result
    3.5 Show breakpoints command
          3.5.1 Syntax
          3.5.2 Examples
          3.5.3 Result
    3.6 Next command
          3.6.1 Syntax
          3.6.2 Examples
          3.6.3 Result
    3.7 Step command
          3.7.1 Syntax
          3.7.2 Examples
          3.7.3 Result
    3.8 Finish command
          3.8.1 Syntax
          3.8.2 Examples
          3.8.3 Result
    3.9 Until command
          3.9.1 Syntax
          3.9.2 Examples
          3.9.3 Result
    3.10 Continue command
            3.10.1 Syntax
            3.10.2 Examples
            3.10.3 Result
    3.11 Depth command
            3.11.1 Syntax
            3.11.2 Examples
            3.11.3 Result
    3.12 Frames command
            3.12.1 Syntax
            3.12.2 Examples
            3.12.3 Result
    3.13 Print command
            3.13.1 Syntax
            3.13.2 Expressions
                       3.13.2.1 Additive expressions
                       3.13.2.2 Dereference expression
                       3.13.2.3 Address-of expression
                       3.13.2.4 Postfix expressions
                       3.13.2.5 Member selection expression
                       3.13.2.6 Base selection expression
                       3.13.2.7 Subscript expression
                       3.13.2.8 Range expression
                       3.13.2.9 Primary expressions
                       3.13.2.10 Printing value of a local variable
                       3.13.2.11 Printing information about a type
                       3.13.2.12 Cast expression
            3.13.3 Containers
            3.13.4 Type identifiers
    3.14 Set condition command
            3.14.1 Syntax
    3.15 Set debugger variable command
            3.15.1 Syntax
    3.16 Exit command
            3.16.1 Syntax
4 Common results
    4.1 Stopped result
    4.2 Error result
5 Summary of the command syntax
6 Known bugs

1. Requirements

2. Running the debugger

The debugger is started by giving command cmdb followed by an absolute or relative path of a Cmajor executable program with or without the .exe suffix (Windows). The debugger starts GDB and prints a prompt cmdb> . You may now enter debugger commands. If a plain ENTER is given as a debugger command, the latest command is repeated. The debugger exits by commands: exit, e, quit and q.

2.1 Command-line Options

Long option Short option Description
--help -h Print help and exit.
--verbose -v Be verbose.
--debug -d Debug the debugger.
--dontBreakOnThrow -t Set breakOnThrow to off. By default it is on.
‑‑sessionPort=PORT_NUBER ‑s=PORT_NUMBER Set the port number of the CMDB session that cmdb and the program being debugged will use for exchanging console I/O messages. Default port number is 54322.

3. Debugger commands

3.1 List command

The list command shows source file content starting from the specified list location. If no source file path is given, shows contents of current source file starting from the specified line number. If source file path is given, but no line number is given, starts from the line number 1. If '*' is specified as the list location, lists around the instruction to where the process is currently stopped. If the list command is given without a list location, lists starting from the succeeding line of the last line of the previous list command.

A source location can contain a bare file name, a bare line number, a file name and a source line number, the name of a project followed by a slash and a file name and an optional source line number, an absolute or relative source file path followed by an optional source line number, or drive letter followed by a colon and an absolute source file path followed by an optional source line number.

A source file path consists of path components separated by the slash character. A path component can contain alphanumeric characters, and plus, minus, period and underscore characters. A path component has to start with a letter, underscore, plus, or period character.

If more than one source file matches the given source location expression, the debugger asks to disambiguate the source location for example using project name slash prefix.

3.1.1 Syntax

list‑command (list | l) list‑location?
list‑location source‑location | *
source‑location path (: line)? | line
path (drive :)? (/? (comp /)*)? comp
drive [A-Za-z]
comp [A-Za-z_.+][a-zA-Z_0-9.+-]*
line integer
integer [0-9]+

3.1.2 Examples

  1. list Main.cm:10
    Lists Main.cm source file starting from the line 10.
  2. list Calculator/Parser.cm
    Lists Parser.cm source file of the Calculator project starting from line 1.
  3. list projects/examples/Calculator/Scanner.cm:1
    Lists Scanner.cm source file starting from line 1.
  4. list 10
    Lists starting from the line 10 of the current source file.
  5. list
    Lists starting from the following line where the previous list command ended.
  6. list foo.cm
    If source file foo.cm does not exist, the result is the following error JSON object:
        {
            "error" : "no source file path matched location 'foo.cm:1'",
            "success" : false
        }                
        

3.1.3 Result

If the list command succeeds, the result is 11 lines of source code. If the list command fails, the result is an error result.

3.2 Break command

The break command sets a breakpoint to a source location. What have been said about source location expressions in the list command case excluding the * source location expression applies to the break command as well. A successful break command sets the current source file path to file path of the source location.

3.2.1 Syntax

break‑command (break | b) source‑location

3.2.2 Examples

  1. break Calculator/Parser.cm:43
    Result:
        {
            "breakpoint" :
            {
                "id" : "1"
                "location" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Parser.cm",
                    "func" : "Calculator.Parse(const String&)",
                    "line" : "43"
                }
                ,
                "numInsts" : "1",
            }
            ,
            "success" : true
        }            
        
  2. break 44
    Result:
        {
            "breakpoint" :
            {
                "id" : "2"
                "location" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Parser.cm",
                    "func" : "Calculator.Parse(const String&)",
                    "line" : "44"
                }
                ,
                "numInsts" : "1",
            }
            ,
            "success" : true
        }    
        
  3. break foo.cm:10
    If source file foo.cm does not exist, result is the following error JSON object:
        {
            "error" : "no source file path matched location 'foo.cm:10'",
            "success" : false
        }    
        

3.2.3 Result

If the break command succeeds, the debugger prints a JSON object describing the created breakpoint. This JSON object has the following fields:

If the break command fails, the debugger prints an error result.

3.3 Delete command

The delete command deletes a breakpoint.

3.3.1 Syntax

delete‑command (delete | d) breakpoint-id
breakpoint‑id integer

3.3.2 Examples

  1. delete 1
    Result:
        {
            "success" : true
        }
        
  2. d 2
    Result:
        {
            "success" : true
        }
        
  3. delete 3
    If breakpoint 3 does not exist, result is the following error JSON object:
        {
            "error" : "error: breakpoint 3 not found",
            "success" : false
        }
        

3.3.3 Result

If the delete command succeeds, the debugger prints a JSON object with the following field:

If the delete command fails, the debugger prints an error result.

3.4 Show breakpoint command

The show breakpoint command shows information about a breakpoint given a breakpoint identifier.

3.4.1 Syntax

show‑breakpoint‑command show breakpoint breakpoint-id

3.4.2 Examples

  1. show breakpoint 1
    Result:
        {
            "breakpoint" :
            {
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Parser.cm",
                    "func" : "Calculator.Parse(const String&)",
                    "line" : "43"
                }
                ,
                "id" : "1"
            }
            ,
            "success" : true
        }
        
  2. show breakpoint 3
    If breakpoint 3 does not exist, result is the following JSON object:
        {
            "error" : "breakpoint id '3' not found",
            "success" : false
        }
        

3.4.3 Result

If the show breakpoint command succeeds, the debugger prints a JSON object with the following fields:

If the show breakpoint command fails, the debugger prints an error result.

3.5 Show breakpoints command

The show breakpoints command lists current breakpoints.

3.5.1 Syntax

show‑breakpoints‑command show breakpoints

3.5.2 Examples

  1. show breakpoints
    Result:
        {
            "breakpoints" :
            [
                {
                    "frame" :
                    {
                        "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Parser.cm",
                        "func" : "Calculator.Parse(const String&)",
                        "line" : "43"
                    }
                    ,
                    "id" : "1"
                }
                ,
                {
                    "frame" :
                    {
                        "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Parser.cm",
                        "func" : "Calculator.Parse(const String&)",
                        "line" : "44"
                    }
                    ,
                    "id" : "2"
                }
            ]
            ,
            "success" : true
        }
        

3.5.3 Result

If the show breakpoints command succeeds, the debugger prints a JSON object that contains a JSON array of breakpoints. This JSON object has the following fields:

If the show breakpoints command fails, the debugger prints an error result.

3.6 Next command

The next command executes current source line of the program being debugged, transfers control to the next source line and stops the process. Any intervening function calls are stepped over. The process may hit a breakpoint before control reaches the next source line, in which case the debugger stops execution of the process. After execution the debugger prints a JSON object describing current state of the process and lists source lines around the current instruction.

3.6.1 Syntax

next‑command next | n

3.6.2 Examples

  1. next
    Result:
        {
            "stopped" :
            {
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/lib\/cpp\/gcc\/debug\/Main.cpp",
                    "func" : "function_main_99F3726C50455B4187460FBE611E3885299323E1",
                    "line" : "3732"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Main.cm",
                    "func" : "main()",
                    "line" : "30"
                }
                ,
                "reason" : "end-stepping-range",
                "threadId" : "1"
            }
            ,
            "success" : true
        }    
        
  2. n
    Result:
        {
            "stopped" :
            {
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/lib\/cpp\/gcc\/debug\/Main.cpp",
                    "func" : "function_main_99F3726C50455B4187460FBE611E3885299323E1",
                    "line" : "3753"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Calculator\/Main.cm",
                    "func" : "main()",
                    "line" : "31"
                }
                ,
                "reason" : "end-stepping-range",
                "threadId" : "1"
            }
            ,
            "success" : true
        }
        
  3. next
    If the process exits and returns a zero exit code, the result is as follows:
        {
            "stopped" :
            {
                "reason" : "exited-normally"
            }
            ,
            "success" : true
        }     
        
  4. next
    If the process exits and returns a non-zero exit code, the result is as follows:
        {
            "stopped" :
            {
                "exitCode" : "01",
                "reason" : "exited"
            }
            ,
            "success" : true
        }
        

3.6.3 Result

If the next command succceeds, the debugger prints a stopped result, a JSON object that describes the current state of the process. The reason field of the stopped result may contain for example string end-stepping-range or breakpoint-hit.

If the next command fails, the debugger prints an error result.

3.7 Step command

The step command starts executing current source line of the program being debugged. If no function call is encountered, the debugger transfers control to the next source line and stops the process. If a function call is encountered, the debugger steps inside that function and stops the process. After execution the debugger prints a JSON object describing the current state of the process and lists source lines around the current instruction.

3.7.1 Syntax

step‑command step | s

3.7.2 Examples

  1. step
    Result:
        {
            "stopped" :
            {
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/lib\/cpp\/gcc\/debug\/Console.cpp",
                    "func" : "member_function_WriteLine_Console_9FE02332C7669B128638EA7B0A2A2EE07C3A0A17",
                    "line" : "6794"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/Console.cm",
                    "func" : "System.Console.WriteLine(const char*)",
                    "line" : "99"
                }
                ,
                "reason" : "end-stepping-range",
                "threadId" : "1"
            }
            ,
            "success" : true
        }
        

3.7.3 Result

If the step command succceeds, the debugger prints a stopped result, a JSON object that describes the current state of the process. The reason field of the stopped result will most likely contain a string end-stepping-range.

If the step command fails, the debugger prints an error result.

3.8 Finish command

The finish command runs the program to the end of the current function and steps out of the function. The process may hit a breakpoint before that point, in which case the debugger stops execution of the process. After execution the debugger prints a JSON object describing current state of the process and lists source lines around the current instruction.

3.8.1 Syntax

finish‑command finish | f

3.8.2 Examples

  1. finish
    Result:
        {
            "stopped" :
            {
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/lib\/cpp\/gcc\/debug\/Hello.cpp",
                    "func" : "function_main_99F3726C50455B4187460FBE611E3885299323E1",
                    "line" : "641"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/Hello.cm",
                    "func" : "main()",
                    "line" : "6"
                }
                ,
                "reason" : "function-finished",
                "threadId" : "1"
            }
            ,
            "success" : true
        }
        

3.8.3 Result

If the finish command succceeds, the debugger prints a stopped result, a JSON object that describes the current state of the process. The reason field of the stopped result may contain for example function-finished or breakpoint-hit.

If the finish command fails, the debugger prints an error result.

3.9 Until command

The until command runs the program to the specified source location.

3.9.1 Syntax

until‑command (until | u) source‑location

3.9.2 Examples

  1. until 5
    Result:
        {
            "stopped" :
            {
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/lib\/cpp\/gcc\/debug\/Hello.cpp",
                    "func" : "function_main_99F3726C50455B4187460FBE611E3885299323E1",
                    "line" : "637"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/Hello.cm",
                    "func" : "main()",
                    "line" : "5"
                }
                ,
                "reason" : "location-reached",
                "threadId" : "1"
            }
            ,
            "success" : true
        }        
        

3.9.3 Result

If the until command succceeds, the debugger prints a stopped result, a JSON object that describes the current state of the process. The reason field of the stopped result may contain for example location-reached or breakpoint-hit.

If the until command fails, the debugger prints an error result.

3.10 Continue command

The continue command starts executing the program being debugged from the current source line, and runs it until a breakpoint is hit, the process receives a signal, or the process exits gracefully or not so gracefully.

3.10.1 Syntax

continue‑command continue | c

3.10.2 Examples

  1. continue
    Result:
        {
            "stopped" :
            {
                "reason" : "exited-normally"
            }
            ,
            "success" : true
        }        
        
  2. c
    Result:
        {
            "stopped" :
            {
                "breakpointId" : "1",
                "cppFrame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/lib\/cpp\/gcc\/debug\/Console.cpp",
                    "func" : "member_function_WriteLine_Console_9FE02332C7669B128638EA7B0A2A2EE07C3A0A17",
                    "line" : "6838"
                }
                ,
                "frame" :
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/Console.cm",
                    "func" : "System.Console.WriteLine(const char*)",
                    "line" : "100"
                }
                ,
                "gdbBreakpointNumber" : "2",
                "reason" : "breakpoint-hit",
                "threadId" : "1"
            }
            ,
            "success" : true
        }
        

3.10.3 Result

If the continue command succceeds, the debugger prints a stopped result, a JSON object that describes the current state of the process. The reason field of the stopped result may contain for example exited-normally, exited, breakpoint-hit or signal-received.

If the continue command fails, the debugger prints an error result.

3.11 Depth command

The depth command prints a JSON object that contains the depth of the current call stack.

3.11.1 Syntax

depth‑command depth

3.11.2 Examples

  1. depth
    Result:
        {
            "depth" : "4",
            "success" : true
        }
            

3.11.3 Result

If the depth command succeeds, the debugger prints a JSON object that contains the depth of the call stack. The JSON object contains the following fields:

If the depth command fails, the debugger prints an error result.

3.12 Frames command

The frames command prints a JSON object that contains specified frames of the current call stack. If no frame numbers are given, the debugger prints entire call stack. The number of the current frame is zero and outer frames have succeeding numbers.

3.12.1 Syntax

frames‑command frames (low‑frame‑number high‑frame‑number)?
low‑frame‑number integer
high‑frame‑number integer

3.12.2 Examples

  1. frames
    Result:
        {
            "cppFrames" :
            [
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/lib\/cpp\/gcc\/debug\/BinaryReader.cpp",
                    "func" : "constructor_String_char_1A2E459753926DA4BB6C50F78EAA85228F458D8D",
                    "level" : "0",
                    "line" : "1096"
                }
                ,
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/lib\/cpp\/gcc\/debug\/Console.cpp",
                    "func" : "member_function_WriteLine_Console_9FE02332C7669B128638EA7B0A2A2EE07C3A0A17",
                    "level" : "1",
                    "line" : "6860"
                }
                ,
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/lib\/cpp\/gcc\/debug\/Hello.cpp",
                    "func" : "function_main_99F3726C50455B4187460FBE611E3885299323E1",
                    "level" : "2",
                    "line" : "639"
                }
                ,
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/lib\/cpp\/gcc\/debug\/__main__.cpp",
                    "func" : "main",
                    "level" : "3",
                    "line" : "1319"
                }
            ]
            ,
            "frames" :
            [
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/String.cm",
                    "func" : "String.@constructor(String, const char*)",
                    "level" : "0",
                    "line" : "38"
                }
                ,
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/Console.cm",
                    "func" : "System.Console.WriteLine(const char*)",
                    "level" : "1",
                    "line" : "100"
                }
                ,
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/projects\/examples\/Hello\/Hello.cm",
                    "func" : "main()",
                    "level" : "2",
                    "line" : "5"
                }
                ,
                {
                    "level" : "3"
                }
            ]
            ,
            "success" : true
        }
        
  2. frames 0 0
    Result:
        {
            "cppFrames" :
            [
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/lib\/cpp\/gcc\/debug\/BinaryReader.cpp",
                    "func" : "constructor_String_char_1A2E459753926DA4BB6C50F78EAA85228F458D8D",
                    "level" : "0",
                    "line" : "1096"
                }
            ]
            ,
            "frames" :
            [
                {
                    "file" : "D:\/work\/cmajorm\/cmajor\/system\/System.Base\/String.cm",
                    "func" : "String.@constructor(String, const char*)",
                    "level" : "0",
                    "line" : "38"
                }
            ]
            ,
            "success" : true
        }
        

3.12.3 Result

If the frames command succeeds, the debugger prints a JSON object that contains two JSON arrays of frame objects, one for C++ frames and one for Cmajor frames:

If the frames command fails, the debugger prints an error result.

The print command evaluates an expression and prints the result as a JSON object. The expression can contain for example a name of a local variable, this pointer, subscript or range expression, pointer dereference, member selection or address-of expression.

print‑command (print | p) expression
expression additive‑expression
additive‑expression prefix‑expression ((+ | -) prefix‑expression)*
prefix‑expression dereference‑expression | address‑of‑expression | postfix‑expression
dereference‑expression * prefix‑expression |
address‑of‑expression & prefix‑expression |
postfix‑expression primary‑expression
( member‑selection‑expression | base‑selection‑expression |
subscript‑expression | range‑expression )*
member‑selection‑expression . identifier
base‑selection‑expression . base
subscript‑expression [ expression ]
range‑expression [ expression , expression ]
primary‑expression identifier |
this |
integer |
parenthesized‑expression |
typeid‑expression |
cast‑expression |
identifier [a-zA-Z_][a-zA-Z0-9_]*
parenthesized‑expression ( expression )
typeid‑expression typeid ( string )
string " ([^\n\r"]| escape )* "
escape \ ((x | X) hex‑digits | (d | D) integer | octal‑digits | u hex‑4 | U hex‑8 | [abfnrtv\"'\\])
hex‑digits hex‑digit+
hex‑4 hex‑digit hex‑digit hex‑digit hex‑digit
hex‑8 hex‑4 hex‑4
hex‑digit [0-9a-fA-F]
octal‑digits [0-7]+
cast‑expression cast < typeid‑expression > ( expression )

3.13.2.1 Additive expressions

Additive expressions are of the form ptr+offset, offset+ptr, ptr-offset and ptr-ptr, where ptr is a pointer, e.g. a local variable or other expression of a pointer type, and offset is an integer.

Additive expressions may not have direct uses for debugger users, but cmdb uses it internally to translate a subscript expression regarding to a List container to dereference and an additive pointer expression. For example, if intList is a variable of type List<int>, cmdb does the following translations for these three subscript expressions:

            intList[0] ⇒ *(intList.items+0)
            intList[1] ⇒ *(intList.items+1)
            intList[2] ⇒ *(intList.items+2)
        
and generally for List<T> x:
            x[i] ⇒ *(x.items+i)
        

3.13.2.2 Dereference expression

A dereference expression is of the form *ptr, where ptr if a pointer type expression. It yields a value of a memory location pointed by ptr. For example, after executing the following code:

        int x = 42;
        int* p = &x;
    

and then issuing the following print command:

        print *p
    

the debugger will print a JSON object with the value field having value 42.

If *ptr is of a composite type, the value field of the printed JSON object will just have value

            {...}
        

3.13.2.3 Address-of expression

An address-of expression is of the form &expr, where expr can be for example a local or member variable. It yields the memory address of expr. After executing the following code:

        int x;
    

and then issuing the following print command:

        print &x;
    

the debugger will print a JSON object with the value field having e.g. a value "0x2ccf944".

3.13.2.4 Postfix expressions

A postfix expression consists of a primary expression followed by a possibly empty sequence of member selection, base selection, subscript and range expressions.

3.13.2.5 Member selection expression

Member selection expression is of the form o.m, where o is an expression of a class type and m is a member variable of that class type.

If p is a pointer to a class type object, (*p).m denotes a member m of that class object. In this case the parentheses are necessary because the precedence of the member selection operator . is greater than the precedence of the dereference operator *.

3.13.2.6 Base selection expression

Base selection expression is of the form o.base, where o is an expression of a class type having a base class. It denotes the base class object of class object o.

3.13.2.7 Subscript expression

Substricpt expression is of the form e[index], where e is of an array, pointer or container type and index is an integer. Indeces start from 0.

When e is

After executing the following code:

        List<int> x;
        x.Add(1);
    

and then issuing the following print command:

        print x[0];
    

the debugger will print a JSON object with the value field having value "1".

3.13.2.8 Range expression

A range expression is of the form r[s,e], where r is of an array, pointer or container type, s is an integer denoting range start and e is an integer denoting range end. Ranges are half-open so that r[0,10] means indeces 0 to 10 excluding 10.

When r is of an array type that has its size specified, or of a container type, e can also be a special identifier, count, that denotes the number of elements in r.

The resulting JSON object has a field range that is a JSON array of JSON objects. Each of those JSON objects have a value field having the value of an element.

After executing the following code:

        Set<int> s;
        s.Insert(1);
        s.Insert(2);
        s.Insert(3);
    

and then issuing the following print command:

        print s[0,count];
    

the debugger will print a JSON object with a range field that is a JSON array of JSON objects that have value fields containing values 1, 2 and 3.

3.13.2.9 Primary expressions

A primary expression can be

3.13.2.10 Printing value of a local variable

If x is a local variable, command

        print x
        
prints information about x and the value of x if available.

If x is of a primitive type, the resulting JSON object contains the following fields:

If x is of a class type, but not of a container type, the resulting JSON object contains the following fields:

If x is of a pointer type, the resulting JSON object contains the following fields:

If x is of a container type, the resulting JSON object contains the following fields:

3.13.2.11 Printing information about a type

A typeid expression consists of the keyword typeid followed by a type dentifier string, an UUID, in parentheses.

If t is a type identifier string, command

        print t
        
prints information about the type with identifier t as a JSON object.

The JSON object contains the following fields:

3.13.2.12 Cast expression

A cast expression consists of the keyword cast followed by a typeid expression in angle brackets followed by an expression in parentheses.

It casts the given expression to the type identified by the typeid expression.

cmdb can print elements of and information about the following container types:

container namecontainer type
forwardListForwardList<T>
hashMapHashMap<K, T, H, C>
hashSetHashSet<T, H, C>
linkedListLinkedList<T>
listList<T>
mapMap<Key, Value, KeyCompare>
queueQueue<T>
setSet<T>
stackStack<T>

A type identifier is a UUID string of the form "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx". It uniquely identifies a Cmajor type.

3.14 Set condition command

The set condition command sets a breakpoint as a conditional breakpoint and sets the condition of that breakpoint.

3.14.1 Syntax

set‑condition‑command set condition breakpoint‑id condition
breakpoint‑id integer
condition disjunctive‑expr
disjunctive‑expr conjunctive‑expr (|| conjunctive‑expr)*
conjunctive‑expr bit‑or‑expr (&& bit‑or‑expr)*
bit‑or‑expr bit‑xor‑expr (| bit‑xor‑expr)*
bit‑xor‑expr bit‑and‑expr (^ bit‑and‑expr)*
bit‑and‑expr equality‑expr (& equality‑expr)*
equality‑expr relational‑expr ((== | !=) relational‑expr)*
relational‑expr shift‑expr ((<= | >= | < | >) shift‑expr)*
shift‑expr additive‑expr ((<< | >>) additive‑expr)*
additive‑expr multiplicative‑expr ((+ | -) multiplicative‑expr)*
multiplicative‑expr prefix‑expr ((* | / | %) prefix‑expr)*
prefix‑expr * prefix‑expr | & prefix‑expr | postfix‑expr
postfix‑expr primary‑expr (. identifier | . base | [ additive‑expr ])*
primary‑expr identifier | integer | ( disjunctive‑expr )

3.15 Set debugger variable command

The set debugger variable command sets the state of a debugger variable. There's just one debugger variable defined at the moment: breakOnThrow.

When the breakOnThrow variable is true (default), the debugger stops the program when a throw statement is encountered. If the breakOnThrow variable is false, the program does not stop automatically on throw statements.

When a program is stopped on a throw statement, the next debugger command drives the program to the corresponding catch statement and stops the program.

3.15.1 Syntax

set‑debugger‑var‑command set breakOnThrow = (true | false)

3.16 Exit command

The exit command exists the debugger.

3.16.1 Syntax

exit‑command exit | e | quit | q

4. Common results

4.1 Stopped result

Whenever execution of the process stops for some reason, the debugger prints a JSON object that describes the state of the process. This JSON object has the following fields:

4.2 Error result

If a debugger command fails, the debugger prints a JSON object with the following fields:

5. Summary of the command syntax

debugger‑command list‑command |
break‑command |
delete‑command |
show‑breakpoint‑command |
show‑breakpoints‑command |
next‑command |
step‑command |
finish‑command |
until‑command |
continue‑command |
depth‑command |
frames‑command |
print‑command |
set‑condition‑command |
set‑debugger‑var‑command |
exit‑command
list‑command (list | l) list‑location?
list‑location source‑location | *
source‑location path (: line)? | line
path (drive :)? (/? (comp /)*)? comp
drive [A-Za-z]
comp [A-Za-z_.+][a-zA-Z_0-9.+-]*
line integer
integer [0-9]+
break‑command (break | b) source‑location
delete‑command (delete | d) breakpoint-id
breakpoint‑id integer
show‑breakpoint‑command show breakpoint breakpoint-id
show‑breakpoints‑command show breakpoints
next‑command next | n
step‑command step | s
finish‑command finish | f
until‑command (until | u) source‑location
continue‑command continue | c
depth‑command depth
frames‑command frames (low‑frame‑number high‑frame‑number)?
low‑frame‑number integer
high‑frame‑number integer
print‑command (print | p) expression
expression additive‑expression
additive‑expression prefix‑expression ((+ | -) prefix‑expression)*
prefix‑expression dereference‑expression | address‑of‑expression | postfix‑expression
dereference‑expression * prefix‑expression |
address‑of‑expression & prefix‑expression |
postfix‑expression primary‑expression
( member‑selection‑expression | base‑selection‑expression | subscript‑expression | range‑expression )*
member‑selection‑expression . identifier
base‑selection‑expression . base
subscript‑expression [ expression ]
range‑expression [ expression , expression ]
primary‑expression identifier |
this |
integer |
parenthesized‑expression |
typeid‑expression |
cast‑expression |
identifier [a-zA-Z_][a-zA-Z0-9_]*
parenthesized‑expression ( expression )
typeid‑expression typeid ( string )
string " ([^\n\r"]| escape )* "
escape \ ((x | X) hex‑digits | (d | D) integer | octal‑digits | u hex‑4 | U hex‑8 | [abfnrtv\"'\\])
hex‑digits hex‑digit+
hex‑4 hex‑digit hex‑digit hex‑digit hex‑digit
hex‑8 hex‑4 hex‑4
hex‑digit [0-9a-fA-F]
octal‑digits [0-7]+
cast‑expression cast < typeid‑expression > ( expression )
set‑condition‑command set condition breakpoint‑id condition
breakpoint‑id integer
condition disjunctive‑expr
disjunctive‑expr conjunctive‑expr (|| conjunctive‑expr)*
conjunctive‑expr bit‑or‑expr (&& bit‑or‑expr)*
bit‑or‑expr bit‑xor‑expr (| bit‑xor‑expr)*
bit‑xor‑expr bit‑and‑expr (^ bit‑and‑expr)*
bit‑and‑expr equality‑expr (& equality‑expr)*
equality‑expr relational‑expr ((== | !=) relational‑expr)*
relational‑expr shift‑expr ((<= | >= | < | >) shift‑expr)*
shift‑expr additive‑expr ((<< | >>) additive‑expr)*
additive‑expr multiplicative‑expr ((+ | -) multiplicative‑expr)*
multiplicative‑expr prefix‑expr ((* | / | %) prefix‑expr)*
prefix‑expr * prefix‑expr | & prefix‑expr | postfix‑expr
postfix‑expr primary‑expr (. identifier | . base | [ additive‑expr ])*
primary‑expr identifier | integer | ( disjunctive‑expr )
set‑debugger‑var‑command set breakOnThrow = (true | false)
exit‑command exit | e | quit | q

6. Known bugs