Debugging Rust in Vim

On Fedora:

yum install termdebug

in ~/.vimrc

let g:termdebug_config = {}
let g:termdebug_config['command'] = 'rust-gdb'

packadd! termdebug
                   

Inside vim:

Termdebug target/debug<executable>

Use Ctrl-W DownArrow to switch between windows

Use :Break to set a breakpoint in the code window

Use Ctrl-W UpArrow to go to the gdb window

use run to run the program and cont to continue after hitting a break point.

DHCP Lease Design

The key piece of persisted data in an DHCP server is the lease. A lease is a the mapping between a MAC address and an IP address, limited in time. A Lease typically has a start time and an end time, but can be renewed. Because I am still living in an IPV4 world, I have to deal with arbitrarily small pools of IP addresses. Thus, the design needs to strike the balance between static and dynamic: a machine should generally get back the same IP address each time. However, if addresses get tight, address reuse should be aggressive.

Continue reading

Extract Function Refactoring using inline functions.

The Extract Function refactoring is the starting point for much of my code clean up. Once a “Main” function gets sufficiently complicated, I pull pieces of it out into their own functions, often with an eye to making them methods of the involved classes.

While working with some rust code, I encountered an opportunity to execute this refactoring on some logging code. Here’s how I executed it.

Continue reading