Skip to content

Instantly share code, notes, and snippets.

View jprudent's full-sized avatar
🦋
Chasing butterflies

Jérôme Prudent jprudent

🦋
Chasing butterflies
View GitHub Profile
@jprudent
jprudent / mockito.clj
Created September 7, 2021 11:45
Mockito but for clojure
(defn mix-behaviours
[& behaviours]
(fn [& args]
(doseq [f (butlast behaviours)]
(apply f args))
(apply (last behaviours) args)))
(defn dyn-type
[implementations]
(let [instance (reify)
@jprudent
jprudent / loop3.rb
Created September 28, 2020 15:54
loop3
bass = (ring :d, :r, :r, :a, :f5, :r, :a, :r)
bass2 = (ring :d, :r, :r, :Bb, :g5, :r, :Bb, :r)
live_loop :hanabera do
sync :metronom
use_synth :fm
if (one_in(12))
melody = bass2
else
melody = bass
end
@jprudent
jprudent / loop2.rb
Created September 28, 2020 15:00
Loop2
use_bpm 102
delta = (line 0, 0.1, steps: 5).mirror
chords = knit(:minor, 5, :m7, 5)
tonics = knit(60, 10, 65, 10)
live_loop :foo do
use_synth :dsaw
sync :kick
play chord(tonics.tick, chords.tick(:chord)), sustain: 1.9, amp: 0.1
sleep 1
@jprudent
jprudent / aoc2019.clj
Last active December 8, 2019 19:04
Advent of code 2019
;; _ _ _ __ ____ _
;; / \ __| |_ _____ _ __ | |_ ___ / _| / ___|___ __| | ___
;; / _ \ / _` \ \ / / _ \ '_ \| __| / _ \| |_ | | / _ \ / _` |/ _ \
;; / ___ \ (_| |\ V / __/ | | | |_ | (_) | _| | |__| (_) | (_| | __/
;;/_/ \_ \__, _| \_/ \___|_| |_| \__| \___/|_| \____ \___/ \__, _| \___|
;; ____ ___ _ ___
;; |___ \ / _ \/ |/ _ \
;; __) | | | | | (_) |
@jprudent
jprudent / build.boot
Created May 23, 2017 20:49
Boot SOAP binary client generator from WSDL in 2017
(set-env! :dependencies '[[me.raynes/conch "0.8.0"]
[onetom/boot-lein-generate "0.1.3" :scope "test"]]
:source-paths #{"src"})
(require 'boot.lein)
(boot.lein/generate)
(task-options!
@jprudent
jprudent / playground.rs
Created January 18, 2017 13:36 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Hook;
struct Timer;
struct ComputerUnit<'a> {
hooks: Vec<&'a mut Hook>,
memory: Mmu<'a>
}
impl<'a> ComputerUnit<'a> {
fn new(hooks: Vec<&'a mut Hook>, timer: &'a Timer) -> ComputerUnit<'a> {
@jprudent
jprudent / channels.rs
Created January 16, 2017 22:39
Playing with Rust channels
#[cfg(test)]
mod tests {
use std::sync::mpsc::{sync_channel, SyncSender, Receiver};
use std::thread;
enum TimerCommand {
Read,
Write(u8),
Update(u8)
}
@jprudent
jprudent / playground.rs
Created January 14, 2017 17:07 — forked from anonymous/playground.rs
Shared via Rust Playground
struct CpuHook {
counter: u64
}
impl CpuHook {
pub fn inspect(&mut self, cpu: &Cpu) {
// here I don't use the cpu but I could log the cpu register in a mutable file for instance
self.counter = self.counter.wrapping_add(1);
}
}
@jprudent
jprudent / playground.rs
Created January 12, 2017 14:33 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Element {
x: u8
}
impl Element {
pub fn inc(&mut self, container: &Container) {
self.x = self.x + 1;
}
}

Motivations

Un debugger est un outil fabuleux : cette sensation de contrôle divin ! La possibilité de figer l'exécution d'un process et d'inspecter les arcanes de sa mémoire.

C'était les deux phrases lyriques de cet article :) Nous verrons que le divin n'est qu'une machinerie bien huilée.

Le débugger est un outil que j'utilise quotidiennement. Je trouve important d'en comprendre les mécanismes sous-jacents. Ecrire un concurrent à GDB n'est certainement pas la meilleur façon d'utiliser son temps libre. En revanche écrire un POC de débugger est certainement la manière la plus didactique d'apprendre ! Et c'est ce que je vous propose aujourd'hui, d'écrire un petit debugger pas super pratique mais fonctionnel.

Concernant le fond, cet article ne traite que de Linux sous architecture x86_64. Il part du principe que vous avez de vagues notions sur ce qu'est :