LLDB Column Breakpoints

If you’ve ever used the debugger, chances are you’ve used a file and line number to set a breakpoint. Most of the time this provides enough granularity. Sometimes, though, more fine grained control would be helpful. Consider the following example: int foo() { return 1; } int bar() { return 2; } int baz() { return 3; } int main(int argc, char** argv) { return foo() + bar() + baz(); } Line Breakpoints Let’s say we want to step into the function baz on line 11 and can’t set a breakpoint on baz itself....

February 20, 2020

Lua Scripting in LLDB

LLDB is the debugger developed as part of the LLVM project. It is probably most known as the debugger in Xcode, but many use it as an alternative to GDB. Scripting in LLDB One thing that makes LLDB really powerful is how scriptable it is. It has a stable C++ API, called the SB API or Scripting Bridge API, which is accessible through Python. Following LLVM’s model of reusable components, most of LLDB constitutes a debugger library and the SB API is how tools like the command line driver interface with it....

December 22, 2019

Sanitizing C++ Python Modules

Python has great interoperability with C and C++ through extension modules. There are many reasons to do this, such as improving performance, accessing APIs not exposed by the language, or interfacing with libraries written in C or C++. Unlike Python however, C and C++ are not memory safe. Luckily, great tools exist to help diagnose these kind of issues. One of those tools is ASan (Address Sanitizer) which uses compiler instrumentation to detect memory errors at runtime....

December 20, 2019

Calling Into C or C++ Code From Python

Recently I wanted to call some C code from Python to check who was sending a particular signal. Apparently this functionality is only available as of Python 3 so I decided to write a custom module. Doing so is relatively easy but all the documentation I found only was usingdistutils to build the module and skipped over how to find the newly builtmodule. This post is mostly a write up of what I found out....

December 5, 2018

Using LSP & clangd in Vim

After having used YouCompleteMe, I finally decided to give one of the Language Server Protocol (LSP) implementations a spin. As an LLVM developer I’ve been following clangd’s development and wanted to try it out. At the time of writing, several LSP implementations exist for Vim: LanguageClient-neovim vim-lsc vim-lsp Setting up vim-lsp I decided to go with vim-lsp because it’s asyncronous, written in vimscript and easy to setup. The plugin has a single dependency: async....

April 22, 2018

Finding Reviewers for Your Patch

Finding the right people to review your patch can be tough. I see the question “who should I add as reviewer for this patch?” popping up on IRC quite regularly and not something I’m unfamiliar with myself. Not every project has a list of code owners and as soon as your change spans multiple components things might get tricky. Preferable you want reviewers that know the code you’ve changed. If the project is using git you can use git blame to find out for each individual line of a file, who changed it last....

December 16, 2017

Reference Counting PIMPL Idiom

The pointer to implementation or PIMPL idiom is a popular C++ idiom for decoupling the representation and implementation of a class. It reduces compilation times and enables a stable API while allowing the internals to change. Reference counting is another ubiquitous programming technique, used to manage an object’s lifetime by keeping track of the number of references held to it. C++’s std::shared_ptr uses this technique to provide shared ownership of an object through a pointer....

August 8, 2017

Exposing Containers of Unique Pointers

The std::unique_ptr is probably one of my favorite and most used features in modern C++. The unique pointer is as powerful as it is simple, and assuming you’ve used it before, you surely know how awesome it is. There are many great articles written about unique pointers, so I won’t go into detail. What I will mention though is that unique pointers provide ownership semantics. What this means is that the unique pointer follows a well defined set of rules regarding the lifetime of its allocated resource....

April 17, 2017

One Year At GuardSquare

Today marks my one year anniversary at GuardSquare. On the one hand it feels like yesterday (as cliché as that might sound) but on the other hand it feels like ages ago, considering how much we have been able to do in just one year’s time. For those that don’t know GuardSquare yet, allow me to quickly introduce our company. If you have ever used Java, you probably know ProGuard, our open source optimizer for Java bytecode....

March 7, 2017

Building a Workstation

January 2017 marks the sixth birthday of my desktop computer. When I purchased my trusty Intel Core i5-2500K, I would’ve never guessed that I’d use it for that long. However, rather than jumping to the recently released Kaby Lake CPUs, I’m building my new workstation around two Intel Xeon E5-2670s. Why Xeon? There’s several reasons I went with a dual Xeon setup rather than a flagship i5 or i7. The first reason is that I’m not building a gaming rig but a workstation....

January 13, 2017