From: Philippe E. <ph...@us...> - 2002-09-22 19:35:24
|
Update of /cvsroot/oprofile/oprofile/libdb In directory usw-pr-cvs1:/tmp/cvs-serv21107/libdb Modified Files: Makefile.in db-debug.c db-insert.c db-test.c Log Message: libdb/db-insert.c: fix samples count overflow allow to build db-test, enhance checking allowing to be used as $ db-test samples_dir regards, Phil Index: Makefile.in =================================================================== RCS file: /cvsroot/oprofile/oprofile/libdb/Makefile.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.in 6 May 2002 18:00:32 -0000 1.3 +++ Makefile.in 22 Sep 2002 19:35:19 -0000 1.4 @@ -1,7 +1,5 @@ include ../make.common -# disabled db-test etc. for now - HEADERS=db.h SOURCES=db-manage.c db-insert.c db-travel.c db-debug.c @@ -18,5 +16,8 @@ $(TARGET): $(OBJECTS) $(AR) cr $@ $^ + +db-test: db-test.c $(TARGET) + $(CC) -o $@ db-test.c $(TARGET) include ../make.deps Index: db-debug.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/libdb/db-debug.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- db-debug.c 7 Sep 2002 18:19:35 -0000 1.7 +++ db-debug.c 22 Sep 2002 19:35:19 -0000 1.8 @@ -133,6 +133,9 @@ page = page_nr_to_page_ptr(tree, page_nr); + if (page->count == 0) + return 1; + if (page->p0 != db_nil_page) do_check_tree(tree, page->p0, last); @@ -153,8 +156,10 @@ int db_check_tree(db_tree_t const * tree) { int ret = db_check_page_pointer(tree); - if (!ret) - ret = do_check_tree(tree, tree->descr->root_idx, 0u); + if (!ret) { + if (tree->descr->root_idx != db_nil_page) + ret = do_check_tree(tree, tree->descr->root_idx, 0u); + } return ret; } Index: db-insert.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/libdb/db-insert.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- db-insert.c 22 Sep 2002 17:45:59 -0000 1.9 +++ db-insert.c 22 Sep 2002 19:35:19 -0000 1.10 @@ -243,8 +243,12 @@ /* found: even if the write is non-atomic we do not need * to lock() because we work only in the case of one writer, * multiple reader. */ - // FIXME: where is the overflow handling here ? - page->page_table[pos].info += value->info; + if (page->page_table[pos].info + value->info >= + page->page_table[pos].info) + page->page_table[pos].info += value->info; + else + /* FIXME: post profile must handle that */ + page->page_table[pos].info += (db_info_t)-1; return 0; } Index: db-test.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/libdb/db-test.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- db-test.c 7 Sep 2002 18:19:35 -0000 1.7 +++ db-test.c 22 Sep 2002 19:35:19 -0000 1.8 @@ -169,8 +169,29 @@ } } -int main(void) +static void sanity_check(char const * filename) { + db_tree_t tree; + + db_open(&tree, filename, DB_RDONLY, 128); + + if (db_check_tree(&tree)) { + printf("checking file %s FAIL\n", filename); + ++nr_error; + } + + db_close(&tree); +} + +int main(int argc, char * argv[1]) +{ + /* if a filename is given take it as a checking of this db */ + if (argc > 1) { + int i; + for (i = 1 ; i < argc ; ++i) + sanity_check(argv[i]); + return 0; + } do_test(); do_callback_test(); |