-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add documentation of mambo API used in exercise 2 #118
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. Great work!
I added some comments. Mostly they're minor suggestions to improve readability and add some extra information. However, mambo_set/ger_*_data
needs a bit more work. At the moment text in all 4 functions is too confusing. I added some comments, but I'm happy to discuss it further.
api/hash_table.h
Outdated
* @param ht The hash-table to be initialised. | ||
* @param initial_size The initial size of the hash-table. Will be round up to a | ||
* power of 2. | ||
* @param index_shift How many times a key is shifted to determine the index in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to say: The number of bits a key ... . For me how many times implies, there are multiple shift operations.
api/hash_table.h
Outdated
* | ||
* @param ht The hash-table to add the key-value pair. | ||
* @param key The key of the key-value pair. | ||
* @param value The value of the key-value pair. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make clear that the value can be a pointer to a more complex data structure, so that the user knows the hashmp supports more than just a 64-bit integer pair?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, a developer can use a variable however they want. As far as the hash-table is conserned, the value is just a value though. I can add that statement, but I believe the function's documentation should focus on what the function does
api/hash_table.h
Outdated
* @pre @c key must be greater than 0. | ||
* | ||
* @param ht The hash-table to add the key-value pair. | ||
* @param key The key of the key-value pair. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also say that the key often is an address in the hosted applications that we want to associate the data with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again this refers to a use case. We could write a tutorial where we showcase the hash-table being used for that reason. But regarding the hash-table, the key is just a key. I can add it though if we want to add further use cases into the documentation
api/hash_table.h
Outdated
* | ||
* @param ht The hash-table to retrieve the value from. | ||
* @param key The key used to locate the value within the hash-table. | ||
* @param value Pointer to the address where the value will be stored after this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about: "Pointer where the address of the retrieved data will be stored after this..."? I know it's a tricky one to write.
api/plugin_support.h
Outdated
* DBM use case. | ||
* | ||
* An mmap wrapper that allocates private to MAMBO memory space with read/write | ||
* permissions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add: It should be used instead of the regular libc malloc inside plugins.
api/plugin_support.h
Outdated
* accessible between callbacks of all threads running in MAMBO. | ||
* | ||
* @param ctx The context that holds the plugin state. | ||
* @param data Pointer to the address where data will be stored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again this is very confusing. Do you mean: Pointer that is stored by the helpers and that pointer points to a global data structure? I think now the text implies that data is the pointer where the helper will store some data.
api/plugin_support.h
Outdated
* | ||
* @param addr The untranslated address of the application's instruction. | ||
* @param sym_name Pointer to the pointer to the address where the symbol name | ||
* will be stored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or simply: Pointer to a string?
api/plugin_support.h
Outdated
* will be stored. | ||
* @param start_addr Pointer to the pointer to the address where the starting | ||
* address of the symbol name will be stored. | ||
* @param filename Pointer to the pointer to the address where the filename will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: Pointer to a string?
api/plugin_support.h
Outdated
* @param addr The untranslated address of the application's instruction. | ||
* @param sym_name Pointer to the pointer to the address where the symbol name | ||
* will be stored. | ||
* @param start_addr Pointer to the pointer to the address where the starting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd simplify this one to: Pointer to a pointer where the starting ...
I know we discussed that, but the current writing makes it confusing when I'm reading it.
d10aec5
to
c37af0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing the feedback. The PR is almost ready, but I added few small comments to remove any potential confusion from the text.
api/plugin_support.h
Outdated
void mambo_free(mambo_context *ctx, void *ptr); | ||
|
||
/* Access plugin data */ | ||
/** | ||
* @brief Stores an address to a global structure, making data of that address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about: ... making data stored at that address ... ?
api/plugin_support.h
Outdated
* accessible between callbacks of all threads running in MAMBO. | ||
* | ||
* @param ctx The context that holds the plugin state. | ||
* @param data The pointer of the address to be stored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be either: "The address to be stored" or "The pointer to be stored" or ".... pointer to the address ...". Otherwise it'd imply data is pointer to pointer. In this case think about void* as uintptr_t.
api/plugin_support.h
Outdated
|
||
/** | ||
* @brief Uses the untranslated address of the application's instruction to | ||
* return the symbol name, the starting address of the symbol name and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "name" in "the starting address of the symbol name".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the small typo it looks good to me. I added @jkressel so he can review it as well.
api/plugin_support.h
Outdated
void mambo_free(mambo_context *ctx, void *ptr); | ||
|
||
/* Access plugin data */ | ||
/** | ||
* @brief Stores an address to a global structure, making data storedat that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small typo: "storedat" -> "stored at"
The following functions are documented: --------------------------------------- In api/plugin_support.h: ------------------------ mambo_alloc mambo_free mambo_set_plugin_data mambo_get_plugin_data mambo_set_thread_plugin_data mambo_get_thread_plugin_data mambo_get_source_addr mambo_get_thread_id get_symbol_info_by_addr In api/hash_table.h: -------------------- mambo_ht_init mambo_ht_add mambo_ht_get
The following functions are documented:
In api/plugin_support.h:
mambo_alloc
mambo_free
mambo_set_plugin_data
mambo_get_plugin_data
mambo_set_thread_plugin_data
mambo_get_thread_plugin_data
mambo_get_source_addr
mambo_get_thread_id
get_symbol_info_by_addr
In api/hash_table.h:
mambo_ht_init
mambo_ht_add
mambo_ht_get