tclreadline - insert-completions - c

I'm using tclreadline to handle completions in my project, which is written in C/C++ and TCL.
I had to modify some configurations to deal with Readline 6.2, but I managed it.
I have 3 problems:
I defined other commands in the TCL interpreter, like get_ports and get_modules.
If I type get_por, it correctly executes get_ports, but the history says get_por.
If I type get_por -of_objects [get_mod], it correctly executes get_ports -of_objects [get_modules], but the history says get_por -of_objects [get_mod]. So the command is not expanded before adding it to the history. How can I manage this?
If I type get_por -of [get_mod] it doesn't expand -of in -of_objects, because I check for -of_objects inside the command and it doesn't appear. How can I manage INSERT-COMPLETIONS mode of readline? Or alternatively, any kind of INSERT-ALL-COMPLETIONS ?
If I type get_por -ofTAB, tclreadline issues an error of ScriptCompleter, which says that get_por is not a command. It should complete the command, first, and then complete the option, which is defined in a proc complete(get_ports).

Related

How to specify the flags and files needed for the program to work in debug mode? [duplicate]

I need someone to outline how to pass command line arguments to CLion. What I've found so far hasn't worked for me. Specifically I need to know how to pass multiple arguments to the program from the command line.
If you click on Run-Edit Configurations you can create an "Application" configuration that allows you to provide the Program arguments - either in a single line, or in a separate window one argument per line.
I landed on this SO page as I was using CLion with Rust.
For Rust I was able to add the command line arguments to the end of the Run\Edit Configurations\Command. Notice the required --.
I got this tip from Jetbrains.
For C, it was Run\Edit Configurations\Program Arguments, as #Zulan said.

Frama-c: save plugin analysis results in c file

I'am new in frama-c. So I apologize in advance for my question.
I would like to make a plugin that will modify the source code, clone some functions, insert some functions calls and I would like my plugin to generate a second file that will contain the modified version of the input file.
I would like to know if it is possible to generate a new file c with frama-c. For example, the results of the Sparecode and Semantic constant folding plugins are displayed on the terminal directly and not in a file. So I would like to know if Frama-c has the function to write to a file instead of sending the result of the analysis to the standard output.
Of course we can redirect the output of frama-c to a file.c for example, but in this case, for the plugin scf for example, the results of value is there and I found that frama-c replaces for example the "for" loops by while.
But what I would like is that frama-c can generate a file that will contain my original code plus the modifications that I would have inserted.
I looked in the directory src / kernel_services / ast_printing but I have not really found functions that can guide me.
Thanks.
On the command line, option -ocode <file> indicates that any subsequent -print will be done in <file> instead of the standard output (use -ocode "" after that if you want to print on stdout again). Note that -print prints the code corresponding to the current project. You can use -then-on <prj> to change the project you're interested in. More information is of course available in the user manual.
All of this is of course available programmatically. In particular, File.pretty_ast by defaults pretty-prints (i.e. output a C program) the AST of the current project on stdout, but takes two optional argument for changing the project or the formatter to which the output should be done.

Missing built-in command "history" for Tcl C extension

I am working on a project need Tclsh like support with some self-defined commands. I implemented following code (based on Tcl 8.5):
Tcl_Main(argc, argv, Tcl_AppInit);
And put new commands registration in Tcl_AppInit. Everything looks fine, except that with the new command line interpreter, when I type Tcl built-in command "history", I got :
% history
invalid command name "history"
Other built-in commands work fine, like "puts", "set", etc.
Why ? Do I have to implement my own "history" command instead?
Add my solution here:
It turns out history is part of Tcl script library which needs to be sourced during initialization, either by sourcing $TCL_LIBRARY/init.tcl or calling Tcl_Init(interp).

How do I properly pass command line arguments to a C program in CLion?

I need someone to outline how to pass command line arguments to CLion. What I've found so far hasn't worked for me. Specifically I need to know how to pass multiple arguments to the program from the command line.
If you click on Run-Edit Configurations you can create an "Application" configuration that allows you to provide the Program arguments - either in a single line, or in a separate window one argument per line.
I landed on this SO page as I was using CLion with Rust.
For Rust I was able to add the command line arguments to the end of the Run\Edit Configurations\Command. Notice the required --.
I got this tip from Jetbrains.
For C, it was Run\Edit Configurations\Program Arguments, as #Zulan said.

C to NASM conversion

I'm trying to find a way to convert simple C code to NASM assembly. I have tried using objconv and downloaded and unzipped and built it since I am using a MAC; however, it doesn't seem to be working. I keep getting "-bash: objconv: command not found". Does anyone know another way or can help me solve the -bash error.
Bash is the program that takes the words you type in a terminal and launches other programs. If it is reporting an error, it is because it cannot find the program you want to run (at least in this case).
You need to either find a pre-packaged installation of objconv, or you need to do the work to "integrate" your copy of objconv yourself.
If you can identify the executable you want to run (probably called objconv) you need to add that to your path. The easiest way (if it is just for you) is to verify that your ~/.bashrc or ~/.bashprofile has a line that looks something like
PATH=$PATH:${HOME}/bin
Don't worry if it doesn't look exactly the same. Just make sure there's a ${HOME}/bin or ~/bin (~ is the short version of ${HOME}).
If you have that then type the commands
cd ~/bin
ln -fs ../path/to/objconv
and you will create a soft link (a type of file) in your home binary directory, and the program should be available to the command line.
If you create the file, and nothing above has any errors, but it is not available to the command line, you might need to set the executable bit on your "real" (not link) copy of objconv.
If this doesn't work, by now you should be well primed for a better, more specific question.
If you have gcc installed, try gcc -masm=intel -S source.c to generate assembly files in a syntax very similar to that of MASM.

Resources