DynamoRIO / DynamoRIO/dynamorio

add drcontainers hashtable iterator

Open
#2,782 0 comments 0 reactions 0 assignees View on GitHub
Component-Extension help wanted Type-Feature
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

Today, the drcontainers hashtable does not have an iterator interface and
instead the user has to walk the table and traverse the pointers on his
or her own.

There are uses in several tools, libraries, and tests:

```
$ git grep HASHTABLE_SIZE | egrep -v '^core|drcontainers/hash|custom_tr'
clients/drcachesim/tracer/raw2trace.cpp: for (uint i = 0; i < HASHTABLE_SIZE(decode_cache.table_bits); i++) {
clients/drcov/postprocess/drcov2lcov.cpp: for (i = 0; i < HASHTABLE_SIZE(module_htable.table_bits); i++) {
clients/drcov/postprocess/drcov2lcov.cpp: for (i = 0; i < HASHTABLE_SIZE(line_htable.table_bits); i++) {
ext/drwrap/drwrap.c: for (i = 0; i < HASHTABLE_SIZE(wrap_table.table_bits); i++) {
ext/drx/drx.c: for (i = 0; i < HASHTABLE_SIZE(job_table.table_bits); i++) {
suite/tests/client-interface/pcache.dll.c: for (i = 0; i < HASHTABLE_SIZE(sample_pointer_table.table_bits); i++) {
suite/tests/client-interface/pcache.dll.c: for (i = 0; i < HASHTABLE_SIZE(sample_inlined_table.table_bits); i++) {
```

There are also many uses in Dr. Memory:

```
$ git grep HASHTABLE_SIZE | grep -v winsyms
common/alloc.c: for (i = 0; i < HASHTABLE_SIZE(alloc_routine_table.table_bits); i++) {
common/alloc.c: for (i = 0; i < HASHTABLE_SIZE(malloc_table.table_bits); i++) {
common/alloc_replace.c: for (i = 0; i < HASHTABLE_SIZE(pre_us_table.table_bits); i++) {
common/alloc_replace.c: for (i = 0; i < HASHTABLE_SIZE(pre_us_table.table_bits); i++) {
common/alloc_replace.c: for (i = 0; i < HASHTABLE_SIZE(pre_us_table.table_bits); i++) {
common/alloc_replace.c: for (i = 0; i < HASHTABLE_SIZE(crtheap_handle_table.table_bits); i++) {
common/utils.c: for (i = 0; i < HASHTABLE_SIZE(table->table_bits); i++) {
drheapstat/drheapstat.c: for (i = 0; i < HASHTABLE_SIZE(alloc_stack_table.table_bits); i++) {
drmemory/gdicheck.c: for (i = 0; i < HASHTABLE_SIZE(dc_table.table_bits); i++) {
drmemory/handlecheck.c: for (i = 0; i < HASHTABLE_SIZE(table->table_bits); i++) {
drmemory/instru.c: for (i = 0; i < HASHTABLE_SIZE(stringop_app2us_table.table_bits); i++) {
drmemory/report.c: for (i = 0; i < HASHTABLE_SIZE(error_table.table_bits); i++) {
drsymcache/drsymcache.c: for (i = 0; i < HASHTABLE_SIZE(symtable->table_bits); i++) {
drsymcache/drsymcache.c: for (i = 0; i < HASHTABLE_SIZE(symcache_table.table_bits); i++) {
drsyscall/drsyscall.c: for (i = 0; i < HASHTABLE_SIZE(systable.table_bits); i++) {
```

The goal would be to provide an interface that can replace all of those
uses with something cleaner, and enable us to remove the exposure of the
hashtable internals in the header file (though we may have to leave them
there for backward compatibility). At least some of these uses require an
iterator that supports calling hashtable_remove*() while iterating.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.