void db_end_transaction(JCR *jcr, B_DB *mdb);
int db_int64_handler(void *ctx, int num_fields, char **row);
void db_thread_cleanup();
-void _db_print_dbg(JCR *jcr, FILE *fp);
+void _dbg_print_db(JCR *jcr, FILE *fp);
/* sql_create.c */
bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
* ie, after a fatal signal and before exiting the program
* Print information about a B_DB object.
*/
-void _db_print_dbg(JCR *jcr, FILE *fp)
+void _dbg_print_db(JCR *jcr, FILE *fp)
{
B_DB *mdb = jcr->db;
init_job_server(director->MaxConcurrentJobs);
- dbg_add_hook(_db_print_dbg); /* used to debug B_DB connexion after fatal signal */
+ dbg_jcr_add_hook(_dbg_print_db); /* used to debug B_DB connexion after fatal signal */
// init_device_resources();
return true;
}
+void dump_fd_plugin(Plugin *plugin, FILE *fp)
+{
+ if (!plugin) {
+ return ;
+ }
+ pInfo *info = (pInfo *) plugin->pinfo;
+ fprintf(fp, "\tversion=%d\n", info->version);
+ fprintf(fp, "\tdate=%s\n", NPRTB(info->plugin_date));
+ fprintf(fp, "\tmagic=%s\n", NPRTB(info->plugin_magic));
+ fprintf(fp, "\tauthor=%s\n", NPRTB(info->plugin_author));
+ fprintf(fp, "\tlicence=%s\n", NPRTB(info->plugin_license));
+ fprintf(fp, "\tversion=%s\n", NPRTB(info->plugin_version));
+ fprintf(fp, "\tdescription=%s\n", NPRTB(info->plugin_description));
+}
+
/*
* This entry point is called internally by Bacula to ensure
* that the plugin IO calls come into this code.
Dmsg1(dbglvl, "Loaded plugin: %s\n", plugin->file);
}
+
+ dbg_plugin_add_hook(dump_fd_plugin);
}
/*
extern void free_jcr(JCR *jcr);
#endif
-/* Used to display job information after a fatal signal */
-typedef void (dbg_jcr_hook)(JCR *jcr, FILE *fp);
-void dbg_add_hook(dbg_jcr_hook *fct);
+/* Used to display specific job information after a fatal signal */
+typedef void (dbg_jcr_hook_t)(JCR *jcr, FILE *fp);
+void dbg_jcr_add_hook(dbg_jcr_hook_t *fct);
#endif /* __JCR_H_ */
return; /* thus interrupting the function */
}
-/* Used to display mdb information after a fatal signal */
+/* Used to display specific daemon information after a fatal signal
+ * (like B_DB in the director)
+ */
#define MAX_DBG_HOOK 10
-static dbg_jcr_hook *dbg_hooks[MAX_DBG_HOOK];
+static dbg_jcr_hook_t *dbg_jcr_hooks[MAX_DBG_HOOK];
static int dbg_jcr_handler_count;
-void dbg_add_hook(dbg_jcr_hook *fct)
+void dbg_jcr_add_hook(dbg_jcr_hook_t *fct)
{
ASSERT(dbg_jcr_handler_count < MAX_DBG_HOOK);
- dbg_hooks[dbg_jcr_handler_count++] = fct;
+ dbg_jcr_hooks[dbg_jcr_handler_count++] = fct;
}
/*
* !!! WARNING !!!
*
- * This function should be used ONLY after a violent signal. We walk through the
+ * This function should be used ONLY after a fatal signal. We walk through the
* JCR chain without doing any lock, bacula should not be running.
*/
-void _print_jcr_dbg(FILE *fp)
+void _dbg_print_jcr(FILE *fp)
{
char buf1[128], buf2[128], buf3[128], buf4[128];
if (!jcrs) {
jcr->db, jcr->db_batch, jcr->batch_started);
for(int i=0; i < dbg_jcr_handler_count; i++) {
- dbg_jcr_hook *fct = dbg_hooks[i];
+ dbg_jcr_hook_t *fct = dbg_jcr_hooks[i];
fct(jcr, fp);
}
}
delete plugin_list;
plugin_list = NULL;
}
+
+/*
+ * Dump plugin information
+ * Each daemon can register a hook that will be called
+ * after a fatal signal.
+ */
+#define DBG_MAX_HOOK 10
+static dbg_plugin_hook_t *dbg_plugin_hooks[DBG_MAX_HOOK];
+static int dbg_plugin_hook_count=0;
+
+void dbg_plugin_add_hook(dbg_plugin_hook_t *fct)
+{
+ ASSERT(dbg_plugin_hook_count < DBG_MAX_HOOK);
+ dbg_plugin_hooks[dbg_plugin_hook_count++] = fct;
+}
+
+void _dbg_print_plugin(FILE *fp)
+{
+ Plugin *plugin;
+ fprintf(fp, "Attempt to dump plugins\n");
+
+ if (!plugin_list) {
+ return;
+ }
+
+ foreach_alist(plugin, plugin_list) {
+ for(int i=0; i < dbg_plugin_hook_count; i++) {
+ dbg_plugin_hook_t *fct = dbg_plugin_hooks[i];
+ fprintf(fp, "Plugin %p name=\"%s\" disabled=%d\n",
+ plugin, plugin->file, plugin->disabled);
+ fct(plugin, fp);
+ }
+ }
+}
extern bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char *type);
extern void unload_plugins();
+/* Each daemon can register a debug hook that will be called
+ * after a fatal signal
+ */
+typedef void (dbg_plugin_hook_t)(Plugin *plug, FILE *fp);
+extern void dbg_plugin_add_hook(dbg_plugin_hook_t *fct);
#endif /* __PLUGINS_H */
}
/* defined in jcr.c */
-extern void _print_jcr_dbg(FILE *fp);
+extern void _dbg_print_jcr(FILE *fp);
+/* defined in plugin.c */
+extern void _dbg_print_plugin(FILE *fp);
/*
* !!! WARNING !!!
* This function should be used ONLY after a violent signal. We walk through the
* JCR chain without doing any lock, bacula should not be running.
*/
-static void print_bacula_dbg()
+static void dbg_print_bacula()
{
char buf[512];
fp = stderr;
}
- _print_jcr_dbg(fp);
+ /* Print also B_DB and RWLOCK structure
+ * Can add more info about JCR with dbg_jcr_add_hook()
+ */
+ _dbg_print_jcr(fp);
+
+ _dbg_print_plugin(fp);
if (fp != stderr) {
fclose(fp);
Dmsg0(500, "Done waitpid\n");
fprintf(stderr, _("Traceback complete, attempting cleanup ...\n"));
/* print information about the current state into working/<file>.bactrace */
- print_bacula_dbg();
+ dbg_print_bacula();
exit_handler(sig); /* clean up if possible */
Dmsg0(500, "Done exit_handler\n");
} else {
General:
11Nov08
+ebl Add Plugin debug after a fatal signal.
ebl Add db and rwlock debug after a fatal signal.
10Nov08
ebl Fix maxwaittime to fit documentation, this time is now counted