[darwinbuild-changes] [716] branches/PR-7489777/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 23 19:40:01 PST 2010
Revision: 716
http://trac.macosforge.org/projects/darwinbuild/changeset/716
Author: wsiegrist at apple.com
Date: 2010-02-23 19:39:58 -0800 (Tue, 23 Feb 2010)
Log Message:
-----------
Clean up debug messages
Modified Paths:
--------------
branches/PR-7489777/darwinup/Archive.cpp
branches/PR-7489777/darwinup/DB.cpp
branches/PR-7489777/darwinup/Database.cpp
branches/PR-7489777/darwinup/Depot.cpp
branches/PR-7489777/darwinup/Table.cpp
Modified: branches/PR-7489777/darwinup/Archive.cpp
===================================================================
--- branches/PR-7489777/darwinup/Archive.cpp 2010-02-24 00:53:25 UTC (rev 715)
+++ branches/PR-7489777/darwinup/Archive.cpp 2010-02-24 03:39:58 UTC (rev 716)
@@ -89,7 +89,6 @@
char* Archive::create_directory(const char* prefix) {
int res = 0;
char* path = this->directory_name(prefix);
- IF_DEBUG("creating directory: %s\n", path);
if (path && res == 0) res = mkdir(path, 0777);
if (res != 0) {
fprintf(stderr, "%s:%d: could not create directory: %s: %s (%d)\n", __FILE__, __LINE__, path, strerror(errno), errno);
@@ -106,7 +105,6 @@
char uuidstr[37];
uuid_unparse_upper(m_uuid, uuidstr);
asprintf(&tarpath, "%s/%s.tar.bz2", prefix, uuidstr);
- IF_DEBUG("compacting %s/%s to %s\n", prefix, uuidstr, tarpath);
if (tarpath) {
const char* args[] = {
"/usr/bin/tar",
@@ -130,7 +128,6 @@
char uuidstr[37];
uuid_unparse_upper(m_uuid, uuidstr);
asprintf(&tarpath, "%s/%s.tar.bz2", prefix, uuidstr);
- IF_DEBUG("expanding %s to %s\n", tarpath, prefix);
if (tarpath) {
const char* args[] = {
"/usr/bin/tar",
Modified: branches/PR-7489777/darwinup/DB.cpp
===================================================================
--- branches/PR-7489777/darwinup/DB.cpp 2010-02-24 00:53:25 UTC (rev 715)
+++ branches/PR-7489777/darwinup/DB.cpp 2010-02-24 03:39:58 UTC (rev 716)
@@ -430,7 +430,6 @@
}
int DarwinupDatabase::get_archive(uint8_t** data, uint64_t serial) {
- IF_DEBUG("get_archive serial: %llu \n", serial);
int res = this->get_row("archive__serial",
data,
this->m_archives_table,
Modified: branches/PR-7489777/darwinup/Database.cpp
===================================================================
--- branches/PR-7489777/darwinup/Database.cpp 2010-02-24 00:53:25 UTC (rev 715)
+++ branches/PR-7489777/darwinup/Database.cpp 2010-02-24 03:39:58 UTC (rev 716)
@@ -87,7 +87,6 @@
void Database::init_cache() {
- IF_DEBUG("CACHE: init_cache \n");
cache_attributes_t attrs;
attrs.version = CACHE_ATTRIBUTES_VERSION_2;
attrs.key_hash_cb = cache_key_hash_cb_cstring;
@@ -100,33 +99,27 @@
}
void Database::destroy_cache() {
- IF_DEBUG("CACHE: destroy_cache \n");
cache_destroy(m_statement_cache);
}
bool cache_key_is_equal(void* key1, void* key2, void* user) {
bool res = (strcmp((char*)key1, (char*)key2) == 0);
- IF_DEBUG("CACHE: key1: %s key2: %s res: %d\n", (char*)key1, (char*)key2, res);
return res;
}
void cache_key_retain(void* key_in, void** key_out, void* user_data) {
- IF_DEBUG("CACHE: key_retain %s\n", (char*)key_in);
*key_out = strdup((char*)key_in);
}
void cache_key_release(void* key, void* user_data) {
- IF_DEBUG("CACHE: key_release %s\n", (char*)key);
free(key);
}
void cache_value_retain(void* value, void* user_data) {
- IF_DEBUG("CACHE: value_retain %p\n", value);
// do nothing
}
void cache_value_release(void* value, void* user_data) {
- IF_DEBUG("CACHE: value_release %p\n", value);
sqlite3_finalize((sqlite3_stmt*)value);
}
@@ -192,7 +185,6 @@
int Database::create_tables() {
int res = SQLITE_OK;
for (uint32_t i=0; i<m_table_count; i++) {
- IF_DEBUG("[DATABASE] creating table #%u \n", i);
res = this->sql_once(m_tables[i]->create());
if (res!=SQLITE_OK) {
fprintf(stderr, "Error: sql error trying to create table: %s: %s\n",
@@ -338,44 +330,32 @@
free(key);
size_t Database::store_column(sqlite3_stmt* stmt, int column, uint8_t* output) {
- IF_DEBUG("store_column: column = %d output = %p \n", column, output);
size_t used;
int type = sqlite3_column_type(stmt, column);
const void* blob;
int blobsize;
- IF_DEBUG("column type = %d \n", type);
switch(type) {
case SQLITE_INTEGER:
*(uint64_t*)output = (uint64_t)sqlite3_column_int64(stmt, column);
used = sizeof(uint64_t);
- IF_DEBUG("store_column used=%u output(%p) = %llu \n",
- (uint32_t)used, output, *(uint64_t*)output);
break;
case SQLITE_TEXT:
*(const char**)output = strdup((const char*)sqlite3_column_text(stmt, column));
- IF_DEBUG("[ALLOC] text: %p %s \n", *(char**)output, *(char**)output);
used = sizeof(char*);
- IF_DEBUG("store_column used=%u output(%p) = %s \n",
- (uint32_t)used, output, *(char**)output);
break;
case SQLITE_BLOB:
blob = sqlite3_column_blob(stmt, column);
blobsize = sqlite3_column_bytes(stmt, column);
- IF_DEBUG("blob(%p) size=%d \n", blob, blobsize);
*(void**)output = malloc(blobsize);
- IF_DEBUG("[ALLOC] blob %p \n", *(void**)output);
if (*(void**)output && blobsize) {
memcpy(*(void**)output, blob, blobsize);
} else {
fprintf(stderr, "Error: unable to get blob from database stmt.\n");
}
used = sizeof(void*);
- IF_DEBUG("store_column used=%u output(%p) = %s \n",
- (uint32_t)used, *(char**)output, *(char**)output);
break;
case SQLITE_NULL:
// result row has a NULL value which is okay
- IF_DEBUG("store_column got a NULL column value for: %d \n", column);
*(const char**)output = NULL;
used = sizeof(char*);
break;
@@ -398,20 +378,14 @@
int Database::step_once(sqlite3_stmt* stmt, uint8_t* output, uint32_t* used) {
int res = sqlite3_step(stmt);
uint8_t* current = output;
- IF_DEBUG("output = %p current = %p \n", output, current);
if (used) *used = 0;
- if (used) IF_DEBUG("step_once used(%p) = %u \n", used, *used);
-
if (res == SQLITE_ROW) {
int count = sqlite3_column_count(stmt);
for (int i = 0; i < count; i++) {
- IF_DEBUG("loop current ptr before = %p \n", current);
current += this->store_column(stmt, i, current);
- IF_DEBUG("loop current ptr after = %p \n", current);
}
if (used) {
*used = current - output;
- IF_DEBUG("step_once after store used(%p) = %u \n", used, *used);
}
}
@@ -424,19 +398,15 @@
uint32_t rowsize = size / INITIAL_ROWS;
uint8_t* current = *(uint8_t**)output;
*count = 0;
- IF_DEBUG("rowsize = %u \n", rowsize);
int res = SQLITE_ROW;
while (res == SQLITE_ROW) {
current = *(uint8_t**)output + total_used;
- IF_DEBUG("calling step_once with current(%p) \n", current);
res = this->step_once(stmt, current, &used);
if (res == SQLITE_ROW) (*count)++;
total_used += used;
- IF_DEBUG("stepped: used = %u total_used = %u size = %u \n", used, total_used, size);
if (total_used >= (size - rowsize)) {
size *= REALLOC_FACTOR;
*output = realloc(*output, size);
- IF_DEBUG("reallocating: output = %p size = %u \n", *output, size);
if (!*output) {
fprintf(stderr, "Error: ran out of memory in Database::step_all \n");
return SQLITE_ERROR;
@@ -456,7 +426,6 @@
uint32_t size = value_column->size();
*output = malloc(size);
res = this->step_once(stmt, (uint8_t*)*output, NULL);
- IF_DEBUG("get_value: res = %d output(%p) = %llu \n", res, *output, **(uint64_t**)output);
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, &stmt);
return res;
@@ -465,15 +434,12 @@
int Database::get_column(const char* name, void** output, uint32_t* result_count,
Table* table, Column* column, uint32_t count, ...) {
__get_stmt(table->get_column(m_db, column, count, args));
- IF_DEBUG("stmt = %s \n", sqlite3_sql(stmt));
int res = SQLITE_OK;
uint32_t param = 1;
__bind_va_columns(count);
uint32_t size = INITIAL_ROWS * column->size();
*output = malloc(size);
- IF_DEBUG("get_column output = %p size = %u \n", *output, size);
res = this->step_all(stmt, output, size, result_count);
- IF_DEBUG("get_colu output(%p) = %llu \n", *output, **(uint64_t**)output);
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, &stmt);
return res;
@@ -481,14 +447,11 @@
int Database::get_row(const char* name, uint8_t** output, Table* table, uint32_t count, ...) {
__get_stmt(table->get_row(m_db, count, args));
- IF_DEBUG("stmt = %s \n", sqlite3_sql(stmt));
int res = SQLITE_OK;
uint32_t param = 1;
__bind_va_columns(count);
*output = table->alloc_result();
- IF_DEBUG("Table::alloc_result = %p \n", *output);
res = this->step_once(stmt, *output, NULL);
- IF_DEBUG("get_row output(%p) = %llu \n", *output, **(uint64_t**)output);
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, &stmt);
return res;
@@ -497,14 +460,11 @@
int Database::get_row_ordered(const char* name, uint8_t** output, Table* table, Column* order_by,
int order, uint32_t count, ...) {
__get_stmt(table->get_row_ordered(m_db, order_by, order, count, args));
- IF_DEBUG("stmt = %s \n", sqlite3_sql(stmt));
int res = SQLITE_OK;
uint32_t param = 1;
__bind_va_columns(count);
*output = table->alloc_result();
- IF_DEBUG("Table::alloc_result = %p \n", *output);
res = this->step_once(stmt, *output, NULL);
- IF_DEBUG("get_row_ordered output(%p) = %llu \n", *output, **(uint64_t**)output);
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, &stmt);
return res;
@@ -513,7 +473,6 @@
int Database::get_all_ordered(const char* name, uint8_t*** output, uint32_t* result_count,
Table* table, Column* order_by, int order, uint32_t count, ...) {
__get_stmt(table->get_row_ordered(m_db, order_by, order, count, args));
- IF_DEBUG("stmt = %s \n", sqlite3_sql(stmt));
int res = SQLITE_OK;
uint32_t param = 1;
__bind_va_columns(count);
@@ -532,15 +491,11 @@
"in get_all_ordered.\n");
return DB_ERROR;
}
- IF_DEBUG("get_all_ordered realloc: %p \n", *output);
}
current = table->alloc_result();
- IF_DEBUG("Table::alloc_result = %p \n", current);
res = this->step_once(stmt, current, NULL);
if (res == SQLITE_ROW) {
(*output)[(*result_count)] = current;
- IF_DEBUG("get_all_ordered count: %u output(%p) = %llu \n",
- (*result_count), (*output)[(*result_count)], (uint64_t)(*output)[(*result_count)][0]);
(*result_count)++;
} else {
table->free_result(current);
@@ -549,7 +504,6 @@
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, &stmt);
- IF_DEBUG("get_all_ordered res = %d \n", res);
return res;
}
Modified: branches/PR-7489777/darwinup/Depot.cpp
===================================================================
--- branches/PR-7489777/darwinup/Depot.cpp 2010-02-24 00:53:25 UTC (rev 715)
+++ branches/PR-7489777/darwinup/Depot.cpp 2010-02-24 03:39:58 UTC (rev 716)
@@ -200,11 +200,9 @@
return Depot::archive(serial);
}
if (strncasecmp("oldest", arg, 6) == 0) {
- IF_DEBUG("looking for oldest\n");
return Depot::archive(DEPOT_ARCHIVE_OLDEST);
}
if (strncasecmp("newest", arg, 6) == 0) {
- IF_DEBUG("looking for newest\n");
return Depot::archive(DEPOT_ARCHIVE_NEWEST);
}
return Depot::archive((archive_name_t)arg);
@@ -215,18 +213,15 @@
int res = DB_OK;
uint8_t** archlist;
res = this->m_db->get_archives(&archlist, count, verbosity & VERBOSE_DEBUG);
- IF_DEBUG("get_all_archives for count %d from get_archives, res: %d \n", *count, res);
Archive** list = (Archive**)malloc(sizeof(Archive*) * (*count));
if (!list) {
fprintf(stderr, "Error: ran out of memory in Depot::get_all_archives\n");
return NULL;
}
- IF_DEBUG("done with malloc archive list \n");
if (FOUND(res)) {
for (uint32_t i=0; i < *count; i++) {
Archive* archive = this->m_db->make_archive(archlist[i]);
- IF_DEBUG("make_archive gave back archive %llu \n", archive->serial());
if (archive) {
list[i] = archive;
} else {
@@ -235,8 +230,6 @@
break;
}
}
- } else {
- IF_DEBUG("get_archives found no archives \n");
}
return list;
@@ -266,11 +259,9 @@
uint8_t** filelist;
uint32_t count;
res = this->m_db->get_files(&filelist, &count, archive);
- IF_DEBUG("iterate_files for count %d from get_files, res: %d \n", count, res);
if (FOUND(res)) {
for (uint32_t i=0; i < count; i++) {
File* file = this->m_db->make_file(filelist[i]);
- IF_DEBUG("make_file gave back file %llu \n", file->serial());
if (file) {
res = func(file, context);
delete file;
@@ -280,8 +271,6 @@
break;
}
}
- } else {
- IF_DEBUG("iterate_files for archive (%llu) found no files \n", archive->serial());
}
return res;
@@ -318,7 +307,6 @@
File* actual = FileFactory(actpath);
File* preceding = this->file_preceded_by(file);
- if (preceding) IF_DEBUG("[PRECED] %llu %s \n", preceding->serial(), preceding->path());
if (actual == NULL) {
// No actual file exists already, so we create a placeholder.
@@ -483,7 +471,6 @@
int res = 0;
IF_DEBUG("[backup] backup_file: %s , %s \n", file->path(), context->archive->m_name);
- IF_DEBUG("info = %d \n", file->info());
if (INFO_TEST(file->info(), FILE_INFO_ROLLBACK_DATA)) {
char *path; // the file's path
@@ -655,7 +642,6 @@
if (ent->fts_info == FTS_D) {
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/%s", m_archives_path, ent->fts_name);
- IF_DEBUG("pruning: %s\n", path);
res = remove_directory(path);
}
ent = ent->fts_link;
@@ -694,12 +680,10 @@
IF_DEBUG("[uninstall] changes since install; skipping\n");
} else {
File* superseded = context->depot->file_superseded_by(file);
- if (superseded) IF_DEBUG("[SUPER] %llu %s \n", superseded->serial(), superseded->path());
if (superseded == NULL) {
// no one's using this file anymore
File* preceding = context->depot->file_preceded_by(file);
assert(preceding != NULL);
- IF_DEBUG("[PRECED] %llu %s \n", preceding->serial(), preceding->path());
if (INFO_TEST(preceding->info(), FILE_INFO_NO_ENTRY)) {
state = 'R';
IF_DEBUG("[uninstall] removing file\n");
@@ -776,7 +760,6 @@
uint32_t i;
for (i = 0; i < context.files_to_remove->count; ++i) {
uint64_t serial = context.files_to_remove->values[i];
- IF_DEBUG("deleting file %lld\n", serial);
if (res == 0) res = m_db->delete_file(serial);
}
if (res == 0) res = this->commit_transaction();
Modified: branches/PR-7489777/darwinup/Table.cpp
===================================================================
--- branches/PR-7489777/darwinup/Table.cpp 2010-02-24 00:53:25 UTC (rev 715)
+++ branches/PR-7489777/darwinup/Table.cpp 2010-02-24 03:39:58 UTC (rev 716)
@@ -40,18 +40,6 @@
// how much we grow by when we need more space
#define REALLOC_FACTOR 4
-
-// XXX
-void __hex_str(const char* s) {
- int len = strlen(s);
- IF_DEBUG("HEXSTR: %d \n", len);
- for (int i=0; i <= len; i++) {
- IF_DEBUG("%02x", (unsigned int)s[i]);
- }
- IF_DEBUG("\n");
-}
-
-
Table::Table() {
m_column_max = 1;
m_column_count = 0;
@@ -60,7 +48,6 @@
m_result_max = 1;
m_result_count = 0;
m_results = (uint8_t**)malloc(sizeof(uint8_t*) * m_result_max);
- IF_DEBUG("[ALLOC] constructor %p \n", m_results);
m_name = strdup("unnamed_table");
m_create_sql = NULL;
m_insert_sql = NULL;
@@ -80,7 +67,6 @@
m_result_max = 1;
m_result_count = 0;
m_results = (uint8_t**)malloc(sizeof(uint8_t*) * m_result_max);
- IF_DEBUG("[ALLOC] constructor %p \n", m_results);
m_name = strdup(name);
m_create_sql = NULL;
m_insert_sql = NULL;
@@ -100,11 +86,9 @@
for (uint32_t i=0; i < m_result_count; i++) {
if (m_results[i]) {
- IF_DEBUG("[FREE] destructor loop %d %p \n", i, m_results[i]);
this->free_result(m_results[i]);
}
}
- IF_DEBUG("[FREE] destructor free %p \n", m_results);
free(m_results);
free(m_name);
@@ -160,7 +144,6 @@
uint8_t* Table::alloc_result() {
if (m_result_count >= m_result_max) {
m_results = (uint8_t**)realloc(m_results, m_result_max * sizeof(uint8_t*) * REALLOC_FACTOR);
- IF_DEBUG("[ALLOC] realloc m_results %p \n", m_results);
if (!m_results) {
fprintf(stderr, "Error: unable to reallocate memory to add a result row\n");
return NULL;
@@ -169,8 +152,6 @@
}
m_result_count++;
m_results[m_result_count-1] = (uint8_t*)calloc(1, this->row_size());
- IF_DEBUG("[ALLOC] calloc(%d) %d %p \n", this->row_size(), m_result_count-1,
- m_results[m_result_count-1]);
return m_results[m_result_count-1];
}
@@ -185,7 +166,6 @@
break;
default:
memcpy(&ptr, current, sizeof(void*));
- IF_DEBUG("[FREE] %s: %p (type of %d: %d) \n", m_name, ptr, i, m_columns[i]->type());
free(ptr);
current += sizeof(void*);
}
@@ -198,7 +178,6 @@
// look for matching result
if (result == m_results[i]) {
this->free_row((uint8_t*)m_results[i]);
- IF_DEBUG("[FREE] %s result %d %p \n", m_name, i, m_results[i]);
free(m_results[i]);
m_results[i] = NULL;
// if we did not free the last result,
@@ -257,9 +236,7 @@
}
}
}
-
- IF_DEBUG("[TABLE] create(): %s \n", m_create_sql);
-
+
return m_create_sql;
}
@@ -364,7 +341,6 @@
__check_and_cat(" WHERE 1");
__where_va_columns;
strlcat(query, ";", size);
- IF_DEBUG("[TABLE] get_row query: %s \n", query);
__prepare_stmt;
return stmt;
@@ -381,7 +357,6 @@
__check_and_cat(order_by->name());
__check_and_cat((order == ORDER_BY_DESC ? " DESC" : " ASC"));
strlcat(query, ";", size);
- IF_DEBUG("[TABLE] get_row_ordered query: %s \n", query);
__prepare_stmt;
return stmt;
@@ -409,12 +384,8 @@
sqlite3_stmt* Table::update(sqlite3* db) {
// we only need to prepare once, return if we already have it
if (m_prepared_update) {
- IF_DEBUG("[TABLE] %s table found cached update statement at %p \n", m_name, m_prepared_update);
return m_prepared_update;
}
-
- IF_DEBUG("[TABLE] %s is generating an update statement \n", m_name);
-
uint32_t i = 0;
bool comma = false; // flag we set to start adding commas
@@ -450,9 +421,7 @@
}
}
strlcat(m_update_sql, ";", size);
-
- IF_DEBUG("[TABLE] prepared update: %s \n", m_update_sql);
-
+
// prepare
int res = sqlite3_prepare_v2(db, m_update_sql, strlen(m_update_sql), &m_prepared_update, NULL);
if (res != SQLITE_OK) {
@@ -466,13 +435,9 @@
sqlite3_stmt* Table::insert(sqlite3* db) {
// we only need to prepare once, return if we already have it
if (m_prepared_insert) {
- IF_DEBUG("[TABLE] %s table found cached insert statement at %p \n",
- m_name, m_prepared_insert);
return m_prepared_insert;
}
-
- IF_DEBUG("[TABLE] %s is generating an insert statement \n", m_name);
-
+
uint32_t i = 0;
bool comma = false; // flag we set to start adding commas
@@ -508,9 +473,7 @@
}
}
strlcat(m_insert_sql, ");", size);
-
- IF_DEBUG("[TABLE] prepared insert: %s \n", m_insert_sql);
-
+
// prepare
int res = sqlite3_prepare_v2(db, m_insert_sql, strlen(m_insert_sql), &m_prepared_insert, NULL);
if (res != SQLITE_OK) {
@@ -563,8 +526,6 @@
}
strlcat(m_delete_sql, ";", size);
- IF_DEBUG("[TABLE] prepared delete: %s \n", m_delete_sql);
-
// prepare
int res = sqlite3_prepare_v2(db, m_delete_sql, strlen(m_delete_sql), &m_prepared_delete, NULL);
if (res != SQLITE_OK) {
@@ -586,4 +547,3 @@
return stmt;
}
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100223/ba67be3c/attachment-0001.html>
More information about the darwinbuild-changes
mailing list