12.07.2015 Views

Strumenti di Sviluppo Programmi in UNIX

Strumenti di Sviluppo Programmi in UNIX

Strumenti di Sviluppo Programmi in UNIX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Corso <strong>di</strong> Fondamenti <strong>di</strong> Informatica 2CdL Ingegneria InformaticaIng. Franco ZambonelliIL SISTEMA OPERATIVO <strong>UNIX</strong>:STRUMENTI PER LO SVILUPPO DIPROGRAMMILuci<strong>di</strong> Realizzati <strong>in</strong> Collaborazione con:Prof. Letizia Leonar<strong>di</strong>Università <strong>di</strong> ModenaProf. Antonio Corra<strong>di</strong>Università <strong>di</strong> BolognaProf. Cesare StefanelliUniversità <strong>di</strong> FerraraUnix: <strong>Strumenti</strong> <strong>di</strong> <strong>Sviluppo</strong> - 1Coman<strong>di</strong> per lo sviluppo <strong>di</strong> un programmaCC o GCC: Compilatore C (+ l<strong>in</strong>ker)cc -o prog -g nomefile1 ... nomefileN• I file oggetto hanno estensione .o• Opzione -o specifica nome dell’eseguibile (qui, prog)[ default: a.out ]• I vari nomefile1 ... nomefileN possono essere anchedei file oggetto (.o) vengono solo l<strong>in</strong>kati (noncompilati)• Il qualificatore -g aggiunge le tabelle per il debuggercb: C program Beautifiermigliora <strong>in</strong>dentazione e paragrafazionecflow: crea il grafo <strong>di</strong> chiamate dei vari file <strong>in</strong><strong>in</strong>gressocflow nomfilesorgente1 ... nomefilesorgente.n• per default, solo funzioni• con l’opzione -ix anche variabili extern e staticcxref: costruisce una tabella dei riferimenti <strong>in</strong>crociaticxref nomefilesorgente• <strong>di</strong>ce chi viene chiamato da chi (<strong>in</strong> che file, a che riga, ...)Unix: <strong>Strumenti</strong> <strong>di</strong> <strong>Sviluppo</strong> - 2


un argomenti { <strong>in</strong>izia l’ esecuzione }stop at l<strong>in</strong>eastop if con<strong>di</strong>zione { ad es. sul valore <strong>di</strong> una variabile }stop <strong>in</strong> proc { varie forme <strong>di</strong> breakpo<strong>in</strong>t }cont { cont<strong>in</strong>ua f<strong>in</strong>o al prossimo breakpo<strong>in</strong>t }step n { trace <strong>in</strong>to, esegue n l<strong>in</strong>ee per volta (def.1)ctrace: controlla l’esecuzione(attenzione: mo<strong>di</strong>fica il file sorgente)Uso suggerito:ctrace sorgente.c > temp.c {un file per volta}cc temp.c { uscita <strong>di</strong> default su a.out }a.out { esecuzione controllata }dbx: Debugger SimbolicoI file eseguibili devono essere stati prodotti conl'opzione -g dal compilatore cc o gcc.Coman<strong>di</strong> per la mo<strong>di</strong>fica:list l<strong>in</strong>eaIniziale, l<strong>in</strong>eaF<strong>in</strong>alee<strong>di</strong>t nomeFilee<strong>di</strong>t nomeFunzionefunc nomeFunzione {<strong>di</strong>chiara la funzione corrente}Si possono analizzare e variare i dati:<strong>di</strong>splay espressioneconvariabili (watch delTurboC)un<strong>di</strong>splay espressioneconvariabiliwhatis identificatore { dà il tipo della variabile }which identificatore { dà <strong>in</strong><strong>di</strong>cazioni sulla variabilecorrentemente specificata }whereis identificatore { fornisce <strong>in</strong><strong>di</strong>cazioni relative avariabili o entità con quel nome}dump funzione { stampa i valori ed i parametridella funzione stessa, se attiva }Unix: <strong>Strumenti</strong> <strong>di</strong> <strong>Sviluppo</strong> - 3Esecuzione controllata:}next n { step over, idem come sopra}Ad esempio, per partire:stop <strong>in</strong> ma<strong>in</strong>runMAKE, il correlatore <strong>di</strong> strumentiIl make gestisce <strong>in</strong> modo ‘automatico’ il progetto <strong>di</strong> fileche costituiscono un’applicazioneLo sviluppo <strong>di</strong>venta automatico dopo aver specificato le<strong>di</strong>pendenze fra i fileUnix: <strong>Strumenti</strong> <strong>di</strong> <strong>Sviluppo</strong> - 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!