cake a tool for adaptation of object code
play

Cake: a tool for adaptation of object code Stephen Kell - PowerPoint PPT Presentation

Cake: a tool for adaptation of object code Stephen Kell Stephen.Kell@cl.cam.ac.uk Computer Laboratory University of Cambridge Cake. . . p.1/32 Some familiar problems Software is expensive to develop expensive to maintain


  1. Cake: a tool for adaptation of object code Stephen Kell Stephen.Kell@cl.cam.ac.uk Computer Laboratory University of Cambridge Cake. . . – p.1/32

  2. Some familiar problems Software is � expensive to develop � expensive to maintain � inflexible Cake. . . – p.2/32

  3. Some common ideas, all entailing mismatch Better programming languages � great for new codebases � mismatch: inevitably many languages Decentralised development � many variant codebases evolving in parallel � mismatch: no more interface consensus Unanticipated composition � mismatch: no a priori agreement on interfaces Cake. . . – p.3/32

  4. Starting point: Cake’s big picture foo.o xyzzy.o bar.o plugh.o Cake. . . – p.4/32

  5. Cake in one slide Cake is � a language expressing compositions of software � a productive tool for overcoming mismatch � operating on binaries � designed around practical experience � ongoing work In this talk, I’ll cover � two motivational case-studies � the Cake language design � some implementation and status Cake. . . – p.5/32

  6. Wanted: a tool for helping with tasks like... Unanticipated composition: port feature P from app X to Y Case study: Konqueror + ROX-Filer Evolution: link client version 1 against library version 2 Case study: gtk-theme-switch Cake. . . – p.6/32

  7. Outline of the rest of this talk � Design and first case study � Second case study: object exchange � The Cake language: core � The Cake language: practicalities � Status and questions Cake. . . – p.7/32

  8. Experiment 1: a simple exercise in glue I like program X , but it lacks feature P found in program Y . � let X = ROX-Filer , P = history and Y = Konqueror static GList ∗ history = NULL; / ∗ Most recent ∗ / first static GList ∗ history tail / ∗ Oldest item ∗ / = NULL; void bookmarks add history( const gchar ∗ path ); GtkWidget ∗ build history menu(FilerWindow ∗ filer window ); class LIBKONQ EXPORT KonqHistoryManager : public KParts::HistoryProvider, public KonqHistoryComm { // ... void addToHistory( bool pending, const KURL& url, const QString& typedURL = QString::null, const QString& title = QString :: null ); virtual QStringList allURLs() const ; / ∗ ∗ / } ; ... Cake. . . – p.8/32

  9. Decision: black-box approach Why not hack source? � must understand source language � must understand code internals � poor compositionality � poor maintainability � time sink? Instead choose black-box approach; but possibly � less powerful? � performance? ... Cake. . . – p.9/32

  10. Decision: work with binaries Why binaries? � unify many source languages � convenience � no source code? � debugging analogue: use DWARF metadata But oblivious to � cross-module macro expansion � cross-module inlining � template metaprogramming, ... (...at compile time. First two are bad ideas anyway.) Cake. . . – p.10/32

  11. Konqueror + ROX case-study: findings Easy: � converting and transferring data � interposing on control flow Hard: � extricating the history feature from libkonq � altering embedded policy � bypassing language quirks ( protected ) � manual set-up of infrastructure state � understanding infrastructure (binding convention, ...) Interesting: difficulties were infrastructure , not application Cake. . . – p.11/32

  12. Outline of the rest of this talk � Design and first case study � Second case study: object exchange � The Cake language: core � The Cake language: practicalities � Status and questions Cake. . . – p.12/32

  13. A second case study: evolution gtk-theme-switch � one version for Gtk+ 1.2, another for Gtk+ 2.0 � forked codebase (maintenance) � ... diff ( -U3 ) is ∼ 500 lines � can one binary work with both libraries? Main challenge: exchange of mismatched objects. Cake. . . – p.13/32

  14. Object exchange in action Cake. . . – p.14/32

  15. Outline of the rest of this talk � Design and first case study � Second case study: object exchange � The Cake language: core � The Cake language: practicalities � Status and questions Cake. . . – p.15/32

  16. Introducing the Cake language Cake is a configuration language � i.e. expresses inter-component relationships � specifically: mismatch resolutions Cake complements existing languages: � accommodates heterogeneity � accommodates plug-incompatibility Cake. . . – p.16/32

  17. Cake language: basics Two main kinds of statement: � exists —describes existing binaries � derive —derives new ones A simple Cake module: exists elf reloc (”switch2.o”) switch2; exists elf external sharedlib (”gtk-x11-2.0”) gtk-x11-2.0; exists elf external sharedlib (”gdk-x11-2.0”) gdk-x11-2.0; // ... more follow derive elf executable (”switch2”) switch-exec = make exec( link [switch2, gtk-x11-2.0, gdk-x11-2.0, / ∗ ∗ / ] ... ); Cake. . . – p.17/32

  18. A simple mismatch, using C ++ struct foo { struct foo { int a; float b; float b; int a; } ; char pad ignored [42]; } ; int manipulate foo( struct foo ∗ f ); int manipulate foo( struct foo ∗ f ); In C ++ , you might write wrap manipulate foo ( first :: foo ∗ f) { int obj.a = f − > a; obj.b = f − > b; second::foo obj; int retval = second:: manipulate foo(&obj); f − > a = obj.a; f − > b = obj.b; return retval ; } Cake. . . – p.18/32

  19. A simple mismatch, in Cake In Cake, you’d write... ...nothing! (Assuming sufficient debug information...) Cake. . . – p.19/32

  20. Function correspondences (1) Consider these two mismatched functions. ∗ o, guint gtk signal connect (GtkObject ∗ name, const gchar GtkSignalFunc f , gpointer f data ); gulong g signal connect data ( gpointer inst , ∗ detail , const gchar GCallback c h, gpointer data , GClosureNotify destroy data , GConnectFlags flags ); How would you manually code around this mismatch? Cake. . . – p.20/32

  21. Function correspondences (2) In Cake: derive / ∗ ∗ / switch exec = link [switch12, libgtk20 ] ... { // ... switch12 ↔ libgtk20 { gtk signal connect (i , d, c h, data) → g signal connect data (i , d, c h, data , null , {} ); // more correspondences ... } // more pairwise blocks... } ; � pattern-matching + “dual scoping” � primitive values (e.g. guint ↔ guint ) for free Cake. . . – p.21/32

  22. Value correspondences Name-matching gets so far. Further: value correspondences . GtkWindow { GtkWindow { struct struct GtkBin bin; gchar ∗ title ; // GtkBin bin; gchar ∗ title ; // ... ... gchar ∗ wm role; GtkWindowType type; guint type :4; / ∗ GtkWindowType ∗ / guint window has focus:1; } ; guint has focus :1; } ; Cake. . . – p.22/32

  23. Value correspondences Name-matching gets so far. Further: value correspondences . GtkWindow { GtkWindow { struct struct GtkBin bin; gchar ∗ title ; // GtkBin bin; gchar ∗ title ; // ... ... gchar ∗ wm role; GtkWindowType type; guint type :4; / ∗ GtkWindowType ∗ / guint window has focus:1; } ; guint has focus :1; } ; switch12 ↔ libgtk20 { values GtkWindow ↔ GtkWindow { Cake. . . – p.22/32

  24. Value correspondences Name-matching gets so far. Further: value correspondences . GtkWindow { GtkWindow { struct struct GtkBin bin; gchar ∗ title ; // GtkBin bin; gchar ∗ title ; // ... ... gchar ∗ wm role; GtkWindowType type; guint type :4; / ∗ GtkWindowType ∗ / guint window has focus:1; } ; guint has focus :1; } ; switch12 ↔ libgtk20 { values GtkWindow ↔ GtkWindow { void → wm role; Cake. . . – p.22/32

  25. Value correspondences Name-matching gets so far. Further: value correspondences . GtkWindow { GtkWindow { struct struct GtkBin bin; gchar ∗ title ; // GtkBin bin; gchar ∗ title ; // ... ... gchar ∗ wm role; GtkWindowType type; guint type :4; / ∗ GtkWindowType ∗ / guint window has focus:1; } ; guint has focus :1; } ; switch12 ↔ libgtk20 { values GtkWindow ↔ GtkWindow { void → wm role; type as .GtkWindowType < −− > type as .GtkWindowType; Cake. . . – p.22/32

  26. Value correspondences Name-matching gets so far. Further: value correspondences . GtkWindow { GtkWindow { struct struct GtkBin bin; gchar ∗ title ; // GtkBin bin; gchar ∗ title ; // ... ... gchar ∗ wm role; GtkWindowType type; guint type :4; / ∗ GtkWindowType ∗ / guint window has focus:1; } ; guint has focus :1; } ; switch12 ↔ libgtk20 { values GtkWindow ↔ GtkWindow { void → wm role; type as .GtkWindowType < −− > type as .GtkWindowType; window has focus ↔ has focus ; } } Cake. . . – p.22/32

  27. More complex correspondence patterns Function patterns may be predicated on call content: // rule matched when using a particular argument value → ( true ); gtk type check object cast (0, ) Simple stub language for defining sequences (on RHS): ) → gtk window set policy (win, shrink , grow, ( if shrink then gtk window set size request (win, 0, 0) else void ; if grow then gtk window set resizable (win, TRUE) else void ); � future: context -predicated patterns (stack; sequence...) Cake. . . – p.23/32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend