Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pd/experiment/add source location logging #4419

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions scripts/insert-source-locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3

import os
import re
import sys

CPP_EXTENSIONS = set([".cpp", ".cc"])

ANCHOR_NAMES = [
"api_entry",
"api_entry_plain",
"api_entry_void",
"api_entry_with_context",
"api_entry_context",
"api_entry_error"
]

ANCHOR = "(" + "|".join(ANCHOR_NAMES) + ")"
WRAPPER_RE = re.compile(ANCHOR + "\<[\sa-zA-Z0-9:_]+\>\(", re.MULTILINE)


def process_file(fname):
with open(fname) as handle:
source = handle.read()

to_write = []
curr_pos = 0
while True:
match = WRAPPER_RE.search(source, pos=curr_pos)
if match is None:
break
to_write.append(source[curr_pos:match.span(0)[1]])
to_write.append("TILEDB_SOURCE_LOCATION()")
curr_pos = match.span(0)[1]
if source[curr_pos] != ")":
to_write.append(", ")

if not len(to_write):
# No instances found in this file, avoid the unnecessary write.
return

to_write.append(source[curr_pos:])

print("Rewriting: " + fname)
new_source = "".join(to_write)
with open(fname, "w") as handle:
handle.write(new_source)


def main():
if len(sys.argv) != 2:
print("usage: {} BASE_DIRECTORY".format(sys.argv[0]))
exit(1)

for path, dnames, fnames in os.walk(sys.argv[1]):
for fname in fnames:
# Don't patch the definitions
if fname == "exception_wrapper.h":
continue
if os.path.splitext(fname)[-1] not in CPP_EXTENSIONS:
continue
fname = os.path.join(path, fname)
process_file(fname)


if __name__ == "__main__":
main()
38 changes: 20 additions & 18 deletions tiledb/api/c_api/attribute/attribute_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,90 +211,92 @@ int32_t tiledb_attribute_alloc(
tiledb_datatype_t type,
tiledb_attribute_handle_t** attr) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_alloc>(
ctx, name, type, attr);
TILEDB_SOURCE_LOCATION(), ctx, name, type, attr);
}

void tiledb_attribute_free(tiledb_attribute_handle_t** attr) noexcept {
return tiledb::api::api_entry_void<tiledb::api::tiledb_attribute_free>(attr);
return tiledb::api::api_entry_void<tiledb::api::tiledb_attribute_free>(
TILEDB_SOURCE_LOCATION(), attr);
}

int32_t tiledb_attribute_set_nullable(
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint8_t nullable) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_set_nullable>(
ctx, attr, nullable);
TILEDB_SOURCE_LOCATION(), ctx, attr, nullable);
}

int32_t tiledb_attribute_set_filter_list(
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
tiledb_filter_list_t* filter_list) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_set_filter_list>(
ctx, attr, filter_list);
TILEDB_SOURCE_LOCATION(), ctx, attr, filter_list);
}

int32_t tiledb_attribute_set_cell_val_num(
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint32_t cell_val_num) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_set_cell_val_num>(
ctx, attr, cell_val_num);
TILEDB_SOURCE_LOCATION(), ctx, attr, cell_val_num);
}

int32_t tiledb_attribute_get_name(
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
const char** name) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_name>(
ctx, attr, name);
TILEDB_SOURCE_LOCATION(), ctx, attr, name);
}

int32_t tiledb_attribute_get_type(
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
tiledb_datatype_t* type) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_type>(
ctx, attr, type);
TILEDB_SOURCE_LOCATION(), ctx, attr, type);
}

int32_t tiledb_attribute_get_nullable(
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint8_t* nullable) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_nullable>(
ctx, attr, nullable);
TILEDB_SOURCE_LOCATION(), ctx, attr, nullable);
}

int32_t tiledb_attribute_get_filter_list(
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
tiledb_filter_list_t** filter_list) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_filter_list>(
ctx, attr, filter_list);
TILEDB_SOURCE_LOCATION(), ctx, attr, filter_list);
}

int32_t tiledb_attribute_get_cell_val_num(
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
uint32_t* cell_val_num) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_cell_val_num>(
ctx, attr, cell_val_num);
TILEDB_SOURCE_LOCATION(), ctx, attr, cell_val_num);
}

int32_t tiledb_attribute_get_cell_size(
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
uint64_t* cell_size) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_cell_size>(
ctx, attr, cell_size);
TILEDB_SOURCE_LOCATION(), ctx, attr, cell_size);
}

int32_t tiledb_attribute_dump(
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
FILE* out) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_dump>(ctx, attr, out);
return api_entry_context<tiledb::api::tiledb_attribute_dump>(
TILEDB_SOURCE_LOCATION(), ctx, attr, out);
}

int32_t tiledb_attribute_set_fill_value(
Expand All @@ -303,7 +305,7 @@ int32_t tiledb_attribute_set_fill_value(
const void* value,
uint64_t size) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_set_fill_value>(
ctx, attr, value, size);
TILEDB_SOURCE_LOCATION(), ctx, attr, value, size);
}

int32_t tiledb_attribute_get_fill_value(
Expand All @@ -312,7 +314,7 @@ int32_t tiledb_attribute_get_fill_value(
const void** value,
uint64_t* size) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_fill_value>(
ctx, attr, value, size);
TILEDB_SOURCE_LOCATION(), ctx, attr, value, size);
}

int32_t tiledb_attribute_set_fill_value_nullable(
Expand All @@ -323,7 +325,7 @@ int32_t tiledb_attribute_set_fill_value_nullable(
uint8_t valid) noexcept {
return api_entry_context<
tiledb::api::tiledb_attribute_set_fill_value_nullable>(
ctx, attr, value, size, valid);
TILEDB_SOURCE_LOCATION(), ctx, attr, value, size, valid);
}

int32_t tiledb_attribute_get_fill_value_nullable(
Expand All @@ -334,21 +336,21 @@ int32_t tiledb_attribute_get_fill_value_nullable(
uint8_t* valid) noexcept {
return api_entry_context<
tiledb::api::tiledb_attribute_get_fill_value_nullable>(
ctx, attr, value, size, valid);
TILEDB_SOURCE_LOCATION(), ctx, attr, value, size, valid);
}

capi_return_t tiledb_attribute_set_enumeration_name(
tiledb_ctx_t* ctx,
tiledb_attribute_t* attr,
const char* enumeration_name) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_set_enumeration_name>(
ctx, attr, enumeration_name);
TILEDB_SOURCE_LOCATION(), ctx, attr, enumeration_name);
}

capi_return_t tiledb_attribute_get_enumeration_name(
tiledb_ctx_t* ctx,
tiledb_attribute_t* attr,
tiledb_string_t** name) noexcept {
return api_entry_context<tiledb::api::tiledb_attribute_get_enumeration_name>(
ctx, attr, name);
TILEDB_SOURCE_LOCATION(), ctx, attr, name);
}
14 changes: 8 additions & 6 deletions tiledb/api/c_api/buffer/buffer_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,29 @@ using tiledb::api::api_entry_void;

capi_return_t tiledb_buffer_alloc(
tiledb_ctx_t* ctx, tiledb_buffer_t** buffer) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_alloc>(ctx, buffer);
return api_entry_context<tiledb::api::tiledb_buffer_alloc>(
TILEDB_SOURCE_LOCATION(), ctx, buffer);
}

void tiledb_buffer_free(tiledb_buffer_t** buffer) noexcept {
return api_entry_void<tiledb::api::tiledb_buffer_free>(buffer);
return api_entry_void<tiledb::api::tiledb_buffer_free>(
TILEDB_SOURCE_LOCATION(), buffer);
}

capi_return_t tiledb_buffer_set_type(
tiledb_ctx_t* ctx,
tiledb_buffer_t* buffer,
tiledb_datatype_t datatype) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_set_type>(
ctx, buffer, datatype);
TILEDB_SOURCE_LOCATION(), ctx, buffer, datatype);
}

capi_return_t tiledb_buffer_get_type(
tiledb_ctx_t* ctx,
const tiledb_buffer_t* buffer,
tiledb_datatype_t* datatype) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_get_type>(
ctx, buffer, datatype);
TILEDB_SOURCE_LOCATION(), ctx, buffer, datatype);
}

capi_return_t tiledb_buffer_get_data(
Expand All @@ -129,7 +131,7 @@ capi_return_t tiledb_buffer_get_data(
void** data,
uint64_t* size) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_get_data>(
ctx, buffer, data, size);
TILEDB_SOURCE_LOCATION(), ctx, buffer, data, size);
}

capi_return_t tiledb_buffer_set_data(
Expand All @@ -138,5 +140,5 @@ capi_return_t tiledb_buffer_set_data(
void* data,
uint64_t size) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_set_data>(
ctx, buffer, data, size);
TILEDB_SOURCE_LOCATION(), ctx, buffer, data, size);
}
13 changes: 7 additions & 6 deletions tiledb/api/c_api/buffer_list/buffer_list_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,20 @@ using tiledb::api::api_entry_void;
capi_return_t tiledb_buffer_list_alloc(
tiledb_ctx_t* ctx, tiledb_buffer_list_t** buffer_list) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_list_alloc>(
ctx, buffer_list);
TILEDB_SOURCE_LOCATION(), ctx, buffer_list);
}

void tiledb_buffer_list_free(tiledb_buffer_list_t** buffer_list) noexcept {
return api_entry_void<tiledb::api::tiledb_buffer_list_free>(buffer_list);
return api_entry_void<tiledb::api::tiledb_buffer_list_free>(
TILEDB_SOURCE_LOCATION(), buffer_list);
}

capi_return_t tiledb_buffer_list_get_num_buffers(
tiledb_ctx_t* ctx,
const tiledb_buffer_list_t* buffer_list,
uint64_t* num_buffers) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_num_buffers>(
ctx, buffer_list, num_buffers);
TILEDB_SOURCE_LOCATION(), ctx, buffer_list, num_buffers);
}

capi_return_t tiledb_buffer_list_get_buffer(
Expand All @@ -145,21 +146,21 @@ capi_return_t tiledb_buffer_list_get_buffer(
uint64_t buffer_idx,
tiledb_buffer_t** buffer) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_buffer>(
ctx, buffer_list, buffer_idx, buffer);
TILEDB_SOURCE_LOCATION(), ctx, buffer_list, buffer_idx, buffer);
}

capi_return_t tiledb_buffer_list_get_total_size(
tiledb_ctx_t* ctx,
const tiledb_buffer_list_t* buffer_list,
uint64_t* total_size) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_total_size>(
ctx, buffer_list, total_size);
TILEDB_SOURCE_LOCATION(), ctx, buffer_list, total_size);
}

capi_return_t tiledb_buffer_list_flatten(
tiledb_ctx_t* ctx,
tiledb_buffer_list_t* buffer_list,
tiledb_buffer_t** buffer) noexcept {
return api_entry_context<tiledb::api::tiledb_buffer_list_flatten>(
ctx, buffer_list, buffer);
TILEDB_SOURCE_LOCATION(), ctx, buffer_list, buffer);
}
Loading