sample.cis compiled into thesampexecutable usingmake- Depending on an argument it calls different function.
- 'm' =>
myFunctionjust adds numbers and prints. - 's' =>
segfsegfaults. - 'f' =>
fork_exampleforks a child process and then waits on it. - 'u' =>
useAfterFreeuse after free error. - 'l' =>
leakcreates a memory leak.
samp_sanexecutable viamake samp_san- Compilied with clang sanatizers turned on.
- Use for memory leak and use after free.
- How to use:
- Compile with
-gflag (and- Wall) - start via
$ gdb <executable> - Begin debugging
(gdb) start <args> - Toggle in/out of terminal UI (TUI) via
ctrl-x a- If the ui looks wonky, simple leave and re-enter ui mode.
- Compile with
- Simple usage [use myFunction()
./samp m]step(s)breakpoint(b)info breakpointsd <breakpoint>clear(Deletes all breakpoints)
continue(c)finish(f)
- How to debug with segfaults [use segf()
./samp s]:backtrace(bt)
- How to debugg multi-threaded programs [use fork_example()
./samp f]set follow-fork-mode <child/parent>
- Signal Handling
catch signal <code>- stops
gdbfrom passing the signal to program
- stops
handle <signal> <action>
- Sanitziers
- Compile options for
clang/gcc- Wrap
malloc,free, etc. - Maintain metadata, find problems
- Wrap
- Great for memory leaks, use after free, etc.
- What do we need?
- Compile options (see
Makefile) llvm-symbolizer- You probably need to install it (usually in the
llvmpackage) - You may also already have it installed as
llvm-symbolizer-6.0orllvm-symbolizer-3.6- In either of these cases symlink the newer version to the default path
sudo ln -s /usr/bin/llvm-symbolizer-<version> /usr/bin/llvm-symbolizer
- You probably need to install it (usually in the
- Compile options (see
- How to debug use after free [useAfterFree()
./samp_san u] - How to debug leak [leak()
./samp_san l]
- Compile options for
- Resources
- What does it do?
- One
sshsession, multiple terminals - Keep session state.
- One
- Basic operation
$ tmux new-session -c ~/path/to/project -s <name>tmux attach -t <name>tmux afor most recent
- Once you're in...
- prefix
ctrl-b- most commands are prefix then action
- Panes
- horizontal split
<prefix> " - vertical split
<prefix> % - switch panes with arrow keys or
h j k l(vim) - delete pane
<prefix> x
- horizontal split
- Tabs
- create
<prefix> c - switch
<prefix> <number>
- create
- prefix
- Good Config
- cis380/gists
- install by copying into
~/.tmux.conf
- I'm assuming you have basic git familiarity.
- Collaboration
- Often we are in a scenario when two people want to push to the same branch.
- This creates a problem, as only one will be able to do it and the other will need to merge.
- What we really want is whoever is second to have their changes be on top of first's.
git pull --rebase- Will apply the commits you are pulling under your current work.
- I'm going to assume you're familiar with basic vim.
- Settings
jjescapes to normal mode from insert mode.- Line numbering on.
- Tabs are 4 spaces.
- Extra goodies
ctrl psearch for files in git repo which are opened in buffers.:bufferor:b...ddeleteppreviousnnext
:b <Tab>to autocomplete with open buffers.
- linting
- auto formatting (with a
.clang-formatfile)- Make one here, click on a line to see what it does.
- Simply put it in the project root.
- Good syntax highlighting
gitintegration:GBlame= see who messed up the code
gitline status
- Plenty of plugins are there, check them out, look at
~/.vimrc
- Most of what
makeis doing is dependancy resolution. - What comes before the
:is a target.- What comes after are the things it depends on.
- Beneath the target and dependancies is the receipe.
- This means, given all the dependancies, it will construct the target.
- Essentially, a Makefile defines a graph from your source files/directories to executable binaries.
- Please see the Makefile in the repo for more details.