Skip to content

Instantly share code, notes, and snippets.

GDB Tips and Tricks for Debugging Pintos

As I get more familiar with the Pintos environment, I want to save notes on techniques I've found improved my quality of life when debugging through the assignments. Please don't add any comments that discuss project solutions, but feel free to contribute your own favorite ways of improving the debugging process, since I'm hoping we can create a trail of breadcrumbs for future students.

Save GDB Command History Between Sessions

One of the first things I like to do is ensure I can use the up arrow to access commands from a previous gdb session, since debugging tends to involve a lot of repetition!

@petewarden
petewarden / restart_vscode_on_myth.sh
Created February 29, 2024 19:18
Restarting VSCode Server on Stanford Myth Machines
# I use VS Code for Pintos development on Stanford's myth servers, but sometimes it fails to connect
# and can be hard to reset. Normally I'd delete `~/.vscode-server` on the remote machine, but the
# networked file system used at Stanford often seems to leave files open semi-permanently even after
# an SSH session has completed, so if I run `rm -rf ~/.vscode-server` I see errors like:
$ rm -rf .vscode-server
rm: cannot remove '.vscode-server/cli/servers/Stable-903b1e9d8990623e3d7da1df3d33db3e42d80eda/server/bin': Directory not empty
rm: cannot remove '.vscode-server/extensions/ms-vscode.cpptools-1.18.5-linux-x64.-5974b6c6.vsctmp/bin/.__afsC4E7': Device or resource busy
# To solve this, I've taken to using the `lsof` command to figure out which processes have those
@petewarden
petewarden / arch_of.py
Created July 6, 2024 20:33
Python script to determine the architecture type of a DLL on Windows
#!/usr/bin/env python
import os
import struct
import sys
# adapted from: http://stackoverflow.com/a/495305/1338797 and
# https://github.com/tgandor/meats/blob/master/missing/arch_of.py
def arch_of(dll_file):
@petewarden
petewarden / librispeech_wer.py
Last active January 2, 2025 22:26
Script to calculate the word error rate of Moonshine models
import argparse
from typing import List, Tuple
import numpy as np
from datasets import load_dataset as load_ds
from jiwer import wer
from model import MoonshineOnnxModel
from transcribe import load_tokenizer
from tqdm import tqdm
from whisper.normalizers import EnglishTextNormalizer
@petewarden
petewarden / gist:ca150f85774fd293b1bab8a684ba46b1
Created December 19, 2024 02:07
React savings calculator (from Claude)
import React, { useState } from 'react';
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
const PricingCalculator = () => {
const [downloads, setDownloads] = useState(1000);
const [fileSize, setFileSize] = useState(500);
const [downloadCostPerMB, setDownloadCostPerMB] = useState(0.12);
const [shrinkFactor, setShrinkFactor] = useState(0.3);
const calculateTotal = () => {