Cling: unknown type name ‘source’

Hi @bellenot ,

I suppose I have CLING vesion 1.0~dev installed on my windows machine, as I get the below output:
C:\Release_NEW\bin>cling.exe --version
1.0~dev

I am able to call my project specific DLL functions from the CLING interpreter now. Now, I am trying to write a .cpp script so as to call the DLL functions and then load that whole .cpp file into CLING interpreter and execute it all at once instead of typing each line on the CLING interpreter.

I got to know that “source” is the keyword that will be used for loading a .cpp file to CLING interpreter. But, when I try to source , i get the below error:
[cling]$ source C:\Release_NEW\bin\try.cpp
input_line_3:2:2: error: unknown type name ‘source’
source C:\Release_NEW\bin\try.cpp

Can you please tell me if source is available with CLING version 1.0~dev? If not, where can I get the latest version that supports this?

First, please don’t reply to an old and unrelated topic.
Then

Where did you get this information from? To see the list of possible command in cling, just type .?:

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ .?

 Cling (C/C++ interpreter) meta commands usage
 All commands must be preceded by a '.', except
 for the evaluation statement { }
 ==============================================================================
 Syntax: .Command [arg0 arg1 ... argN]

   .L <filename>                - Load the given file or library

   .(x|X) <filename>[(args)]    - Same as .L and runs a function with
                                  signature: ret_type filename(args)

   .> <filename>                - Redirect command to a given file
      '>' or '1>'               - Redirects the stdout stream only
      '2>'                      - Redirects the stderr stream only
      '&>' (or '2>&1')          - Redirects both stdout and stderr
      '>>'                      - Appends to the given file

   .undo [n]                    - Unloads the last 'n' inputs lines

   .U <filename>                - Unloads the given file

   .(I|include) [path]          - Shows all include paths. If a path is given,
                                  adds the path to the include paths.

   .O <level>                   - Sets the optimization level (0-3)
                                  If no level is given, prints the current setting.

   .class <name>                - Prints out class <name> in a CINT-like style (one-level).
                                  If no name is given, prints out list of all classes.

   .Class <name>                - Prints out class <name> in a CINT-like style (all-levels).
                                  If no name is given, prints out list of all classes.

   .namespace                   - Prints list of all known namespaces

   .typedef <name>              - Prints out typedef <name> in a CINT-like style
                                  If no name is given, prints out list of all typedefs.

   .files                       - Prints names of all included (parsed) files

   .fileEx                      - Prints out included (parsed) file statistics
                                  as well as a list of their names

   .g <var>                     - Prints out information about global variable
                                  'var' - if no name is given, print them all

   .@                           - Cancels and ignores the multiline input

   .rawInput [0|1]              - Toggle wrapping and printing the
                                  execution results of the input

   .dynamicExtensions [0|1]     - Toggles the use of the dynamic scopes
                                  and the late binding

   .debug <level>               - Generates debug symbols (level is optional, 0 to disable)

   .printDebug [0|1]            - Toggles the printing of input's corresponding
                                  state changes

   .storeState <filename>       - Store the interpreter's state to a given file

   .compareState <filename>     - Compare the interpreter's state with the one
                                  saved in a given file

   .stats [name]                - Show stats for internal data structures
                                  'ast'  abstract syntax tree stats
                                  'asttree [filter]'  abstract syntax tree layout
                                  'decl' dump ast declarations
                                  'undo' show undo stack

   .T <filePath> <comment>      - Generate autoload map

   .trace <repr> <id>           - Dump trace of requested respresentation
                                  (see .stats arguments for <repr>)

   .help                        - Shows this information (also .?)

   .q                           - Exit the program

[cling]$

So as you can see, you can either execute the code with .x or load the code with .L and then call a function from that code.

Thanks for the response. I am able to laod the .cpp script file using .L and call the script functions.

Suppose my .script has 100 lines of code and I want to get a breakpoint at the 40th line of my .cpp script when I call the script function from the CLING interpreter, how can I do this?

Will I be able to debug the .cpp script line wise when called from the CLING interpreter after loading it?

AFAIK it is not possible (at least on Windows)

is it possible on linux??

I don’t know, but maybe @vvassilev knows

Because, we currently have CINT being used in our project and we are able to take the breakpoints on .cpp scripts on both windows and linux.
So, I hoped it would be available with CLING as well as its more advanced than CINT !

@bellenot and @vvassilev ,
any update for the above query related to debug point in .cpp script?

The new llvm infrastructure will allow you to set a breakpoint in jitted code. You need to run cling under a debugger like lldb or gdb. You can read more here: GDB JIT Interface 101

1 Like