25 #include "pips_config.h"
127 va_copy(acpy, *args);
128 fprintf(stdout,
"\nWaiting for your response: ");
129 vfprintf(stdout, fmt, acpy);
147 va_start(args, a_message_format);
148 string str = (* pips_request_handler)(a_message_format, &args);
155 #define LOG_FILE "Logfile"
180 if ((
log_file = fopen(log_file_name,
"a")) == NULL) {
182 "Check access rights.");
193 NULL, NULL, -1, NULL, NULL, -1, -1,
194 NULL, NULL, (
const string) desc);
221 NULL, NULL, -1, NULL, NULL, -1, -1,
222 NULL, NULL, (
const string) format, args);
228 va_start(args, format);
237 va_start(args, format);
247 #define PIPS_THANKS_STRING(arch) \
248 "%s (ARCH=" arch ")\n running as %s\n" \
250 " (c) 1989-2018 MINES ParisTech\n" \
251 " Centre de recherche en informatique.\n" \
253 " CRI URL: http://www.cri.mines-paristech.fr/\n" \
254 " PIPS URL: http://pips4u.org/\n" \
255 " EMAIL: pips-support at cri dot mines-paristech dot fr\n" \
257 " This software is provided as is, under the terms of the GPL.\n" \
258 " It includes and uses software from GNU (gnulib, readline),\n" \
259 " Berkeley (fsplit), INRIA, IRISA and others (polylib, janus)...\n" \
267 if (isatty(fileno(stdout)))
281 #define WARNING_FILE_NAME "Warnings"
307 const char * calling_function_name,
316 (
const string) calling_function_name, NULL, -1,
318 NULL, NULL, (
const string) format, args);
329 const char * function_name,
330 const char * funcfile,
340 (
const string) function_name, (
const string)funcfile, funcline,
342 NULL, NULL, (
const string) format, args);
347 const char * calling_function_name,
348 const char * funcfile,
354 va_start(args, format);
367 va_start(args, format);
376 const char * funcname,
377 const char * funcfile,
385 (
const string) funcname, (
const string) funcfile, funcline,
387 NULL, NULL, (
const string) format, args);
395 const char * funcname,
396 const char * funcfile,
413 va_start(args, format);
459 const char * calling_function_name,
460 const char * funcfile,
469 (
const string) calling_function_name, (
const string) funcfile, funcline,
471 NULL, NULL, (
const string) format, args);
479 const char * func_name,
480 const char * funcfile,
486 va_start(args, format);
497 va_start(args, format);
517 const char * func_name,
518 const char * funcfile,
526 (
const string) func_name, (
const string) funcfile, funcline,
528 NULL, NULL, (
const string) format, args);
536 const char * func_name,
537 const char * funcfile,
543 va_start(args, format);
555 va_start(args, format);
562 return strcmp(
s1, s2) == 0;
597 const string attribute,
613 if (!getenv(
"PIPS_VALIDATION_IN_PROGRESS"))
643 const string attribute,
675 const string pips_pass,
676 const string pips_owner,
677 const string pips_func,
678 const string pips_file,
685 if (pips_file && getenv(
"PIPS_VALIDATION_IN_PROGRESS"))
688 string short_file = strstr(pips_file,
"/src/");
703 const string pips_pass,
704 const string pips_owner,
705 const string pips_func,
706 const string pips_file,
708 const string user_func,
711 const int user_line2,
713 const string suggestion,
714 const string description)
732 pips_func, pips_file, pips_line);
737 while (*s && (*s ==
'\n' || *s ==
'\t' || *s ==
' ')) s++;
744 string desc = description;
745 while (desc && *desc && *desc ==
' ') desc++;
763 case -1:
return "ABORT";
765 case 1:
return "INTERNAL_ERROR";
767 default:
return "USER_ERROR";
774 const string pips_func,
775 const string pips_file,
777 const string description)
783 "<Exit Code=\"%d\" Status=\"%s\" Source=\"%s\">\n",
787 " <Description AppFunction=\"\" AppFile=\"\" "
788 "AppLine=\"\" Statement=\"\" Proposition=\"\" ");
791 pips_func, pips_file, pips_line);
805 const char * pips_func,
806 const char * pips_file,
808 const string description)
828 if (pips_file &&
code == -1)
829 fprintf(
out,
"at (\"%s\":%d) ", pips_file, pips_line);
831 if (description && *description)
834 fputs(description,
out);
839 fprintf(
out,
"Pips is done: %s\n", description);
848 const string pips_func,
849 const string pips_file,
864 tag,
code, pips_func, pips_file, pips_line, desc);
886 const string pips_func,
887 const string pips_file,
894 va_copy(acpy, *args);
906 const char * pips_func,
907 const char * pips_file,
916 va_start(args, format);
918 (
const string) pips_func, (
const string) pips_file, pips_line,
931 va_start(args, format);
943 case info_log:
return "information";
950 default:
return "<missing tag name>";
957 const string pips_pass,
958 const string pips_owner,
959 const string pips_func,
960 const string pips_file,
962 const string user_func,
965 const int user_line2,
967 const string suggestion,
968 const string description)
974 fprintf(
out,
"%s[%s] ", pips_pass, pips_owner? pips_owner:
"?");
984 fprintf(
out,
"(%s:%d) ", pips_file, pips_line);
988 if (user_func && !pips_owner) {
999 if (user_line < user_line2)
1010 if (user_line < user_line2)
1017 if (nl ||
stmt) fputc(
'\n',
out);
1021 while (*s && *s ==
'\n') s++;
1022 fprintf(
out,
"at statement:\n\n\t%s\n\n", s);
1026 fputs(description,
out);
1031 fputs(suggestion,
out);
1042 const string pips_pass,
1043 const string pips_owner,
1044 const string pips_func,
1045 const string pips_file,
1046 const int pips_line,
1047 const string user_func,
1049 const int user_line,
1050 const int user_line2,
1052 const string suggestion,
1057 pips_pass, pips_owner,
1058 pips_func, pips_file, pips_line,
1059 user_func,
user_file, user_line, user_line2,
1060 stmt, suggestion, desc);
1065 pips_pass, pips_owner,
1066 pips_func, pips_file, pips_line,
1067 user_func,
user_file, user_line, user_line2,
1068 stmt, suggestion, desc);
1073 pips_pass, pips_owner,
1074 pips_func, pips_file, pips_line,
1075 user_func,
user_file, user_line, user_line2,
1076 stmt, suggestion, desc);
1081 pips_pass, pips_owner,
1082 pips_func, pips_file, pips_line,
1083 user_func,
user_file, user_line, user_line2,
1084 stmt, suggestion, desc);
1090 const char * pips_func,
1091 const char * pips_file,
1092 const int pips_line)
1098 fprintf(stderr,
"pips_log recursion (%d) from %s (%s:%d)\n",
1144 pips_stop(
tag, 2,
"CLOSE_WORKSPACE_AND_QUIT_ON_ERROR");
1147 pips_stop(
tag, -1,
"too many property errors pending");
1153 static int user_error_called = 0;
1159 "over MAXIMUM_USER_ERROR=%d user errors",
1163 user_error_called++;
1175 const string pips_pass,
1176 const string pips_owner,
1177 const string pips_func,
1178 const string pips_file,
1179 const int pips_line,
1180 const string user_func,
1182 const int user_line,
1183 const int user_line2,
1185 const string suggestion,
1186 const string description)
1191 pips_func, pips_file, pips_line,
1192 user_func,
user_file, user_line, user_line2,
1193 stmt, suggestion, description);
1204 const string pips_pass,
1205 const string pips_owner,
1207 const string pips_func,
1208 const string pips_file,
1209 const int pips_line,
1211 const string user_func,
1213 const int user_line,
1214 const int user_line2,
1218 const string suggestion,
1219 const string format,
1225 string description = NULL;
1227 va_copy(acpy, *args);
1235 string desc = description;
1236 while (*desc && (*desc ==
'\n' || *desc ==
'\t' || *desc ==
'\r'))
1238 int last = strlen(desc) - 1;
1240 (desc[last] ==
'\n' || desc[last] ==
'\t' || desc[last] ==
' ' ||
1241 desc[last] ==
'\r'))
1242 desc[last--] =
'\0';
1246 pips_func, pips_file, pips_line,
1247 user_func,
user_file, user_line, user_line2,
1248 stmt, suggestion, desc);
1256 va_copy(acpy, *args);
1263 va_copy(acpy, *args);
1269 va_copy(acpy, *args);
1275 va_copy(acpy, *args);
1288 const string pips_func,
1289 const string pips_file,
1290 const int pips_line,
1294 const string pips_pass,
1295 const string pips_owner,
1297 const string user_func,
1299 const int user_line,
1300 const int user_line2,
1304 const string suggestion,
1305 const string format,
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);
1324 const char *
function,
1329 const string format,
1334 va_start(args, format);
1335 fprintf(stderr,
"(%s) [%s] stopping pips on code %d (%s) for ",
1337 vfprintf(stderr, format, args);
1339 fputs(
"\n", stderr);
1346 "<Exit Code=\"%d\" Status=\"%s\" Source=\"%s\">\n",
1354 " <Description AppFunction=\"\" AppFile=\"\" "
1355 "AppLine=\"\" Statement=\"\" Proposition=\"\" "
1356 "Pass=\"%s\" Owner=\"%s\" PipsFunction=\"%s\" ",
1359 if (file && getenv(
"PIPS_VALIDATION_IN_PROGRESS"))
1362 string short_file = strstr(file,
"/src/");
1364 "PipsFile=\"%s\" PipsLine=\"...\" ",
1365 short_file? short_file:
"...");
1374 va_start(args, format);
1401 va_copy(acpy, args);
1411 va_start(args, fmt);
bool too_many_property_errors_pending_p(void)
void _NORETURN_ pips_user_error_func2(const char *format,...)
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 format,...)
expecititely declare "noreturn" functions...
static void pips_stop_xml(pips_log_t tag, int code, const string pips_func, const string pips_file, const int pips_line, const string description)
int get_int_property(const string)
bool function_same_string_p(const char *s1, const char *s2)
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...
void _NORETURN_ pips_internal_error_func2(const char *format,...)
void pips_log_func(const string pips_func, const string pips_file, const int pips_line, const pips_log_t tag, const string pips_pass, const string pips_owner, 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,...)
direct pips_log call with format and free arguments ("...")
static void _NORETURN_ pips_user_error_alist(const char *calling_function_name, const char *funcfile, const int funcline, const char *format, va_list *args)
void pips_thanks(string name, string path)
display pips thanks on startup, if it on a tty.
void open_warning_file(const char *dir)
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...
static string current_phase
CATCH/TRY/UNCATCH/THROW stuff is here.
static void pips_log_done(void)
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
void close_log_file(void)
static string pips_log_xml_tag(pips_log_t tag)
static void pips_log_end(pips_log_t tag)
end of log entry (nothing, exception, abort, exit...)
void _NORETURN_ pips_stop_func2(pips_log_t tag, int code, const string format,...)
int safe_vasprintf(char **strp, const char *fmt, va_list args)
void open_xml_logfile(const char *filename)
static void _NORETURN_ pips_stop_desc(pips_log_t tag, int code, const string pips_func, const string pips_file, const int pips_line, const string desc)
int safe_asprintf(char **strp, const char *fmt,...)
void user_log(const char *format,...)
static string current_module
static string pips_revisions
static void pips_log_file(FILE *out, 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)
void log_on_file(const char *desc)
void _NORETURN_ pips_user_irrecoverable_error_func2(const char *format,...)
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
static string code2status(int code)
static void pips_log_xml_pips_level(string_buffer sb, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line)
append pips-level stuff (function, file, line) to xml file
void _NORETURN_ pips_internal_error_func(const char *funcname, const char *funcfile, const int funcline, const char *fmt,...)
void pips_user_log_func(const char *format,...)
void open_log_file(const string dir)
char * get_string_property(const char *)
bool properties_initialized_p(void)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static void append_xml_line_numbers(string_buffer sb, const string attribute, int val1, int val2)
#define WARNING_FILE_NAME
USER_WARNING issues a warning and don't stop the program (cf.
static void _NORETURN_ pips_internal_error_alist(const char *funcname, const char *funcfile, const int funcline, const char *format, va_list *args)
static void pips_stop_file(FILE *out, pips_log_t tag, int code, const char *pips_func, const char *pips_file, const int pips_line, const string description)
static string xml_logfile_name
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)
void _NORETURN_ pips_user_irrecoverable_error_func(const char *func_name, const char *funcfile, const int funcline, const char *format,...)
void close_warning_file(void)
void set_pips_current_computation(const char *rname, const char *oname)
message.c
string get_pips_current_pass_name(void)
Export this piece of information to customize warning functions in passes.
static void pips_log_in_progress(const char *pips_func, const char *pips_file, const int pips_line)
static FILE * xml_logfile
static FILE * warning_file
void reset_pips_current_computation(void)
static void pips_user_log_alist(const char *format, va_list *args)
static FILE * log_file
The log file is closed by default.
static void append_xml_attribute(string_buffer sb, const string attribute, const string value)
generate xml: attribute="escaped-stuff"
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...
string(* pips_request_handler)(const char *, va_list *)
default assignment of pips_request_handler is default_user_request.
#define PIPS_THANKS_STRING(arch)
The # "stringificator" only works in a macro expansion...
string pips_log_tag_name(pips_log_t tag)
void(* pips_error_handler)(const char *, const char *, va_list *)
PROMPT_USER schould be implemented.
string get_pips_current_module(void)
void _NORETURN_ pips_user_irrecoverable_error_alist(const char *func_name, const char *funcfile, const int funcline, const char *format, va_list *args)
void pips_user_warning_alist(const char *function_name, const char *funcfile, const int funcline, const char *format, va_list *args)
static string warning_file_name
void _NORETURN_ pips_user_error_func(const char *func_name, const char *funcfile, const int funcline, const char *format,...)
void pips_user_warning_func2(const char *format,...)
fallback version without a calling function name
void pips_user_warning_func(const char *calling_function_name, const char *funcfile, const int funcline, const char *format,...)
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.
void close_xml_logfile(void)
void set_pips_meta_informations(const char *revs, const char *date, const char *comp)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void append_to_warning_file(const char *calling_function_name, const char *format, va_list *args)
To be used in error handling functions.
static int pips_log_recursion_count
void(* pips_warning_handler)(const char *, const char *, va_list *)
default assignment of pips_warning_handler is default_user_warning.
static void pips_log_xml(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)
add a full log entry to the xml log file
void pips_log_stop(const char *function, const char *file, const int lineno, const pips_log_t tag, const int code, const string format,...)
quick log and stop, called on timeout this must not invoke malloc as it may still held locks if inter...
#define ret(why, what)
true if not a remapping for old.
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
char * safe_readline(FILE *file)
returns the allocated line read, whatever its length.
static FILE * user_file
These functions implements the writing of objects.
#define STRINGIFY(symbol)
If not using this 2-stage macro evaluation, the generated string is not the value of the macro but th...
#define pips_unknown_function
@ irrecoverable_error_log
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
string user_request(const char *,...)
string concatenate(const char *,...)
Return the concatenation of the given strings.
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_printf(string_buffer, const string,...)
append a formatted string to sb
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
string_buffer string_buffer_make(bool dup)
allocate a new string buffer
void string_buffer_cat(string_buffer, const string,...)
append a NULL terminated list of string to sb.
void string_buffer_append_xml_text(string_buffer, const string, bool)
append a string with XML escapes
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
internally defined structure.
int vasprintf(char **resultp, const char *format, va_list args)
Formatted output to strings.