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

Step 7 - Relating two variables, continued #7

Closed
github-learning-lab bot opened this issue Mar 1, 2022 · 2 comments
Closed

Step 7 - Relating two variables, continued #7

github-learning-lab bot opened this issue Mar 1, 2022 · 2 comments
Assignees

Comments

@github-learning-lab
Copy link

Step 7: Relating two variables, continued

In step 5, you wrote a query that finds the definitions of macros named ntohs, ntohl and ntohll in the codebase. Now, we want to find all the invocations of these macros in the codebase.

This will be similar to what you did in step 6, where you created variables for functions and function calls, and restricted them to look for a particular function and its calls.

Note: A macro invocation is a place in the source code that calls a particular macro. This is comparable to how a function call is a place in the source code that calls a particular function.

@github-learning-lab
Copy link
Author

⌨️ Activity: Find all the invocations of ntoh* macros

This query will look like the previous one, but with macros instead of functions.

  1. Edit the file 7_macro_invocations.ql
  2. Use the auto-completion to find the class that represents macro invocations, and declare a variable that belongs to this class.
  3. Use auto-completion again on your macro invocation variable, to find the predicate that tells us the target macro being invoked.
  4. Combine this with your logic from step 5 to make sure the target is one of the ntoh* macros.
  5. As in the previous step, you can make your query more compact by omitting superfluous variable declarations.
  6. Once you're happy with the results, submit your solution.

@github-learning-lab
Copy link
Author

Congratulations, looks like the query you introduced in 1d5fdff finds the correct results!

If you created a pull request, merge it.

Let's continue to the next step.

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

No branches or pull requests

1 participant