PIPS
tpips.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  res_or_rule
 Storage for arguments of tpips commands. More...
 

Macros

#define TPIPS_PRIMARY_PROMPT   "tpips> " /**prompt for readline */
 
#define TPIPS_REQUEST_PROMPT   "tpips-request> "
 
#define TPIPS_SECONDARY_PROMPT   "> "
 
#define TPIPS_CONTINUATION_CHAR   '\\'
 
#define TPIPS_HISTENV   "TPIPS_HISTORY" /**history file env variable */
 
#define TPIPS_HISTORY_LENGTH   100 /**max length of history file */
 
#define TPIPS_COMMENT_PREFIX   '#' /**comment prefix */
 
#define TPIPS_HISTORY   ".tpips.history" /**default history file */
 
#define SHELL_ESCAPE   "shell" /**! used for history reference */
 
#define CHANGE_DIR   "cd"
 
#define TPIPS_SOURCE   "source"
 
#define SET_ENV   "setenv"
 
#define GET_ENV   "getenv"
 
#define SET_PROP   "setproperty"
 
#define GET_PROP   "getproperty"
 
#define QUIT   "quit"
 
#define HELP   "help"
 
#define ECHO_N   "echo"
 macro ECHO is reserved by flex More...
 
#define skip_blanks(str)    while (*str && (*str==' ' || *str=='\t' || *str=='\n')) str++
 

Functions

int tp_lex ()
 
int tp_parse ()
 
void tp_error ()
 
void tp_init_lex ()
 
void tp_begin_key ()
 
void tp_begin_fname ()
 
string tpips_current_file_name (void)
 
int tpips_current_line_number (void)
 
void tpips_next_line (void)
 
int tpips_current_line (void)
 
string tpips_current_name (void)
 
bool tpips_behaves_like_a_shell (void)
 
FILE * jpips_out_file (void)
 
void jpips_begin_tag (string)
 
void jpips_add_tag (string)
 
void jpips_end_tag (void)
 
void jpips_tag (string)
 
void jpips_tag2 (string, string)
 
void jpips_done (void)
 
void jpips_string (const char *, va_list)
 
void jpips_printf (const string,...)
 
char ** get_module_names (void)
 Build an array with the names of all available modules. More...
 
void tpips_internal_error (const char *, const char *,...)
 
void tpips_help (string)
 
void tpips_close (void)
 
void tpips_init (void)
 
void tpips_process_a_file (FILE *, string, bool)
 processing command line per line. More...
 
int tpips_main (int, char *[])
 MAIN: interactive loop and history management. More...
 
bool phase_name_p (string)
 
bool resource_name_p (string)
 
bool property_name_p (string)
 
void tpips_wrapper (void)
 wrapper.c More...
 
void tpips_set_line_to_parse (char *)
 in lex file More...
 
char * tpips_get_line_to_parse (void)
 
void tpips_lex_print_pos (FILE *)
 
void tp_restart (FILE *)
 
void tp_pop_buffer_state (void)
 
int tp_get_lineno (void)
 
FILE * tp_get_in (void)
 
FILE * tp_get_out (void)
 
int tp_get_leng (void)
 
char * tp_get_text (void)
 
void tp_set_lineno (int)
 
void tp_set_in (FILE *)
 
void tp_set_out (FILE *)
 
int tp_get_debug (void)
 
void tp_set_debug (int)
 
int tp_lex_destroy (void)
 
void * tp_alloc (yy_size_t)
 
void * tp_realloc (void *, yy_size_t)
 
void tp_free (void *)
 
int tp_wrap (void)
 
void tp_error (const char *)
 

Variables

FILE * tp_in
 
bool tpips_execution_mode
 cproto-generated files More...
 
bool tpips_is_interactive
 
bool jpips_is_running
 
bool tpips_init_done
 variable globale, utilisee par le parser helas More...
 
bool consistency_enforced_p
 Pipsmake does not enforce consistency when properties are changed. More...
 
int tp_char
 revisions.c More...
 
int tp_nerrs
 
int tp_leng
 tp_lex.c More...
 
FILE * tp_out
 
int tp_lineno
 
int tp__flex_debug
 
char * tp_text
 
string tpips_unknown_string
 

Macro Definition Documentation

◆ CHANGE_DIR

#define CHANGE_DIR   "cd"

Definition at line 65 of file tpips.h.

◆ ECHO_N

#define ECHO_N   "echo"

macro ECHO is reserved by flex

Definition at line 77 of file tpips.h.

◆ GET_ENV

#define GET_ENV   "getenv"

Definition at line 69 of file tpips.h.

◆ GET_PROP

#define GET_PROP   "getproperty"

Definition at line 72 of file tpips.h.

◆ HELP

#define HELP   "help"

Definition at line 75 of file tpips.h.

◆ QUIT

#define QUIT   "quit"

Definition at line 74 of file tpips.h.

◆ SET_ENV

#define SET_ENV   "setenv"

Definition at line 68 of file tpips.h.

◆ SET_PROP

#define SET_PROP   "setproperty"

Definition at line 71 of file tpips.h.

◆ SHELL_ESCAPE

#define SHELL_ESCAPE   "shell" /**! used for history reference */

Definition at line 64 of file tpips.h.

◆ skip_blanks

#define skip_blanks (   str)     while (*str && (*str==' ' || *str=='\t' || *str=='\n')) str++

Definition at line 79 of file tpips.h.

◆ TPIPS_COMMENT_PREFIX

#define TPIPS_COMMENT_PREFIX   '#' /**comment prefix */

Definition at line 61 of file tpips.h.

◆ TPIPS_CONTINUATION_CHAR

#define TPIPS_CONTINUATION_CHAR   '\\'

Definition at line 57 of file tpips.h.

◆ TPIPS_HISTENV

#define TPIPS_HISTENV   "TPIPS_HISTORY" /**history file env variable */

Definition at line 59 of file tpips.h.

◆ TPIPS_HISTORY

#define TPIPS_HISTORY   ".tpips.history" /**default history file */

Definition at line 62 of file tpips.h.

◆ TPIPS_HISTORY_LENGTH

#define TPIPS_HISTORY_LENGTH   100 /**max length of history file */

Definition at line 60 of file tpips.h.

◆ TPIPS_PRIMARY_PROMPT

#define TPIPS_PRIMARY_PROMPT   "tpips> " /**prompt for readline */

Definition at line 54 of file tpips.h.

◆ TPIPS_REQUEST_PROMPT

#define TPIPS_REQUEST_PROMPT   "tpips-request> "

Definition at line 55 of file tpips.h.

◆ TPIPS_SECONDARY_PROMPT

#define TPIPS_SECONDARY_PROMPT   "> "

Definition at line 56 of file tpips.h.

◆ TPIPS_SOURCE

#define TPIPS_SOURCE   "source"

Definition at line 66 of file tpips.h.

Function Documentation

◆ get_module_names()

char** get_module_names ( void  )

Build an array with the names of all available modules.

Free after a previous use:

By default, no available module:

Mainly inspired from wpips/emacs.c

Overkilling since most of time, the module list does not change but I guess there is no indicator in PIPS to tell some modules have been created or destroyed.

Note that since calloc initialize the memory to 0, this array will end with a NULL pointer as expected.

Definition at line 332 of file tpips.c.

333 {
334  static char **names = NULL;
335  static gen_array_t modules = NULL;
336 
337  if (names != NULL) {
338  /* Free after a previous use: */
339  free(names);
340  gen_array_full_free(modules);
341  /* By default, no available module: */
342  names = NULL;
343  }
344 
345  /* Mainly inspired from wpips/emacs.c
346 
347  Overkilling since most of time, the module list does not change but I
348  guess there is no indicator in PIPS to tell some modules have been
349  created or destroyed. */
350  if (db_get_current_workspace_name() != NULL) {
351  int module_list_length, i;
352  modules = db_get_module_list();
353  module_list_length = gen_array_nitems(modules);
354  /* Note that since calloc initialize the memory to 0, this array will
355  end with a NULL pointer as expected. */
356  names = calloc(module_list_length + 1, sizeof(char *));
357  for(i = 0; i < module_list_length; i++)
358  names[i] = gen_array_item(modules, i);
359  }
360  return names;
361 }
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
void free(void *)
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
Definition: database.c:1266
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82

References db_get_current_workspace_name(), db_get_module_list(), free(), gen_array_full_free(), gen_array_item(), and gen_array_nitems().

Referenced by param_generator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_add_tag()

void jpips_add_tag ( string  s)

Definition at line 192 of file tpips.c.

193 {
194  fprintf(out_to_jpips, " %s", s);
195 }
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
static FILE * out_to_jpips
Definition: tpips.c:180

References fprintf(), and out_to_jpips.

Referenced by jpips_tag2(), and tp_some_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_begin_tag()

void jpips_begin_tag ( string  s)

Definition at line 187 of file tpips.c.

188 {
189  fprintf(out_to_jpips, JPIPS_TAG " %s", s);
190 }
#define JPIPS_TAG
jpips specials.
Definition: tpips.c:164

References fprintf(), JPIPS_TAG, and out_to_jpips.

Referenced by jpips_tag(), jpips_tag2(), and tp_some_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_done()

void jpips_done ( void  )

Definition at line 216 of file tpips.c.

217 {
218  jpips_tag("done");
219 }
void jpips_tag(string s)
Definition: tpips.c:203

References jpips_tag().

Referenced by tpips_process_a_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_end_tag()

void jpips_end_tag ( void  )

Definition at line 197 of file tpips.c.

198 {
199  fprintf(out_to_jpips, "\n");
200  fflush(out_to_jpips);
201 }

References fprintf(), and out_to_jpips.

Referenced by jpips_tag(), jpips_tag2(), and tp_some_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_out_file()

FILE* jpips_out_file ( void  )

Definition at line 182 of file tpips.c.

183 {
184  return out_to_jpips;
185 }

References out_to_jpips.

◆ jpips_printf()

void jpips_printf ( const  string,
  ... 
)
Parameters
stringormat

Definition at line 229 of file tpips.c.

230 {
231  va_list some_arguments;
232  va_start(some_arguments, format);
233  (void) vfprintf(out_to_jpips, format, some_arguments);
234  va_end(some_arguments);
235 }

References out_to_jpips.

Referenced by tpips_user_error(), and tpips_user_request().

+ Here is the caller graph for this function:

◆ jpips_string()

void jpips_string ( const char *  a_message_format,
va_list  some_arguments 
)
Parameters
a_message_format_message_format
some_argumentsome_arguments

Definition at line 221 of file tpips.c.

222 {
223  vfprintf(out_to_jpips, a_message_format, some_arguments);
224  fflush(out_to_jpips);
225 }

References out_to_jpips.

Referenced by tpips_user_error(), and tpips_user_request().

+ Here is the caller graph for this function:

◆ jpips_tag()

void jpips_tag ( string  s)

Definition at line 203 of file tpips.c.

204 {
205  jpips_begin_tag(s);
206  jpips_end_tag();
207 }
void jpips_end_tag(void)
Definition: tpips.c:197
void jpips_begin_tag(string s)
Definition: tpips.c:187

References jpips_begin_tag(), and jpips_end_tag().

Referenced by jpips_done(), tpips_user_error(), and tpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jpips_tag2()

void jpips_tag2 ( string  s1,
string  s2 
)
Parameters
s11
s22

Definition at line 209 of file tpips.c.

210 {
212  jpips_add_tag(s2);
213  jpips_end_tag();
214 }
s1
Definition: set.c:247
void jpips_add_tag(string s)
Definition: tpips.c:192

References jpips_add_tag(), jpips_begin_tag(), jpips_end_tag(), and s1.

Referenced by display_a_resource(), and tp_some_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phase_name_p()

bool phase_name_p ( string  )

◆ property_name_p()

bool property_name_p ( string  )

◆ resource_name_p()

bool resource_name_p ( string  )

◆ tp_alloc()

void* tp_alloc ( yy_size_t  )

◆ tp_begin_fname()

void tp_begin_fname ( )

◆ tp_begin_key()

void tp_begin_key ( )

◆ tp_error() [1/2]

void tp_error ( )

◆ tp_error() [2/2]

void tp_error ( const char *  )

◆ tp_free()

void tp_free ( void *  )

◆ tp_get_debug()

int tp_get_debug ( void  )

◆ tp_get_in()

FILE* tp_get_in ( void  )

◆ tp_get_leng()

int tp_get_leng ( void  )

◆ tp_get_lineno()

int tp_get_lineno ( void  )

◆ tp_get_out()

FILE* tp_get_out ( void  )

◆ tp_get_text()

char* tp_get_text ( void  )

◆ tp_init_lex()

void tp_init_lex ( )

◆ tp_lex()

int tp_lex ( )

◆ tp_lex_destroy()

int tp_lex_destroy ( void  )

◆ tp_parse()

int tp_parse ( )

◆ tp_pop_buffer_state()

void tp_pop_buffer_state ( void  )

◆ tp_realloc()

void* tp_realloc ( void *  ,
yy_size_t   
)

◆ tp_restart()

void tp_restart ( FILE *  )

◆ tp_set_debug()

void tp_set_debug ( int  )

◆ tp_set_in()

void tp_set_in ( FILE *  )

◆ tp_set_lineno()

void tp_set_lineno ( int  )

◆ tp_set_out()

void tp_set_out ( FILE *  )

◆ tp_wrap()

int tp_wrap ( void  )

◆ tpips_behaves_like_a_shell()

bool tpips_behaves_like_a_shell ( void  )

Definition at line 143 of file tpips.c.

144 {
147 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static bool tpips_is_a_shell
Definition: tpips.c:67
static bool string_is_true(string s)
Definition: tpips.c:131
#define TPIPS_IS_A_SHELL
Whether pips should behave as a shell.
Definition: tpips.c:141

References get_bool_property(), string_is_true(), tpips_is_a_shell, and TPIPS_IS_A_SHELL.

+ Here is the call graph for this function:

◆ tpips_close()

void tpips_close ( void  )

Definition at line 868 of file tpips.c.

869 {
870  // close history: truncate list and write history file
871  if (use_readline)
872  {
874  stifle_history(TPIPS_HISTORY_LENGTH);
875  write_history(file_name);
876  }
877 
879 
880  if (logfile) {
881  safe_fclose (logfile, "the log file");
882  logfile = NULL;
883  }
884 
885  // do not close yet!
886  //close_xml_logfile();
887 }
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
#define TPIPS_HISTORY_LENGTH
Definition: tpips-local.h:52
static void close_workspace_if_opened(bool is_quit)
Definition: tpips.c:862
static bool use_readline
Definition: tpips.c:68
static string default_hist_file_name(void)
returns the allocated full tpips history file name, i.e.
Definition: tpips.c:662
static FILE * logfile
Definition: tpips.c:69
static string file_name

References close_workspace_if_opened(), default_hist_file_name(), file_name, logfile, safe_fclose(), TPIPS_HISTORY_LENGTH, and use_readline.

Referenced by tpips_exec(), and tpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tpips_current_file_name()

string tpips_current_file_name ( void  )

Definition at line 76 of file tpips.c.

77 {
78  return current_name;
79 }
static string current_name
Definition: tpips.c:73

References current_name.

◆ tpips_current_line()

int tpips_current_line ( void  )

Definition at line 91 of file tpips.c.

92 {
93  return current_line;
94 }
static int current_line
Definition: tpips.c:74

References current_line.

Referenced by tpips_lex_print_pos().

+ Here is the caller graph for this function:

◆ tpips_current_line_number()

int tpips_current_line_number ( void  )

Definition at line 81 of file tpips.c.

82 {
83  return current_line;
84 }

References current_line.

◆ tpips_current_name()

string tpips_current_name ( void  )

Definition at line 96 of file tpips.c.

97 {
98  return current_name;
99 }

References current_name.

Referenced by tpips_lex_print_pos().

+ Here is the caller graph for this function:

◆ tpips_get_line_to_parse()

char* tpips_get_line_to_parse ( void  )

Definition at line 961 of file tp_lex.c.

962 {
963  return line_to_parse;
964 }
static char * line_to_parse
Definition: tp_lex.c:950

References line_to_parse.

◆ tpips_help()

void tpips_help ( string  line)

get the number of colunms for 80 chars

get the number of colunms for 80 chars

Parameters
lineine

Definition at line 688 of file tpips.c.

689 {
690  skip_blanks(line);
691 
692  printf("\n");
693  TP_HELP("readline", "* readline interaction facilities\n",
694  "\ttry <tab><tab> for automatic completion\n"
695  "\temacs-tyle editing capabilities (see man readline)\n");
696  TP_HELP("create", "create <workspace-name> <file-name>...\n",
697  "\tcreate a new worspace from a list of fortran files\n"
698  "\tfirst delete the workspace if it exists\n");
699  TP_HELP("open", "open <workspace-name>\n",
700  "\topen an existing workspace\n");
701  TP_HELP("checkactive", "checkactive <resourcename>\n",
702  "\ttell which phase would produce this resource.\n");
703  TP_HELP("checkpoint", "checkpoint\n",
704  "\tcheckpoint the current workspace\n");
705  TP_HELP("close", "close\n",
706  "\tclose the current opened workspace\n");
707  TP_HELP("delete", "delete <workspace-name>\n",
708  "\tdelete an existing workspace\n");
709  TP_HELP("module", "module <module-name>\n",
710  "\tselect a module from an opened workspace\n");
711  TP_HELP("activate", "activate <rule-name>\n",
712  "\ttell a rule to be active\n");
713  TP_HELP("make", "make <resourcename([OWNER])>\n",
714  "\tbuild a resource\n"
715  "\n\tExamples:\n\n"
716  "\t\t make PRINTED_FILE\n"
717  "\t\t make CALLGRAPH_FILE[my_module]\n"
718  "\t\t make DG_FILE[%%ALL]\n"
719  "\t\t make ICFG_FILE[%%CALLEES]\n\n");
720  TP_HELP("apply", "apply <rulename[(OWNER)]>\n",
721  "\tmake the produced resources of a rule\n"
722  "\n\tExamples:\n\n"
723  "\t\t apply PRINT_SOURCE_WITH_REGIONS\n"
724  "\t\t apply HPFC_CLOSE[my_module]\n"
725  "\t\t apply PRINT_CODE[%%ALL]\n"
726  "\t\t apply PRINT_ICFG[%%CALLEES]\n");
727  TP_HELP("capply", "capply <rulename[(OWNER)]>\n",
728  "\tconcurrently apply a transformation rule\n"
729  "\n\tExamples:\n\n"
730  "\t\t apply SUPPRESS_DEAD_CODE[%%ALL]\n"
731  "\t\t apply PARTIAL_EVAL[%%CALLEES]\n");
732  TP_HELP("display", "display <fileresourcename([OWNER])>\n",
733  "\tprint a file resource\n"
734  "\n\tExamples:\n\n"
735  "\t\t display PRINTED_FILE\n"
736  "\t\t display CALLGRAPH_FILE[my_module]\n"
737  "\t\t display DG_FILE[%%ALL]\n"
738  "\t\t display ICFG_FILE[%%CALLEES]\n\n");
739  TP_HELP("remove", "remove <resourcename([OWNER])>\n",
740  "\tremove a resource from the database.\n");
741  TP_HELP("cd", "cd <dirname>\n",
742  "\tchange directory\n");
743  TP_HELP("pwd", "pwd\n", "\tprint current working directory\n");
744  TP_HELP("setenv", "setenv <name>=<value>\n",
745  "\tchange environment\n");
746  TP_HELP("unsetenv", "unsetenv <name>\n",
747  "\tremove variable from environment\n");
748  TP_HELP("getenv", "getenv <name>\n",
749  "\tprint from environment (echo ${<name>} also ok)\n");
750  TP_HELP("setproperty", "setproperty <name>=<value>\n",
751  "\tchange property\n");
752  TP_HELP(GET_PROP, GET_PROP " <name>\n",
753  "\t print property\n");
754  TP_HELP("echo", "echo <string>\n",
755  "\tprint the string\n");
756  TP_HELP("quit", "quit\n",
757  "\texit tpips (you should close the workspace before\n");
758  TP_HELP("exit", "exit\n",
759  "\texit tpips quickly (rhough!)\n");
760  TP_HELP("source", "source <filenames...>\n",
761  "\tread tpips commands from files.\n");
762  TP_HELP("help", "help (<help-item>)\n",
763  "\tprint a list of all the commands or a \"detailled\""
764  " description of one\n");
765  TP_HELP("show", "show <resourcename([OWNER])>\n",
766  "\treturns the file of this resource\n");
767  TP_HELP("timeout", "timeout <delay>\n",
768  "\tset pips timeout in seconds\n");
769  TP_HELP("info", "info <name>\n",
770  "\tprint information about <name>\n"
771  "\tname: module, modules, workspace, directory\n");
772  TP_HELP("shell", "shell [<shell-function>]\n",
773  "\tallow shell functions call\n");
774  TP_HELP("version", "version\n",
775  "\tshow tpips version informations, such as:\n"
776  "\t\trepository revisions used by the compilation\n"
777  "\t\tdate of compilation\n"
778  "\t\tcompiler used\n");
779  TP_HELP("owner", "- owner : variable*\n",
780  "\tList of available owners:\n"
781  "\t\t%%MODULE\n"
782  "\t\t%%ALL\n"
783  "\t\t%%ALLFUNC\n"
784  "\t\t%%PROGRAM\n"
785  "\t\t%%CALLEES\n"
786  "\t\t%%CALLERS\n"
787  "\t\t<module_name>\n");
788  TP_HELP("*", "* default rule...\n",
789  "\tan implicit \"shell\" is assumed.\n");
790 
791  if (!*line || prefix_equal_p(line,"rulename") ||
792  prefix_equal_p(line,"rule")) {
793  printf("* rulename : variable*\n");
794  if (*line) {
795  char ** ps = tp_phase_names;
796  int big_size = 0;
797  int current_size;
798  int columns, count;
799 
800  while (*ps) {
801  current_size = strlen (*ps);
802  if (big_size < current_size)
803  big_size = current_size;
804  ps++;
805  }
806  big_size++;
807  /* get the number of colunms for 80 chars */
808  columns = tgetnum ("co");
809  pips_debug (1, "number of columns is %d\n", columns);
810  columns = (columns > 0) ? columns /big_size : 1;
811  count = 1;
812  printf("\tList of available rules\n");
813  ps = tp_phase_names;
814  while (*ps)
815  {
816  printf("%-*s",big_size,*ps);
817  if ((count % columns) == 0)
818  printf("\n");
819  ps++;
820  count++;
821  }
822  }
823  }
824  if (!*line || prefix_equal_p(line,"resourcename") ||
825  prefix_equal_p(line,"resource")) {
826  printf("* resourcename : variable*\n");
827  if (*line) {
828  char ** ps = tp_resource_names;
829  int big_size = 0;
830  int current_size;
831  int columns, count;
832 
833  while (*ps)
834  {
835  current_size = strlen (*ps);
836  if (big_size < current_size)
837  big_size = current_size;
838  ps++;
839  }
840  /* get the number of colunms for 80 chars */
841  columns = tgetnum ("co");
842  big_size++;
843  pips_debug (1, "number of columns is %d\n", columns);
844  columns = (columns > 0) ? columns /big_size : 1;
845  count = 1;
846  printf("\tList of available resources\n");
847  ps = tp_resource_names;
848  while (*ps)
849  {
850  printf("%-*s",big_size,*ps);
851  if ((count % columns) == 0)
852  printf("\n");
853  ps++;
854  count++;
855  }
856  }
857  }
858  printf("\n");
859  fflush(stdout);
860 }
static int count
Definition: SDG.c:519
static char * tp_phase_names[]
static char * tp_resource_names[]
static int current_size
returns the number of bytes allocated for a given structure may need additional fonctions for externa...
Definition: genClib.c:2561
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
int printf()
static int line
FLEX_SCANNER.
Definition: scanner.c:852
#define GET_PROP
Definition: tpips-local.h:64
#define skip_blanks(str)
Definition: tpips-local.h:71
int tgetnum()
static bool prefix_equal_p(string str, string prf)
Definition: tpips.c:125
#define TP_HELP(prefix, simple, full)
Handlers.
Definition: tpips.c:684

References count, current_size, GET_PROP, line, pips_debug, prefix_equal_p(), printf(), skip_blanks, tgetnum(), TP_HELP, tp_phase_names, and tp_resource_names.

+ Here is the call graph for this function:

◆ tpips_init()

void tpips_init ( void  )

set_exception_callbacks(push_pips_context, pop_pips_context);

initialize_signal_catcher();

???

Definition at line 970 of file tpips.c.

971 {
972  if (tpips_init_done) return;
973 
974  in_from_jpips = stdin;
975  out_to_jpips = stdout;
976 
977  pips_checks();
978 
981  /* set_exception_callbacks(push_pips_context, pop_pips_context); */
982  /* initialize_signal_catcher(); */
983 
984  set_bool_property("ABORT_ON_USER_ERROR", false); /* ??? */
985  consistency_enforced_p = get_bool_property("CONSISTENCY_ENFORCED_P");
986 
990 
991  tpips_init_done = true;
992 }
void(* pips_internal_error_handler)(const char *, const char *,...)
PIPS_ERROR is a function that should be called to terminate PIPS execution when data structures are c...
Definition: message.c:511
string(* pips_request_handler)(const char *, va_list *)
default assignment of pips_request_handler is default_user_request.
Definition: message.c:139
void(* pips_error_handler)(const char *, const char *, va_list *)
PROMPT_USER schould be implemented.
Definition: message.c:455
void pips_checks(void)
add checkings here (FI: why in help.c?) SG : PIPS_ROOT should not be required :)
Definition: help.c:100
void initialize_newgen()
cproto-generated files
Definition: newgen.c:48
void set_bool_property(const char *, bool)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
void initialize_sc(char *(*var_to_string)(Variable))
Definition: sc_debug.c:253
static FILE * in_from_jpips
Ronan suggested a signal driven handling of jpips requests, so as to let the prompt available for dir...
Definition: tpips.c:179
bool tpips_init_done
variable globale, utilisee par le parser helas
Definition: tpips.c:964
static void tpips_user_error(const char *calling_function_name, const char *format, va_list *args)
handle a user error DO NOT TERMINATE here, see pips_log_end
Definition: tpips.c:611
bool consistency_enforced_p
Pipsmake does not enforce consistency when properties are changed.
Definition: tpips.c:968
static string tpips_user_request(const char *fmt, va_list *args)
Definition: tpips.c:571
void tpips_internal_error(_UNUSED_ const char *calling_function_name, _UNUSED_ const char *a_message_format,...)
In case of a tpips internal error, either core dump or try to save the workspace.
Definition: tpips.c:643
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References consistency_enforced_p, entity_local_name(), get_bool_property(), in_from_jpips, initialize_newgen(), initialize_sc(), out_to_jpips, pips_checks(), pips_error_handler, pips_internal_error_handler, pips_request_handler, set_bool_property(), tpips_init_done, tpips_internal_error(), tpips_user_error(), and tpips_user_request().

Referenced by tp_substitutions(), and tpips_exec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tpips_internal_error()

void tpips_internal_error ( const char *  ,
const char *  ,
  ... 
)

◆ tpips_lex_print_pos()

void tpips_lex_print_pos ( FILE *  fout)
Parameters
foutout

Definition at line 968 of file tp_lex.c.

969 {
970  int shift = (int)((long) line_to_parse - (long)line_parsed) - back;
971  fprintf(fout,
972  "%s\n"
973  "%*s^\n"
974  "at line %d in \"%s\"\n", line_parsed, shift, "",
976 }
void const char const char const int
static int back
Definition: tp_lex.c:966
static char * line_parsed
Definition: tp_lex.c:951
int tpips_current_line(void)
Definition: tpips.c:91
string tpips_current_name(void)
Definition: tpips.c:96

References back, fprintf(), int, line_parsed, line_to_parse, tpips_current_line(), and tpips_current_name().

+ Here is the call graph for this function:

◆ tpips_main()

int tpips_main ( int  argc,
char *  argv[] 
)

MAIN: interactive loop and history management.

I need this one right now, as tpips init may be called too late.

Parameters
argcrgc
argvrgv

Definition at line 1298 of file tpips.c.

1299 {
1300  // what about initialize_sc?
1302  debug_on("TPIPS_DEBUG_LEVEL");
1304  /* I need this one right now, as tpips init may be called too late. */
1307 
1308  {
1309  char *pid = NULL;
1310  asprintf(&pid, "PID=%d", (int) getpid());
1311  putenv(pid);
1312  }
1313 
1314  parse_arguments(argc, argv);
1315  fprintf(stdout, "\n"); // for Ctrl-D terminations
1316  tpips_close();
1317  pips_stop(info_log, 0, "tpips end of main");
1318  return 0; // not reached
1319 }
void set_pips_meta_informations(const char *revs, const char *date, const char *comp)
Definition: message.c:102
void set_exception_callbacks(exception_callback_t, exception_callback_t)
void push_pips_context(char const *file, char const *function, int line)
exception.c
Definition: exception.c:43
void pop_pips_context(char const *file, char const *function, int line)
Definition: exception.c:50
char *(* variable_debug_name)(Variable)
Debug support: pointer to the function used by debug print outs.
Definition: variable.c:114
#define debug_on(env)
Definition: misc-local.h:157
#define asprintf
Definition: misc-local.h:225
@ info_log
Definition: misc-local.h:33
#define pips_stop
Definition: misc-local.h:151
void initialize_signal_catcher(void)
Definition: signal.c:126
void tpips_close(void)
Definition: tpips.c:868
const char * soft_date
Definition: tpips.c:1124
static void parse_arguments(int argc, char *argv[])
Definition: tpips.c:1126
const char * cc_version
Definition: tpips.c:1124
const char * soft_revisions
could be shared somewhere?
Definition: revisions.c:33

References asprintf, cc_version, debug_on, entity_local_name(), fprintf(), info_log, initialize_signal_catcher(), parse_arguments(), pips_stop, pop_pips_context(), push_pips_context(), set_exception_callbacks(), set_pips_meta_informations(), soft_date, soft_revisions, tpips_close(), and variable_debug_name.

+ Here is the call graph for this function:

◆ tpips_next_line()

void tpips_next_line ( void  )

Definition at line 86 of file tpips.c.

87 {
88  current_line++;
89 }

References current_line.

Referenced by get_next_line().

+ Here is the caller graph for this function:

◆ tpips_process_a_file()

void tpips_process_a_file ( FILE *  file,
string  name,
bool  use_rl 
)

processing command line per line.

might be called recursively thru source.

push globals

interactive loop

Parameters
fileile
nameame
use_rlse_rl

Definition at line 1062 of file tpips.c.

1063 {
1064  static bool readline_initialized = false;
1065  char * line;
1066 
1067  // PUSH
1068  FILE * saved_file = current_file;
1069  string saved_name = current_name;
1070  int saved_line = current_line;
1071  bool saved_use_rl = use_readline;
1072 
1073  /* push globals */
1074  current_file = file;
1075  current_name = name;
1076  current_line = 0;
1077  use_readline = use_rl;
1078 
1079  if (use_readline && !readline_initialized)
1080  {
1083  readline_initialized = true;
1084  }
1085 
1086  /* interactive loop
1087  */
1089  {
1090  tpips_exec(line);
1091  free(line);
1092  if (jpips_is_running && file==stdin) jpips_done();
1093  }
1094 
1095  // POP
1096  current_file = saved_file;
1097  current_name = saved_name;
1098  current_line = saved_line;
1099  use_readline = saved_use_rl;
1100 }
#define TPIPS_PRIMARY_PROMPT
Definition: tpips-local.h:46
static void initialize_readline(void)
Tell the GNU Readline library how to complete.
Definition: tpips.c:501
static void tpips_exec(char *line)
Definition: tpips.c:1000
bool jpips_is_running
Definition: tpips.c:166
static FILE * current_file
current file being processed, with its name and the line number
Definition: tpips.c:72
static char * tpips_read_a_line(char *main_prompt)
returns an allocated line read, including continuations.
Definition: tpips.c:538
void jpips_done(void)
Definition: tpips.c:216
static void initialize_tpips_history(void)
Definition: tpips.c:672

References current_file, current_line, current_name, free(), initialize_readline(), initialize_tpips_history(), jpips_done(), jpips_is_running, line, tpips_exec(), TPIPS_PRIMARY_PROMPT, tpips_read_a_line(), and use_readline.

Referenced by parse_arguments(), and process_file_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tpips_set_line_to_parse()

void tpips_set_line_to_parse ( char *  line)

in lex file

store line pointer

Parameters
lineine

Definition at line 953 of file tp_lex.c.

954 {
955  skip_blanks(line);
956  /* store line pointer */
958  cr_not_returned = true;
959 }
static bool cr_not_returned
Definition: tp_lex.c:949

References cr_not_returned, line, line_parsed, line_to_parse, and skip_blanks.

◆ tpips_wrapper()

void tpips_wrapper ( void  )

wrapper.c

wrapper.c

the child is a new tpips, it keeps on executing... the parent just acts as a wrapper, it never returns from here.

CHILD is tpips and returns.

code for the WRAPPER starts here. the PARENT.

special handlers.

forward to tpips. how to ensure that tpips is alive? SIGCHLD and SIGPIPE are caught.

handle signals.

stop tpips on EOF.

wrapper mission done.

Definition at line 270 of file wrapper.c.

271 {
272  char * line;
273 
275 
276  /* the child is a new tpips, it keeps on executing...
277  * the parent just acts as a wrapper, it never returns from here.
278  */
279  if (tpips_pid==0) return; /* CHILD is tpips and returns. */
280 
281  /* code for the WRAPPER starts here. the PARENT.
282  */
283 
284  /* special handlers.
285  */
287 
288  while ((line = tpw_read_line(stdin)))
289  {
290  /* forward to tpips.
291  * how to ensure that tpips is alive?
292  * SIGCHLD and SIGPIPE are caught.
293  */
295 
296  /* handle signals.
297  */
299  {
300  line += strlen(SIGNAL_TAG);
301 
302  if (starts_with(line, CHECKPOINT)) {
303  KILL(tpips_pid, SIGUSR1);
304  } else if (starts_with(line, INTERRUPT)) {
305  KILL(tpips_pid, SIGINT);
306  } else if (starts_with(line, ABORTIT)) {
307  KILL(tpips_pid, SIGABRT);
308  } else if (starts_with(line, KILLNOW)) {
309  KILL(tpips_pid, SIGUSR2);
310  } else {
312  }
313  }
314  }
315 
316  /* stop tpips on EOF.
317  */
318  tpw_log("exiting...");
319  fputs("exit\n", stdout);
320  fclose(stdout);
321  KILL(tpips_pid, SIGKILL);
322 
323  exit(0); /* wrapper mission done. */
324 }
#define exit(code)
Definition: misc-local.h:54
static char * tpw_read_line(FILE *in)
Definition: wrapper.c:238
static void tpw_fatal_error(char *message)
Definition: wrapper.c:97
#define starts_with(s1, s2)
Definition: wrapper.c:77
static void tpw_set_sig_handlers(void)
special handlers for tpips wrapper.
Definition: wrapper.c:166
#define KILL(pid, sig)
Definition: wrapper.c:118
#define ABORTIT
Definition: wrapper.c:73
static void tpw_log(__attribute__((__unused__)) char *message)
Enable log with -DLOG for debug.
Definition: wrapper.c:85
static pid_t tpw_fork_inout(void)
fork, with stdout-stdin link kept
Definition: wrapper.c:190
#define INTERRUPT
Definition: wrapper.c:71
static void tpw_send_string_to_tpips(char *line)
send line to tpips.
Definition: wrapper.c:254
#define KILLNOW
Definition: wrapper.c:72
#define CHECKPOINT
available tags
Definition: wrapper.c:70
#define SIGNAL_TAG
Definition: wrapper.c:66
static pid_t tpips_pid
global because needed in tpw_fatal_error.
Definition: wrapper.c:81

References ABORTIT, CHECKPOINT, exit, INTERRUPT, KILL, KILLNOW, line, SIGNAL_TAG, starts_with, tpips_pid, tpw_fatal_error(), tpw_fork_inout(), tpw_log(), tpw_read_line(), tpw_send_string_to_tpips(), and tpw_set_sig_handlers().

Referenced by parse_arguments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ consistency_enforced_p

bool consistency_enforced_p
extern

Pipsmake does not enforce consistency when properties are changed.

The consistency can be enforced by forbidding setproperty during a processing phase.

Definition at line 968 of file tpips.c.

Referenced by tpips_init().

◆ jpips_is_running

bool jpips_is_running
extern

◆ tp__flex_debug

int tp__flex_debug
extern

◆ tp_char

int tp_char
extern

revisions.c

tp_yacc.c

◆ tp_in

FILE* tp_in
extern

Definition at line 128 of file tpips.h.

◆ tp_leng

int tp_leng
extern

◆ tp_lineno

int tp_lineno
extern

◆ tp_nerrs

int tp_nerrs
extern

◆ tp_out

FILE* tp_out
extern

◆ tp_text

char* tp_text
extern

◆ tpips_execution_mode

bool tpips_execution_mode
extern

cproto-generated files

tpips.c

cproto-generated files

Definition at line 89 of file tpips.h.

Referenced by parse_arguments().

◆ tpips_init_done

bool tpips_init_done
extern

variable globale, utilisee par le parser helas

Definition at line 111 of file tpips.h.

Referenced by tpips_exec(), and tpips_init().

◆ tpips_is_interactive

bool tpips_is_interactive
extern

Definition at line 90 of file tpips.h.

Referenced by parse_arguments().

◆ tpips_unknown_string

string tpips_unknown_string
extern

Definition at line 948 of file tp_lex.c.