-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from soasme/doxygen
Generate docs using Sphinx & Doxygen.
- Loading branch information
Showing
32 changed files
with
1,942 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'Peppa PEG' | ||
copyright = '2021, Ju' | ||
author = 'Ju' | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = '1.4.0' | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
'furo', | ||
'breathe', | ||
] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = 'furo' | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] | ||
|
||
# Breathe Configuration | ||
breathe_projects = { "PeppaPEG": "../build/docs/xml/" } | ||
breathe_default_project = 'PeppaPEG' | ||
breathe_domain_by_extension = {"h": "c"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Development | ||
=========== | ||
|
||
Debug | ||
----- | ||
|
||
If you encounter segfaults or memory leaks, please check with your grammar implementation. | ||
If you believe the issue origins from Peppa PEG and want to debug it, this document can be helpful. | ||
|
||
Checking Segfaults | ||
`````````````````` | ||
|
||
Assuming your operation system has gdb or lldb installed. Depending on your toolchain, use gdb if using gcc, use lldb if using llvm. After installing a debugger, you can create a simple program that recurs the segfault problem. | ||
|
||
For example, | ||
|
||
.. code-block:: c | ||
#include "peppapeg.h" | ||
int main() { | ||
P4_Grammar* grammar = NULL; | ||
printf("%lu\n", grammar->count); | ||
} | ||
Compile the program with debugging option enabled: | ||
|
||
.. code-block:: console | ||
$ gcc -g peppapeg.c debug.c | ||
Run the program with a debugger. Gdb directive `run` can run the program, `where` can output where the program stops, and `p` can print the value of the variable. | ||
|
||
|
||
.. code-block:: console | ||
$ gdb ./a.out | ||
(gdb) run | ||
Starting program: /app/a.out | ||
warning: Error disabling address space randomization: Operation not permitted | ||
Program received signal SIGSEGV, Segmentation fault. | ||
0x000055c62cc11e6e in main () at debug.c:4 | ||
4 printf("count: %u\n", grammar->count); | ||
(gdb) where | ||
#0 0x000055c62cc11e6e in main () at debug.c:4 | ||
(gdb) p grammar | ||
$1 = (P4_Grammar *) 0x0 | ||
(gdb) quit | ||
In this case, it's `0x0` so a segfault occurred. To fix it, create the grammar using `P4_CreateGrammar()`. | ||
|
||
Checking Memory Leaks | ||
````````````````````` | ||
|
||
Assuming your operation system has gdb or lldb installed. Depending on your toolchain, use gdb if using gcc, use lldb if using llvm. After installing a debugger, you can create a simple program that recurs the segfault problem. | ||
|
||
For example, | ||
|
||
.. code-block:: c | ||
#include "peppapeg.h" | ||
int main() { | ||
P4_Grammar* grammar = NULL; | ||
printf("%lu\n", grammar->count); | ||
} | ||
Compile the program with debugging option enabled: | ||
|
||
.. code-block:: console | ||
$ gcc -g peppapeg.c debug.c | ||
Run the program with a debugger. Gdb directive `run` can run the program, `where` can output where the program stops, and `p` can print the value of the variable. | ||
|
||
|
||
.. code-block:: console | ||
$ gdb ./a.out | ||
(gdb) run | ||
Starting program: /app/a.out | ||
warning: Error disabling address space randomization: Operation not permitted | ||
Program received signal SIGSEGV, Segmentation fault. | ||
0x000055c62cc11e6e in main () at debug.c:4 | ||
4 printf("count: %u\n", grammar->count); | ||
(gdb) where | ||
#0 0x000055c62cc11e6e in main () at debug.c:4 | ||
(gdb) p grammar | ||
$1 = (P4_Grammar *) 0x0 | ||
(gdb) quit | ||
In this case, it's `0x0` so a segfault occurred. To fix it, create the grammar using `P4_CreateGrammar()`. | ||
|
||
Conclusion | ||
`````````` | ||
|
||
Programs are not always correct as human makes mistakes. | ||
By crafting the debugging skills using tools like gdb/lldb/valgrind, we will follow the trace, pin point the problem, and fix the bug 🐛. | ||
|
||
|
Oops, something went wrong.