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

print global stmts #69

Closed
wants to merge 2 commits into from
Closed

print global stmts #69

wants to merge 2 commits into from

Conversation

ahuoguo
Copy link
Collaborator

@ahuoguo ahuoguo commented Jun 19, 2024

deals with #66

@wavid-b can you check the output for test_global_stmts? The script

        i32 a;
        a = 1;
        dummy_fn() {
            a = strcmp((arg0, arg1), "bookings");
            strcmp((arg0, arg1), "bookings");
        }
        BEGIN{
            strcmp((arg0, arg1), "bookings");
        }
        a = 10;
        END {
            a = 2;
        }

Gives me the following AST:

---- parser::tests::test_global_stmts stdout ----
Whamm functions:
-- strcmp (str_addr: (int, int), value: str) -> bool {
-- }

Scripts:
-- `script0`:
---- user defined functions:
------ dummy_fn () -> () {
-------- a = strcmp((arg0, arg1), "bookings");
-------- strcmp((arg0, arg1), "bookings");
-------- return ();
------ }

---- script global statements:
------ a = 10;
---- script providers:
------ `whamm` {
-------- packages:
---------- `` {
------------ package events:
-------------- `` {
---------------- event probe_map:
------------------ begin: (
------------------ `BEGIN` probe {
-------------------- `predicate`:
---------------------- / None /
-------------------- `body`:
---------------------- strcmp((arg0, arg1), "bookings");
------------------ }
------------------ `BEGIN` probe {
-------------------- `predicate`:
---------------------- / None /
-------------------- `body`:
---------------------- a = 2;
------------------ }
)
-------------- }
---------- }
------ }

I also have a question on

pub struct Script {
    pub name: String,
    /// The providers of the probes that have been used in the Script.
    pub providers: HashMap<String, Provider>,
    pub fns: Vec<Fn>,                     // User-provided
    pub globals: HashMap<String, Global>, // User-provided, should be VarId
    pub global_stmts: Vec<Statement>,
}

What does user-provided global means? What is the different between globals and global_stmts? Since declaring a global in front of script is Statement::Decl

ejrgilbert
ejrgilbert previously approved these changes Jun 20, 2024
@ahuoguo
Copy link
Collaborator Author

ahuoguo commented Jun 20, 2024

Now: wavid-b#5

@ahuoguo ahuoguo closed this Jun 20, 2024
@ahuoguo ahuoguo mentioned this pull request Jun 20, 2024
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.

3 participants