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

Add documentation of mambo API used in exercise 2 #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mskordal
Copy link
Contributor

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

@IgWod IgWod self-assigned this Mar 14, 2024
@IgWod IgWod self-requested a review March 14, 2024 09:50
Copy link
Collaborator

@IgWod IgWod left a 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
Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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.

* DBM use case.
*
* An mmap wrapper that allocates private to MAMBO memory space with read/write
* permissions.
Copy link
Collaborator

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 Show resolved Hide resolved
* 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.
Copy link
Collaborator

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.

*
* @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.
Copy link
Collaborator

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?

* 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
Copy link
Collaborator

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?

* @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
Copy link
Collaborator

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.

@mskordal mskordal force-pushed the doc_branch branch 2 times, most recently from d10aec5 to c37af0f Compare April 12, 2024 11:53
Copy link
Collaborator

@IgWod IgWod left a 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.

void mambo_free(mambo_context *ctx, void *ptr);

/* Access plugin data */
/**
* @brief Stores an address to a global structure, making data of that address
Copy link
Collaborator

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 ... ?

* 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.
Copy link
Collaborator

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.


/**
* @brief Uses the untranslated address of the application's instruction to
* return the symbol name, the starting address of the symbol name and the
Copy link
Collaborator

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".

Copy link
Collaborator

@IgWod IgWod left a 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.

void mambo_free(mambo_context *ctx, void *ptr);

/* Access plugin data */
/**
* @brief Stores an address to a global structure, making data storedat that
Copy link
Collaborator

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"

@IgWod IgWod requested a review from jkressel May 29, 2024 10:48
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants