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

document cflags argument to BPF() #1709

Merged
merged 2 commits into from
Apr 26, 2018
Merged

Conversation

ahrens
Copy link
Contributor

@ahrens ahrens commented Apr 25, 2018

This relates to #1707

@@ -758,7 +758,7 @@ Constructors.

### 1. BPF

Syntax: ```BPF({text=BPF_program | src_file=filename} [, usdt_contexts=[USDT_object, ...]])```
Syntax: ```BPF({text=BPF_program | src_file=filename} [, usdt_contexts=[USDT_object, ...]] [, cflags=[arg1, ...]])```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you change it. How about make it complete, include debug and hdr_file as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to, if you can explain to me what they are.

@brendangregg
Copy link
Member

I'm not sure, so I checked from src/python/bcc/init.py:

    def __init__(self, src_file=b"", hdr_file=b"", text=None, debug=0,
            cflags=[], usdt_contexts=[]):
        """Create a new BPF module with the given source code.

        Note:
            All fields are marked as optional, but either `src_file` or `text`
            must be supplied, and not both.

        Args:
            src_file (Optional[str]): Path to a source file for the module
            hdr_file (Optional[str]): Path to a helper header file for the `src_file`
            text (Optional[str]): Contents of a source file for the module
            debug (Optional[int]): Flags used for debug prints, can be |'d together
                                   See "Debug flags" for explanation
[...]
# Debug flags

# Debug output compiled LLVM IR.
DEBUG_LLVM_IR = 0x1
# Debug output loaded BPF bytecode and register state on branches.
DEBUG_BPF = 0x2
# Debug output pre-processor result.
DEBUG_PREPROCESSOR = 0x4
# Debug output ASM instructions embedded with source.
DEBUG_SOURCE = 0x8
#Debug output register state on all instructions in addition to DEBUG_BPF.
DEBUG_BPF_REGISTER_STATE = 0x10

I don't know the purpose of hdr_file.

@drzaeus77
Copy link
Collaborator

            src_file (Optional[str]): Path to a source file for the module
            hdr_file (Optional[str]): Path to a helper header file for the `src_file`

These are both holdovers from src/cc/frontends/b, and shouldn't be used when using restricted-c style programs.

@drzaeus77
Copy link
Collaborator

Sorry, I spoke without looking at the source. While hdr_file is for frontends/b, src_file is still used for both modes, though I think most if not all scripts use BPFModule::load_string and hence use the python text="" argument, which is mutually exclusive with src_file.

@yonghong-song
Copy link
Collaborator

Okay, so let just document debug flags since hdr_files is for b frontend.

@ahrens
Copy link
Contributor Author

ahrens commented Apr 26, 2018

@yonghong-song I added documentation of the debug flags.

@yonghong-song
Copy link
Collaborator

[buildbot, ok to test]

@yonghong-song
Copy link
Collaborator

Looks good. Thanks for help improving our documentation!

@yonghong-song yonghong-song merged commit 8f1a22a into iovisor:master Apr 26, 2018
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.

None yet

4 participants