PIPS
debug.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "genC.h"
#include "misc.h"
+ Include dependency graph for debug.c:

Go to the source code of this file.

Data Structures

struct  debug_level
 

Macros

#define STACK_LENGTH   50
 
#define MAX_MARGIN   (8)
 

Functions

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. 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 i)
 
void debug_on_function (const char *env, const char *function, const char *file, const int line)
 
void debug_off_function (const char *function, const char *file, const int line)
 
void print_debug_stack (void)
 function used to debug (can be called from dbx) BB 6.12.91 More...
 
void debug (const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
 ARARGS0. More...
 
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. More...
 
double get_process_memory_size (void)
 
double get_process_gross_heap_size (void)
 

Variables

int the_current_debug_level = 0
 Debugging functions. More...
 
static debug_level debug_stack [STACK_LENGTH]
 idls points to the first free bucket in debug_stack More...
 
static _int idls = 0
 

Macro Definition Documentation

◆ MAX_MARGIN

#define MAX_MARGIN   (8)

◆ STACK_LENGTH

#define STACK_LENGTH   50

Definition at line 72 of file debug.c.

Function Documentation

◆ 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
#define pips_internal_error
Definition: misc-local.h:149
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:

◆ 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_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 }

◆ 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:

◆ 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:

◆ 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 }
#define message_assert(msg, ex)
Definition: newgen_assert.h:47

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 }
#define pips_user_warning
Definition: misc-local.h:146

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:

Variable Documentation

◆ debug_stack

debug_level debug_stack[STACK_LENGTH]
static

idls points to the first free bucket in debug_stack

Definition at line 85 of file debug.c.

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

◆ idls

◆ the_current_debug_level

int the_current_debug_level = 0

Debugging functions.

Copyright 2007, 2008 Alain Muller, Frederique Silber-Chaussumier.

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 53 of file debug.c.

Referenced by debug(), get_debug_level(), outliner_patch_parameters(), pips_debug_function(), and set_debug_level().