PIPS
database.c File Reference
#include "genC.h"
#include "naming.h"
#include "private.h"
#include "pipsdbm_private.h"
#include <regex.h>
+ Include dependency graph for database.c:

Go to the source code of this file.

Data Structures

struct  t_tmp_result
 FI wants a sort... More...
 

Macros

#define IGNORE_RX   "PIPS_IGNORE_FUNCTION_RX"
 
#define db_resource_stored_p(r)   db_status_stored_p(db_resource_db_status(r))
 shorthands More...
 
#define db_resource_loaded_p(r)   db_status_loaded_p(db_resource_db_status(r))
 
#define db_resource_required_p(r)    db_status_required_p(db_resource_db_status(r))
 
#define db_resource_loaded_and_stored_p(r)    db_status_loaded_and_stored_p(db_resource_db_status(r))
 
#define DB_OK   pips_assert("defined database", !pips_database_undefined_p())
 the pips_database stores pips resources. More...
 
#define DB_UNDEF   pips_assert("undefined database", pips_database_undefined_p())
 
#define debug_db_resource(l, r, o, p)   ifdebug(l) { dump_db_resource(r, o, p);}
 
#define gen_DB_VOID_cons(i, l)   gen_cons(i,l)
 

Typedefs

typedef struct t_tmp_resultp_tmp_result
 

Functions

static bool simple_name_p (const char *name)
 Module names must use some characters. More...
 
static db_symbol find_or_create_db_symbol (const char *name)
 
void db_create_pips_database (void)
 exported interface is minimal. More...
 
static void db_clean_db_resources ()
 latter More...
 
bool db_open_pips_database (FILE *fd)
 
void db_save_pips_database (FILE *fd)
 
void db_close_pips_database (void)
 
void db_reset_pips_database_if_necessary (void)
 
static string db_status_string (db_status s)
 
static void dump_db_resource (const char *rname, const char *oname, db_resource r)
 
void dump_all_db_resource_status (FILE *file, string where)
 
static void init_owned_resources_if_necessary (const char *name)
 
static db_owned_resources get_db_owned_resources (const char *oname)
 
static db_resource get_resource (const char *rname, db_owned_resources or)
 
static db_resource get_db_resource (const char *rname, const char *oname)
 
static db_resource get_real_db_resource (const char *rname, const char *oname)
 
static db_resource find_or_create_db_resource (const char *rname, const char *oname)
 
void db_delete_resource (const char *rname, const char *oname)
 Delete a resource. More...
 
bool db_update_time (const char *rname, const char *oname)
 this should really be a put. More...
 
static p_tmp_result make_tmp_result (int t, const char *on, const char *rn)
 
static int tmp_result_cmp (const p_tmp_result *p1, const p_tmp_result *p2)
 
void db_print_all_required_resources (FILE *file)
 
void db_clean_all_required_resources (void)
 
bool db_resource_required_or_available_p (const char *rname, const char *oname)
 from now on we must not know about the database internals? More...
 
bool db_resource_is_required_p (const char *rname, const char *oname)
 true if exists and in required state. More...
 
bool db_resource_p (const char *rname, const char *oname)
 true if exists and in loaded or stored state. More...
 
bool db_touch_resource (const char *rname, const char *oname)
 touch logical time for resource[owner], possibly behind the back of pipsdbm. More...
 
static void db_check_time (const char *rname, const char *oname, db_resource r)
 
static void db_load_resource (const char *rname, const char *oname, db_resource r)
 
int db_time_of_resource (const char *rname, const char *oname)
 
static void db_save_resource (const char *rname, const char *oname, db_resource r)
 
static void db_save_and_free_resource (const char *rname, const char *oname, db_resource r, bool do_free)
 
string db_get_resource_id (const char *rname, const char *oname)
 some way to identify a resource... More...
 
string db_get_memory_resource (const char *rname, const char *oname, bool pure)
 Return the pointer to the resource, whatever it is. More...
 
void db_set_resource_as_required (const char *rname, const char *oname)
 
void db_put_or_update_memory_resource (const char *rname, const char *oname, void *p, bool update_is_ok)
 Put a resource into the current workspace database. More...
 
void db_invalidate_memory_resource (const char *rname, const char *oname)
 
int db_unput_resources (const char *rname)
 Delete all the resources of a given type "rname". More...
 
list db_retrieve_resources (const char *rname)
 Retrieve all the db resources of a given resource type, "rname". More...
 
static string db_resource_name_or_owner_name (db_resource dbr, bool owner_p)
 Retrieve the resource name, a.k.a. More...
 
string db_resource_name (void *dbr)
 To be used for debugging. More...
 
string db_resource_owner_name (void *dbr)
 To be used for debugging. More...
 
void db_save_and_free_memory_resource_if_any (const char *rname, const char *oname, bool do_free)
 
void db_delete_all_resources (void)
 FC: I added this function to clean all resources, hence avoiding to save them. More...
 
bool db_set_current_module_name (const char *name)
 
string db_get_current_module_name (void)
 Also used to check whether set... More...
 
void db_reset_current_module_name (void)
 
int db_delete_obsolete_resources (bool(*keep_p)(const char *, const char *))
 delete all obsolete resources before a close. More...
 
bool db_module_exists_p (const char *name)
 Return whether name is a "valid" module. More...
 
gen_array_t db_get_module_list_initial_order (void)
 
static gen_array_t db_get_module_or_function_list (bool module_p, bool func_p)
 Returns an allocated array a with the sorted list of modules. More...
 
gen_array_t db_get_module_list (void)
 Get an array of all the modules (functions, procedures and compilation units) of a workspace. More...
 
gen_array_t db_get_function_list (void)
 Get an array of all the functions and procedures (not compilation units) of a workspace. More...
 
gen_array_t db_get_compilation_unit_list (void)
 Get an array of all the compilation units of a workspace. More...
 

Variables

static char * current_module_name = NULL
 when telling the database about a module name, the module is registered as a db_symbol, and it is added to the database. More...
 

Macro Definition Documentation

◆ DB_OK

#define DB_OK   pips_assert("defined database", !pips_database_undefined_p())

the pips_database stores pips resources.

{init,close,set_reset,get}_pips_database() {store,load,delete,update,store_or_update}_pips_database() bound_pips_database_p()

Definition at line 104 of file database.c.

◆ db_resource_loaded_and_stored_p

#define db_resource_loaded_and_stored_p (   r)     db_status_loaded_and_stored_p(db_resource_db_status(r))

Definition at line 56 of file database.c.

◆ db_resource_loaded_p

#define db_resource_loaded_p (   r)    db_status_loaded_p(db_resource_db_status(r))

Definition at line 53 of file database.c.

◆ db_resource_required_p

#define db_resource_required_p (   r)     db_status_required_p(db_resource_db_status(r))

Definition at line 54 of file database.c.

◆ db_resource_stored_p

#define db_resource_stored_p (   r)    db_status_stored_p(db_resource_db_status(r))

shorthands

Definition at line 52 of file database.c.

◆ DB_UNDEF

#define DB_UNDEF   pips_assert("undefined database", pips_database_undefined_p())

Definition at line 105 of file database.c.

◆ debug_db_resource

#define debug_db_resource (   l,
  r,
  o,
 
)    ifdebug(l) { dump_db_resource(r, o, p);}

Definition at line 221 of file database.c.

◆ gen_DB_VOID_cons

#define gen_DB_VOID_cons (   i,
 
)    gen_cons(i,l)

Definition at line 401 of file database.c.

◆ IGNORE_RX

#define IGNORE_RX   "PIPS_IGNORE_FUNCTION_RX"

Definition at line 46 of file database.c.

Typedef Documentation

◆ p_tmp_result

typedef struct t_tmp_result * p_tmp_result

Function Documentation

◆ db_check_time()

static void db_check_time ( const char *  rname,
const char *  oname,
db_resource  r 
)
static

just check for updates

update time of actual resource if appropriate

??? just warn... may be a user error?

Definition at line 547 of file database.c.

548 {
549  pips_assert("resource is loaded",
551 
552  /* just check for updates */
553  if (displayable_file_p(rname))
554  {
555  int its_time = dbll_stat_local_file(db_resource_pointer(r), false);
556  if (its_time > db_resource_file_time(r))
557  {
558  pips_user_warning("file resource %s[%s] updated!\n", rname, oname);
559 
560  /* update time of actual resource if appropriate
561  */
564  {
565  pips_user_warning("file '%s' for %s[%s] edited (%d -> %d)\n",
566  db_resource_pointer(r), rname, oname,
567  db_resource_file_time(r), its_time);
568  db_resource_file_time(r) = its_time;
569 
573  }
574  }
575  }
576  else
577  {
578  int its_time = dbll_stat_resource_file(rname, oname, true);
579  if (its_time > db_resource_file_time(r))
580  {
581  /* ??? just warn... may be a user error? */
582  pips_user_warning("internal resource %s[%s] updated!\n", rname, oname);
583  }
584  }
585 }
#define db_resource_loaded_and_stored_p(r)
Definition: database.c:56
#define db_resource_loaded_p(r)
Definition: database.c:53
bool dbll_database_managed_file_p(const char *name)
returns whether the file is managed within the database.
Definition: lowlevel.c:376
int dbll_stat_local_file(const char *file_name, bool okifnotthere)
It is impportant that the workspace directory does not appear in the file name so as to allow workspa...
Definition: lowlevel.c:251
bool displayable_file_p(const char *name)
rather approximated.
Definition: lowlevel.c:361
int dbll_stat_resource_file(const char *rname, const char *oname, bool okifnotthere)
Definition: lowlevel.c:265
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
int db_inc_logical_time(void)
0 means not set...
Definition: workspace.c:107
int db_get_logical_time(void)
Definition: workspace.c:112
#define db_resource_pointer(x)
#define db_resource_time(x)
#define db_resource_file_time(x)

References db_get_logical_time(), db_inc_logical_time(), db_resource_file_time, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_pointer, db_resource_time, dbll_database_managed_file_p(), dbll_stat_local_file(), dbll_stat_resource_file(), displayable_file_p(), pips_assert, and pips_user_warning.

Referenced by db_load_resource(), and db_time_of_resource().

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

◆ db_clean_all_required_resources()

void db_clean_all_required_resources ( void  )

of db_symbols

Owner Symbol, Owned Resources

Resource Symbol, DB Resource

DEBUG?

Mark owner symbol os as to be deleted if set of owned resouces is empty.

maybe temporarily required by pipsmake but some error occured

Definition at line 460 of file database.c.

461 {
462  list /* of db_symbols */ owners_to_delete = NIL;
463  db_resources db = get_pips_database();
464 
465  /* Owner Symbol, Owned Resources */
466  DB_RESOURCES_MAP(os, or,
467  {
468  /* Resource Symbol, DB Resource */
470  {
471  string rn = db_symbol_name(rs);
472  string on = db_symbol_name(os);
473  pips_debug(8, "considering %s[%s] (%p)\n", rn, on, (void*) r);
474 
475  if (db_resource_required_p(r))
476  {
477  pips_debug(1, "deleting %s[%s]\n", rn, on);
478  dump_db_resource(rn, on, r); /* DEBUG? */
479  db_delete_resource(rn, on);
480  }
481  },
482  or);
483 
484  /* Mark owner symbol os as to be deleted if set of owned resouces is
485  empty. */
487  {
488  pips_user_warning("module '%s' to be deleted, no more resources owned.\n",
489  /* maybe temporarily required by pipsmake but some error occured */
490  db_symbol_name(os));
491 
492  owners_to_delete = CONS(DB_SYMBOL, os, owners_to_delete);
493  }
494  },
495  db);
496 
497  MAP(DB_SYMBOL, os, delete_db_resources(db, os), owners_to_delete);
498 }
db_owned_resources delete_db_resources(db_resources f, db_symbol k)
#define db_resource_required_p(r)
Definition: database.c:54
static void dump_db_resource(const char *rname, const char *oname, db_resource r)
Definition: database.c:183
void db_delete_resource(const char *rname, const char *oname)
Delete a resource.
Definition: database.c:353
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
int hash_table_entry_count(hash_table htp)
now we define observers in order to hide the hash_table type...
Definition: hash.c:818
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define DB_SYMBOL(x)
DB_SYMBOL.
#define DB_RESOURCES_MAP(k, v, c, f)
#define db_symbol_name(x)
#define DB_OWNED_RESOURCES_MAP(k, v, c, f)
#define db_owned_resources_hash_table(x)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, db_delete_resource(), db_owned_resources_hash_table, DB_OWNED_RESOURCES_MAP, db_resource_required_p, DB_RESOURCES_MAP, DB_SYMBOL, db_symbol_name, delete_db_resources(), dump_db_resource(), hash_table_entry_count(), MAP, NIL, pips_debug, and pips_user_warning.

Referenced by make(), and safe_do_something().

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

◆ db_clean_db_resources()

static void db_clean_db_resources ( )
static

latter

on checkpoints...

there are some incoherencies!

  • status may be 'loaded', but it is not true!
  • status may be 'required', but it is not true either.
  • also, as obsolete resources are not cleaned...

maybe the required stuff should be handled by pipsmake on its own?

scan

to be deleted later on

also if the file vanished... maybe on checkpoints where obsolete resources are not removed...

delete

Definition at line 295 of file database.c.

296 {
297  list lr = NIL, lo = NIL, lo_init = NIL, lr_init = NIL;
298 
299  /* scan */
300  DB_RESOURCES_MAP(os, or,
301  {
303  {
304  string rn = db_symbol_name(rs);
305  string on = db_symbol_name(os);
306  pips_debug(8, "considering %s[%s] (0x%p)\n", rn, on, (void*) r);
307 
308  if (db_resource_required_p(r))
309  {
310  pips_debug(1, "resource %s[%s] in state required...\n", rn, on);
311  /* to be deleted later on */
312  lr = CONS(STRING, rn, lr);
313  lo = CONS(STRING, on, lo);
314  }
315  /* also if the file vanished...
316  * maybe on checkpoints where obsolete resources are not removed...
317  */
318  else if (dbll_stat_resource_file(rn, on, true)==0)
319  {
320  pips_debug(1, "resource %s[%s] file vanished...\n", rn, on);
321  lr = CONS(STRING, rn, lr);
322  lo = CONS(STRING, on, lo);
323  }
325  {
326  pips_debug(1, "resource %s[%s] set as stored\n", rn, on);
328  db_resource_pointer(r) = NULL;
329  }
330  },
331  or)
332  },
333  get_pips_database());
334 
335  /* delete */
336  for (; lr && lo; lr = CDR(lr), lo = CDR(lo))
337  {
338  string rn = STRING(CAR(lr)), on = STRING(CAR(lo));
339  db_resource r = get_db_resource(rn, on);
340  pips_debug(1, "deleting required %s[%s]\n", rn, on);
341  dump_db_resource(rn, on, r);
342  db_delete_resource(rn, on);
343  }
344 
345  gen_free_list(lr_init);
346  gen_free_list(lo_init);
347 
349 }
static db_resource get_db_resource(const char *rname, const char *oname)
Definition: database.c:247
void dump_all_db_resource_status(FILE *file, string where)
Definition: database.c:198
static void db_clean_db_resources()
latter
Definition: database.c:295
#define STRING(x)
Definition: genC.h:87
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define db_resource_db_status(x)
#define db_status_tag(x)
@ is_db_status_stored
#define ifdebug(n)
Definition: sg.c:47

References CAR, CDR, CONS, db_delete_resource(), DB_OWNED_RESOURCES_MAP, db_resource_db_status, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_pointer, db_resource_required_p, DB_RESOURCES_MAP, db_status_tag, db_symbol_name, dbll_stat_resource_file(), dump_all_db_resource_status(), dump_db_resource(), gen_free_list(), get_db_resource(), ifdebug, is_db_status_stored, NIL, pips_debug, and STRING.

Referenced by db_open_pips_database().

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

◆ db_close_pips_database()

void db_close_pips_database ( void  )

Definition at line 150 of file database.c.

151 {
152  DB_OK; close_pips_database(); DB_UNDEF;
153 }
#define DB_UNDEF
Definition: database.c:105
#define DB_OK
the pips_database stores pips resources.
Definition: database.c:104

References DB_OK, and DB_UNDEF.

Referenced by save_meta_data().

+ Here is the caller graph for this function:

◆ db_create_pips_database()

void db_create_pips_database ( void  )

exported interface is minimal.

??? statement_mapping

Definition at line 109 of file database.c.

110 {
111  DB_UNDEF; init_pips_database(); DB_OK;
112 }

References DB_OK, and DB_UNDEF.

Referenced by db_create_workspace().

+ Here is the caller graph for this function:

◆ db_delete_all_resources()

void db_delete_all_resources ( void  )

FC: I added this function to clean all resources, hence avoiding to save them.

This speed up hpfc at low cost;-).

Definition at line 1030 of file database.c.

1031 {
1032  int nr = dbll_number_of_resources(), i;
1033  DB_OK;
1034  for (i=0; i<nr; i++)
1036 }
int db_unput_resources(const char *rname)
Delete all the resources of a given type "rname".
Definition: database.c:915
int dbll_number_of_resources(void)
Definition: lowlevel.c:108
string dbll_get_ith_resource_name(int i)
Definition: lowlevel.c:113

References DB_OK, db_unput_resources(), dbll_get_ith_resource_name(), and dbll_number_of_resources().

Referenced by delete_all_resources(), and delete_some_resources().

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

◆ db_delete_obsolete_resources()

int db_delete_obsolete_resources ( bool(*)(const char *, const char *)  keep_p)

delete all obsolete resources before a close.

return the number of resources destroyed.

of string

Definition at line 1076 of file database.c.

1077 {
1078  int ndeleted = 0;
1079  list /* of string */ lr = NIL, lo = NIL, lrp, lop;
1080  DB_OK;
1081  debug_on("PIPSDBM_DEBUG_LEVEL");
1082 
1083  // builds the lists to delete.
1084  pips_debug(4, "building list of resources to delete... (keep=%p)\n", keep_p);
1085  DB_RESOURCES_FOREACH(os, or, get_pips_database())
1086  {
1087  DB_OWNED_RESOURCES_FOREACH(rs, r, or)
1088  {
1089  string rn = db_symbol_name(rs), on = db_symbol_name(os);
1090  pips_debug(8, "considering %s of %s (%p)\n", rn, on, (void *) r);
1091  if (!db_resource_required_p(r) && !keep_p(rn, on)) {
1092  pips_debug(8, "to be destroyed: %s of %s\n", rn, on);
1093  ndeleted++;
1094  lr = CONS(STRING, rn, lr);
1095  lo = CONS(STRING, on, lo);
1096  }
1097  }
1098  }
1099 
1100  // delete the resources.
1101  pips_debug(4, "deleting obsolete resources...\n");
1102  for(lrp=lr, lop=lo; !ENDP(lrp); POP(lrp), POP(lop))
1103  {
1104  string rname = STRING(CAR(lrp)), oname = STRING(CAR(lop));
1105  db_delete_resource(rname, oname);
1106  dbll_unlink_resource_file(rname, oname, false);
1107  }
1108 
1109  gen_free_list(lr);
1110  gen_free_list(lo);
1111  pips_debug(4, "deleting obsolete resources done.\n");
1112  debug_off();
1113  return ndeleted;
1114 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
void dbll_unlink_resource_file(const char *rname, const char *oname, bool erroriffailed)
Definition: lowlevel.c:219
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
#define DB_RESOURCES_FOREACH(k, v, f)
#define DB_OWNED_RESOURCES_FOREACH(k, v, f)

References CAR, CONS, db_delete_resource(), DB_OK, DB_OWNED_RESOURCES_FOREACH, db_resource_required_p, DB_RESOURCES_FOREACH, db_symbol_name, dbll_unlink_resource_file(), debug_off, debug_on, ENDP, gen_free_list(), NIL, pips_debug, POP, and STRING.

Referenced by delete_obsolete_resources().

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

◆ db_delete_resource()

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

Delete a resource.

let us do it!

??? I should unlink the file

Parameters
rnamename
onamename

Definition at line 353 of file database.c.

354 {
355  db_resource r;
357  DB_OK;
358 
359  or = get_db_owned_resources(oname);
360  pips_assert("valid owned resources", !db_owned_resources_undefined_p(or));
361  r = get_resource(rname, or);
362  if (!db_resource_undefined_p(r))
363  {
364  /* let us do it! */
368  {
369  dbll_free_resource(rname, oname, db_resource_pointer(r));
370  /* ??? I should unlink the file */
371  }
372  db_resource_pointer(r) = NULL;
373  free_db_resource(r);
375  }
376 }
void free_db_resource(db_resource p)
db_resource delete_db_owned_resources(db_owned_resources f, db_symbol k)
static db_resource get_resource(const char *rname, db_owned_resources or)
Definition: database.c:238
static db_symbol find_or_create_db_symbol(const char *name)
Definition: database.c:85
static db_owned_resources get_db_owned_resources(const char *oname)
Definition: database.c:231
void dbll_free_resource(const char *rname, const char *oname, void *p)
Definition: lowlevel.c:313
#define db_owned_resources_undefined_p(x)
#define db_resource_undefined_p(x)

References DB_OK, db_owned_resources_undefined_p, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_pointer, db_resource_undefined_p, dbll_free_resource(), delete_db_owned_resources(), find_or_create_db_symbol(), free_db_resource(), get_db_owned_resources(), get_resource(), and pips_assert.

Referenced by db_clean_all_required_resources(), db_clean_db_resources(), db_delete_obsolete_resources(), db_get_memory_resource(), db_save_and_free_resource(), db_unput_resources(), outliner_independent(), and remove_a_resource().

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

◆ db_get_current_module_name()

◆ db_get_module_list_initial_order()

gen_array_t db_get_module_list_initial_order ( void  )

of db_symbol

Definition at line 1151 of file database.c.

1152 {
1153  list /* of db_symbol */ ls;
1154  db_resources dbr;
1155  gen_array_t a;
1156  // should this filtering out performed here? needed for UNSPLIT
1157  string ignore_rx = getenv(IGNORE_RX);
1158  regex_t ignore;
1159 
1160  DB_OK;
1161 
1162  if (ignore_rx && regcomp(&ignore, ignore_rx, 0))
1163  pips_user_error("recomp failed for \"%s\"", ignore_rx);
1164 
1165  // the list returned is reversed...
1167  a = gen_array_make(0);
1168  dbr = get_pips_database();
1169 
1170  // first extract compilation units
1171  FOREACH(DB_SYMBOL, symbol, ls)
1172  {
1173  string name = db_symbol_name(symbol);
1174  // if it is a module, append...
1175  if (!string_undefined_p(name) &&
1176  !same_string_p(name, "") &&
1177  // I should check that some actual resources is stored?
1178  bound_db_resources_p(dbr, symbol) &&
1179  compilation_unit_p(name))
1180  gen_array_dupappend(a, name);
1181  }
1182 
1183  // then extract functions
1184  FOREACH(DB_SYMBOL, symbol, ls)
1185  {
1186  string name = db_symbol_name(symbol);
1187  // if it is a module, append...
1188  if (!string_undefined_p(name) &&
1189  !same_string_p(name, "") &&
1190  // I should check that some actual resources is stored?
1191  bound_db_resources_p(dbr, symbol) &&
1192  !compilation_unit_p(name) &&
1193  (!ignore_rx || regexec(&ignore, name, 0, NULL, 0)))
1194  gen_array_dupappend(a, name);
1195  }
1196 
1197  gen_free_list(ls);
1198  return a;
1199 }
bool bound_db_resources_p(db_resources f, db_symbol k)
#define IGNORE_RX
Definition: database.c:46
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_dupappend(gen_array_t a, void *what)
Definition: array.c:117
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#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
static void symbol(Pproblem XX, int v)
N note: if use janus.c then not static DN.
Definition: isolve.c:113
#define pips_user_error
Definition: misc-local.h:147
#define same_string_p(s1, s2)
list gen_filter_tabulated(bool(*)(gen_chunk *), int)
returns the list of entities with this caracteristics.
Definition: tabulated.c:144
#define string_undefined_p(s)
Definition: newgen_types.h:41
#define db_symbol_domain
newgen_db_status_domain_defined

References bound_db_resources_p(), compilation_unit_p(), DB_OK, DB_SYMBOL, db_symbol_domain, db_symbol_name, FOREACH, gen_array_dupappend(), gen_array_make(), gen_filter_tabulated(), gen_free_list(), gen_true(), IGNORE_RX, pips_user_error, same_string_p, string_undefined_p, and symbol().

Referenced by step_compile_generated_module(), step_install(), and unsplit_internal().

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

◆ db_get_resource_id()

string db_get_resource_id ( const char *  rname,
const char *  oname 
)

some way to identify a resource...

could be an id...

Parameters
rnamename
onamename

Definition at line 704 of file database.c.

705 {
706  return (char*) get_real_db_resource(rname, oname);
707 }
static db_resource get_real_db_resource(const char *rname, const char *oname)
Definition: database.c:259

References get_real_db_resource().

Referenced by check_physical_resource_up_to_date(), make_required(), rmake(), and update_preserved_resources().

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

◆ db_invalidate_memory_resource()

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

Check the database coherency:

Get the database resource associated to the given resource:

Parameters
rnamename
onamename

Definition at line 897 of file database.c.

898 {
899  db_resource r;
900  /* Check the database coherency: */
901  DB_OK;
902 
903  /* Get the database resource associated to the given resource: */
904  r = find_or_create_db_resource(rname, oname);
907 }
static db_resource find_or_create_db_resource(const char *rname, const char *oname)
Definition: database.c:267
#define db_status_undefined_p(x)

References DB_OK, db_resource_db_status, db_resource_file_time, db_status_undefined_p, and find_or_create_db_resource().

+ Here is the call graph for this function:

◆ db_load_resource()

static void db_load_resource ( const char *  rname,
const char *  oname,
db_resource  r 
)
static

should it be checked elsewhere?

Definition at line 587 of file database.c.

588 {
589  pips_debug(7, "loading %s[%s]\n", rname, oname);
590  pips_assert("resource is stored", db_resource_stored_p(r));
591 
592  db_resource_pointer(r) = dbll_load_resource(rname, oname);
593 
594  if (dbll_very_special_resource_p(rname, oname))
596  else
598 
599  /* should it be checked elsewhere? */
600  db_check_time(rname, oname, r);
601 }
static void db_check_time(const char *rname, const char *oname, db_resource r)
Definition: database.c:547
#define db_resource_stored_p(r)
shorthands
Definition: database.c:52
bool dbll_very_special_resource_p(const char *rname, const char *oname)
Definition: lowlevel.c:119
void * dbll_load_resource(const char *rname, const char *oname)
Definition: lowlevel.c:294
@ is_db_status_loaded_and_stored
@ is_db_status_loaded

References db_check_time(), db_resource_db_status, db_resource_pointer, db_resource_stored_p, db_status_tag, dbll_load_resource(), dbll_very_special_resource_p(), is_db_status_loaded, is_db_status_loaded_and_stored, pips_assert, and pips_debug.

Referenced by db_get_memory_resource(), and db_time_of_resource().

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

◆ db_open_pips_database()

bool db_open_pips_database ( FILE *  fd)
Returns
whether okay.
Parameters
fdd

Definition at line 119 of file database.c.

120 {
121  db_resources rs;
122  DB_UNDEF;
123  rs = read_db_resources(fd);
124  if (db_resources_undefined_p(rs)) return false;
125  set_pips_database(rs);
126 
127  // coredump in copy if done on save in next function ???.
129 
130  ifdebug(1)
132 
133  DB_OK;
134  return true;
135 }
db_resources read_db_resources(FILE *f)
bool db_open_pips_database(FILE *fd)
Definition: database.c:119
#define true
Definition: newgen_types.h:81
#define db_resources_undefined_p(x)
return(s1)

References db_clean_db_resources(), DB_OK, db_resources_undefined_p, DB_UNDEF, dump_all_db_resource_status(), ifdebug, and read_db_resources().

Referenced by load_meta_data().

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

◆ db_print_all_required_resources()

void db_print_all_required_resources ( FILE *  file)

first collect result

then sort, dump and free

Parameters
fileile

Definition at line 421 of file database.c.

422 {
423  list lres = NIL;
424 
425  /* first collect result */
426  DB_RESOURCES_MAP(os, or,
427  {
429  {
430  string rn = db_symbol_name(rs);
431  string on = db_symbol_name(os);
432  pips_debug(8, "resource %s[%s] is %s\n",
434 
435  if (db_resource_required_p(r)) {
436  lres = CONS(DB_VOID,
437  make_tmp_result(db_resource_time(r), on, rn),
438  lres);
439  }
440  },
441  or);
442  },
443  get_pips_database());
444 
445  /* then sort, dump and free */
447 
448  MAPL(l,
449  {
450  p_tmp_result p = (p_tmp_result) CAR(l).e;
451  fprintf(file,
452  "resource %s[%s] is in 'required' status since %d\n",
453  p->res_name, p->owner_name, p->time);
454  free(p);
455  },
456  lres);
457  gen_free_list(lres);
458 }
static p_tmp_result make_tmp_result(int t, const char *on, const char *rn)
Definition: database.c:403
static int tmp_result_cmp(const p_tmp_result *p1, const p_tmp_result *p2)
Definition: database.c:412
struct t_tmp_result * p_tmp_result
static string db_status_string(db_status s)
Definition: database.c:163
void free(void *)
#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
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
Definition: list.c:796
int(* gen_cmp_func_t)(const void *, const void *)
Definition: newgen_types.h:114
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
FI wants a sort...
Definition: database.c:395
const char * res_name
Definition: database.c:398
const char * owner_name
Definition: database.c:397

References CAR, CONS, DB_OWNED_RESOURCES_MAP, db_resource_db_status, db_resource_required_p, db_resource_time, DB_RESOURCES_MAP, db_status_string(), db_symbol_name, fprintf(), free(), gen_free_list(), gen_sort_list(), make_tmp_result(), MAPL, NIL, t_tmp_result::owner_name, pips_debug, t_tmp_result::res_name, t_tmp_result::time, and tmp_result_cmp().

Referenced by make(), and rmake().

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

◆ db_reset_current_module_name()

void db_reset_current_module_name ( void  )

Definition at line 1064 of file database.c.

1065 {
1066  DB_OK; pips_assert("some current module name", current_module_name);
1068 }

References current_module_name, DB_OK, free(), and pips_assert.

Referenced by display(), make_close_workspace(), open_module(), and perform().

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

◆ db_reset_pips_database_if_necessary()

void db_reset_pips_database_if_necessary ( void  )

Definition at line 155 of file database.c.

156 {
157  // rough! memory leak...
158  if (!pips_database_undefined_p()) reset_pips_database();
159 }

Referenced by reset_meta_data().

+ Here is the caller graph for this function:

◆ db_resource_is_required_p()

bool db_resource_is_required_p ( const char *  rname,
const char *  oname 
)

true if exists and in required state.

Parameters
rnamename
onamename

Definition at line 512 of file database.c.

513 {
514  db_resource r;
515  DB_OK;
516  r = get_db_resource(rname, oname);
518  return false;
519  else
520  return db_resource_required_p(r);
521 }

References DB_OK, db_resource_required_p, db_resource_undefined_p, and get_db_resource().

Referenced by rmake().

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

◆ db_resource_name()

string db_resource_name ( void *  dbr)

To be used for debugging.

Parameters
dbrbr

Definition at line 1000 of file database.c.

1001 {
1002  return db_resource_name_or_owner_name((db_resource) dbr, false);
1003 }
static string db_resource_name_or_owner_name(db_resource dbr, bool owner_p)
Retrieve the resource name, a.k.a.
Definition: database.c:975

References db_resource_name_or_owner_name().

Referenced by make_cache_consistent_p(), print_make_cache(), and remove_resource_from_make_cache().

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

◆ db_resource_name_or_owner_name()

static string db_resource_name_or_owner_name ( db_resource  dbr,
bool  owner_p 
)
static

Retrieve the resource name, a.k.a.

kind or nature, or the resource owner name of db_resource "dbr" according to "owner_p".

The two-level mapping must be inverted.

string_undefined is returned if "dbr" is not found in the current resource database.

This is used for interactive debugging and for debug messages.

Definition at line 975 of file database.c.

976 {
977  string name = string_undefined;
978  DB_OK;
979  DB_RESOURCES_MAP(s1, or,
980  {
981  pips_debug(9, "Resources for module \"%s\":\n", db_symbol_name(s1));
982  DB_OWNED_RESOURCES_MAP(s2, dbr21,
983  {
984  pips_debug(9, "\t\"%s\":\n", db_symbol_name(s2));
985  if(dbr==dbr21) {
986  if(owner_p)
987  name = db_symbol_name(s1);
988  else
989  name = db_symbol_name(s2);
990  break;
991  }
992  },
993  or);
994  },
995  get_pips_database());
996  return name;
997 }
#define string_undefined
Definition: newgen_types.h:40
s1
Definition: set.c:247

References DB_OK, DB_OWNED_RESOURCES_MAP, DB_RESOURCES_MAP, db_symbol_name, pips_debug, s1, and string_undefined.

Referenced by db_resource_name(), and db_resource_owner_name().

+ Here is the caller graph for this function:

◆ db_resource_owner_name()

string db_resource_owner_name ( void *  dbr)

To be used for debugging.

Parameters
dbrbr

Definition at line 1006 of file database.c.

1007 {
1008  return db_resource_name_or_owner_name((db_resource) dbr, true);
1009 }

References db_resource_name_or_owner_name().

Referenced by make_cache_consistent_p(), print_make_cache(), and remove_resource_from_make_cache().

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

◆ db_resource_p()

◆ db_resource_required_or_available_p()

bool db_resource_required_or_available_p ( const char *  rname,
const char *  oname 
)

from now on we must not know about the database internals?

true if exists and in ANY state.

Parameters
rnamename
onamename

Definition at line 505 of file database.c.

506 {
507  DB_OK;
508  return !db_resource_undefined_p(get_db_resource(rname, oname));
509 }

References DB_OK, db_resource_undefined_p, and get_db_resource().

Referenced by AddEntityToCompilationUnit(), outliner_independent(), RemoveEntityFromCompilationUnit(), and step_analysed_module_p().

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

◆ db_retrieve_resources()

list db_retrieve_resources ( const char *  rname)

Retrieve all the db resources of a given resource type, "rname".

Scan all module hash tables to find all resources of kind "rname", no matter what the owner is.

Used only to clean up the make cache in pipsmake.c.

Derived from db_unput_resources()

Scan all resource maps or of owners

See if it contains a resource of kind rname, normalized to r

Parameters
rnamename

Definition at line 943 of file database.c.

944 {
945  list rl = NIL;
946  db_symbol r;
947  DB_OK;
948  r = find_or_create_db_symbol(rname);
949  /* Scan all resource maps or of owners */
950  DB_RESOURCES_MAP(s, or,
951  {
952  pips_debug(9, "Resources for owner \"%s\"\n", (string) s);
953  /* See if it contains a resource of kind rname,
954  normalized to r */
955  if (bound_db_owned_resources_p(or, r)) {
956  /* */
957  db_resource dbr = get_resource(rname, or);
958  rl = CONS(DB_RESOURCE, dbr, rl);
959  }
960  },
961  get_pips_database());
962  return rl;
963 }
bool bound_db_owned_resources_p(db_owned_resources f, db_symbol k)
#define DB_RESOURCE(x)
DB_RESOURCE.

References bound_db_owned_resources_p(), CONS, DB_OK, DB_RESOURCE, DB_RESOURCES_MAP, find_or_create_db_symbol(), get_resource(), NIL, and pips_debug.

Referenced by delete_named_resources().

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

◆ db_save_and_free_memory_resource_if_any()

void db_save_and_free_memory_resource_if_any ( const char *  rname,
const char *  oname,
bool  do_free 
)
Parameters
rnamename
onamename
do_freeo_free

Definition at line 1012 of file database.c.

1014 {
1015  db_resource r;
1016  DB_OK;
1017 
1018  pips_debug(8, "maybe saving%s... %s[%s]\n",
1019  do_free? " and freeing":"", rname, oname);
1020 
1021  r = get_db_resource(rname, oname);
1022  if (!db_resource_undefined_p(r) &&
1024  db_save_and_free_resource(rname, oname, r, do_free);
1025 }
static void db_save_and_free_resource(const char *rname, const char *oname, db_resource r, bool do_free)
Definition: database.c:648

References DB_OK, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_undefined_p, db_save_and_free_resource(), get_db_resource(), and pips_debug.

Referenced by db_close_module().

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

◆ db_save_and_free_resource()

static void db_save_and_free_resource ( const char *  rname,
const char *  oname,
db_resource  r,
bool  do_free 
)
static

??? manual fix for entities... which are not well integrated.

is loaded

lost.. just delete the resource.

Definition at line 648 of file database.c.

650 {
651  pips_debug(7, "saving%s... %s[%s]\n",
652  do_free? " and freeing": "", rname, oname);
653 
654  pips_assert("resource is loaded",
656 
658  {
659  if (do_free) {
660  dbll_free_resource(rname, oname, db_resource_pointer(r));
662  db_resource_pointer(r) = NULL;
663  }
664  return;
665  }
666  else if (dbll_storable_p(rname))
667  {
668  dbll_save_and_free_resource(rname, oname,
669  db_resource_pointer(r), do_free);
670  if (do_free)
671  {
672  db_resource_pointer(r) = NULL;
674  }
675  else
676  {
677  /* ??? manual fix for entities... which are not well integrated. */
678  if (!dbll_very_special_resource_p(rname, oname))
679  {
682  }
683  else /* is loaded */
684  {
686  }
687  }
688 
689  db_resource_file_time(r) = dbll_stat_resource_file(rname, oname, true);
690  }
691  else
692  { /* lost.. just delete the resource. */
693  if (do_free)
694  {
695  dbll_free_resource(rname, oname, db_resource_pointer(r));
696  db_resource_pointer(r) = NULL;
697  db_delete_resource(rname, oname);
698  }
699  }
700 }
bool dbll_storable_p(const char *rname)
Definition: lowlevel.c:341
void dbll_save_and_free_resource(const char *rname, const char *oname, void *p, bool do_free)
Definition: lowlevel.c:350

References db_delete_resource(), db_resource_db_status, db_resource_file_time, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_pointer, db_status_tag, dbll_free_resource(), dbll_save_and_free_resource(), dbll_stat_resource_file(), dbll_storable_p(), dbll_very_special_resource_p(), is_db_status_loaded, is_db_status_loaded_and_stored, is_db_status_stored, pips_assert, and pips_debug.

Referenced by db_save_and_free_memory_resource_if_any().

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

◆ db_save_pips_database()

void db_save_pips_database ( FILE *  fd)

db_resources dbres;

??? check for required resources left over?

save a cleaned COPY with status artificially set as STORED...

dbres = copy_db_resources(get_pips_database()); db_clean_db_resources(dbres);

free_db_resources(dbres);

Parameters
fdd

Definition at line 137 of file database.c.

138 {
139  /* db_resources dbres; */
140  DB_OK;
141  /* ??? check for required resources left over? */
142 
143  /* save a cleaned COPY with status artificially set as STORED... */
144  /* dbres = copy_db_resources(get_pips_database());
145  db_clean_db_resources(dbres);*/
146  write_db_resources(fd, get_pips_database());
147  /* free_db_resources(dbres); */
148 }
void write_db_resources(FILE *f, db_resources p)

References DB_OK, and write_db_resources().

Referenced by save_meta_data().

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

◆ db_save_resource()

static void db_save_resource ( const char *  rname,
const char *  oname,
db_resource  r 
)
static

already saved

let us set the file time if appropriate...

Definition at line 627 of file database.c.

628 {
629  pips_debug(7, "saving %s[%s]\n", rname, oname);
630  pips_assert("resource loaded",
632 
633  if (!dbll_storable_p(rname))
634  pips_internal_error("cannot store %s\n",rname);
635 
636  /* already saved */
638  return;
639 
640  dbll_save_resource(rname, oname, db_resource_pointer(r));
642 
643  /* let us set the file time if appropriate... */
644  if (!displayable_file_p(rname))
645  db_resource_file_time(r) = dbll_stat_resource_file(rname, oname, true);
646 }
void dbll_save_resource(const char *rname, const char *oname, void *p)
save rname of oname p.
Definition: lowlevel.c:275
#define pips_internal_error
Definition: misc-local.h:149

References db_resource_db_status, db_resource_file_time, db_resource_loaded_and_stored_p, db_resource_loaded_p, db_resource_pointer, db_status_tag, dbll_save_resource(), dbll_stat_resource_file(), dbll_storable_p(), displayable_file_p(), is_db_status_stored, pips_assert, pips_debug, and pips_internal_error.

Referenced by db_get_memory_resource().

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

◆ db_set_current_module_name()

bool db_set_current_module_name ( const char *  name)

can be rejected softly

Parameters
nameame

Definition at line 1045 of file database.c.

1046 {
1047  bool ok = false;
1048  DB_OK; pips_assert("no current module", !current_module_name);
1049  if (simple_name_p(name)) {
1050  current_module_name = strdup(name);
1052  ok = true;
1053  } else /* can be rejected softly */
1054  pips_user_warning("invalid module name \"%s\"\n", name);
1055  return ok;
1056 }
static bool simple_name_p(const char *name)
Module names must use some characters.
Definition: database.c:80
static void init_owned_resources_if_necessary(const char *name)
Definition: database.c:223
char * strdup()
static bool ok

References current_module_name, DB_OK, init_owned_resources_if_necessary(), ok, pips_assert, pips_user_warning, simple_name_p(), and strdup().

Referenced by display(), open_module(), and perform().

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

◆ db_set_resource_as_required()

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

newly created db_resource...

Parameters
rnamename
onamename

Definition at line 797 of file database.c.

798 {
799  db_resource r;
800  db_status s;
801  DB_OK;
802 
803  pips_debug(5, "set %s[%s] as required at %d\n", rname, oname,
805 
806  r = find_or_create_db_resource(rname, oname);
807  s = db_resource_db_status(r);
808  if (db_status_undefined_p(s)) {
809  /* newly created db_resource... */
811  }
812  else
813  {
814  pips_debug(1, "set %s[%s] as 'required' from '%s' at %d\n",
815  rname, oname,
818 
821  {
822  dbll_free_resource(rname, oname, db_resource_pointer(r));
823  db_resource_pointer(r) = NULL;
824  }
825  }
826 
829 }
db_status make_db_status(enum db_status_utype tag, void *val)
#define UU
Definition: newgen_types.h:98
#define db_status_loaded_and_stored_p(x)
@ is_db_status_required
#define db_status_loaded_p(x)

References db_get_logical_time(), DB_OK, db_resource_db_status, db_resource_pointer, db_resource_time, db_status_loaded_and_stored_p, db_status_loaded_p, db_status_string(), db_status_tag, db_status_undefined_p, dbll_free_resource(), find_or_create_db_resource(), is_db_status_required, make_db_status(), pips_debug, and UU.

Referenced by rmake().

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

◆ db_status_string()

static string db_status_string ( db_status  s)
static

Definition at line 163 of file database.c.

164 {
165  if (db_status_undefined_p(s))
166  return "undefined";
167  switch (db_status_tag(s))
168  {
169  case is_db_status_stored:
170  return "stored";
171  case is_db_status_loaded:
172  return "loaded";
174  return "required";
176  return "loaded&stored";
177  default:
178  pips_internal_error("unexpected db_status tag %d\n", db_status_tag(s));
179  return NULL;
180  }
181 }

References db_status_tag, db_status_undefined_p, is_db_status_loaded, is_db_status_loaded_and_stored, is_db_status_required, is_db_status_stored, and pips_internal_error.

Referenced by db_print_all_required_resources(), db_set_resource_as_required(), dump_all_db_resource_status(), and dump_db_resource().

+ Here is the caller graph for this function:

◆ db_time_of_resource()

int db_time_of_resource ( const char *  rname,
const char *  oname 
)

we load the resource if it is a simple file name... the file time stamps are checked here anyway.

will update time if needed.

may update time...

Parameters
rnamename
onamename

Definition at line 603 of file database.c.

604 {
605  db_resource r;
606  DB_OK;
607 
608  r = get_db_resource(rname, oname);
609 
611  return -1;
612 
613  /* we load the resource if it is a simple file name...
614  * the file time stamps are checked here anyway.
615  */
616  if (displayable_file_p(rname))
617  {
618  if (db_resource_stored_p(r))
619  db_load_resource(rname, oname, r); /* will update time if needed. */
620  else
621  db_check_time(rname, oname, r); /* may update time... */
622  }
623 
624  return db_resource_time(r);
625 }
static void db_load_resource(const char *rname, const char *oname, db_resource r)
Definition: database.c:587

References db_check_time(), db_load_resource(), DB_OK, db_resource_required_p, db_resource_stored_p, db_resource_time, db_resource_undefined_p, displayable_file_p(), and get_db_resource().

Referenced by check_physical_resource_up_to_date(), and rmake().

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

◆ db_touch_resource()

bool db_touch_resource ( const char *  rname,
const char *  oname 
)

touch logical time for resource[owner], possibly behind the back of pipsdbm.

Parameters
rnamename
onamename

Definition at line 538 of file database.c.

539 {
540  db_resource r;
541  DB_OK;
542  r = get_real_db_resource(rname, oname);
544  return true;
545 }

References db_get_logical_time(), DB_OK, db_resource_time, and get_real_db_resource().

Referenced by AddEntityToCompilationUnit(), linearize_array_generic(), normalize_microcode(), outliner_independent(), preserve_virtual_resource(), RemoveEntityFromCompilationUnit(), sort_parameters(), and touch_a_resource().

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

◆ db_unput_resources()

int db_unput_resources ( const char *  rname)

Delete all the resources of a given type "rname".

Return the number of deleted resources

Each owner map has to be checked because of two-level mapping used.

Parameters
rnamename

Definition at line 915 of file database.c.

916 {
917  db_symbol r;
918  int count = 0;
919  DB_OK;
920  r = find_or_create_db_symbol(rname);
921  DB_RESOURCES_MAP(s, or,
922  {
923  pips_debug(7, "deleting %s[%s] if any\n", rname, db_symbol_name(s));
924  if (bound_db_owned_resources_p(or, r)) {
926  dbll_unlink_resource_file(rname, db_symbol_name(s), false);
927  count ++;
928  }
929  },
930  get_pips_database());
931  return count;
932 }
static int count
Definition: SDG.c:519

References bound_db_owned_resources_p(), count, db_delete_resource(), DB_OK, DB_RESOURCES_MAP, db_symbol_name, dbll_unlink_resource_file(), find_or_create_db_symbol(), and pips_debug.

Referenced by activate_phase(), db_delete_all_resources(), and delete_named_resources().

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

◆ db_update_time()

bool db_update_time ( const char *  rname,
const char *  oname 
)

this should really be a put.

Just there for upward compatibility.

bll_stat_resource_file(rname, oname, true);

Parameters
rnamename
onamename

Definition at line 380 of file database.c.

381 {
382  db_resource r;
383  DB_OK;
384  pips_assert("displayable resource", displayable_file_p(rname));
385  r = get_real_db_resource(rname, oname);
388  dbll_stat_local_file((char*) db_resource_pointer(r), false);
389  /*dbll_stat_resource_file(rname, oname, true); */
390  return true;
391 }

References db_get_logical_time(), DB_OK, db_resource_file_time, db_resource_pointer, db_resource_time, dbll_stat_local_file(), displayable_file_p(), get_real_db_resource(), and pips_assert.

+ Here is the call graph for this function:

◆ dump_all_db_resource_status()

void dump_all_db_resource_status ( FILE *  file,
string  where 
)
Parameters
fileile
wherehere

Definition at line 198 of file database.c.

199 {
200  pips_debug(1, "doing at '%s'\n", where);
201 
202  DB_RESOURCES_MAP(os, or,
203  {
205  {
206  string rn = db_symbol_name(rs);
207  string on = db_symbol_name(os);
208  fprintf(file, "resource %s[%s] status '%s' since %td (%td) 0x%p\n",
209  rn, on,
211  db_resource_time(r),
214  },
215  or);
216  },
217  get_pips_database());
218 
219 }

References DB_OWNED_RESOURCES_MAP, db_resource_db_status, db_resource_file_time, db_resource_pointer, db_resource_time, DB_RESOURCES_MAP, db_status_string(), db_symbol_name, fprintf(), and pips_debug.

Referenced by db_checkpoint_workspace(), db_clean_db_resources(), and db_open_pips_database().

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

◆ dump_db_resource()

static void dump_db_resource ( const char *  rname,
const char *  oname,
db_resource  r 
)
static

Definition at line 183 of file database.c.

185 {
186  ifdebug(1)
187  {
188  pips_debug(1, "rname=%s, oname=%s, r=%p\n", rname, oname, r);
189  if (!db_resource_undefined_p(r)) {
191  pips_debug(1, "pointer=%p, status=%s, time=%td, file_time=%td\n",
194  }
195  }
196 }

References db_resource_db_status, db_resource_file_time, db_resource_pointer, db_resource_time, db_resource_undefined_p, db_status_string(), ifdebug, and pips_debug.

Referenced by db_clean_all_required_resources(), and db_clean_db_resources().

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

◆ find_or_create_db_resource()

static db_resource find_or_create_db_resource ( const char *  rname,
const char *  oname 
)
static

still lazy...

create it

Definition at line 267 of file database.c.

268 {
269  db_resource r;
271  or = get_db_owned_resources(oname);
273  { /* still lazy... */
274  pips_debug(1, "module %s should have been registered\n", oname);
276  or = get_db_owned_resources(oname);
277  }
278  r = get_resource(rname, or);
280  { /* create it */
282  r = make_db_resource(NULL, db_status_undefined, 0, 0);
283  extend_db_owned_resources(or, rs, r);
284  }
285  return r;
286 }
db_resource make_db_resource(db_void a1, db_status a2, intptr_t a3, intptr_t a4)
void extend_db_owned_resources(db_owned_resources f, db_symbol k, db_resource v)
#define db_status_undefined

References db_owned_resources_undefined_p, db_resource_undefined_p, db_status_undefined, extend_db_owned_resources(), find_or_create_db_symbol(), get_db_owned_resources(), get_resource(), init_owned_resources_if_necessary(), make_db_resource(), and pips_debug.

Referenced by db_invalidate_memory_resource(), db_put_or_update_memory_resource(), and db_set_resource_as_required().

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

◆ find_or_create_db_symbol()

static db_symbol find_or_create_db_symbol ( const char *  name)
static

Definition at line 85 of file database.c.

86 {
88  if (!simple_name_p(name))
89  pips_user_warning("strange name \"%s\"\n", name);
90  return db_symbol_undefined_p(s)? make_db_symbol(strdup(name)): s;
91 }
db_symbol make_db_symbol(string a1)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define db_symbol_undefined_p(x)

References db_symbol_domain, db_symbol_undefined_p, gen_find_tabulated(), make_db_symbol(), pips_user_warning, simple_name_p(), and strdup().

Referenced by db_delete_resource(), db_retrieve_resources(), db_unput_resources(), find_or_create_db_resource(), get_db_owned_resources(), get_resource(), and init_owned_resources_if_necessary().

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

◆ get_db_owned_resources()

static db_owned_resources get_db_owned_resources ( const char *  oname)
static

Definition at line 231 of file database.c.

232 {
234  return bound_pips_database_p(o)?
235  load_pips_database(o): db_owned_resources_undefined;
236 }
#define db_owned_resources_undefined

References db_owned_resources_undefined, and find_or_create_db_symbol().

Referenced by db_delete_resource(), find_or_create_db_resource(), and get_db_resource().

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

◆ get_db_resource()

static db_resource get_db_resource ( const char *  rname,
const char *  oname 
)
static

lazy...

pips_internal_error("no owned resources for %s", oname, rname);

Definition at line 247 of file database.c.

248 {
250  or = get_db_owned_resources(oname);
251  if (db_owned_resources_undefined_p(or)) { /* lazy... */
252  pips_debug(1, "creating or for %s...\n", oname);
254  or = get_db_owned_resources(oname);
255  } /* pips_internal_error("no owned resources for %s", oname, rname);*/
256  return get_resource(rname, or);
257 }

References db_owned_resources_undefined_p, get_db_owned_resources(), get_resource(), init_owned_resources_if_necessary(), and pips_debug.

Referenced by db_clean_db_resources(), db_get_memory_resource(), db_resource_is_required_p(), db_resource_p(), db_resource_required_or_available_p(), db_save_and_free_memory_resource_if_any(), db_time_of_resource(), and get_real_db_resource().

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

◆ get_real_db_resource()

static db_resource get_real_db_resource ( const char *  rname,
const char *  oname 
)
static

Definition at line 259 of file database.c.

260 {
261  db_resource r = get_db_resource(rname, oname);
263  pips_internal_error("no resource %s of %s\n", rname, oname);
264  return r;
265 }

References db_resource_required_p, db_resource_undefined_p, get_db_resource(), and pips_internal_error.

Referenced by db_get_resource_id(), db_touch_resource(), and db_update_time().

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

◆ get_resource()

static db_resource get_resource ( const char *  rname,
db_owned_resources  or 
)
static

Definition at line 238 of file database.c.

239 {
243  debug_db_resource(9, rname, "?", r);
244  return r;
245 }
db_resource apply_db_owned_resources(db_owned_resources f, db_symbol k)
#define debug_db_resource(l, r, o, p)
Definition: database.c:221
#define db_resource_undefined

References apply_db_owned_resources(), bound_db_owned_resources_p(), db_resource_undefined, debug_db_resource, and find_or_create_db_symbol().

Referenced by db_delete_resource(), db_retrieve_resources(), find_or_create_db_resource(), and get_db_resource().

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

◆ init_owned_resources_if_necessary()

static void init_owned_resources_if_necessary ( const char *  name)
static

set the owner_resources in the pips_database.

Definition at line 223 of file database.c.

224 {
226  /* set the owner_resources in the pips_database. */
227  if (!bound_pips_database_p(s))
228  store_pips_database(s, make_db_owned_resources());;
229 }
db_owned_resources make_db_owned_resources(void)

References find_or_create_db_symbol(), and make_db_owned_resources().

Referenced by db_set_current_module_name(), find_or_create_db_resource(), and get_db_resource().

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

◆ make_tmp_result()

static p_tmp_result make_tmp_result ( int  t,
const char *  on,
const char *  rn 
)
static

Definition at line 403 of file database.c.

404 {
405  p_tmp_result res = (p_tmp_result) malloc(sizeof(t_tmp_result));
406  res->time = t;
407  res->owner_name = on;
408  res->res_name = rn;
409  return res;
410 }
void * malloc(YYSIZE_T)

References malloc(), t_tmp_result::owner_name, t_tmp_result::res_name, and t_tmp_result::time.

Referenced by db_print_all_required_resources().

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

◆ simple_name_p()

static bool simple_name_p ( const char *  name)
static

Module names must use some characters.

Upper case letters and underscore for Fortran, but also lower case letters and the FILE_SEP_STRING "#" added for C compilation unit FC 12/08/2003

FILE_SEP_STRING added for compilation units (FI) MODULE_SEP_STRING added for static C functions (FI) #ifndef FILE_SEP_STRING /* in ri-util *\/ #define FILE_SEP_STRING "!" #endif /* FILE_SEP_STRING *\/ #ifndef MODULE_SEP_STRING /* in ri-util *\/ #define MODULE_SEP_STRING ":" #endif /* MODULE_SEP_STRING *\/ #define MODULE_NAME_CHARS \ ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "0123456789" \ "abcdefghijklmnopqrstuvwxyz" \ FILE_SEP_STRING MODULE_SEP_STRING "|_#-." )

Definition at line 80 of file database.c.

81 {
82  return strlen(name)==strspn(name, MODULE_NAME_CHARS);
83 }
#define MODULE_NAME_CHARS
Definition: naming-local.h:43

References MODULE_NAME_CHARS.

Referenced by db_set_current_module_name(), and find_or_create_db_symbol().

+ Here is the caller graph for this function:

◆ tmp_result_cmp()

static int tmp_result_cmp ( const p_tmp_result p1,
const p_tmp_result p2 
)
static

Definition at line 412 of file database.c.

413 {
414  if ((*p1)->time != (*p2)->time)
415  return (*p1)->time - (*p2)->time;
416  if ((*p1)->owner_name != (*p2)->owner_name)
417  return strcmp((*p1)->owner_name, (*p2)->owner_name);
418  return strcmp((*p1)->res_name, (*p2)->res_name);
419 }
if(!(yy_init))
Definition: genread_lex.c:1029

References if().

Referenced by db_print_all_required_resources().

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

Variable Documentation

◆ current_module_name

char* current_module_name = NULL
static

when telling the database about a module name, the module is registered as a db_symbol, and it is added to the database.

Definition at line 1043 of file database.c.

Referenced by db_get_current_module_name(), db_reset_current_module_name(), and db_set_current_module_name().