PIPS
misc.h File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <setjmp.h>
+ Include dependency graph for misc.h:

Go to the source code of this file.

Macros

#define TIMEOUT_CODE   (128+14)
 
#define STRINGIFY_SECOND_STAGE(symbol)   #symbol
 To generate a string from a macro: More...
 
#define STRINGIFY(symbol)   STRINGIFY_SECOND_STAGE(symbol)
 If not using this 2-stage macro evaluation, the generated string is not the value of the macro but the name of the macro... More...
 
#define abort()   pips_stop(internal_error_log, -1, "abort() called")
 
#define exit(code)   pips_stop(user_error_log, code, "exit(%d) called", code)
 
#define pips_unknown_function   "Unknown Function Name"
 
#define CURRENT_FUNCTION   pips_unknown_function
 
#define pips_debug   pips_debug_func2
 these macros use the GNU extensions that allow variadic macros, including with an empty list. More...
 
#define pips_user_warning   pips_user_warning_func2
 
#define pips_user_error   pips_user_error_func2
 
#define pips_user_irrecoverable_error   pips_user_irrecoverable_error_func2
 
#define pips_internal_error   pips_internal_error_func2
 
#define pips_log   pips_log_func2
 
#define pips_stop   pips_stop_func2
 
#define pips_where(out)    fprintf(out, "[%s] (%s:%d) ", CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define debug_on(env)    debug_on_function(env, CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define debug_off()    debug_off_function(CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define pips_assert(what, predicate)
 common macros, two flavors depending on NDEBUG More...
 
#define pips_user_assert(what, predicate)
 
#define ifdebug(l)   if (the_current_debug_level>=(l))
 
#define pips_exit(code, format, args...)    pips_user_warning(format, ##args), exit(code)
 
#define same_string_p(s1, s2)   function_same_string_p(s1,s2)
 FI:need to breakpoint while inlining is available. More...
 
#define same_stringn_p(a, b, c)   (!strncmp((a),(b),(c)))
 
#define MAXPATHLEN   1024
 MAXPATHLEN is defined in <sys/param.h> for SunOS... More...
 
#define PIPS_CATCH(what)
 
#define SIGN_EQ(a, b)   ((((a)>0 && (b)>0) || ((a)<0 && (b)<0)) ? true : false)
 SG moved there from transformation.h. More...
 
#define FORTRAN_DIV(n, d)   (SIGN_EQ((n),(d)) ? ABS(n)/ABS(d) : -(ABS(n)/ABS(d)))
 
#define C_DIVISION(n, d)   ((n)/(d))
 
#define FORTRAN_MOD(n, m)   (SIGN_EQ((n),(m)) ? ABS(n)%ABS(m) : -(ABS(n)%ABS(m)))
 
#define C_MODULO(n, m)   ((n)%(m))
 
#define asprintf   safe_asprintf
 
#define vasprintf   safe_vasprintf
 
#define __has_attribute(att)   0
 
#define _UNUSED_   __attribute__((unused))
 
#define _NORETURN_   __attribute__((noreturn))
 
#define _FALLTHROUGH_
 
#define user_warning(fn, ...)    pips_user_warning_func(fn, __FILE__, __LINE__, __VA_ARGS__)
 
#define user_error(fn, ...)    pips_user_error_func(fn, __FILE__, __LINE__, __VA_ARGS__)
 

Typedefs

typedef void(* reset_func_t) (void)
 

Enumerations

enum  pips_log_t {
  none_log , info_log , warning_log , spear_warning_log ,
  spear_error_log , user_error_log , internal_error_log , irrecoverable_error_log ,
  none_log , info_log , warning_log , spear_warning_log ,
  spear_error_log , user_error_log , internal_error_log , irrecoverable_error_log
}
 Warning! Do not modify this file that is automatically generated! More...
 
enum  measurement_type {
  SBRK_MEASURE , NET_MEASURE , GROSS_MEASURE , SBRK_MEASURE ,
  NET_MEASURE , GROSS_MEASURE
}
 Measurement type for mem_spy.c. More...
 

Functions

void _NORETURN_ pips_stop_func (const char *, const char *, const int, pips_log_t, int, const string,...)
 expecititely declare "noreturn" functions... More...
 
void _NORETURN_ pips_internal_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_user_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_user_irrecoverable_error_alist (const char *, const char *, const int, const char *, va_list *)
 
void _NORETURN_ pips_user_irrecoverable_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_stop_func2 (pips_log_t, int, const string,...)
 
void _NORETURN_ pips_internal_error_func2 (const char *,...)
 
void _NORETURN_ pips_user_error_func2 (const char *,...)
 
void _NORETURN_ pips_user_irrecoverable_error_func2 (const char *,...)
 
void set_debug_level (const int)
 SET_DEBUG_LEVEL is a function that sets the current debuging level to the value passed as argument. More...
 
int get_debug_level (void)
 GET_DEBUG_LEVEL returns the current debugging level. More...
 
_int get_debug_stack_pointer (void)
 The pair get_ and set_debug_stack_pointer() should never be used except to clean up the stack after a long jump. More...
 
void set_debug_stack_pointer (const int)
 
void debug_on_function (const char *, const char *, const char *, const int)
 
void debug_off_function (const char *, const char *, const int)
 
void print_debug_stack (void)
 function used to debug (can be called from dbx) BB 6.12.91 More...
 
void debug (const int, const char *, const char *,...)
 ARARGS0. More...
 
void pips_debug_function (const int, const char *,...)
 pips_debug is a nice macro that depends on gcc to generate the function name and to handle a variable number of arguments. More...
 
double get_process_memory_size (void)
 
double get_process_gross_heap_size (void)
 
FILE * check_fopen (const char *, const char *)
 file.c More...
 
FILE * safe_fopen (const char *, const char *)
 
int safe_fclose (FILE *, const char *)
 
int safe_fflush (FILE *, char *)
 
FILE * safe_freopen (char *, char *, FILE *)
 
int safe_fseek (FILE *, long int, int, char *)
 
long int safe_ftell (FILE *, char *)
 
void safe_rewind (FILE *, char *)
 
int safe_fgetc (FILE *, char *)
 
int safe_getc (FILE *, char *)
 
char * safe_fgets (char *, int, FILE *, char *)
 
int safe_fputc (int, FILE *, char *)
 
int safe_putc (int, FILE *, char *)
 
int safe_fputs (char *, FILE *, char *)
 
int safe_fread (char *, int, int, FILE *, char *)
 
int safe_fwrite (char *, int, int, FILE *, char *)
 
int safe_list_files_in_directory (gen_array_t, string, string, bool(*)(const char *))
 returns a sorted arg list of files matching regular expression re in directory 'dir' and with file_name_predicate() returning true on the file name (for example use directory_exists_p to select directories, of file_exists_p to select regular files). More...
 
void list_files_in_directory (gen_array_t, string, string, bool(*)(const char *))
 The same as the previous safe_list_files_in_directory() but with no return code and a call to user error if it cannot open the directory. More...
 
bool directory_exists_p (const char *)
 
bool file_exists_p (const char *)
 
char * strescape (const char *)
 protect a string, for example for use in a system call list of non escaped characters in the macro above. More...
 
string nth_path (const char *, int)
 Returns the allocated nth path from colon-separated path string. More...
 
char * find_file_in_directories (const char *, const char *)
 returns an allocated string pointing to the file, possibly with an additional path taken from colon-separated dir_path. More...
 
bool file_readable_p (char *)
 
bool create_directory (char *)
 
bool purge_directory (char *)
 
char * get_cwd (void)
 returns the current working directory name. More...
 
char * safe_readline (FILE *)
 returns the allocated line read, whatever its length. More...
 
string safe_read_nth_line (string, int)
 Assumes "fn" is the name of a text file, opens it, and returns its nth line (starting with 1) in a newly allocated buffer, whatever the line length. More...
 
string safe_get_line_interval (const string, int, int)
 return lines f-l from file fn as a string More...
 
void safe_copy_line_interval (string, int, int, FILE *)
 Assumes "fn" is the name of a text file, opens it, and copies the lines whose number belongs to [f..l] into file descriptor "out", except if they have been generated by a C preprocessor. More...
 
char * safe_readfile (FILE *)
 returns the file as an allocated string. More...
 
void safe_cat (FILE *, FILE *)
 
void safe_append (FILE *, char *, int, bool)
 
void safe_copy (char *, char *)
 
int safe_display (char *)
 Display a file through $PIPS_MORE (or $PAGER) if stdout is a TTY, on stdout otherwise. More...
 
char * pips_filename (char *, char *, bool)
 Some OS do not define basename and dirname. More...
 
char * pips_basename (char *, char *)
 
char * pips_initial_filename (char *, char *)
 The source file name access path is shortened or not depending on the property. More...
 
char * pips_dirname (char *)
 
void safe_unlink (const char *)
 Delete the given file. More...
 
void safe_symlink (const char *, const char *)
 
void safe_link (const char *, const char *)
 Create a hard link to topath. More...
 
char * safe_system_output (char *)
 attempt shell substitutions to what. More...
 
char * safe_system_substitute (char *)
 returns what after variable, command and file substitutions. More...
 
char * safe_new_tmp_file (char *)
 SunOS forgets to declare this one. More...
 
FILE * fopen_config (const char *, const char *, const char *)
 
void set_pips_current_computation (const char *, const char *)
 message.c More...
 
string get_pips_current_pass_name (void)
 Export this piece of information to customize warning functions in passes. More...
 
string get_pips_current_module (void)
 
void reset_pips_current_computation (void)
 
void set_pips_meta_informations (const char *, const char *, const char *)
 
string default_user_request (const char *, va_list *)
 USER_REQUEST is a function that should be called to request some data from the user. More...
 
string user_request (const char *,...)
 
void close_log_file (void)
 
void open_log_file (const string)
 
void log_on_file (const char *)
 
void pips_user_log_func (const char *,...)
 
void user_log (const char *,...)
 
void pips_thanks (string, string)
 display pips thanks on startup, if it on a tty. More...
 
void open_warning_file (const char *)
 
void close_warning_file (void)
 
void append_to_warning_file (const char *, const char *, va_list *)
 To be used in error handling functions. More...
 
void pips_user_warning_alist (const char *, const char *, const int, const char *, va_list *)
 
void pips_user_warning_func (const char *, const char *, const int, const char *,...)
 
void pips_user_warning_func2 (const char *,...)
 fallback version without a calling function name More...
 
bool function_same_string_p (const char *, const char *)
 
void open_xml_logfile (const char *)
 
void close_xml_logfile (void)
 
string pips_log_tag_name (pips_log_t tag)
 
void pips_log_desc (const pips_log_t tag, const string, const string, const string, const string, const int, const string, const string, const int, const int, const string, const string, const string)
 log entry with preprocessed format/arguments More...
 
void pips_log_alist (const pips_log_t tag, const string, const string, const string, const string, const int, const string, const string, const int, const int, const string, const string, const string, va_list *)
 log entry with unprocessed format/alist arguments More...
 
void pips_log_func (const string, const string, const int, const pips_log_t tag, const string, const string, const string, const string, const int, const int, const string, const string, const string,...)
 direct pips_log call with format and free arguments ("...") More...
 
void pips_log_stop (const char *, const char *, const int, const pips_log_t tag, const int, const string,...)
 quick log and stop, called on timeout this must not invoke malloc as it may still held locks if interrupted this implementation is missing XML escapes... More...
 
int safe_vasprintf (char **, const char *, va_list)
 
int safe_asprintf (char **, const char *,...)
 
void start_dotting (FILE *, const char, const char *,...)
 dotting.c More...
 
void stop_dotting (void)
 
void list_to_array (list, gen_array_t)
 args.c More...
 
void update_list_from_array (list, gen_array_t)
 Just modify the strings in a list from an array of strings. More...
 
void sort_list_of_strings (list)
 Sort a list of strings. More...
 
string list_to_string (list)
 Return the malloc()ed version of the concatenation of all the strings in the list. More...
 
void safe_system (string)
 system.c More...
 
int safe_system_no_abort (string)
 the command to be executed More...
 
int safe_system_no_abort_no_warning (string)
 the command to be executed More...
 
void push_pips_context (char const *, char const *, int)
 exception.c More...
 
void pop_pips_context (char const *, char const *, int)
 
void push_performance_spy (void)
 perf_spy.c More...
 
void pop_performance_spy (FILE *, string)
 
void pips_malloc_debug (void)
 malloc_debug.c More...
 
void reset_hooks_register (reset_func_t)
 reset_hooks.c More...
 
void reset_hooks_call (void)
 this function is expected to be called when catching an exception. More...
 
void reset_hooks_is_empty (void)
 check that the stack was cleaned. More...
 
void reset_hooks_unregister (reset_func_t)
 remove registered cleanup hook. More...
 

Variables

int the_current_debug_level
 cproto-generated files More...
 
string(* pips_request_handler )(const char *, va_list *)
 default assignment of pips_request_handler is default_user_request. More...
 
void(* pips_log_handler )(const char *fmt, va_list *args)
 USER_LOG is a function that should be called to log the current PIPS request, as soon as it is relevant. More...
 
void(* pips_warning_handler )(const char *, const char *, va_list *)
 default assignment of pips_warning_handler is default_user_warning. More...
 
void(* pips_error_handler )(const char *, const char *, va_list *)
 PROMPT_USER schould be implemented. More...
 
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 corrupted. More...
 

Macro Definition Documentation

◆ __has_attribute

#define __has_attribute (   att)    0

Definition at line 237 of file misc.h.

◆ _FALLTHROUGH_

#define _FALLTHROUGH_

Definition at line 246 of file misc.h.

◆ _NORETURN_

#define _NORETURN_   __attribute__((noreturn))

Definition at line 241 of file misc.h.

◆ _UNUSED_

#define _UNUSED_   __attribute__((unused))

Definition at line 240 of file misc.h.

◆ abort

#define abort ( )    pips_stop(internal_error_log, -1, "abort() called")

Definition at line 61 of file misc.h.

◆ asprintf

#define asprintf   safe_asprintf

Definition at line 233 of file misc.h.

◆ C_DIVISION

#define C_DIVISION (   n,
 
)    ((n)/(d))

Definition at line 222 of file misc.h.

◆ C_MODULO

#define C_MODULO (   n,
 
)    ((n)%(m))

Definition at line 224 of file misc.h.

◆ CURRENT_FUNCTION

#define CURRENT_FUNCTION   pips_unknown_function

Definition at line 79 of file misc.h.

◆ debug_off

#define debug_off ( )     debug_off_function(CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 168 of file misc.h.

◆ debug_on

#define debug_on (   env)     debug_on_function(env, CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 165 of file misc.h.

◆ exit

#define exit (   code)    pips_stop(user_error_log, code, "exit(%d) called", code)

Definition at line 62 of file misc.h.

◆ FORTRAN_DIV

#define FORTRAN_DIV (   n,
 
)    (SIGN_EQ((n),(d)) ? ABS(n)/ABS(d) : -(ABS(n)/ABS(d)))

Definition at line 221 of file misc.h.

◆ FORTRAN_MOD

#define FORTRAN_MOD (   n,
 
)    (SIGN_EQ((n),(m)) ? ABS(n)%ABS(m) : -(ABS(n)%ABS(m)))

Definition at line 223 of file misc.h.

◆ ifdebug

#define ifdebug (   l)    if (the_current_debug_level>=(l))

Definition at line 197 of file misc.h.

◆ MAXPATHLEN

#define MAXPATHLEN   1024

MAXPATHLEN is defined in <sys/param.h> for SunOS...

but not for all OS!

Definition at line 211 of file misc.h.

◆ pips_assert

#define pips_assert (   what,
  predicate 
)
Value:
do { \
if (!(predicate)) { \
pips_internal_error("assertion failed\n\n '%s' not verified\n\n", \
what); \
abort(); \
} \
} while(0)

common macros, two flavors depending on NDEBUG

Definition at line 180 of file misc.h.

◆ PIPS_CATCH

#define PIPS_CATCH (   what)
Value:
if (push_debug_status(), \
setjmp(*push_exception_on_stack(what, __CURRENT_FUNCTION_NAME__, \
__FILE__, __LINE__, pop_debug_status)))
jmp_buf * push_exception_on_stack(const int, const char *, const char *, const int)

Definition at line 214 of file misc.h.

◆ pips_debug

#define pips_debug   pips_debug_func2

these macros use the GNU extensions that allow variadic macros, including with an empty list.

if not available, function calls are used.

a slightly better job could be done if C99 is assumed.

Definition at line 153 of file misc.h.

◆ pips_exit

#define pips_exit (   code,
  format,
  args... 
)     pips_user_warning(format, ##args), exit(code)

Definition at line 201 of file misc.h.

◆ pips_internal_error

#define pips_internal_error   pips_internal_error_func2

Definition at line 157 of file misc.h.

◆ pips_log

#define pips_log   pips_log_func2

Definition at line 158 of file misc.h.

◆ pips_stop

#define pips_stop   pips_stop_func2

Definition at line 159 of file misc.h.

◆ pips_unknown_function

#define pips_unknown_function   "Unknown Function Name"

Definition at line 71 of file misc.h.

◆ pips_user_assert

#define pips_user_assert (   what,
  predicate 
)
Value:
do { \
if (!(predicate)) { \
pips_user_error("assertion failed\n\n '%s' not verified\n\n" \
"this is a USER ERROR, I guess\n", what); \
} \
} while(0)

Definition at line 189 of file misc.h.

◆ pips_user_error

#define pips_user_error   pips_user_error_func2

Definition at line 155 of file misc.h.

◆ pips_user_irrecoverable_error

#define pips_user_irrecoverable_error   pips_user_irrecoverable_error_func2

Definition at line 156 of file misc.h.

◆ pips_user_warning

#define pips_user_warning   pips_user_warning_func2

Definition at line 154 of file misc.h.

◆ pips_where

#define pips_where (   out)     fprintf(out, "[%s] (%s:%d) ", CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 162 of file misc.h.

◆ same_string_p

#define same_string_p (   s1,
  s2 
)    function_same_string_p(s1,s2)

FI:need to breakpoint while inlining is available.

#define same_string_p(s1, s2) (strcmp((s1), (s2)) == 0)

Definition at line 206 of file misc.h.

◆ same_stringn_p

#define same_stringn_p (   a,
  b,
 
)    (!strncmp((a),(b),(c)))

Definition at line 207 of file misc.h.

◆ SIGN_EQ

#define SIGN_EQ (   a,
 
)    ((((a)>0 && (b)>0) || ((a)<0 && (b)<0)) ? true : false)

SG moved there from transformation.h.

Definition at line 220 of file misc.h.

◆ STRINGIFY

#define STRINGIFY (   symbol)    STRINGIFY_SECOND_STAGE(symbol)

If not using this 2-stage macro evaluation, the generated string is not the value of the macro but the name of the macro...

Who said C was a simple language? :-/

Definition at line 58 of file misc.h.

◆ STRINGIFY_SECOND_STAGE

#define STRINGIFY_SECOND_STAGE (   symbol)    #symbol

To generate a string from a macro:

Definition at line 54 of file misc.h.

◆ TIMEOUT_CODE

#define TIMEOUT_CODE   (128+14)

Definition at line 51 of file misc.h.

◆ user_error

#define user_error (   fn,
  ... 
)     pips_user_error_func(fn, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 273 of file misc.h.

◆ user_warning

#define user_warning (   fn,
  ... 
)     pips_user_warning_func(fn, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 270 of file misc.h.

◆ vasprintf

#define vasprintf   safe_vasprintf

Definition at line 234 of file misc.h.

Typedef Documentation

◆ reset_func_t

typedef void(* reset_func_t) (void)

Definition at line 230 of file misc.h.

Enumeration Type Documentation

◆ measurement_type

Measurement type for mem_spy.c.

Enumerator
SBRK_MEASURE 
NET_MEASURE 
GROSS_MEASURE 
SBRK_MEASURE 
NET_MEASURE 
GROSS_MEASURE 

Definition at line 65 of file misc.h.

measurement_type
Measurement type for mem_spy.c.
Definition: misc.h:65
@ SBRK_MEASURE
Definition: misc.h:65
@ GROSS_MEASURE
Definition: misc.h:65
@ NET_MEASURE
Definition: misc.h:65

◆ pips_log_t

enum pips_log_t

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/misc/misc-local.h instead, to add your own modifications. header file built by cproto misc-local.h

Enumerator
none_log 
info_log 
warning_log 
spear_warning_log 
spear_error_log 
user_error_log 
internal_error_log 
irrecoverable_error_log 
none_log 
info_log 
warning_log 
spear_warning_log 
spear_error_log 
user_error_log 
internal_error_log 
irrecoverable_error_log 

Definition at line 39 of file misc.h.

39  {
40  none_log, // nought
41  info_log, // some information
42  warning_log, // just a warning
45  user_error_log, // phase is stopped because of user, exception
46  internal_error_log, // phase is stopped because of pips, exception
47  irrecoverable_error_log // phase is stopped because of pips + exit/abort
48 } pips_log_t;
pips_log_t
Warning! Do not modify this file that is automatically generated!
Definition: misc.h:39
@ warning_log
Definition: misc.h:42
@ internal_error_log
Definition: misc.h:46
@ user_error_log
Definition: misc.h:45
@ spear_warning_log
Definition: misc.h:43
@ spear_error_log
Definition: misc.h:44
@ none_log
Definition: misc.h:40
@ info_log
Definition: misc.h:41
@ irrecoverable_error_log
Definition: misc.h:47

Function Documentation

◆ append_to_warning_file()

void append_to_warning_file ( const char *  calling_function_name,
const char *  format,
va_list *  args 
)

To be used in error handling functions.

Parameters
calling_function_namealling_function_name
formatormat
argsrgs

Definition at line 306 of file message.c.

310 {
311  if (properties_initialized_p() && get_bool_property("NO_USER_WARNING"))
312  return;
313 
316  (const string) calling_function_name, NULL, -1,
317  NULL, NULL, -1, -1,
318  NULL, NULL, (const string) format, args);
319 }
void pips_log_alist(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string format, va_list *args)
log entry with unprocessed format/alist arguments
Definition: message.c:1200
bool properties_initialized_p(void)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
string get_pips_current_pass_name(void)
Export this piece of information to customize warning functions in passes.
Definition: message.c:77
string get_pips_current_module(void)
Definition: message.c:82
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
@ warning_log
Definition: misc-local.h:34

References get_bool_property(), get_pips_current_module(), get_pips_current_pass_name(), pips_log_alist(), properties_initialized_p(), and warning_log.

+ Here is the call graph for this function:

◆ check_fopen()

FILE* check_fopen ( const char *  file,
const char *  mode 
)

file.c

Returns
a file descriptor.
Parameters
fileile
modeode

Definition at line 56 of file file.c.

57 {
58  FILE * fd = fopen(file, mode);
59  if (fd==(FILE*)NULL)
60  {
61  pips_user_warning("fopen failed on file \"%s\" (mode \"%s\")\n%s\n",
62  file, mode, strerror(errno));
63  }
64  return fd;
65 }
#define pips_user_warning
Definition: misc-local.h:146

References pips_user_warning.

Referenced by load_meta_data().

+ Here is the caller graph for this function:

◆ close_log_file()

void close_log_file ( void  )

Definition at line 162 of file message.c.

163 {
164  if (log_file != NULL && get_bool_property("USER_LOG_P") )
165  if (fclose(log_file) != 0)
166  pips_internal_error("Could not close log file");
167  log_file = NULL;
168 }
static FILE * log_file
The log file is closed by default.
Definition: message.c:159
#define pips_internal_error
Definition: misc-local.h:149

References get_bool_property(), log_file, and pips_internal_error.

Referenced by check_delete_workspace(), close_workspace(), create_workspace(), gpips_main(), open_log_file(), and wpips_main().

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

◆ close_warning_file()

void close_warning_file ( void  )

Definition at line 293 of file message.c.

294 {
295  if (warning_file)
296  {
298 
299  warning_file = (FILE*) NULL;
301  warning_file_name = (string) NULL;
302  }
303 }
static FILE * warning_file
Definition: message.c:283
static string warning_file_name
Definition: message.c:284
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
void free(void *)
char * string
STRING.
Definition: newgen_types.h:39

References free(), safe_fclose(), warning_file, and warning_file_name.

Referenced by check_delete_workspace(), close_workspace(), and create_workspace().

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

◆ close_xml_logfile()

void close_xml_logfile ( void  )

Definition at line 631 of file message.c.

632 {
633  if (xml_logfile)
634  {
636  xml_logfile = NULL;
637  xml_logfile_name = NULL;
638  }
639 }
static string xml_logfile_name
Definition: message.c:568
static FILE * xml_logfile
Definition: message.c:567

References safe_fclose(), xml_logfile, and xml_logfile_name.

+ Here is the call graph for this function:

◆ create_directory()

bool create_directory ( char *  name)
Parameters
nameame

Definition at line 435 of file file.c.

436 {
437  bool success = true;
438 
439  if (directory_exists_p(name)) {
440  pips_internal_error("existing directory: %s", name);
441  }
442 
443  if (mkdir(name, 0777) == -1) {
444  pips_user_warning("cannot create directory: %s (%s)\n",
445  name, strerror(errno));
446  success = false;
447  }
448 
449  return success;
450 }
bool directory_exists_p(const char *name)
Definition: file.c:314
bool success
Definition: gpips-local.h:59

References directory_exists_p(), pips_internal_error, and pips_user_warning.

Referenced by db_create_workspace(), and db_get_directory_name_for_module().

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

◆ debug()

void debug ( const int  the_expected_debug_level,
const char *  calling_function_name,
const char *  a_message_format,
  ... 
)

ARARGS0.

margin_length is the length of the part of the margin that is not used

If the current debug level is not high enough, do nothing:

print name of function printing debug message

print out remainder of message

Parameters
the_expected_debug_levelhe_expected_debug_level
calling_function_namealling_function_name
a_message_format_message_format

Definition at line 189 of file debug.c.

193 {
194  va_list some_arguments;
195 #define MAX_MARGIN (8)
196  static char * margin = " ";
197  /* margin_length is the length of the part of the margin that is not used */
198  int margin_length;
199 
200  /* If the current debug level is not high enough, do nothing: */
201  if (the_expected_debug_level > the_current_debug_level)
202  return;
203 
204  /* print name of function printing debug message */
205  margin_length = MAX_MARGIN+1-the_expected_debug_level;
206  (void) fprintf(stderr, "%s[%s] ",
207  margin + (margin_length>0 ? margin_length : 0),
208  calling_function_name);
209 
210  va_start(some_arguments, a_message_format);
211 
212  /* print out remainder of message */
213  (void) vfprintf(stderr, a_message_format, some_arguments);
214 
215  va_end(some_arguments);
216 }
int the_current_debug_level
Debugging functions.
Definition: debug.c:53
#define MAX_MARGIN
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), MAX_MARGIN, and the_current_debug_level.

Referenced by abbrev_menu_event_filter_proc(), abbrev_menu_with_text_menu_notify(), add_common_variables_to_hash_table(), add_loop_skip_condition(), adg_build_Psysteme(), adg_compact_quast(), adg_dataflowgraph(), adg_dataflowgraph_with_extremities(), adg_decreasing_stat_order_sort(), adg_dup_disjunctive_nodes(), adg_enrichir(), adg_fill_with_quast(), adg_fprint_pred(), adg_fprint_predicate_list(), adg_get_conjonctions(), adg_get_disjunctions(), adg_get_exec_domain(), adg_get_integer_entity(), adg_get_predicate_of_loops(), adg_get_read_entity_vertices(), adg_get_write_entity_vertices(), adg_list_same_order_in_dg(), adg_list_to_vect(), adg_make_disjunctions(), adg_max_of_leaves(), adg_merge_entities_lists(), adg_number_of_same_loops(), adg_number_to_vertex(), adg_only_call_WR_dependence(), adg_path_max_source(), adg_path_possible_source(), adg_predicate_list_dup(), adg_pure_dfg(), adg_pure_dfg2(), adg_quast_leaf_label_equal_p(), adg_quast_leaf_solution_equal_p(), adg_rename_entities(), adg_reorder_statement_number(), adg_reverse_graph(), adg_same_dfg_vertex_number(), adg_same_order_in_dg(), adg_same_order_in_dvl(), adg_sc_dup(), adg_suppress_2nd_in_1st_ps(), adg_update_dfg(), adg_vertex_to_ordering(), adg_write_reference_list(), affect_comp_regions(), array_bound_check_bottom_up(), array_bound_check_interprocedural(), atomize_one_message(), atomizer_of_block(), atomizer_of_expression(), atomizer_of_loop(), atomizer_of_statement(), atomizer_of_test(), atomizer_of_unstructured(), attach_to_character_region(), attach_to_word_list(), basic_of_constant(), block_to_postcondition(), bound_distribution(), bound_generation(), build_and_test_dependence_context(), build_image_base(), build_sc_machine(), build_sc_with_several_uniform_ref(), build_trail(), c_statement(), call_instruction_to_communications(), check_first_statement(), check_range_wrt_precondition(), choose_one_syntax_in_references_list(), classify_reference(), close_workspace_notify(), comp_regions_of_implied_do(), comp_regions_of_ioelem(), comp_regions_of_iolist(), complex_bound_computation(), complex_bound_generation(), compute_iteration_domain(), conflict_dup(), constraint_distribution(), control_to_label_name(), create_tile_basis(), creer_nom_entite(), creer_nom_var(), current_module(), deal_with_attachment_boundary(), deal_with_attachments_at_this_character(), declaration_with_overlaps(), DeclareVariable(), decorate_trail(), defs_elim_of_assign_call(), defs_elim_of_statement(), defs_elim_of_unstructured(), dependance_vertices_p(), dfg_vertex_label_dup(), dg_arc_label_dup(), dg_vertex_dup(), dg_vertex_label_dup(), directory_gen_pullright(), display_memory_usage(), do_it(), edge_weight(), EffectsInfDifference(), EffectsSupDifference(), egalite_distribution(), end_query_pad_notify(), epips_execute_command(), EvalBinaryOp(), event_procedure(), expression_int_scalar(), fetch_callees_complexities(), find_iteration_domain(), flinter(), formal_and_actual_parameters_association(), formal_array_resizing_bottom_up(), full_unroll_pragma(), generate_one_message(), genref_statement(), get_more_derived_resources(), GetChar(), gpips_main_loop(), hpfc_overlap_kill_unused_scalars_rewrite(), hyperplane(), in_effect_list_p(), init_cost_table(), init_host_and_node_entities(), interactive_hyperplane_direction(), interactive_partitioning_matrix(), io_comp_regions(), IsCapKeyword(), iteration_domain_from_statement(), local_entity_of_module_p(), logical_expression_p(), loop_bounds_to_tile_bounds(), loop_increment_value(), loop_index_domaine_to_contrainte(), loop_iteration_domaine_to_sc(), loop_nest_to_local_variables(), loop_nest_to_wp65_code(), loop_strip_mine(), loop_to_postcondition(), lower_bound_generation(), main(), make(), make_all_movement_blocks(), make_datum_movement(), make_emulated_shared_variable(), make_lin_op_exp(), make_load_blocks(), make_movements_loop_body_wp65(), make_new_local_variables(), make_nlc_entity(), make_nsp_entity(), make_nub_entity(), make_op_exp(), make_scanning_over_one_tile(), make_scanning_over_tiles(), make_store_blocks(), make_tile_constraints(), MakeAtom(), MakeLabel(), MakeNewLabelledStatement(), MakeStatement(), message_manageable_p(), messages_handling(), module_name_to_preconditions(), module_to_wp65_modules(), movement_computation(), my_adg_expressions_to_predicate(), nlc_linear_expression_p(), no_write_comp_regions(), normal_expression_of_statement(), normal_expression_of_unstructured(), old_array_bound_check_instrumentation(), old_reductions(), old_summary_precondition(), Overlap_Analysis(), parametric_statement_feasible_p(), partial_eval_reference(), pip_solve(), pip_solve_min_with_big(), pips_malloc_debug(), prgm_mapping(), PrintData(), proper_comp_regions_of_intrinsic(), query_canvas_event_proc(), read_commands_from_emacs(), read_reference_list(), ReadLine(), reference_conflicting_p(), reference_conflicting_test_and_update(), reference_conversion_expression(), reference_conversion_statement(), region_dynamic_var_elim(), region_exact_projection_along_parameters(), region_exact_projection_along_variables(), region_non_exact_projection_along_parameters(), region_sc_projection_ofl_along_parameter(), RegionsEntitiesInfDifference(), RegionsInfDifference(), RegionsIntersection(), RegionsMayUnion(), RegionsMustUnion(), RegionsSupDifference(), remove_useless_continue_or_empty_code_in_unstructured(), restructure_if_then_else(), ReuseLabelledStatement(), rice_loop(), rice_update_dependence_graph(), sc_faisabilite_optim(), sc_image_computation(), sc_minmax_of_variable_optim(), sc_proj_on_di(), sc_to_tableau(), scalar_assign_call(), scalar_written_in_call(), schoose_abbrev_menu_with_text_text_notify(), set_control_to_label(), set_dimensions_of_local_variable_family(), set_dimensions_of_local_variables(), set_first_format_statement(), sort_unknowns(), st_arguments(), st_declarations(), st_declarations_comment(), st_declarations_init(), st_statement(), statement_does_return(), statement_to_communications(), statement_to_label(), stco_common_loops_of_statements(), strip_mine(), summary_total_postcondition(), test_bound_generation(), test_to_postcondition(), TestDependence(), text_unstructured(), tile_hyperplane_constraints(), tile_membership(), tile_membership_constraints(), transformer_general_consistency_p(), undefined_statement_list_p(), unframe_commands_from_emacs(), uniform_dependence_p(), unstructured_reorder(), unstructured_to_total_precondition(), unstructured_while_p(), update_basis(), update_common_layout(), update_common_sizes(), update_options(), update_summary_precondition(), update_used_labels(), upper_bound_generation(), wp65(), wp65_conform_p(), wp65_debug_print_text(), wpips_main_loop(), and xml_declarations_with_explicit_motif().

+ Here is the call graph for this function:

◆ debug_off_function()

void debug_off_function ( const char *  function,
const char *  file,
const int  line 
)
Parameters
functionunction
fileile
lineine

Definition at line 135 of file debug.c.

139 {
141 
142  pips_assert("debug stack not empty", idls > 0);
143 
144  idls--;
146 
147  if (!same_string_p(current->file, file) ||
148  !same_string_p(current->function, function))
149  {
150  pips_internal_error("\ndebug %s (level is %d)"
151  "[%s] (%s:%d) debug on and\n"
152  "[%s] (%s:%d) debug off don't match\n",
153  current->name, current->level,
154  current->function, current->file, current->line,
155  function, file, line);
156  }
157 
159 }
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static _int idls
Definition: debug.c:86
void set_debug_level(const int l)
SET_DEBUG_LEVEL is a function that sets the current debuging level to the value passed as argument.
Definition: debug.c:60
static debug_level debug_stack[STACK_LENGTH]
idls points to the first free bucket in debug_stack
Definition: debug.c:85
#define same_string_p(s1, s2)
#define level
static int line
FLEX_SCANNER.
Definition: scanner.c:852
static size_t current
Definition: string.c:115

References current, debug_stack, idls, level, line, pips_assert, pips_internal_error, same_string_p, and set_debug_level().

+ Here is the call graph for this function:

◆ debug_on_function()

void debug_on_function ( const char *  env,
const char *  function,
const char *  file,
const int  line 
)
Parameters
envnv
functionunction
fileile
lineine

Definition at line 112 of file debug.c.

117 {
118  pips_assert("stack not full", idls < STACK_LENGTH-1);
119 
120  char * level_env;
121  int dl = ((level_env = getenv(env)) != NULL) ? atoi(level_env) : 0;
122 
123  debug_stack[idls].name = (char*) env;
124  debug_stack[idls].function = (char*) function;
125  debug_stack[idls].file = (char*) file;
127  debug_stack[idls].level = dl;
128 
129  idls++;
130 
131  set_debug_level(dl);
132 }
static jmp_buf env
Definition: genClib.c:2473
#define STACK_LENGTH
Definition: debug.c:72
int level
Definition: debug.c:80
char * name
Definition: debug.c:76
char * function
Definition: debug.c:77
char * file
Definition: debug.c:78
int line
Definition: debug.c:79

References debug_stack, env, debug_level::file, debug_level::function, idls, debug_level::level, debug_level::line, line, debug_level::name, pips_assert, set_debug_level(), and STACK_LENGTH.

+ Here is the call graph for this function:

◆ default_user_request()

string default_user_request ( const char *  fmt,
va_list *  args 
)

USER_REQUEST is a function that should be called to request some data from the user.

It returns the string typed by the user until the return key is typed. USER_REQUEST should be called as:

USER_REQUEST(format [, arg] ... )

where format and arg-list are passed as arguments to vprintf.

Parameters
fmtmt
argsrgs

Definition at line 124 of file message.c.

125 {
126  va_list acpy;
127  va_copy(acpy, *args);
128  fprintf(stdout, "\nWaiting for your response: ");
129  vfprintf(stdout, fmt, acpy);
130  fflush(stdout);
131  va_end(acpy);
132  return safe_readline(stdin);
133 }
char * safe_readline(FILE *file)
returns the allocated line read, whatever its length.
Definition: file.c:497

References fprintf(), and safe_readline().

+ Here is the call graph for this function:

◆ directory_exists_p()

bool directory_exists_p ( const char *  name)
Parameters
nameame

Definition at line 314 of file file.c.

315 {
316  struct stat buf;
317  return (stat(name, &buf) == 0) && S_ISDIR(buf.st_mode);
318 }
static char buf[BSZ]
Definition: split_file.c:157

References buf.

Referenced by create_directory(), db_get_directory_name_for_module(), db_open_workspace(), generate_a_directory_menu(), pips_change_directory(), pips_get_workspace_list(), purge_directory(), and workspace_exists_p().

+ Here is the caller graph for this function:

◆ file_exists_p()

bool file_exists_p ( const char *  name)
Parameters
nameame

Definition at line 321 of file file.c.

322 {
323  struct stat buf;
324  return (stat(name, &buf) == 0) && S_ISREG(buf.st_mode);
325 }

References buf.

Referenced by add_new_compilation_unit(), add_new_module_from_text(), find_file_in_directories(), get_first_main_module(), hpfc_get_file_list(), load_meta_data(), parse_arguments(), pips_get_fortran_list(), safe_display(), and text_area_included().

+ Here is the caller graph for this function:

◆ file_readable_p()

bool file_readable_p ( char *  name)
Parameters
nameame

Definition at line 428 of file file.c.

429 {
430  struct stat buf;
431  return !stat(name, &buf) && (S_IRUSR & buf.st_mode);
432 }

References buf.

Referenced by freia_compile(), freia_opencl_compile_calls(), and workspace_ok_p().

+ Here is the caller graph for this function:

◆ find_file_in_directories()

char* find_file_in_directories ( const char *  file_name,
const char *  dir_path 
)

returns an allocated string pointing to the file, possibly with an additional path taken from colon-separated dir_path.

returns NULL if no file was found.

looks for the file with an additional path ahead.

Parameters
file_nameile_name
dir_pathir_path

Definition at line 399 of file file.c.

400 {
401  char *path;
402  int n=0;
403  pips_assert("some file name", file_name);
404 
407 
408  if (!dir_path || file_name[0]=='/')
409  return (string) NULL;
410 
411  /* looks for the file with an additional path ahead.
412  */
413  while ((path=nth_path(dir_path, n++)))
414  {
415  char *name = strdup(concatenate(path, "/", file_name, NULL)),
416  *res=NULL;
417  free(path);
418  if (file_exists_p(name))
419  res = relative_name_if_necessary(name);
420  free(name);
421  if (res) return res;
422  }
423 
424  return (string) NULL;
425 }
bool file_exists_p(const char *name)
Definition: file.c:321
string nth_path(const char *path_list, int n)
Returns the allocated nth path from colon-separated path string.
Definition: file.c:362
static char * relative_name_if_necessary(const char *name)
Definition: file.c:388
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
char * strdup()
static string file_name

References concatenate(), file_exists_p(), file_name, free(), nth_path(), pips_assert, relative_name_if_necessary(), and strdup().

Referenced by find_file(), parse_arguments(), and process_user_file().

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

◆ fopen_config()

FILE* fopen_config ( const char *  canonical_name,
const char *  cproperty,
const char *  cenv 
)
Parameters
canonical_nameanonical_name
cpropertyproperty
cenvenv

Definition at line 952 of file file.c.

955 {
956  FILE * fconf;
957 
958  // try various combinaison :
959  // pips property
960  if (cproperty) {
961  const string sproperty = get_string_property(cproperty);
962  if (sproperty && (fconf = fopen(sproperty, CONFIG_DEFAULT_RIGHT)))
963  return fconf;
964  }
965 
966  // then pips env var
967  if (cenv) {
968  string senv = getenv(cenv);
969  if (senv && (fconf = fopen(senv, CONFIG_DEFAULT_RIGHT)))
970  return fconf;
971  }
972 
973  // then default, with PIPS_ROOT if set
974  string pipsenv = getenv("PIPS_ROOT");
975  string sdefault;
976  if(pipsenv)
977  sdefault =
978  concatenate(pipsenv,"/" DEFAULT_CONFIG_DIR "/" , canonical_name, NULL);
979  else
980  sdefault = concatenate(CONFIG_DIR "/", canonical_name, NULL);
981 
982  return safe_fopen(sdefault, CONFIG_DEFAULT_RIGHT);
983 }
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
#define CONFIG_DEFAULT_RIGHT
Definition: file.c:950
char * get_string_property(const char *)
#define DEFAULT_CONFIG_DIR
utility to open configuration file, (read only!) its name can be found using various ways property an...
Definition: file.c:949

References concatenate(), CONFIG_DEFAULT_RIGHT, DEFAULT_CONFIG_DIR, get_string_property(), and safe_fopen().

Referenced by build_aliases(), get_help_topic(), get_help_topics(), get_model(), init_cost_table(), parse_makefile(), and simd_treematcher().

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

◆ function_same_string_p()

bool function_same_string_p ( const char *  s1,
const char *  s2 
)
Parameters
s11
s22

Definition at line 560 of file message.c.

561 {
562  return strcmp(s1, s2) == 0;
563 }
s1
Definition: set.c:247

References s1.

◆ get_cwd()

char* get_cwd ( void  )

returns the current working directory name.

argh

Definition at line 486 of file file.c.

487 {
488  static char cwd[PATH_MAX]; /* argh */
489  cwd[PATH_MAX-1] = '\0';
490  return getcwd(cwd, PATH_MAX);
491 }
#define PATH_MAX
Definition: file.c:479

References PATH_MAX.

Referenced by direct_change_directory(), generate_directory_menu(), make_open_workspace(), pips_change_directory(), send_view_to_emacs(), show_directory(), and wpips_display_graph_file_display().

+ Here is the caller graph for this function:

◆ get_debug_level()

int get_debug_level ( void  )

GET_DEBUG_LEVEL returns the current debugging level.

Definition at line 67 of file debug.c.

68 {
70 }

References the_current_debug_level.

Referenced by adg_dataflowgraph(), adg_dataflowgraph_with_extremities(), adg_fill_with_quast(), adg_get_disjunctions(), adg_get_exec_domain(), adg_get_integer_entity(), adg_get_predicate_of_loops(), adg_rename_entities(), adg_update_dfg(), analyze_quast(), array_dfg(), atomizer(), average_probability_matrix(), better_elim_var_with_eg(), bound_compute(), broadcast_conditions(), build_bdt_null(), build_contraction_matrices(), build_first_comb(), build_list_of_min(), build_new_ref(), build_second_comb(), build_third_comb(), build_third_subcomb(), calculate_delay(), change_base_in_sc(), cmf_layout_align(), compatible_pc_p(), constraint_to_bound(), controls_to_hash_table(), count_dataflows_on_ref(), count_implicit_equation(), craft_layout_align(), create_farkas_poly(), cutting_conditions(), dataflows_on_reference(), edge_weight(), find_implicit_equation(), full_loop_unroll(), get_bounds_expression(), get_number_of_ins(), get_unsatisfied_system(), include_trans_on_LC_in_ref(), init_use_preconditions(), is_not_trivial_p(), lhs_subs_in_ins(), list_of_exp_equals_1n_p(), loop_strip_mine(), loops_mapping_of_statement(), make_bounds(), make_causal_external(), make_causal_internal(), make_layout_statement(), make_primal(), make_reindex(), make_shared_statement(), mapping_on_broadcast(), matrix_to_system(), my_adg_expressions_to_predicate(), my_build_new_ref(), my_substitute_var_with_vec(), new_elim_var_with_eg(), node_successors_to_matrix(), nullify_factors(), old_reductions(), partial_broadcast_coefficients(), partial_eval_statement(), partial_eval_syntax(), partition_unknowns(), pip_solve(), pip_solve_min_with_big(), pips_malloc_debug(), plc_elim_var_with_eg(), plc_make_distance(), plc_make_vvs_with_vector(), predicate_to_expression(), prepare_array_bounds(), prepare_reindexing(), prgm_mapping(), print_array_dfg(), print_bdt(), print_parallelizedCMF_code(), print_parallelizedCRAFT_code(), print_plc(), prototype_dimension(), psystem_to_expression(), re_do_it(), reference_filter(), reindexing(), rm_non_x_var(), sa_do_it(), sc_to_tableau(), scheduling(), search_scc_bdt(), separate_variables(), separate_variables_2(), simplify_bdt(), simplify_dimension(), single_assign(), solve_system_by_succ_elim(), unstructured_to_complexity(), valuer(), and wpips_xview_error().

◆ get_debug_stack_pointer()

_int get_debug_stack_pointer ( void  )

The pair get_ and set_debug_stack_pointer() should never be used except to clean up the stack after a long jump.

Definition at line 92 of file debug.c.

93 {
94  return idls;
95 }

References idls.

Referenced by catch_user_error(), push_pips_context(), safe_do_something(), and tpips_exec().

+ Here is the caller graph for this function:

◆ get_pips_current_module()

◆ get_pips_current_pass_name()

string get_pips_current_pass_name ( void  )

Export this piece of information to customize warning functions in passes.

Passes are also called "phases" in PIPS jargon.

Definition at line 77 of file message.c.

78 {
79  return current_phase;
80 }
static string current_phase
CATCH/TRY/UNCATCH/THROW stuff is here.
Definition: message.c:62

References current_phase.

Referenced by append_to_warning_file(), c_parser_user_warning_alist(), csplit_parser_warning_alist(), pips_internal_error_alist(), pips_log_stop(), pips_stop_file(), pips_stop_xml(), pips_user_error_alist(), pips_user_irrecoverable_error_alist(), pips_user_warning_alist(), semantics_user_warning_alist(), and spear_log_alist().

+ Here is the caller graph for this function:

◆ get_process_gross_heap_size()

double get_process_gross_heap_size ( void  )

mallinfo is not portable

This is used part of the heap, but it may be bigger

struct mallinfo heap_info = mallinfo();

double memory_size = (heap_info.uordbytes)/(double)(1 << 20);

sbrk(0))/(double)(1 << 20)

Definition at line 254 of file debug.c.

255 {
256  /* mallinfo is not portable */
257  /* This is *used* part of the heap, but it may be bigger */
258  /* struct mallinfo heap_info = mallinfo(); */
259  /* double memory_size = (heap_info.uordbytes)/(double)(1 << 20); */
260  double memory_size = -1.0 /*(sbrk(0))/(double)(1 << 20)*/;
261  return memory_size;
262 }

Referenced by apply_a_rule(), logs_off(), and logs_on().

+ Here is the caller graph for this function:

◆ get_process_memory_size()

double get_process_memory_size ( void  )

This is about the always increasing swap space

etext is not portable. it is not even documented on SUN:-)

extern etext; double memory_size = (sbrk(0) - etext)/(double)(1 << 20);

Definition at line 244 of file debug.c.

245 {
246  /* This is about the always increasing swap space */
247  /* etext is not portable. it is not even documented on SUN:-) */
248  /* extern etext;
249  double memory_size = (sbrk(0) - etext)/(double)(1 << 20);
250  */
251  return 0.0;
252 }

◆ list_files_in_directory()

void list_files_in_directory ( gen_array_t  files,
string  dir,
string  re,
bool(*)(const char *)  file_name_predicate 
)

The same as the previous safe_list_files_in_directory() but with no return code and a call to user error if it cannot open the directory.

Parameters
filesiles
dirir
ree

Definition at line 299 of file file.c.

304 {
305  int return_code =
306  safe_list_files_in_directory(files, dir, re, file_name_predicate);
307 
308  if (return_code == -1)
309  pips_user_error("opendir() failed on directory \"%s\", %s.\n",
310  dir, strerror(errno));
311 }
int safe_list_files_in_directory(gen_array_t files, string dir, string re, bool(*file_name_predicate)(const char *))
returns a sorted arg list of files matching regular expression re in directory 'dir' and with file_na...
Definition: file.c:250
#define pips_user_error
Definition: misc-local.h:147

References pips_user_error, and safe_list_files_in_directory().

Referenced by pips_get_fortran_list(), and pips_get_workspace_list().

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

◆ list_to_array()

void list_to_array ( list  l,
gen_array_t  a 
)

args.c

Definition at line 38 of file args.c.

39 {
40  int index = 0;
41  MAP(STRING, s, gen_array_addto(a, index++, s), l);
42  gen_free_list(l);
43 }
void gen_array_addto(gen_array_t a, size_t i, void *what)
Definition: array.c:87
#define STRING(x)
Definition: genC.h:87
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226

References gen_array_addto(), gen_free_list(), MAP, and STRING.

Referenced by prettyprint_dependence_graph(), prettyprint_dependence_graph_view(), sort_list_of_strings(), and xml_Chain_Graph().

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

◆ list_to_string()

string list_to_string ( list  l)

Return the malloc()ed version of the concatenation of all the strings in the list.

Definition at line 74 of file args.c.

75 {
76  string result = NULL;
77  if (l == NIL) return strdup("");
78  MAP(STRING,s, {
79  if (result == NULL)
80  result = strdup((const char *)s);
81  else {
82  string new_result = strdup(concatenate(result,s,NULL));
83  free(result);
84  result = new_result;
85  }
86  }, l);
87  return result;
88 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47

References concatenate(), free(), MAP, NIL, strdup(), and STRING.

Referenced by basic_to_string(), c_words_entity(), c_words_simplified_entity(), FindOrCreateCurrentEntity(), flush_statement_comment(), generic_c_words_simplified_entity(), get_symbol_table(), module_loops(), UpdateEntity(), UpdateFunctionEntity(), UpdatePointerEntity(), words_points_to_reference(), and words_type().

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

◆ log_on_file()

void log_on_file ( const char *  desc)
Parameters
descesc

Definition at line 190 of file message.c.

191 {
192  pips_log_desc(info_log, NULL, NULL,
193  NULL, NULL, -1, NULL, NULL, -1, -1,
194  NULL, NULL, (const string) desc);
195 }
void pips_log_desc(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string description)
log entry with preprocessed format/arguments
Definition: message.c:1173
@ info_log
Definition: misc-local.h:33

References info_log, and pips_log_desc().

Referenced by gpips_user_error_message(), gpips_user_log(), gpips_user_warning_message(), wpips_user_error_message(), wpips_user_log(), and wpips_user_warning_message().

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

◆ nth_path()

string nth_path ( const char *  path_list,
int  n 
)

Returns the allocated nth path from colon-separated path string.

Parameters
path_listthe string that contains a colon-separated path
nthe n-th instance to extract
Returns
an allocated string with the n-th part name

If the path is empty or if n is out-of-bound, NULL is returned. The resulting string is *not*escaped, and can contain spaces

Find the n-th part:

Out-of-bound...

Compute the length up to the COLON or the end of string:

Parameters
path_listath_list

Definition at line 362 of file file.c.

363 {
364  int len;
365 
366  if (path_list == NULL)
367  return NULL;
368 
369  /* Find the n-th part: */
370  while (*path_list && n > 0)
371  if (*path_list++ == COLON)
372  n--;
373 
374  if (!*path_list)
375  /* Out-of-bound... */
376  return NULL;
377 
378  /* Compute the length up to the COLON or the end of string: */
379  for(len = 0; path_list[len] && path_list[len] != COLON; len++)
380  ;
381 
382  char *unescaped = strndup(path_list, len);
383  return unescaped;
384 }
#define COLON
Definition: file.c:349
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References COLON, and strndup().

Referenced by find_file_in_directories(), and include_path_to_include_flags().

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

◆ open_log_file()

void open_log_file ( const  string)
Parameters
stringir

Definition at line 171 of file message.c.

172 {
173  if (log_file != NULL)
174  close_log_file();
175 
176  if (get_bool_property("USER_LOG_P"))
177  {
178  string log_file_name = strdup(concatenate(dir, "/", LOG_FILE, NULL));
179 
180  if ((log_file = fopen(log_file_name, "a")) == NULL) {
181  pips_user_error("Cannot open log file in workspace %s. "
182  "Check access rights.");
183  }
184 
185  free(log_file_name);
186  }
187 }
void close_log_file(void)
Definition: message.c:162
#define LOG_FILE
Definition: message.c:155

References close_log_file(), concatenate(), free(), get_bool_property(), LOG_FILE, log_file, pips_user_error, and strdup().

Referenced by create_workspace(), and open_workspace().

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

◆ open_warning_file()

void open_warning_file ( const char *  dir)
Parameters
dirir

Definition at line 286 of file message.c.

287 {
288  assert(warning_file_name == NULL && warning_file == NULL);
291 }
#define WARNING_FILE_NAME
USER_WARNING issues a warning and don't stop the program (cf.
Definition: message.c:281
#define assert(ex)
Definition: newgen_assert.h:41

References assert, concatenate(), safe_fopen(), strdup(), warning_file, WARNING_FILE_NAME, and warning_file_name.

Referenced by create_workspace(), and open_workspace().

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

◆ open_xml_logfile()

void open_xml_logfile ( const char *  filename)
Parameters
filenameilename

Definition at line 607 of file message.c.

608 {
609  xml_logfile_name = (string) filename;
610  xml_logfile = safe_fopen(filename, "w");
611 
612  // put version as an XML comment...
613  if (!getenv("PIPS_VALIDATION_IN_PROGRESS"))
614  {
616  string_buffer_append(sb, "<!-- pips informations:\n ");
617  append_xml_attribute(sb, "Architecture", STRINGIFY(SOFT_ARCH));
618  string_buffer_append(sb, "\n ");
619  append_xml_attribute(sb, "Revisions", pips_revisions);
620  string_buffer_append(sb, "\n ");
622  string_buffer_append(sb, "\n ");
623  append_xml_attribute(sb, "Compiler", pips_cc);
624  string_buffer_append(sb, "\n-->\n");
626  fflush(xml_logfile);
628  }
629 }
static string pips_revisions
Definition: message.c:98
static string pips_date
Definition: message.c:99
static string pips_cc
Definition: message.c:100
static void append_xml_attribute(string_buffer sb, const string attribute, const string value)
generate xml: attribute="escaped-stuff"
Definition: message.c:595
#define STRINGIFY(symbol)
If not using this 2-stage macro evaluation, the generated string is not the value of the macro but th...
Definition: misc-local.h:50
void string_buffer_append(string_buffer, const string)
append string s (if non empty) to string buffer sb, the duplication is done if needed according to th...
void string_buffer_to_file(const string_buffer, FILE *)
put string buffer into file.
void string_buffer_free(string_buffer *)
free string buffer structure, also free string contents according to the dup field
Definition: string_buffer.c:82
string_buffer string_buffer_make(bool dup)
allocate a new string buffer
Definition: string_buffer.c:58
internally defined structure.
Definition: string_buffer.c:47
Definition: statement.c:4047

References append_xml_attribute(), pips_cc, pips_date, pips_revisions, safe_fopen(), string_buffer_append(), string_buffer_free(), string_buffer_make(), string_buffer_to_file(), STRINGIFY, xml_logfile, and xml_logfile_name.

Referenced by parse_arguments().

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

◆ pips_basename()

char* pips_basename ( char *  fullpath,
char *  suffix 
)
Parameters
fullpathullpath
suffixuffix

Definition at line 822 of file file.c.

823 {
824  return pips_filename(fullpath, suffix, true);
825 }
char * pips_filename(char *fullpath, char *suffix, bool short_p)
Some OS do not define basename and dirname.
Definition: file.c:775

References pips_filename().

Referenced by compilation_unit_of_module(), csplit_open_compilation_unit(), get_new_user_file(), hpfc_fclose(), hpfc_fopen(), insert_check_alias_before_statement(), insert_flag_before_call_site(), insert_test_before_caller(), insert_test_before_statement(), module_name_to_input_file_name(), process_thru_fortran_pp(), step_install(), and used_before_set().

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

◆ pips_debug_function()

void pips_debug_function ( const int  the_expected_debug_level,
const char *  a_message_format,
  ... 
)

pips_debug is a nice macro that depends on gcc to generate the function name and to handle a variable number of arguments.

if these feature are not available, it will be this function. the function name won't be available. FC May 95.

If the current debug level is not high enough, do nothing:

print out remainder of message

Parameters
the_expected_debug_levelhe_expected_debug_level
a_message_format_message_format

Definition at line 224 of file debug.c.

227 {
228  va_list some_arguments;
229 
230  /* If the current debug level is not high enough, do nothing: */
231  if (the_expected_debug_level > the_current_debug_level)
232  return;
233 
234  (void) fprintf(stderr, "[unknown] ");
235 
236  va_start(some_arguments, a_message_format);
237 
238  /* print out remainder of message */
239  (void) vfprintf(stderr, a_message_format, some_arguments);
240 
241  va_end(some_arguments);
242 }

References fprintf(), and the_current_debug_level.

+ Here is the call graph for this function:

◆ pips_dirname()

char* pips_dirname ( char *  fullpath)
Parameters
fullpathullpath

Definition at line 837 of file file.c.

838 {
839  char *result = strdup(fullpath);
840  int len = strlen(result);
841  while (result[--len]!='/' && len>=0);
842  result[len] = '\0';
843  return result;
844 }

References strdup().

Referenced by filter_file(), and parse_arguments().

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

◆ pips_filename()

char* pips_filename ( char *  fullpath,
char *  suffix,
bool  short_p 
)

Some OS do not define basename and dirname.

Others like DEC OSF1 do. So define them and use another name for them:

/some/path/to/file.suffix -> file

This may create conflicting file names, when the same source filename is used in different subdirectory as in:

create foo mod.c src/mod.c src/init/mod.c src/close/mod.c

To avoid the problem a larger part of the access path should be preserved. This can be done by substituting / by another character.

Drop the suffix

ok

Keep the basename only

fullpath[i+1:len]

Or substitute slashes by a neutral character

Parameters
fullpathullpath
suffixuffix
short_phort_p

Definition at line 775 of file file.c.

776 {
777  int len = strlen(fullpath)-1, i, j;
778  char *result;
779 
780  if (suffix) /* Drop the suffix */
781  {
782  int ls = strlen(suffix) - 1, le = len;
783  while (suffix[ls] == fullpath[le]) {
784  ls--;
785  le--;
786  if (ls < 0 || le < 0)
787  break;
788  }
789  if (ls < 0) /* ok */
790  len = le;
791  }
792 
793  if(short_p) {
794  /* Keep the basename only */
795  for (i=len; i>=0; i--) if (fullpath[i]=='/') break;
796  /* fullpath[i+1:len] */
797  result = (char*) malloc(sizeof(char)*(len-i+1));
798  for (i++, j=0; i<=len; i++, j++)
799  result[j] = fullpath[i];
800  result[j++] = '\0';
801  }
802  else {
803  /* Or substitute slashes by a neutral character */
804  char * cc;
805 
806  if(fullpath[0]=='.' && fullpath[1]=='/')
807  result = strndup(fullpath+2, len-1);
808  else
809  result = strndup(fullpath, len+1);
810 
811 
812 #define SLASH_SUBSTITUTION_CHARACTER '_'
813 
814  for(cc=result; *cc!='\000'; cc++) {
815  if(*cc=='/')
817  }
818  }
819  return result;
820 }
#define SLASH_SUBSTITUTION_CHARACTER
void * malloc(YYSIZE_T)

References malloc(), SLASH_SUBSTITUTION_CHARACTER, and strndup().

Referenced by pips_basename(), and pips_initial_filename().

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

◆ pips_initial_filename()

char* pips_initial_filename ( char *  fullpath,
char *  suffix 
)

The source file name access path is shortened or not depending on the property.

It is shorten if the name conflicts are not managed.

Parameters
fullpathullpath
suffixuffix

Definition at line 829 of file file.c.

830 {
831  return pips_filename(fullpath, suffix,
832  !get_bool_property("PREPROCESSOR_FILE_NAME_CONFLICT_HANDLING"));
833 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....

References get_bool_property(), and pips_filename().

Referenced by process_thru_C_pp().

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

◆ pips_internal_error_func()

void _NORETURN_ pips_internal_error_func ( const char *  funcname,
const char *  funcfile,
const int  funcline,
const char *  fmt,
  ... 
)
Parameters
funcnameuncname
funcfileuncfile
funclineuncline
fmtmt

Definition at line 394 of file message.c.

400 {
401  va_list args;
402  va_start(args, fmt);
403  pips_internal_error_alist(funcname, funcfile, funcline, fmt, &args);
404  va_end(args);
405 }
static void _NORETURN_ pips_internal_error_alist(const char *funcname, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:375

References pips_internal_error_alist().

+ Here is the call graph for this function:

◆ pips_internal_error_func2()

void _NORETURN_ pips_internal_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 408 of file message.c.

411 {
412  va_list args;
413  va_start(args, format);
415  format, &args);
416  va_end(args);
417 }
#define pips_unknown_function
Definition: misc-local.h:63

References pips_internal_error_alist(), and pips_unknown_function.

+ Here is the call graph for this function:

◆ pips_log_alist()

void pips_log_alist ( const pips_log_t  tag,
const  string,
const  string,
const  string,
const  string,
const int  pips_line,
const  string,
const  string,
const int  user_line,
const int  user_line2,
const  string,
const  string,
const  string,
va_list *  args 
)

log entry with unprocessed format/alist arguments

Parameters
stringips_pass
stringips_owner
stringips_func
stringips_file
pips_lineips_line
stringser_func
stringser_file
user_lineser_line
user_line2ser_line2
stringtmt
stringuggestion
stringormat
argsrgs

Definition at line 1200 of file message.c.

1221 {
1222  pips_log_in_progress(pips_func, pips_file, pips_line);
1223 
1224  // process issue description once and for all
1225  string description = NULL;
1226  va_list acpy;
1227  va_copy(acpy, *args);
1228  // BUG: if a timeout is raised while being in malloc, this call is deadlocked
1229  // as a lock is already held and vasprintf needs to allocate... Also, XML
1230  // output generation also requires malloc later on...
1231  vasprintf(&description, format, acpy);
1232  va_end(acpy);
1233 
1234  // trim leading newlines/tabs and trailing newlines/tabs/spaces
1235  string desc = description;
1236  while (*desc && (*desc == '\n' || *desc == '\t' || *desc == '\r'))
1237  desc ++;
1238  int last = strlen(desc) - 1;
1239  while (last >= 0 &&
1240  (desc[last] == '\n' || desc[last] == '\t' || desc[last] == ' ' ||
1241  desc[last] == '\r'))
1242  desc[last--] = '\0';
1243 
1244  // display part
1245  pips_log_display(tag, pips_pass, pips_owner,
1246  pips_func, pips_file, pips_line,
1247  user_func, user_file, user_line, user_line2,
1248  stmt, suggestion, desc);
1249 
1250  // cleanup
1251  free(description);
1252 
1253  // (legacy?) alist level callbacks...
1254  if (tag == info_log && pips_log_handler)
1255  {
1256  va_copy(acpy, *args);
1257  pips_log_handler(format, &acpy);
1258  va_end(acpy);
1259  }
1260  else if ((tag == warning_log || tag == spear_warning_log) &&
1262  {
1263  va_copy(acpy, *args);
1264  pips_warning_handler(pips_func, format, &acpy);
1265  va_end(acpy);
1266  }
1267  else if (tag == user_error_log && pips_error_handler)
1268  {
1269  va_copy(acpy, *args);
1270  pips_error_handler(pips_func, format, &acpy);
1271  va_end(acpy);
1272  }
1274  {
1275  va_copy(acpy, *args);
1276  pips_internal_error_handler(pips_func, format, &acpy);
1277  va_end(acpy);
1278  }
1279 
1280  // conclusion (exit, abort, whatever), although it may never be reached...
1281  pips_log_end(tag);
1282 }
static void pips_log_display(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string desc)
manage "displaying" a log entry, on stderr, in files...
Definition: message.c:1040
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
static void pips_log_end(pips_log_t tag)
end of log entry (nothing, exception, abort, exit...)
Definition: message.c:1116
static void pips_log_in_progress(const char *pips_func, const char *pips_file, const int pips_line)
Definition: message.c:1089
void(* pips_log_handler)(const char *fmt, va_list *args)
USER_LOG is a function that should be called to log the current PIPS request, as soon as it is releva...
Definition: message.c:216
void(* pips_error_handler)(const char *, const char *, va_list *)
PROMPT_USER schould be implemented.
Definition: message.c:455
void(* pips_warning_handler)(const char *, const char *, va_list *)
default assignment of pips_warning_handler is default_user_warning.
Definition: message.c:325
static FILE * user_file
These functions implements the writing of objects.
Definition: genClib.c:1485
@ internal_error_log
Definition: misc-local.h:38
@ user_error_log
Definition: misc-local.h:37
@ spear_warning_log
Definition: misc-local.h:35
int tag
TAG.
Definition: newgen_types.h:92
Definition: statement.c:54
int vasprintf(char **resultp, const char *format, va_list args)
Formatted output to strings.
Definition: vasprintf.c:33

References free(), info_log, internal_error_log, pips_error_handler, pips_internal_error_handler, pips_log_display(), pips_log_end(), pips_log_handler, pips_log_in_progress(), pips_warning_handler, spear_warning_log, user_error_log, user_file, vasprintf(), and warning_log.

Referenced by append_to_warning_file(), c_parser_user_warning_alist(), csplit_parser_warning_alist(), pips_internal_error_alist(), pips_log_func(), pips_user_error_alist(), pips_user_irrecoverable_error_alist(), pips_user_log_alist(), pips_user_warning_alist(), semantics_user_warning_alist(), and spear_log_alist().

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

◆ pips_log_desc()

void pips_log_desc ( const pips_log_t  tag,
const  string,
const  string,
const  string,
const  string,
const int  pips_line,
const  string,
const  string,
const int  user_line,
const int  user_line2,
const  string,
const  string,
const  string 
)

log entry with preprocessed format/arguments

Parameters
stringips_pass
stringips_owner
stringips_func
stringips_file
pips_lineips_line
stringser_func
stringser_file
user_lineser_line
user_line2ser_line2
stringtmt
stringuggestion
stringescription

Definition at line 1173 of file message.c.

1187 {
1188  pips_log_in_progress(pips_func, pips_file, pips_line);
1189 
1190  pips_log_display(tag, pips_pass, pips_owner,
1191  pips_func, pips_file, pips_line,
1192  user_func, user_file, user_line, user_line2,
1193  stmt, suggestion, description);
1194 
1195  pips_log_end(tag);
1196 }

References pips_log_display(), pips_log_end(), pips_log_in_progress(), and user_file.

Referenced by log_on_file().

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

◆ pips_log_func()

void pips_log_func ( const  string,
const  string,
const int  pips_line,
const pips_log_t  tag,
const  string,
const  string,
const  string,
const  string,
const int  user_line,
const int  user_line2,
const  string,
const  string,
const  string,
  ... 
)

direct pips_log call with format and free arguments ("...")

Parameters
stringips_func
stringips_file
pips_lineips_line
stringips_pass
stringips_owner
stringser_func
stringser_file
user_lineser_line
user_line2ser_line2
stringtmt
stringuggestion
stringormat

Definition at line 1286 of file message.c.

1308 {
1309  va_list args;
1310  va_start(args, format);
1312  pips_pass, pips_owner,
1313  pips_func, pips_file, pips_line,
1314  user_func, user_file, user_line, user_line2,
1315  stmt, suggestion, format, &args);
1316  va_end(args);
1317 }

References pips_log_alist(), and user_file.

+ Here is the call graph for this function:

◆ pips_log_stop()

void pips_log_stop ( const char *  function,
const char *  file,
const int  lineno,
const pips_log_t  tag,
const int  code,
const  string,
  ... 
)

quick log and stop, called on timeout this must not invoke malloc as it may still held locks if interrupted this implementation is missing XML escapes...

Parameters
functionunction
fileile
linenoineno
codeode
stringormat

Definition at line 1323 of file message.c.

1331 {
1332  // STDERR
1333  va_list args;
1334  va_start(args, format);
1335  fprintf(stderr, "(%s) [%s] stopping pips on code %d (%s) for ",
1336  function, pips_log_tag_name(tag), code, code2status(code));
1337  vfprintf(stderr, format, args);
1338  va_end(args);
1339  fputs("\n", stderr);
1340  fflush(stderr);
1341 
1342  // XML
1343  if (xml_logfile)
1344  {
1346  "<Exit Code=\"%d\" Status=\"%s\" Source=\"%s\">\n",
1348 
1349  string
1350  pass = get_pips_current_pass_name(),
1352 
1354  " <Description AppFunction=\"\" AppFile=\"\" "
1355  "AppLine=\"\" Statement=\"\" Proposition=\"\" "
1356  "Pass=\"%s\" Owner=\"%s\" PipsFunction=\"%s\" ",
1357  pass? pass: "", module? module: "", function);
1358 
1359  if (file && getenv("PIPS_VALIDATION_IN_PROGRESS"))
1360  {
1361  // just show a short version of the file & hide the line
1362  string short_file = strstr(file, "/src/");
1364  "PipsFile=\"%s\" PipsLine=\"...\" ",
1365  short_file? short_file: "...");
1366  }
1367  else
1368  {
1369  fprintf(xml_logfile, "PipsFile=\"%s\" PipsLine=\"%d\" ", file, lineno);
1370  }
1371 
1372  fprintf(xml_logfile, "Message=\"");
1373 
1374  va_start(args, format);
1375  vfprintf(xml_logfile, format, args);
1376  va_end(args);
1377 
1378  fprintf(xml_logfile, "\" />\n</Exit>\n");
1379  fflush(xml_logfile);
1380  }
1381 
1382  exit(code);
1383 }
static string code2status(int code)
Definition: message.c:759
string pips_log_tag_name(pips_log_t tag)
Definition: message.c:938
#define exit(code)
Definition: misc-local.h:54
static char * module
Definition: pips.c:74

References code2status(), exit, fprintf(), get_pips_current_module(), get_pips_current_pass_name(), module, pips_log_tag_name(), and xml_logfile.

Referenced by pips_timeout_callback().

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

◆ pips_log_tag_name()

string pips_log_tag_name ( pips_log_t  tag)

Definition at line 938 of file message.c.

939 {
940  switch (tag)
941  {
942  case none_log: return "none";
943  case info_log: return "information";
944  case warning_log: return "warning";
945  case spear_warning_log: return "spear warning";
946  case spear_error_log: return "spear error";
947  case user_error_log: return "user error";
948  case internal_error_log: return "internal error";
949  case irrecoverable_error_log: return "irrecoverable error";
950  default: return "<missing tag name>";
951  }
952 }
@ spear_error_log
Definition: misc-local.h:36
@ none_log
Definition: misc-local.h:32
@ irrecoverable_error_log
Definition: misc-local.h:39

References info_log, internal_error_log, irrecoverable_error_log, none_log, spear_error_log, spear_warning_log, user_error_log, and warning_log.

Referenced by pips_log_file(), pips_log_stop(), pips_stop_file(), and pips_stop_xml().

+ Here is the caller graph for this function:

◆ pips_malloc_debug()

void pips_malloc_debug ( void  )

malloc_debug.c

malloc_debug.c

include "stdlib.h"

Definition at line 34 of file malloc_debug.c.

35 {
36  debug_on("MALLOC_DEBUG_LEVEL");
37 #if __GNUC__foo || sunfoo
38  if (get_debug_level()==9) {
39  debug(9, "pips_malloc_debug",
40  "malloc_debug level of error diagnosis is 2\n");
41  malloc_debug(2);
42  }
43  else if (get_debug_level()>=5) {
44  debug(5, "pips_malloc_debug", "malloc(50) returns %x\n",
45  (int) malloc(50));
46  debug(5, "pips_malloc_debug", "call to malloc_verify()\n");
47  pips_assert("pips_malloc_debug", malloc_verify());
48  malloc_debug(1);
49  }
50  else if (get_debug_level()>=1)
51  malloc_debug(1);
52  else
53  malloc_debug(0);
54 #else
55  debug(1, "pips_malloc_debug", "No malloc_debug on this system\n");
56 #endif
57  debug_off();
58 }
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189

References debug(), debug_off, debug_on, get_debug_level(), malloc(), and pips_assert.

Referenced by apply_a_rule(), and safe_do_something().

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

◆ pips_stop_func()

void _NORETURN_ pips_stop_func ( const char *  pips_func,
const char *  pips_file,
const int  pips_line,
pips_log_t  tag,
int  code,
const  string,
  ... 
)

expecititely declare "noreturn" functions...

because cproto generated headers seem to ignore attributes

Parameters
pips_funcips_func
pips_fileips_file
pips_lineips_line
codeode
formatormat

Definition at line 904 of file message.c.

914 {
915  va_list args;
916  va_start(args, format);
918  (const string) pips_func, (const string) pips_file, pips_line,
919  format, &args);
920  va_end(args);
921 }
static void _NORETURN_ pips_stop_alist(pips_log_t tag, int code, const string pips_func, const string pips_file, const int pips_line, const string format, va_list *args)
Definition: message.c:883

References pips_stop_alist().

Referenced by pips_log_in_progress().

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

◆ pips_stop_func2()

void _NORETURN_ pips_stop_func2 ( pips_log_t  tag,
int  code,
const  string,
  ... 
)
Parameters
codeode
stringormat

Definition at line 924 of file message.c.

929 {
930  va_list args;
931  va_start(args, format);
932  pips_stop_alist(tag, code, NULL, NULL, -1, format, &args);
933  va_end(args);
934 }

References pips_stop_alist().

+ Here is the call graph for this function:

◆ pips_thanks()

void pips_thanks ( string  name,
string  path 
)

display pips thanks on startup, if it on a tty.

Parameters
nameame
pathath

Definition at line 265 of file message.c.

266 {
267  if (isatty(fileno(stdout)))
268  {
269  fprintf(stdout, PIPS_THANKS_STRING(STRINGIFY(SOFT_ARCH)), name, path);
270  fflush(stdout);
271  }
272 }
#define PIPS_THANKS_STRING(arch)
The # "stringificator" only works in a macro expansion...
Definition: message.c:247

◆ pips_user_error_func()

void _NORETURN_ pips_user_error_func ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
  ... 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat

Definition at line 478 of file message.c.

484 {
485  va_list args;
486  va_start(args, format);
487  pips_user_error_alist(func_name, funcfile, funcline, format, &args);
488  va_end(args);
489 }
static void _NORETURN_ pips_user_error_alist(const char *calling_function_name, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:458

References pips_user_error_alist().

+ Here is the call graph for this function:

◆ pips_user_error_func2()

void _NORETURN_ pips_user_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 492 of file message.c.

495 {
496  va_list args;
497  va_start(args, format);
498  pips_user_error_alist(pips_unknown_function, NULL, -1, format, &args);
499  va_end(args);
500 }

References pips_unknown_function, and pips_user_error_alist().

+ Here is the call graph for this function:

◆ pips_user_irrecoverable_error_alist()

void _NORETURN_ pips_user_irrecoverable_error_alist ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
va_list *  args 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat
argsrgs

Definition at line 516 of file message.c.

522 {
526  (const string) func_name, (const string) funcfile, funcline,
527  NULL, NULL, -1, -1,
528  NULL, NULL, (const string) format, args);
529 
530  // dead code, stopped in previous call
531  exit(1);
532 }

References exit, get_pips_current_module(), get_pips_current_pass_name(), irrecoverable_error_log, and pips_log_alist().

Referenced by pips_user_irrecoverable_error_func(), and pips_user_irrecoverable_error_func2().

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

◆ pips_user_irrecoverable_error_func()

void _NORETURN_ pips_user_irrecoverable_error_func ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
  ... 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat

Definition at line 535 of file message.c.

541 {
542  va_list args;
543  va_start(args, format);
544  pips_user_irrecoverable_error_alist(func_name, funcfile, funcline,
545  format, &args);
546  va_end(args);
547 }
void _NORETURN_ pips_user_irrecoverable_error_alist(const char *func_name, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:516

References pips_user_irrecoverable_error_alist().

+ Here is the call graph for this function:

◆ pips_user_irrecoverable_error_func2()

void _NORETURN_ pips_user_irrecoverable_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 550 of file message.c.

553 {
554  va_list args;
555  va_start(args, format);
556  pips_user_irrecoverable_error_alist("UNKNOWN...", NULL, -1, format, &args);
557  va_end(args);
558 }

References pips_user_irrecoverable_error_alist().

+ Here is the call graph for this function:

◆ pips_user_log_func()

void pips_user_log_func ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 225 of file message.c.

226 {
227  va_list args;
228  va_start(args, format);
229  pips_user_log_alist(format, &args);
230  va_end(args);
231 }
static void pips_user_log_alist(const char *format, va_list *args)
Definition: message.c:218

References pips_user_log_alist().

+ Here is the call graph for this function:

◆ pips_user_warning_alist()

void pips_user_warning_alist ( const char *  function_name,
const char *  funcfile,
const int  funcline,
const char *  format,
va_list *  args 
)
Parameters
function_nameunction_name
funcfileuncfile
funclineuncline
formatormat
argsrgs

Definition at line 328 of file message.c.

334 {
335  if (properties_initialized_p() && get_bool_property("NO_USER_WARNING"))
336  return;
337 
340  (const string) function_name, (const string)funcfile, funcline,
341  NULL, NULL, -1, -1,
342  NULL, NULL, (const string) format, args);
343 }

References get_bool_property(), get_pips_current_module(), get_pips_current_pass_name(), pips_log_alist(), properties_initialized_p(), and warning_log.

Referenced by pips_user_warning_func(), and pips_user_warning_func2().

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

◆ pips_user_warning_func()

void pips_user_warning_func ( const char *  calling_function_name,
const char *  funcfile,
const int  funcline,
const char *  format,
  ... 
)
Parameters
calling_function_namealling_function_name
funcfileuncfile
funclineuncline
formatormat

Definition at line 346 of file message.c.

352 {
353  va_list args;
354  va_start(args, format);
355  pips_user_warning_alist(calling_function_name, funcfile, funcline,
356  format, &args);
357  va_end(args);
358 }
void pips_user_warning_alist(const char *function_name, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:328

References pips_user_warning_alist().

+ Here is the call graph for this function:

◆ pips_user_warning_func2()

void pips_user_warning_func2 ( const char *  format,
  ... 
)

fallback version without a calling function name

Parameters
formatormat

Definition at line 362 of file message.c.

365 {
366  va_list args;
367  va_start(args, format);
368  pips_user_warning_alist(pips_unknown_function, NULL, -1, format, &args);
369  va_end(args);
370 }

References pips_unknown_function, and pips_user_warning_alist().

+ Here is the call graph for this function:

◆ pop_performance_spy()

void pop_performance_spy ( FILE *  f,
string  msg 
)
Parameters
msgsg

Definition at line 97 of file perf_spy.c.

100 {
101  struct rusage current;
102  message_assert("stack not empty", stack_index>0);
103  fprintf(f, "[performance_spy] %s\n", msg);
104 
105  getrusage(RUSAGE_SELF, &current);
106  fprintf(f, "self:\n");
108  fprintf(f, "children:\n");
109  getrusage(RUSAGE_CHILDREN, &current);
111 }
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static void printf_usage_delta(FILE *f, struct rusage *begin, struct rusage *end)
simply dump all available information...
Definition: perf_spy.c:70
static struct rusage usage_stack[USAGE_STACK_SIZE]
Definition: perf_spy.c:44
static int stack_index
Definition: perf_spy.c:45

References current, f(), fprintf(), message_assert, printf_usage_delta(), stack_index, and usage_stack.

Referenced by hpf_remapping().

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

◆ pop_pips_context()

void pop_pips_context ( char const *  file,
char const *  function,
int  line 
)
Parameters
fileile
functionunction
lineine

Definition at line 50 of file exception.c.

51 {
52  pips_debug(9, "%s %s:%d\n", function, file, line);
53  if (!debug_stack)
54  pips_internal_error("unexpected pop without push %s %s:%d",
55  function, file, line);
57 }
static stack debug_stack
Stack management for PIPS contexts.
Definition: exception.c:41
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void set_debug_stack_pointer(const int i)
Definition: debug.c:97
void * stack_pop(stack)
POPs one item from stack s.
Definition: stack.c:399
intptr_t _int
_INT
Definition: newgen_types.h:53

References debug_stack, line, pips_debug, pips_internal_error, set_debug_stack_pointer(), and stack_pop().

Referenced by atinit(), gpips_main(), pips_main(), tpips_main(), and wpips_main().

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

◆ print_debug_stack()

void print_debug_stack ( void  )

function used to debug (can be called from dbx) BB 6.12.91

Definition at line 164 of file debug.c.

165 {
166  int i;
167 
168  (void) fprintf(stderr, "Debug stack (last debug_on first): ");
169 
170  for(i=idls-1;i>=0;i--)
171  (void) fprintf(stderr, "%s=%d [%s] (%s:%d)\n",
172  debug_stack[i].name,
173  debug_stack[i].level,
174  debug_stack[i].function,
175  debug_stack[i].file,
176  debug_stack[i].line);
177 }

References debug_stack, fprintf(), idls, level, and line.

+ Here is the call graph for this function:

◆ purge_directory()

bool purge_directory ( char *  name)
Parameters
nameame

Definition at line 453 of file file.c.

454 {
455  bool success = true;
456 
457  if (directory_exists_p(name)) {
458  if(system(concatenate("/bin/rm -r ", name, (char*) NULL))) {
459  // FI: this warning should be emitted by a higher-level routine!
460  pips_user_warning("cannot purge directory %s. Check owner rights\n", name);
461  success = false;
462  }
463  else {
464  success = true;
465  }
466  }
467  else {
468  // Well, it's purged if it does not exist...
469  success = true;
470  }
471 
472  return success;
473 }

References concatenate(), directory_exists_p(), and pips_user_warning.

Referenced by db_create_workspace().

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

◆ push_performance_spy()

void push_performance_spy ( void  )

perf_spy.c

Definition at line 89 of file perf_spy.c.

90 {
91  message_assert("stack not full", stack_index<USAGE_STACK_SIZE);
92  getrusage(RUSAGE_CHILDREN, &usage_stack[stack_index++]);
93  getrusage(RUSAGE_SELF, &usage_stack[stack_index++]);
94 }
#define USAGE_STACK_SIZE
for USAGE information
Definition: perf_spy.c:43

References message_assert, stack_index, usage_stack, and USAGE_STACK_SIZE.

Referenced by hpf_remapping().

+ Here is the caller graph for this function:

◆ push_pips_context()

void push_pips_context ( char const *  file,
char const *  function,
int  line 
)

exception.c

Parameters
fileile
functionunction
lineine

Definition at line 43 of file exception.c.

44 {
45  pips_debug(9, "%s %s:%d\n", function, file, line);
46  if (!debug_stack) debug_stack = stack_make(0, 50, 0);
48 }
_int get_debug_stack_pointer(void)
The pair get_ and set_debug_stack_pointer() should never be used except to clean up the stack after a...
Definition: debug.c:92
void stack_push(void *, stack)
stack use
Definition: stack.c:373
stack stack_make(int, int, int)
allocation
Definition: stack.c:246

References debug_stack, get_debug_stack_pointer(), line, pips_debug, stack_make(), and stack_push().

Referenced by atinit(), gpips_main(), pips_main(), tpips_main(), and wpips_main().

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

◆ reset_hooks_call()

void reset_hooks_call ( void  )

this function is expected to be called when catching an exception.

Definition at line 53 of file reset_hooks.c.

54 {
55  // call reset functions
57  (*((reset_func_t) f))();
58 
59  // cleanup
61  reset_hooks = NIL;
62 }
#define VOID_STAR(x)
Definition: genC.h:95
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
void(* reset_func_t)(void)
Definition: misc-local.h:222
static list reset_hooks
reset functions to call on exceptions to be used by pipsmake?
Definition: reset_hooks.c:40

References f(), FOREACH, gen_free_list(), NIL, reset_hooks, and VOID_STAR.

Referenced by reset_static_phase_variables().

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

◆ reset_hooks_is_empty()

void reset_hooks_is_empty ( void  )

check that the stack was cleaned.

Definition at line 66 of file reset_hooks.c.

67 {
68  pips_assert("no reset functions", reset_hooks == NIL);
69 }

References NIL, pips_assert, and reset_hooks.

Referenced by catch_user_error().

+ Here is the caller graph for this function:

◆ reset_hooks_register()

void reset_hooks_register ( reset_func_t  function)

reset_hooks.c

reset_hooks.c

Parameters
functionunction

Definition at line 44 of file reset_hooks.c.

45 {
46  pips_assert("reset function not already in list",
47  !gen_in_list_p(function, reset_hooks));
48  reset_hooks = CONS(VOID_STAR, function, reset_hooks);
49 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734

References CONS, gen_in_list_p(), pips_assert, reset_hooks, and VOID_STAR.

Referenced by atomize_as_required(), hpfc_close(), hpfc_common(), hpfc_compile(), hpfc_directives_handler(), hpfc_filter(), hpfc_init(), module_to_value_mappings(), and print_module_icfg().

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

◆ reset_hooks_unregister()

void reset_hooks_unregister ( reset_func_t  function)

remove registered cleanup hook.

Parameters
functionunction

Definition at line 73 of file reset_hooks.c.

74 {
75  // should it really be the first? probably too optimistic.
76  /*
77  pips_assert(reset_hooks &&
78  VOID_STAR(CAR(reset_hooks)) == function,
79  "unregister reset functions in reverse order");
80  */
81  pips_assert("unregister a function already registered",
82  gen_in_list_p(function, reset_hooks));
83  gen_remove_once(&reset_hooks, function);
84 }
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691

References gen_in_list_p(), gen_remove_once(), pips_assert, and reset_hooks.

Referenced by atomize_as_required(), free_value_mappings(), hpfc_close(), hpfc_common(), hpfc_compile(), hpfc_directives_handler(), hpfc_filter(), hpfc_init(), and print_module_icfg().

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

◆ reset_pips_current_computation()

void reset_pips_current_computation ( void  )

Definition at line 87 of file message.c.

88 {
89  pips_assert("some current computation", current_module && current_phase);
90 
93 }

References current_module, current_phase, free(), and pips_assert.

Referenced by create_workspace(), and reset_current_phase_context().

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

◆ safe_append()

void safe_append ( FILE *  out,
char *  file,
int  margin,
bool  but_comments 
)
Parameters
outut
fileile
marginargin
but_commentsut_comments

Definition at line 679 of file file.c.

684 {
685  FILE * in = safe_fopen(file, "r");
686  bool first = true;
687  int c, i;
688  while ((c=getc(in))!=EOF)
689  {
690  if (first && (!but_comments || (c!='C' && c!='c' && c!='*' && c!='!')))
691  {
692  for (i=0; i<margin; i++)
693  if (putc(' ', out)==EOF)
694  pips_internal_error("append failed");
695  first = false;
696  }
697  if (c=='\n')
698  first = true;
699  if (putc(c, out)==EOF)
700  pips_internal_error("append failed");
701  }
702  safe_fclose(in, file);
703 }
static FILE * out
Definition: alias_check.c:128

References out, pips_internal_error, safe_fclose(), and safe_fopen().

Referenced by callgraph_module_name().

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

◆ safe_asprintf()

int safe_asprintf ( char **  strp,
const char *  fmt,
  ... 
)
Parameters
strptrp
fmtmt

Definition at line 1408 of file message.c.

1409 {
1410  va_list args;
1411  va_start(args, fmt);
1412  return safe_vasprintf(strp, fmt, args);
1413  va_end(args);
1414 }
int safe_vasprintf(char **strp, const char *fmt, va_list args)
Definition: message.c:1398

References safe_vasprintf().

+ Here is the call graph for this function:

◆ safe_cat()

void safe_cat ( FILE *  out,
FILE *  in 
)
Parameters
outut
inn

Definition at line 669 of file file.c.

670 {
671  int c;
672  while ((c=getc(in))!=EOF)
673  if (putc(c, out)==EOF)
674  pips_internal_error("cat failed");
675  safe_fflush(out, "<probably stdout>");
676 }
int safe_fflush(FILE *stream, char *filename)
Definition: file.c:90

References out, pips_internal_error, and safe_fflush().

Referenced by handle_include_file(), safe_copy(), safe_display(), step_install(), and unsplit_internal().

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

◆ safe_copy()

void safe_copy ( char *  source,
char *  target 
)
Parameters
sourceource
targetarget

Definition at line 706 of file file.c.

707 {
708  FILE * in, * out;
709  in = safe_fopen(source, "r");
710  out = safe_fopen(target, "w");
711  safe_cat(out, in);
712  safe_fclose(out, target);
713  safe_fclose(in, source);
714 }
void safe_cat(FILE *out, FILE *in)
Definition: file.c:669

References out, safe_cat(), safe_fclose(), and safe_fopen().

Referenced by compile_a_pure_function(), compile_a_special_io_function(), and step_compile_generated_module().

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

◆ safe_copy_line_interval()

void safe_copy_line_interval ( string  fn,
int  f,
int  l,
FILE *  out 
)

Assumes "fn" is the name of a text file, opens it, and copies the lines whose number belongs to [f..l] into file descriptor "out", except if they have been generated by a C preprocessor.

Line starting with '#' are counted but not copied.

This function is used by the PIPS preprocessor and its parsers to print out the lines where an error has been detected.

Do not reproduce this line as it was generated by an external preprocessor whose behavior is not controlled

Parameters
fnn
outut

Definition at line 601 of file file.c.

602 {
603  FILE * fd = safe_fopen(fn, "r");
604  int i = 0;
605 #define MAX_INPUT_LINE_SIZE (200)
607 
608  pips_assert("The interval is strictly positive and non empty",
609  f>=1 && l>=f);
610 
611  // Skip f-1 lines
612  for(i=0; i<f-1; i++)
614 
615  // Copy l-f+1 lines
616  int c = l - f + 1;
617  while(c>0) {
618  int n = fgetc(fd);
619  if(n==EOF)
620  break;
621  else {
622  if((char) n == '#') {
623  /* Do not reproduce this line as it was generated by an
624  external preprocessor whose behavior is not controlled */
625  while(c>0) {
626  n = fgetc(fd);
627  if(n==EOF)
628  c = -1; // stop
629  else if((char) n == '\n') {
630  c--; // One useless line has been read
631  break;
632  }
633  }
634  }
635  else {
636  fputc(n, out);
637  if((char) n == '\n')
638  c--;
639  }
640  }
641  }
642 
643  safe_fclose(fd, fn);
644 }
char * safe_fgets(char *s, int n, FILE *stream, char *filename)
Definition: file.c:170
#define MAX_INPUT_LINE_SIZE
static int current_line
Poor attempt at associating physical line numbers to statement.
Definition: statement.c:2405

References current_line, f(), MAX_INPUT_LINE_SIZE, out, pips_assert, safe_fclose(), safe_fgets(), and safe_fopen().

+ Here is the call graph for this function:

◆ safe_display()

int safe_display ( char *  fname)

Display a file through $PIPS_MORE (or $PAGER) if stdout is a TTY, on stdout otherwise.

Return false if the file couldn't be displayed.

Parameters
fnamename

Definition at line 722 of file file.c.

723 {
724  if (!file_exists_p(fname))
725  {
726  pips_user_error("View file \"%s\" not found\n", fname);
727  return 0;
728  }
729 
730  if (isatty(fileno(stdout)))
731  {
732  int pgpid = fork();
733  if (pgpid)
734  {
735  int status;
736  waitpid(pgpid, &status, 0);
737  return WIFEXITED(status) && WEXITSTATUS(status) == 0;
738  }
739  else
740  {
741  char *pager = getenv("PIPS_MORE");
742  if (!pager)
743  pager = getenv("PAGER");
744  if (!pager)
745  pager = "more";
746  execlp(pager, pager, fname, NULL);
747  pips_internal_error("running %s %s: %s",
748  pager, fname, strerror(errno));
749  exit(127);
750  }
751  }
752  else
753  {
754  FILE * in = safe_fopen(fname, "r");
755  safe_cat(stdout, in);
756  safe_fclose(in, fname);
757  return 1;
758  }
759 }
struct _newgen_struct_status_ * status
Definition: database.h:31

References exit, file_exists_p(), pips_internal_error, pips_user_error, safe_cat(), safe_fclose(), and safe_fopen().

Referenced by display(), and display_a_resource().

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

◆ safe_fclose()

int safe_fclose ( FILE *  stream,
const char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 77 of file file.c.

78 {
79  if(fclose(stream) == EOF) {
80  if(errno==ENOSPC)
81  pips_user_irrecoverable_error("fclose failed on file %s (%s)\n",
82  filename, strerror(errno));
83  else
84  pips_internal_error("fclose failed on file %s (%s)",
85  filename, strerror(errno));
86  }
87  return 0;
88 }
#define pips_user_irrecoverable_error
Definition: misc-local.h:148

References pips_internal_error, and pips_user_irrecoverable_error.

Referenced by actual_c_parser(), actual_symbol_table_dump(), add_new_compilation_unit(), add_new_module_from_text(), alias_check(), build_aliases(), check_first_statement(), clean_file(), close_resource_file(), close_warning_file(), close_xml_logfile(), csplit_close_compilation_unit(), csplit_close_files(), csplit_copy(), dag_dot_dump(), davinci_dump_expressions(), davinci_print_control_nodes(), davinci_print_non_deterministic_unstructured(), direct_change_directory(), directive_in_file_p(), dump_current_statement(), f95split(), find_eol_coding(), flinter(), freia_compile(), freia_opencl_compile_calls(), full_graph_of_calls(), generic_print_xml_application(), get_first_main_module(), get_new_user_file(), gfc2pips_namespace(), gpu_xml_dump(), graph_of_calls(), handle_file_name(), handle_include_file(), hbdsc_parallelization(), hpfc_fclose(), html_prettyprint(), html_prettyprint_symbol_table(), load_entities(), load_meta_data(), make_resource_from_starting_node(), make_text_resource(), module_to_callgraph(), open_logfile(), open_makefile(), outliner_independent(), parse_arguments(), parse_makefile(), ParserError(), pips_process_file(), pips_split_file(), print_array_dfg(), print_bdt(), print_code_smalltalk(), print_crough(), print_dependence_or_chains_graph(), print_dinf_statistics(), print_dot_dependence_or_chains_graph(), print_dsup_statistics(), print_filtered_dg_or_dvdg(), print_interface(), print_loopnest_dependence_cone(), print_loops(), print_module_name_to_toposorts(), print_plc(), print_proj_op_statistics(), print_sesam_tasks_buffers_header(), print_umay_statistics(), print_umust_statistics(), print_xml_code(), print_xml_code_with_explicit_motif(), process_user_file(), put_result(), region_translation_statistics_close(), rice_dependence_graph(), safe_append(), safe_copy(), safe_copy_line_interval(), safe_display(), safe_get_line_interval(), safe_read_nth_line(), save_entities(), save_makefile(), save_meta_data(), sequence_dependence_graph(), step_compile_analysed_module(), step_compile_generated_module(), step_install(), text_area_included(), the_actual_parser(), tpips_close(), unimodular(), unsplit_internal(), used_before_set(), write_an_attachment_file(), write_to_eole(), and writeresult().

◆ safe_fflush()

int safe_fflush ( FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 90 of file file.c.

91 {
92  if (fflush(stream) == EOF)
93  pips_internal_error("fflush failed on file %s (%s)",
94  filename,
95  strerror(errno));
96  return 0;
97 }

References pips_internal_error.

Referenced by safe_cat().

+ Here is the caller graph for this function:

◆ safe_fgetc()

int safe_fgetc ( FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 147 of file file.c.

148 {
149  int value;
150  if((value = fgetc( stream)) == EOF) {
151  pips_internal_error("fgetc failed on file %s (%s)",
152  filename, strerror(errno));
153  }
154  return(value);
155 }
struct _newgen_struct_value_ * value
Definition: ri.h:455

References pips_internal_error.

◆ safe_fgets()

char* safe_fgets ( char *  s,
int  n,
FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 170 of file file.c.

171 {
172  if (fgets(s, n, stream) == (char *) NULL) {
173  pips_internal_error("gets failed on file %s (%s)",
174  filename, strerror(errno));
175  }
176  return s;
177 }

References pips_internal_error.

Referenced by get_main_entity_name(), safe_copy_line_interval(), and safe_read_nth_line().

+ Here is the caller graph for this function:

◆ safe_fopen()

FILE* safe_fopen ( const char *  filename,
const char *  what 
)
Parameters
filenameilename
whathat

Definition at line 67 of file file.c.

68 {
69  FILE * f;
70  if((f = fopen( filename, what)) == (FILE *) NULL) {
71  pips_internal_error("fopen failed on file %s\n%s",
72  filename, strerror(errno));
73  }
74  return f;
75 }

References f(), and pips_internal_error.

Referenced by actual_c_parser(), actual_symbol_table_dump(), add_new_compilation_unit(), add_new_module_from_text(), alias_check(), check_first_statement(), clean_file(), csplit(), csplit_open_compilation_unit(), dag_dot_dump(), davinci_dump_expressions(), davinci_print_control_nodes(), davinci_print_non_deterministic_unstructured(), direct_change_directory(), directive_in_file_p(), do_recompile_module(), dump_current_statement(), f95split(), find_eol_coding(), flinter(), fopen_config(), freia_compile(), freia_opencl_compile_calls(), full_graph_of_calls(), generic_print_xml_application(), get_first_main_module(), get_new_user_file(), gfc2pips_namespace(), gpu_xml_dump(), graph_of_calls(), handle_file_name(), handle_include_file(), hbdsc_parallelization(), Hierarchical_tiling(), hpfc_fopen(), html_prettyprint(), html_prettyprint_symbol_table(), load_entities(), make_resource_from_starting_node(), make_text_resource(), module_to_callgraph(), open_logfile(), open_resource_file(), open_warning_file(), open_xml_logfile(), outliner_independent(), pips_process_file(), pips_split_file(), print_array_dfg(), print_bdt(), print_code_smalltalk(), print_crough(), print_dependence_or_chains_graph(), print_dinf_statistics(), print_dot_dependence_or_chains_graph(), print_dsup_statistics(), print_filtered_dg_or_dvdg(), print_interface(), print_loopnest_dependence_cone(), print_loops(), print_module_name_to_toposorts(), print_plc(), print_proj_op_statistics(), print_sesam_tasks_buffers_header(), print_umay_statistics(), print_umust_statistics(), print_xml_code(), print_xml_code_with_explicit_motif(), process_user_file(), put_result(), read_from_eole(), region_translation_statistics_close(), rice_dependence_graph(), safe_append(), safe_copy(), safe_copy_line_interval(), safe_display(), safe_get_line_interval(), safe_read_nth_line(), save_entities(), save_makefile(), save_meta_data(), sc_delimiter(), sequence_dependence_graph(), step_compile_analysed_module(), step_compile_generated_module(), step_install(), text_area_included(), the_actual_parser(), Tiling2_buffer(), Tiling_buffer_allocation(), unimodular(), unsplit_internal(), used_before_set(), write_an_attachment_file(), write_to_eole(), and writeresult().

+ Here is the call graph for this function:

◆ safe_fputc()

int safe_fputc ( int  ,
FILE *  ,
char *   
)

◆ safe_fputs()

int safe_fputs ( char *  s,
FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 203 of file file.c.

206 {
207  if(fputs( s, stream) == EOF) {
208  pips_internal_error("fputs failed on file %s (%s)",
209  filename, strerror(errno));
210  }
211  return(1);
212 }

References pips_internal_error.

◆ safe_fread()

int safe_fread ( char *  ptr,
int  element_size,
int  count,
FILE *  stream,
char *  filename 
)
Parameters
ptrtr
element_sizelement_size
countount
streamtream
filenameilename

Definition at line 214 of file file.c.

219 {
220  if(((int)fread(ptr, element_size, count, stream)) != count) {
221  pips_internal_error("fread failed on file %s (%s)",
222  filename, strerror(errno));
223  }
224  return(count);
225 }
static int count
Definition: SDG.c:519

References count, and pips_internal_error.

◆ safe_freopen()

FILE* safe_freopen ( char *  filename,
char *  what,
FILE *  stream 
)
Parameters
filenameilename
whathat
streamtream

Definition at line 99 of file file.c.

100 {
101  FILE *f;
102 
103  if((f = freopen( filename, what, stream)) == (FILE *) NULL) {
104  pips_internal_error("freopen failed on file %s (%s)",
105  filename,
106  strerror(errno));
107  }
108  return f;
109 }

References f(), and pips_internal_error.

+ Here is the call graph for this function:

◆ safe_fseek()

int safe_fseek ( FILE *  stream,
long int  offset,
int  wherefrom,
char *  filename 
)
Parameters
streamtream
offsetffset
wherefromherefrom
filenameilename

Definition at line 112 of file file.c.

113 {
114  if( fseek( stream, offset, wherefrom) != 0) {
115  pips_internal_error("fseek failed on file %s (%s)",
116  filename,
117  strerror(errno));
118  }
119  return(0);
120 }
static Value offset
Definition: translation.c:283

References offset, and pips_internal_error.

◆ safe_ftell()

long int safe_ftell ( FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 123 of file file.c.

124 {
125  long int pt;
126  pt = ftell( stream);
127  if((pt == -1L) && (errno != 0)) {
128  pips_internal_error("ftell failed on file %s (%s)",
129  filename,
130  strerror(errno));
131  }
132  return(pt);
133 }

References pips_internal_error.

◆ safe_fwrite()

int safe_fwrite ( char *  ptr,
int  element_size,
int  count,
FILE *  stream,
char *  filename 
)
Parameters
ptrtr
element_sizelement_size
countount
streamtream
filenameilename

Definition at line 227 of file file.c.

232 {
233  if(((int)fwrite(ptr, element_size, count, stream)) != count) {
234  pips_internal_error("fwrite failed on file %s (%s)",
235  filename,
236  strerror(errno));
237  }
238  return(count);
239 }

References count, and pips_internal_error.

◆ safe_get_line_interval()

string safe_get_line_interval ( const  string,
int  f,
int  l 
)

return lines f-l from file fn as a string

Parameters
stringn

Definition at line 539 of file file.c.

540 {
541  pips_assert("positive lines", 1 <= f && 1 <= l);
542 
543  if (l < f) {
544  // ooops, empty interval...
545  // TODO: generate an internal error instead
546  // however there are some impact on the validation...
547  string msg;
548  asprintf(&msg, "<empty interval on \"%s\": %d-%d>\n", fn, f, l);
549  return msg;
550  }
551 
552  FILE * fd = safe_fopen(fn, "r");
554 
555  // skip first lines
556  int i;
557  for (i = 1; i < f ; i++) {
558  char * line = safe_readline(fd);
559  pips_assert("expecting a line", line != NULL);
560  free(line);
561  }
562 
563  // keep next lines, although without preprocessor stuff
564  for (i = f; i <= l; i++)
565  {
566  char * line = safe_readline(fd);
567  // pips_assert("expecting a line", line != NULL);
568  if (line == NULL) break;
569 
570  // ??? skip preprocessor #... lines?
571  // I'm not sure that it really works (FC)
572  char * c = line;
573  while (*c && (*c == ' ' || *c == '\t')) c++;
574  if (*c == '#') // ??? preprocessor line?
575  i--;
576  else {
578  string_buffer_append(sb, "\n");
579  }
580 
581  free(line);
582  }
583 
584  // we are done
585  safe_fclose(fd, fn);
586 
587  string extract = string_buffer_to_string(sb);
589 
590  return extract;
591 }
#define asprintf
Definition: misc-local.h:225
string string_buffer_to_string(const string_buffer)
return malloc'ed string from string buffer sb

References asprintf, f(), free(), line, pips_assert, safe_fclose(), safe_fopen(), safe_readline(), string_buffer_append(), string_buffer_free(), string_buffer_make(), and string_buffer_to_string().

Referenced by c_parser_user_warning_alist().

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

◆ safe_getc()

int safe_getc ( FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 158 of file file.c.

159 {
160  int value;
161  if((value = getc( stream)) == EOF ) {
162  pips_internal_error("getc failed on file %s (%s)",
163  filename,
164  strerror(errno));
165  }
166  return(value);
167 }

References pips_internal_error.

◆ safe_link()

void safe_link ( const char *  topath,
const char *  frompath 
)

Create a hard link to topath.

That means that the file is accessible with the new name frompath too.

Throw a pips_internal_error() if it fails.

Parameters
topathopath
frompathrompath

Definition at line 878 of file file.c.

879 {
880  if (link(frompath, topath))
881  {
882  perror("[safe_link] ");
883  pips_internal_error("link(%s,%s) failed", frompath, topath);
884  }
885 }

References pips_internal_error.

Referenced by add_new_module_from_text().

+ Here is the caller graph for this function:

◆ safe_list_files_in_directory()

int safe_list_files_in_directory ( gen_array_t  files,
string  dir,
string  re,
bool(*)(const char *)  file_name_predicate 
)

returns a sorted arg list of files matching regular expression re in directory 'dir' and with file_name_predicate() returning true on the file name (for example use directory_exists_p to select directories, of file_exists_p to select regular files).

re has the ed syntax.

Return 0 on success, -1 on directory openning error.

Parameters
filesiles
diran allocated array
rethe directory we're interested in
file_name_predicateregular expression condition to list a file

Definition at line 250 of file file.c.

255 {
256  DIR * dirp;
257  struct dirent * dp;
258  int index = 0;
259 
260  pips_assert("some dir", strcmp(dir, "") != 0);
261 
262  dirp = opendir(dir);
263 
264  if (dirp != NULL)
265  {
266  regex_t re_compiled;
267 
268  if (regcomp(&re_compiled, re, REG_ICASE))
269  pips_user_error("regcomp() failed to compile \"%s\".\n", re);
270 
271  while((dp = readdir(dirp)) != NULL) {
272  if (!regexec(&re_compiled, dp->d_name, 0, NULL, 0))
273  {
274  char * full_file_name =
275  strdup(concatenate(dir, "/", dp->d_name, NULL));
276  if (file_name_predicate(full_file_name))
277  gen_array_dupaddto(files, index++, dp->d_name);
278  free(full_file_name);
279  }
280  }
281 
282  regfree(&re_compiled);
283 
284  closedir(dirp);
285  }
286  else
287  return -1;
288 
289  gen_array_sort(files);
290  return 0;
291 }
void gen_array_dupaddto(gen_array_t a, size_t i, void *what)
Definition: array.c:111
void gen_array_sort(gen_array_t a)
Definition: array.c:164

References concatenate(), free(), gen_array_dupaddto(), gen_array_sort(), pips_assert, pips_user_error, and strdup().

Referenced by generate_a_directory_menu(), hpfc_get_file_list(), and list_files_in_directory().

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

◆ safe_new_tmp_file()

char* safe_new_tmp_file ( char *  prefix)

SunOS forgets to declare this one.

extern char * mktemp(char *);

Returns
a new temporary file name, starting with "prefix". the name is freshly allocated.

FI: mkstemp() is being deprecated and it returns an integer, usable as file descriptor, not a character string.

Parameters
prefixrefix

Definition at line 935 of file file.c.

936 {
937  string name = strdup(concatenate(prefix, ".XXXXXX", NULL));
938  int desc = mkstemp(name);
939  pips_assert("could create temporary name", desc!=-1);
940  return name;
941 }
static const char * prefix

References concatenate(), pips_assert, prefix, and strdup().

Referenced by apply_eole_on_statement(), and parse_arguments().

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

◆ safe_putc()

int safe_putc ( int  ,
FILE *  ,
char *   
)

◆ safe_read_nth_line()

string safe_read_nth_line ( string  fn,
int  n 
)

Assumes "fn" is the name of a text file, opens it, and returns its nth line (starting with 1) in a newly allocated buffer, whatever the line length.

Returns NULL if it does not exist.

This function is used by the PIPS preprocessor and its parsers to print out the line where an error has been detected.

Parameters
fnn

Definition at line 523 of file file.c.

524 {
525  FILE * fd = safe_fopen(fn, "r");
526  int i = 0;
527 #define MAX_INPUT_LINE_SIZE (200)
529  // Skip n-1 lines
530  for(i=0; i<n-1; i++)
532  string nth_line = safe_readline(fd);
533  safe_fclose(fd, fn);
534  return nth_line;
535 }

References current_line, MAX_INPUT_LINE_SIZE, safe_fclose(), safe_fgets(), safe_fopen(), and safe_readline().

Referenced by csplit_parser_warning_alist().

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

◆ safe_readfile()

char* safe_readfile ( FILE *  file)

returns the file as an allocated string.


is dropped at the time.

Parameters
fileile

Definition at line 650 of file file.c.

651 {
652  char * line, * buf=NULL;
653  while ((line=safe_readline(file)))
654  {
655  if (buf)
656  {
657  buf = (char*)
658  realloc(buf, sizeof(char)*(strlen(buf)+strlen(line)+2));
659  strcat(buf, " ");
660  strcat(buf, line);
661  free(line);
662  }
663  else buf = line;
664  }
665  return buf;
666 }

References buf, free(), line, and safe_readline().

Referenced by safe_system_output().

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

◆ safe_readline()

char* safe_readline ( FILE *  file)

returns the allocated line read, whatever its length.

returns NULL on EOF. also some asserts. FC 09/97.

larger for trailing '\0'

Parameters
fileile

Definition at line 497 of file file.c.

498 {
499  int i=0, size = 20, c;
500  char * buf = (char*) malloc(sizeof(char)*size), * res;
501  pips_assert("malloc ok", buf);
502  while((c=getc(file)) && c!=EOF && c!='\n')
503  {
504  if (i==size-1) /* larger for trailing '\0' */
505  {
506  size+=20; buf = (char*) realloc((char*) buf, sizeof(char)*size);
507  pips_assert("realloc ok", buf);
508  }
509  buf[i++] = (char) c;
510  }
511  if (c==EOF && i==0) { res = NULL; free(buf); }
512  else { buf[i++] = '\0'; res = strdup(buf); free(buf); }
513  return res;
514 }

References buf, free(), malloc(), pips_assert, and strdup().

Referenced by clean_file(), declarations_read(), default_user_request(), get_first_main_module(), get_help_topic(), get_help_topics(), get_next_line(), handle_file(), load_meta_data(), process_user_file(), safe_get_line_interval(), safe_read_nth_line(), and safe_readfile().

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

◆ safe_rewind()

void safe_rewind ( FILE *  stream,
char *  filename 
)
Parameters
streamtream
filenameilename

Definition at line 136 of file file.c.

137 {
138  rewind( stream );
139  if(errno != 0) {
140  pips_internal_error("rewind failed on file %s (%s)",
141  filename,
142  strerror(errno));
143  }
144 }

References pips_internal_error.

◆ safe_symlink()

void safe_symlink ( const char *  topath,
const char *  frompath 
)
Parameters
topathopath
frompathrompath

Definition at line 862 of file file.c.

863 {
864  if (symlink(topath, frompath))
865  {
866  perror("[safe_symlink] ");
867  pips_internal_error("symlink(%s, %s) failed", topath, frompath);
868  }
869 }

References pips_internal_error.

◆ safe_system()

void safe_system ( string  command)

system.c

system.c

abort if fails. FC 09/95 the command to be executed

Parameters
commandommand

Definition at line 38 of file system.c.

39 {
40  int status = system(command);
41 
42  if (status)
43  pips_internal_error("Failed (ret: %d, sig: %d) for %s",
44  (status/0x100) & 0xff, status & 0xff, command);
45 }

References pips_internal_error.

Referenced by apply_eole_on_statement(), direct_change_directory(), edit_notify(), gpips_display_graph_file_display(), help_launch_pips_firefox(), hpfc_filter(), hpfc_install(), hpfc_make(), hpfc_print_file(), hpfc_run(), main(), print_c_code(), step_compile_generated_module(), and step_install().

+ Here is the caller graph for this function:

◆ safe_system_no_abort()

int safe_system_no_abort ( string  command)

the command to be executed

For portability reasons, do not use pips_user_warning() here

Parameters
commandommand

Definition at line 47 of file system.c.

48 {
49  int status = system(command);
50 
51  if (status == 127)
52  pips_internal_error("Could not execute : '%s'", command);
53 
54  if (status) {
55  /* For portability reasons, do not use pips_user_warning() here */
56  pips_user_warning("Failed (ret: %d, sig: %d) for '%s'\n",
57  (status/0x100) & 0xff, status & 0xff, command);
58  }
59 
60  return (status / 256) & 255;
61 }

References pips_internal_error, and pips_user_warning.

Referenced by check_delete_workspace(), check_input_file_syntax(), process_thru_C_pp(), process_thru_fortran_pp(), and unsplit_internal().

+ Here is the caller graph for this function:

◆ safe_system_no_abort_no_warning()

int safe_system_no_abort_no_warning ( string  command)

the command to be executed

Parameters
commandommand

Definition at line 63 of file system.c.

64 {
65  int status = system(command);
66 
67  if (status == 127)
68  pips_internal_error("Could not execute : '%s'", command);
69 
70  return (status / 256) & 255;
71 }

References pips_internal_error.

Referenced by unsplit_internal().

+ Here is the caller graph for this function:

◆ safe_system_output()

char* safe_system_output ( char *  what)

attempt shell substitutions to what.

returns NULL on errors.

on failures, do not stop it anyway...

Parameters
whathat

Definition at line 890 of file file.c.

891 {
892  char * result;
893  FILE * in;
894 
895  in = popen(what, "r");
896 
897  if (in==NULL) {
898  perror("[safe_system_output] ");
899  pips_internal_error("popen failed: %s", what);
900  }
901 
902  result = safe_readfile(in);
903 
904  if (pclose(in)) {
905  /* on failures, do not stop it anyway...
906  */
907  perror("[safe_system_output] ");
908  pips_user_warning("\n pclose failed: %s\n", what);
909  if (result) free(result), result = NULL;
910  }
911 
912  return result;
913 }
char * safe_readfile(FILE *file)
returns the file as an allocated string.
Definition: file.c:650

References free(), pips_internal_error, pips_user_warning, and safe_readfile().

Referenced by safe_system_substitute().

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

◆ safe_system_substitute()

char* safe_system_substitute ( char *  what)

returns what after variable, command and file substitutions.

the returned string is newly allocated. it's NULL on errors.

Parameters
whathat

Definition at line 919 of file file.c.

920 {
921  return safe_system_output(concatenate("echo ", what, NULL));
922 }
char * safe_system_output(char *what)
attempt shell substitutions to what.
Definition: file.c:890

References concatenate(), and safe_system_output().

Referenced by tp_substitutions().

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

◆ safe_unlink()

void safe_unlink ( const char *  file_name)

Delete the given file.

Throw a pips_internal_error() if it fails.

Parameters
file_nameile_name

Definition at line 852 of file file.c.

853 {
854  if (unlink(file_name))
855  {
856  perror("[safe_unlink] ");
857  pips_internal_error("unlink %s failed", file_name);
858  }
859 }

References file_name, and pips_internal_error.

Referenced by add_new_module_from_text(), apply_eole_on_statement(), filter_file(), and handle_include_file().

+ Here is the caller graph for this function:

◆ safe_vasprintf()

int safe_vasprintf ( char **  strp,
const char *  fmt,
va_list  args 
)
Parameters
strptrp
fmtmt
argsrgs

Definition at line 1398 of file message.c.

1399 {
1400  va_list acpy;
1401  va_copy(acpy, args);
1402  int ret = vasprintf(strp, fmt, acpy);
1403  pips_assert("vasprintf is ok", ret >= 0);
1404  va_end(acpy);
1405  return ret;
1406 }
#define ret(why, what)
true if not a remapping for old.
Definition: dynamic.c:986

References pips_assert, ret, and vasprintf().

Referenced by safe_asprintf().

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

◆ set_debug_level()

void set_debug_level ( const int  l)

SET_DEBUG_LEVEL is a function that sets the current debuging level to the value passed as argument.

Valid debuging values are from 0 to 9. 0 means no debug, 9 means extensive debug. Other values are illegal.

Definition at line 60 of file debug.c.

61 {
62  message_assert("debug level not in 0-9", l>=0 && l<=9);
64 }

References message_assert, and the_current_debug_level.

Referenced by debug_off_function(), debug_on_function(), and set_debug_stack_pointer().

+ Here is the caller graph for this function:

◆ set_debug_stack_pointer()

void set_debug_stack_pointer ( const int  i)

Definition at line 97 of file debug.c.

98 {
99  if(i >= 0 && i <= idls) {
100  if (i!=idls) {
101  pips_user_warning("debug level stack is set to %d\n", i);
102  idls = i;
104  }
105  }
106  else
107  pips_internal_error("value %d out of stack range [0..%d]. "
108  "Too many calls to debug_off()\n", i, idls);
109 }

References debug_stack, idls, level, pips_internal_error, pips_user_warning, and set_debug_level().

Referenced by catch_user_error(), pop_pips_context(), safe_do_something(), and tpips_exec().

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

◆ set_pips_current_computation()

void set_pips_current_computation ( const char *  rname,
const char *  oname 
)

message.c

Parameters
rnamename
onamename

Definition at line 65 of file message.c.

66 {
67  pips_assert("no current computation", !current_module && !current_phase);
68 
69  current_phase = strdup(rname);
70  current_module = strdup(oname);
71 }

References current_module, current_phase, pips_assert, and strdup().

Referenced by create_workspace(), and set_current_phase_context().

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

◆ set_pips_meta_informations()

void set_pips_meta_informations ( const char *  revs,
const char *  date,
const char *  comp 
)
Parameters
revsevs
dateate
compomp

Definition at line 102 of file message.c.

106 {
107  pips_revisions = (string) revs;
108  pips_date = (string) date;
109  pips_cc = (string) comp;
110 }

References pips_cc, pips_date, and pips_revisions.

Referenced by atinit(), gpips_main(), pips_init(), pips_main(), tpips_main(), and wpips_main().

+ Here is the caller graph for this function:

◆ sort_list_of_strings()

void sort_list_of_strings ( list  l)

Sort a list of strings.

Definition at line 59 of file args.c.

60 {
61  size_t number_of_strings = gen_length(l);
62  gen_array_t a = gen_array_make(number_of_strings);
63  list_to_array(l, a);
64  pips_assert("same length", number_of_strings == gen_array_nitems(a));
65  gen_array_sort(a);
67  gen_array_free(a);
68 }
void list_to_array(list l, gen_array_t a)
args.c
Definition: args.c:38
void update_list_from_array(list l, gen_array_t a)
Just modify the strings in a list from an array of strings.
Definition: args.c:49
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_free(gen_array_t a)
Definition: array.c:70
size_t gen_length(const list l)
Definition: list.c:150

References gen_array_free(), gen_array_make(), gen_array_nitems(), gen_array_sort(), gen_length(), list_to_array(), pips_assert, and update_list_from_array().

+ Here is the call graph for this function:

◆ start_dotting()

void start_dotting ( FILE *  dotting_file,
const char  dotting_character,
const char *  fmt,
  ... 
)

dotting.c

dotting.c

Emit a message and then a waiting character every second till it is notified to shut up.

Francois Irigoin, 18 April 1990

Modification:

  • installed in Lib/misc/dotting.c, 21 April 1990
  • no more dotting: in wpips, the window io associated to each dotting requires a malloc(); as it may occur at any time, malloc() (or free()) may be already active and wpips core dumps; (Francois Irigoin, Bruno Baron, ?? ???? 1990) start_dotting: the profile should be changed and varargs used so as to let user emit the initial message as with a fprintf the dotting character could be a constant (e.g. '.') or be passed as first argument start_dotting(dotting_file, dotting_character, format, args) ARARGS3
Parameters
dotting_fileotting_file
dotting_characterotting_character
fmtmt

Definition at line 78 of file dotting.c.

82 {
83  pips_debug(9, "dotting with '%c'", dotting_character);
84 
85  va_list args;
86 
87  va_start(args, fmt);
88 
89  if (dotting_file == stdout)
90  (* pips_log_handler)(fmt, &args);
91  else {
92  vfprintf(dotting_file, fmt, args);
93  if(dotting_file!=stderr) fflush(dotting_file);
94  }
95  va_end(args);
96 /*
97  if((int) signal(SIGALRM, print_dot)==-1) {
98  pips_internal_error("signal error");
99  exit(1);
100  }
101  alarm(1);
102  */
103 }

References pips_debug.

◆ stop_dotting()

void stop_dotting ( void  )

alarm(0); (void) signal(SIGALRM, SIG_DFL);

Vire le "\n" qui interfère... RK. if (dotting_file == stdout) user_log("\n"); else { (void) putc('
', dotting_file); if(dotting_file!=stderr) fflush(dotting_file); }

Definition at line 105 of file dotting.c.

106 {
107 /* alarm(0);
108  (void) signal(SIGALRM, SIG_DFL);
109 
110  Vire le "\n" qui interfère... RK.
111  if (dotting_file == stdout)
112  user_log("\n");
113  else {
114  (void) putc('\n', dotting_file);
115  if(dotting_file!=stderr) fflush(dotting_file);
116  }
117 */
118 }

◆ strescape()

char* strescape ( const char *  source)

protect a string, for example for use in a system call list of non escaped characters in the macro above.

Parameters
sourceource

Definition at line 334 of file file.c.

335 {
336  size_t new_size = 1; // for \0
337  for (const char *iter=source; *iter; ++iter,++new_size)
338  if (to_escape(*iter)) ++new_size;
339  char *escaped = malloc(sizeof(char)*new_size);
340  char *eiter = escaped;
341  for (const char *iter=source; *iter; ++iter,++eiter) {
342  if (to_escape(*iter)) *eiter++ = '\\';
343  *eiter = *iter;
344  }
345  *eiter=0;
346  return escaped;
347 }
#define to_escape(c)
Definition: file.c:327

References malloc(), and to_escape.

Referenced by check_delete_workspace(), check_input_file_syntax(), and process_thru_C_pp().

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

◆ update_list_from_array()

void update_list_from_array ( list  l,
gen_array_t  a 
)

Just modify the strings in a list from an array of strings.

The array of string must have at least as much as strings as in the list. No free is done.

Definition at line 49 of file args.c.

50 {
51  int index = 0;
52  MAPL(scons, STRING(CAR(scons)) = gen_array_item(a, index++), l);
53 }
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203

References CAR, gen_array_item(), MAPL, and STRING.

Referenced by sort_list_of_strings().

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

◆ user_log()

void user_log ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 234 of file message.c.

235 {
236  va_list args;
237  va_start(args, format);
238  pips_user_log_alist(format, &args);
239  va_end(args);
240 }

References pips_user_log_alist().

Referenced by abc_with_allocation_size(), add_new_compilation_unit(), add_new_module_from_text(), alias_check(), apply_a_rule(), array_bound_check_instrumentation(), array_bound_check_interprocedural(), array_dfg(), atomizer(), bottom_up_abc_base_reference_implied_do(), bottom_up_abc_call(), bottom_up_abc_reference(), check_input_file_syntax(), checkpoint_workspace(), clean_up_sequences_rewrite(), continue_create_workspace_notify(), create_workspace(), db_close_module(), db_save_workspace(), delete_some_resources(), display_alias_check_statistics(), display_alias_propagation_statistics(), display_bottom_up_abc_statistics(), display_clean_up_sequences_statistics(), display_impact_alias_statistics(), display_interprocedural_abc_statistics(), display_top_down_abc_statistics(), display_unspaghettify_statistics(), display_used_before_set_statistics(), do_resource_usage_check(), end_directory_notify(), find_statements_interactively_walker(), formal_array_resizing_bottom_up(), full_unroll(), full_unroll_pragma(), get_view_file(), gpips_display_graph_file_display(), gpips_user_request(), impact_check(), initialize_and_verify_common_variable(), initialize_and_verify_local_variable(), interactive_hyperplane_direction(), interactive_partitioning_matrix(), interprocedural_abc_arrays(), interprocedural_abc_statement_rwt(), lazy_open_module(), LinkInstToCurrentBlock(), logs_off(), loop_chunk_size_and_strip_mine(), main(), make_close_workspace(), make_special_value(), NewStmt(), notify_hpfc_file_view(), open_module(), open_workspace(), open_workspace_notify(), options_select(), parse_arguments(), pips_main(), pips_signal_handler(), print_array_dfg(), print_bdt(), print_code_static_control(), print_plc(), process_user_file(), put_summary(), referencenodeclfilter(), reindexing(), safe_concurrent_apply(), safe_do_something(), safe_set_property(), select_a_module_by_default(), select_rule(), set_env_log_and_free(), single_assign(), static_controlize(), stmt_flt(), strip_mine(), SubstituteAlternateReturns(), text_comp_region(), text_region_no_action(), top_down_abc_array(), tp_system(), unroll(), update_options(), UpdateEntity(), wpips_display_graph_file_display(), wpips_interrupt_pipsmake(), and wpips_user_request().

+ Here is the call graph for this function:

◆ user_request()

Variable Documentation

◆ pips_error_handler

void(* pips_error_handler) (const char *, const char *, va_list *) ( const char *  ,
const char *  ,
va_list *   
)
extern

PROMPT_USER schould be implemented.

(its a warning with consent of the user) The question is: how schould it be called? USER_ERROR is a function that should be called to terminate the current PIPS request execution or to restore the previous saved stack environment when an error in a Fortran file or elsewhere is detected. USER_ERROR first prints on stderr a description of the error, then tests the property ABORT_ON_USER_ERROR and aborts case true. Else it will restore the last saved stack environment (ie. come back to the last executed setjmp(pips_top_level) ), except for eventuality it has already been called. In this case, it terminates execution with exit. USER_ERROR should be called as:

USER_ERROR(fonction, format [, arg] ... )

where function is a string containing the name of the function calling USER_ERROR, and where format and arg-list are passed as arguments to vprintf.

Modifications:

  • user_error() was initially called when a Fortran syntax error was encountered by the parser; execution was stopped; this had to be changed because different kind of errors can occur and because pips is no longer structured using exec(); one has to go back to PIPS top level, in tpips or in wpips; (Francois Irigoin, 19 November 1990)
  • user_error() calls (* pips_error_handler) which can either be default_user_error or a user_error function specific to the used top-level. But each user_error function should have the same functionalities. default assignment of pips_error_handler is default_user_error. Some top-level (eg. wpips) may need a special user_error proceedure; they should let pips_error_handler point toward it.

Definition at line 455 of file message.c.

Referenced by atinit(), gpips_main(), pips_log_alist(), tpips_init(), and wpips_main().

◆ pips_internal_error_handler

void(* pips_internal_error_handler) (const char *, const char *,...) ( const char *  ,
const char *  ,
  ... 
)
extern

PIPS_ERROR is a function that should be called to terminate PIPS execution when data structures are corrupted.

PIPS_ERROR should be called as: PIPS_ERROR(fonction, format [, arg] ... ) where function is a string containing the name of the function calling PIPS_ERROR, and where format and arg-list are passed as arguments to vprintf. PIPS_ERROR terminates execution with abort.

Definition at line 511 of file message.c.

Referenced by pips_log_alist(), and tpips_init().

◆ pips_log_handler

void(* pips_log_handler) (const char *fmt, va_list *args) ( const char *  fmt,
va_list *  args 
)
extern

USER_LOG is a function that should be called to log the current PIPS request, as soon as it is relevant.

loging will occure if property USER_LOG_P is TRUE. USER_LOG should be called as:

USER_LOG(format [, arg] ... )

where format and arg-list are passed as arguments to vprintf. default assignment of pips_log_handler is default_user_log. Some top-level (eg. wpips) may need a special user_log proceedure; they should let pips_log_handler point toward it.

Every procedure pointed to by pips_log_handler must test the property USER_LOG_P; this is necessary because (* pips_log_handler) may be called anywhere (because VARARGS), whithout verifying it.

Definition at line 216 of file message.c.

Referenced by atinit(), gpips_main(), pips_log_alist(), and wpips_main().

◆ pips_request_handler

string(* pips_request_handler) (const char *, va_list *) ( const char *  ,
va_list *   
)
externdefault

default assignment of pips_request_handler is default_user_request.

Some top-level (eg. wpips) may need a special user_request proceedure; they should let pips_request_handler point toward it.

Definition at line 139 of file message.c.

145 {
146  va_list args;
147  va_start(args, a_message_format);
148  string str = (* pips_request_handler)(a_message_format, &args);
149  va_end(args);
150  return str;
151 }

Referenced by gpips_main(), tpips_init(), and wpips_main().

◆ pips_warning_handler

void(* pips_warning_handler) (const char *, const char *, va_list *) ( const char *  ,
const char *  ,
va_list *   
)
extern

default assignment of pips_warning_handler is default_user_warning.

Some top-level (eg. wpips) may need a special user_warning proceedure; they should let pips_warning_handler point toward it.

Definition at line 325 of file message.c.

Referenced by gpips_main(), pips_log_alist(), and wpips_main().

◆ the_current_debug_level

int the_current_debug_level
extern

cproto-generated files

debug.c

cproto-generated files

Modifications:

  • set_debug_level function has been changed. Mainly the condition test, from (l >= 0 || l <= 9) to (l >= 0 && l <= 9) and else clause has been added, that is pips_error function. (Mar. 21,91 L.Zhou )
  • debug_off(): idls– was replaced by (–idls)-1 (April 7, 1991, Francois Irigoin) I switched this variable from static to non-static in order to avoid a function call in the pips_debug macro. This does not mean that this variable is intended to be touch by anyone directly. the interface remains the set/get functions. Just to reduce the debuging impact on the performance (from low to very low:-) FC, May 95.

debug.c

Definition at line 277 of file misc.h.