Rev 2742 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2742 | Rev 3139 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | Introduction. |
1 | Introduzione. |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | mtdbg is a debugger for Kolibri operating system. This documentation describes |
3 | mtdbg è un debugger per il sistema operativo KolibriOS. Questo documento |
- | 4 | descrive come utilizzare tale programma. Per eventuali domande conviene |
|
4 | debugger features and work with it. Feel free to ask on our board (mostly |
5 | scrivere sul forum (in russo, ma esiste anche una sezione inglese) |
5 | in Russian, but has an English forum) -- board.kolibrios.org. |
6 | -- board.kolibrios.org. |
6 | 7 | ||
7 | General description. |
8 | Descrizione generica. |
8 | 9 | ||
9 | In each moment of time mtdbg can debug only one program. I will call it |
10 | mtdbg è in grado di fare il debug di un solo programma alla volta, se non |
10 | loaded program. If no program is loaded, overwhelming majority of debugging |
- | |
11 | actions is disabled. |
11 | viene caricato nessun programma, il debug viene disabilitato. |
12 | 12 | ||
13 | mtdbg is controlled by command line, entering from keyboard. Command line |
13 | Il programma è a linea di comando, e accetta in input comandi da tastiera |
14 | is drawn in the bottom part of debugger window. Debugger handles standard |
14 | La linea di comando è posizionata in basso, e accetta in input tasti |
15 | input keys Backspace,Delete,Home,End,left/right arrows. |
15 | Backspace,Delete,Home,End,frecce sinistra/destra. |
- | 16 | I comandi non sono case-sensitive e il delimitatore è un numero arbitrario |
|
16 | Commands are case-insensitive. Delimiter is arbitrary nonzero number of spaces. |
17 | non nullo di spazi. |
17 | 18 | ||
18 | At any moment mtdbg can be terminated by command "quit" (without arguments). |
19 | Per chiudere il debugger è sufficiente usare il comando "quit" senza |
- | 20 | nessun argomento, altrimenti da interfaccia cliccando sul pulsante di |
|
19 | You can also simply press to close button in the right upper corner of window. |
21 | chiusura come per le altre applicazioni. |
20 | 22 | ||
21 | When debugger is started without command string parameters, no program is |
23 | Quando il debugger viene avviato senza argomenti, non viene caricato |
22 | loaded. Also mtdbg can be started with command string, in this case it tries |
24 | nessun programma. Se invece viene avviato con degli argomenti, mtdbg |
23 | to load program with the name pointed to in first parameter in command string |
25 | cercherà di caricare il programma indicato come primo argomento e con |
24 | and parameters pointed to following (if present). |
26 | eventuali parametri per il programma passati come argomenti successivi. |
25 | 27 | ||
- | 28 | È possibile caricare un qualsiasi programma in un secondo |
|
26 | If no program is loaded, you can load a program with the command |
29 | momento con il comando |
27 | load |
30 | load |
28 | Examples: |
31 | ad esempio: |
29 | load /rd/1/example |
32 | load /rd/1/example |
30 | LOAD /rd/1/aclock w200 h200 |
33 | LOAD /rd/1/aclock w200 h200 |
- | 34 | LoaD /hd0/1/menuetos/dosbox/dosbox |
|
31 | LoaD /hd0/1/menuetos/dosbox/dosbox |
35 | negli esempi, mtdbg caricherà il programma passato come primo argomenti, |
32 | All that stays after first space after executable file name, is exactly passed |
36 | un eventuale secondo argomento è il parametro da passare al programma |
33 | to program as command string. |
37 | che si vuole caricare. |
34 | The command "load" reports result in the messages window (a little higher |
38 | Il comando "load" restituisce in output nel "messages window", poco più |
35 | than command line window). If program was loaded successfully, there will |
39 | in alto della linea di comando, se il programma è stato caricato con |
36 | be the appropriate message; otherwise the message will contain error reason. |
40 | successo o meno. In caso di errore, verra mostrata la causa. |
- | 41 | L'errore più comune è del tipo, "file not found", probabilmente perché |
|
- | 42 | si è digitato in modo errato il percorso o il nome del programma da |
|
37 | Most probable error is "file not found" if wrong file name is given. |
43 | caricare. |
38 | 44 | ||
- | 45 | Il debugger è in grado di caricare file con simboli relativi al |
|
39 | The debugger can load files with information on symbols in the program |
46 | programma di cui si vuole effetuare il debug. |
40 | (labels, global variables) - text files, each line of which has format |
47 | Si tratta di file di testo, dei quali ogni riga inizia con |
41 | 0x |
48 | 0x |
42 | (lines, which do not have such format, are ignored). Such file can be created |
49 | (righe che non iniziano in questo modo vengono ignorate). Tali file si |
- | 50 | possono creare a mano o tramite fasm. È possibile caricare questi file |
|
43 | by hand or generated automatically by fasm. Evident load can be done by command |
51 | esplicitamente con il comando |
44 | load-symbols |
52 | load-symbols |
45 | Furthermore, when the debugger executes the command "load", it checks for |
53 | Inoltre, quando viene eseguito il comando "load", mtdbg controllerà |
- | 54 | la presenza di un file contenente simboli relativi al programma e di |
|
46 | presence of file with name as of loading binary and extension '.dbg' |
55 | estensione .dbg (nel primo esempio controlla la presenza del file |
47 | (/rd/1/example.dbg in the first of examples above), and if such file exists, |
56 | /rd/1/example.dbg). Se tale file esiste, questo viene caricato |
- | 57 | automaticamente and if such file exists, e verrà notificato tramite il |
|
48 | the debugger loads it automatically (with the message "Symbols loaded", if |
58 | messaggio "Symbols loaded", se il caricamento viene eseguito con |
49 | all is OK). |
59 | successo. |
50 | 60 | ||
- | 61 | Può succedere che un programma che si vuole caricare è stato |
|
51 | It can happen so that loaded program is packed. General principle of |
62 | compresso. La compressione funziona, in linea generale, nel |
52 | program packing is following: at first input file is packed (by some |
63 | seguente modo: il file di input viene compresso (da qualche |
53 | pack algorithm), then is appended small code which gets control at program |
64 | programma apposito), successivamente viene aggiunto un pezzo di codice |
54 | start, unpacks input code in the memory and then passes control to it. |
65 | che all'avvio del programma effettua una decompressione in memoria. |
55 | If program is packed, it "real" code is not visible and for debugging it is |
66 | Se un programma è stato compresso, il suo codice non è visibile al |
56 | needed previously to pass through unpacker code. |
67 | debugger, e deve venir prima decompresso. |
- | 68 | mtdbg è in grado di determinare la maggior parte di compressori |
|
57 | mtdbg determines most of existing packers (mxp,mxp_lzo,mxp_nrv,mtappack) |
69 | (mxp,mxp_lzo,mxp_nrv,mtappack) e in questi casi suggerisce in automatico |
58 | and in this case suggests to automatically go to "real" code. It is recommended |
70 | di effettuare la decompressione per vedere il codice del programma. |
- | 71 | È sufficiente pigiare 'y' e enter per accettare l'opzione, altrimenti |
|
59 | to accept (press 'y' or |
72 | rifiutarla. Se non viene riconosciuto il metodo di compressione, è |
60 | program is packed by something unknown the command "unpack" (without arguments) |
73 | sempre possibile usare il comando unpack (senza argomenti). |
61 | can be used. Call it only in the case when you are sure that program is packed |
74 | Tale comando è da usare solamente se si è sicuro che il programma sia |
62 | and control has not already went to main code! [Starting from Kolibri 0.6.5.0, |
75 | compresso e che non sia già stato decompresso dal debugger. |
63 | this paragraph is no more actual, because one can pack applications as all |
76 | [A partire da Kolibri 0.6.5.0, questo paragrafo non è più attuale poiché |
64 | binary files with kpack and the unpacker code in this case is located in the |
77 | è possibile comprimere le applicazioni con kpack e il decompressore è |
65 | kernel and is transparent for debug.] |
78 | implementato a livello kernel, in modo da rendere il debug trasparente] |
66 | 79 | ||
67 | Loaded program can be terminated by the command "terminate" (without |
80 | Un programma caricato può essere terminato tramite il comando |
- | 81 | "terminate" senza argomenti. Il comando "detach", senza parametri |
|
68 | arguments). The command "detach" (without arguments) detaches from program, |
82 | aggiuntivi "stacca" il programma dal debugger, nel senso che questo |
- | 83 | continuerà la sua normale esecuzione senza il debugger, come se questo |
|
69 | after that program continues execution normally, as if there was no debugger. |
84 | non vi fosse mai stato. |
70 | After both this commands program stops to be debugged. |
85 | Dato uno di questi due comandi, l'attività di debug viene terminata. |
71 | 86 | ||
72 | It is possible to anew load program for debugging by the command "reload" |
87 | È possibile ricaricare il programma precedente con il comando "reload", |
73 | (without arguments). If there is already loaded program, it is terminated |
88 | senza parametri. Se nel frattempo è stato caricato un altro programma, |
74 | and new instance is started (from the beginning) (with the same command |
89 | questo viene terminato e viene ricaricato il programma precedente con |
- | 90 | gli argomenti passati precedentemente, come se fossero stati dati i |
|
75 | string), in this case the command is similar to the commands |
91 | comandi |
76 | terminate |
92 | terminate |
77 | load |
93 | load |
78 | Otherwise is loaded anew latest program, which was debugged (in the current |
- | |
79 | seance of work with mtdbg) (with the same command string), i.e. is similar to |
- | |
80 | load |
94 | Il vantaggio di reload sta nel fatto di essere più immediato e che viene |
81 | but the command "reload" in both cases is shorter and more convenient; |
- | |
82 | moreover, "load" thinks that new program is loaded and moves data window |
95 | mantenuto l'indirizzo di memoria, mentre con il comando load questo |
83 | (see below) to zero address, and "reload" keeps current address. |
96 | viene spostato all'indirizzo 0. (vedi sotto) |
84 | 97 | ||
85 | The command "help", which can be shorten to "h", is always available. |
98 | Il comando "help", oppure "h", è sempre disponibile. |
86 | All commands are divided on groups. |
99 | Tutti i comandi sono divisi in gruppi |
87 | "help" without arguments displays the list of command groups. |
100 | "help" senza argomenti mostra l'elenco dei comandi disponibili |
88 | "help" with group name displays the list of commands in this group with short |
- | |
89 | comments. |
101 | "help" con il nome di un gruppo mostra i comandi relativi al gruppo |
- | 102 | "help" con il nome di un comando mostra informazioni sull'uso di tale |
|
90 | "help" with command name displays information about given command. |
103 | comando |
91 | Examples: |
104 | esempi: |
92 | help |
105 | help |
93 | help control |
106 | help control |
Line 94... | Line 107... | ||
94 | h LoaD |
107 | h LoaD |
95 | 108 | ||
96 | The debugger window consists from the following items enumerated from up |
109 | La finestra del debugger è composta dai seguenti elementi enumerati |
97 | to down: |
110 | dall'alto al basso: |
- | 111 | - status string. Se è stato caricato un programma, mostra il suo nome e |
|
98 | - status string. If there is loaded program, shows its name and state |
112 | stato ("Running/Paused"), altrimenti "No program |
- | 113 | loaded". |
|
99 | ("Running/Paused"), otherwise reports "No program loaded". |
114 | - registers window - Mostra valori di caratteri generico, valori di |
100 | - registers window - shows values of general-purpose registers, register eip |
115 | registro e stato delle singole flag: |
- | 116 | CF,PF,AF,ZF,SF,DF,OF: se una flag viene rimossa, |
|
101 | and states of single flags: CF,PF,AF,ZF,SF,DF,OF: if flag is cleared, then |
117 | allora è contrassegnata da lettere minuscole, se |
- | 118 | creata allora da lettere maiuscole. I valori di |
|
102 | is displayed lower-case letter, if flag is set, then upper-case one. |
119 | registro che vengono modificati sono contrassegnati |
- | 120 | in verde. |
|
103 | Registers which are changed from previous moment are highlighted in green. |
121 | - data window (dump window) - mostra la porzione di memoria contenente |
104 | - data window (dump window) - shows memory contains of loaded program |
122 | il programma caricato |
105 | - code window (disassembler window) - shows program code as disassembled |
123 | - code window (disassembler window) - mostra il codice del programma come |
106 | instructions |
124 | "disassembled instructions" |
Line 107... | Line 125... | ||
107 | - messages window |
125 | - messages window |
108 | - command line window |
126 | - command line window |
109 | 127 | ||
110 | Dump window can display data starting from any address, to this serves |
128 | Nella "Dump window" è possibile osservare i dati a partire da ogni |
111 | the command |
129 | indirizzo, usare il comando |
112 | d |
130 | d |
113 | The command "d" without arguments flicks dump window down. |
131 | Il comando "d", senza parametri mostra la "dump window". |
114 | The same is for code window and the command |
132 | In modo analogo funziona il seguente comando per la "code window" |
115 | u |
133 | u |
116 | or simply "u". |
134 | oppure "u". |
117 | Examples: |
135 | Esempi: |
118 | d esi - displays data at address esi (e.g. is useful before execution of |
136 | d esi - mostra i dati all'indirizzo esi (e.g. utile prima di eseguire |
119 | instruction rep movsb) |
137 | una istruzione rep movsb) |
120 | d esp - displays stack |
138 | d esp - mostra lo stack |
121 | u eip - disassembles instruction starting from the current |
139 | u eip - disassembla le istruzioni a partire dall'attuale indirizzo |
122 | 140 | ||
123 | Expressions in mtdbg can include |
141 | Le espressioni in mtdbg possono includere |
124 | - hexadecimal constants |
142 | - costanti esadecimali |
125 | - names of all general-purpose registers (8 32-bits, 8 16-bits and |
143 | - nomi generici dei registri degli indirizzi (8 32-bits, 8 16-bits e |
126 | 8 8-bits) and register eip; values of 16- and 8-bits registers are padded |
144 | 8 8-bits) e registri eip; valori di 16- e 8-bits sono riempiti nel |
127 | with zeroes to 32 bits |
145 | registro di 0 fino a raggiungere i 32 bit. |
- | 146 | - quattro operatori aritmetici +,-,*,/ (con le priorità standard) e le |
|
128 | - four arithmetic operations +,-,*,/ (with standard priorities) and |
147 | parentesi |
129 | brackets |
148 | - [se sono stati caricati i simboli del programma] nomi, caricati dal |
130 | - [if symbols information was loaded] names, loaded from dbg-file |
149 | file dbg |
131 | All calculations are realized modulo 2^32. |
150 | Tutti i calcoli sono effettuati modulo 2^32. |
132 | Examples of expressions: |
151 | Esempi di espressioni: |
133 | eax |
152 | eax |
134 | eip+2 |
153 | eip+2 |
135 | ecx-esi-1F |
154 | ecx-esi-1F |
136 | al+AH*bl |
155 | al+AH*bl |
137 | ax + 2* bH*(eip+a73) |
156 | ax + 2* bH*(eip+a73) |
138 | 3*esi*di/EAX |
157 | 3*esi*di/EAX |
139 | The command |
158 | Il comando |
140 | ? |
159 | ? |
141 | calculates value of specified expression. |
160 | calcola il valore della espressione passata come argomento. |
142 | 161 | ||
143 | Values of registers in loaded program can be changed by the command "r", which |
162 | I valori del registro caricato nel programma può essere modificato con |
144 | has two absolutely equivalent forms: |
- | |
145 | r |
- | |
146 | r |
- | |
147 | (in both cases you can place spaces as you want). Register can be any of |
163 | il comando "r" in uno dei seguenti modi (sono equivalenti) |
148 | above-mentioned - 24 general-purpose registers and eip. |
164 | r |
149 | - | ||
150 | 165 | r |
|
151 | Let us assume that the command "load" was successfully load program for |
166 | |
152 | debugging. |
167 | Supponendo che sia stato caricato un programma con successo per il |
153 | Immediately after loading program is suspended and does not execute. |
168 | debug, subito dopo il programma verrà sospeso e non più eseguito. |
154 | Press Ctrl+F7 (command-line analog is the command "s") to make one step |
169 | Premendo Ctrl+F7 (oppure dalla linea di comando "s") è possibile far |
- | 170 | effettuare una azione al programma, dopodiché questo verrà sospeso |
|
155 | in loaded program, after that control returns to debugger which displays |
171 | immediatamente, e il debugger mostrerà i nuovi valori nel registro e in |
156 | new contains of registers and memory. The system call "int 40h" is considered |
172 | memoria. |
- | 173 | la chiamata di sistema "int 40h" è considerata una azione. |
|
157 | as one step. |
174 | Premendo Ctrl+F8 (oppure dalla linea di comando "p") permette di |
158 | Pressing Ctrl+F8 (command-line analog is the command "p") also makes step in |
175 | eseguire il programma, e chiamate a procedure esterne, cicli e altre |
159 | loaded program, but procedure calls, string operations with prefix |
176 | strutture di controllo oppure operazioni con prefisso rep/repz/repnz |
160 | rep/repz/repnz and 'loop' cycles are executed as one step. |
177 | verranno interpretate come una singola azione. |
161 | The one-step commands are used usually on single program sections, |
178 | Solitamente si chiede di eseguire azioni singole su sezioni di |
162 | when it is needed, for example, to regularly trace registers value and/or |
179 | programmi, ad esempio per tenere traccia dei valori in memoria e nel |
163 | some variables in memory. |
180 | registro. |
- | 181 | Il comando |
|
164 | The command |
182 | g |
165 | g |
183 | riprende l'esecuzione del programma e attende che il controllo vada a |
166 | resumes program execution and waits until control goes to eip=given address, |
184 | eip=indirizzo dato, e in quel momento sospende il programma. |
167 | and in this moment suspends program. The command "g" without arguments |
185 | Se il comando "g" viene dato senza argomenti, viene semplicemente |
- | 186 | ripresa l'esecuzione del programma. |
|
168 | simply resumes execution. |
187 | |
169 | 188 | Per sospendere l'esecuzione del programma è sufficiente usare il comando |
|
170 | To suspend program use the command "stop" (without arguments). |
189 | "stop", senza parametri o argomenti. |
171 | 190 | ||
- | 191 | In una situazione standard il programma viene eseguito normalmente, |
|
172 | In the typical situation it is required that program is executed normally, |
192 | quando sono soddisfatte alcune condizioni, il programma viene sospeso e |
173 | but when some conditions are satisfied, program suspends and debugger receives |
193 | invia un segnale al debugger. Tali condizioni sono chiamate |
- | 194 | "breakpoints" o "breaks". |
|
174 | control. The corresponding conditions are called breakpoints or simply breaks. |
195 | L'utilizzo principale dei breakpoints è quello di interrompere |
175 | Primary type of breakpoints is to concrete address, i.e. stop execution at |
196 | l'esecuzione del programma in determinati punti. I breakpoint si |
176 | eip= |
197 | impostano con il comando |
177 | bp |
198 | bp |
178 | Note that if there is only one such breakpoint, there is more convenient to use |
199 | Si noti che se è presente un solo breakpoint, allora è più conveniente |
179 | the command "g" with argument instead. |
200 | usare il comando "g" con parametri. |
180 | 201 | ||
181 | Other type of breakpoints is on access to given memory area. Maximum |
202 | Vi sono altri tipi di breakpoint che permettono di accedera ad una data |
- | 203 | area di memoria. Il numero massimo di breakpoint di questo tipo sono 4, |
|
182 | numbers of such breakpoints is 4 (because hardware features of x86 processors |
204 | causa limitazioni hardware. |
- | 205 | bpm |
|
183 | are used and they allows only 4). |
206 | indirizzo dato |
- | 207 | bpm w |
|
184 | bpm |
208 | indirizzo dato |
- | 209 | bpmb,bpmw,bpmd |
|
185 | bpm w |
210 | dword all'indirizzo dato. bpm e bpmb sono |
- | 211 | sinonimi. Quando viene usato bpmw o bpmd, |
|
186 | bpmb,bpmw,bpmd |
212 | gli indirizzi devono essere del tipo |
187 | or dword at given address. bpm ¨ bpmb are synonyms. When bpmw,bpmd are used, |
213 | corrispondenti al tipo di dato, quindi |
188 | address must be aligned according to correspondingly word bound (i.e. be even) |
214 | per i word è dispari, per i dword è |
189 | or dword bound (i.e. be divisible by 4). |
215 | divisibile per 4. |
190 | bpmb,bpmw,bpmd w |
216 | bpmb,bpmw,bpmd w |
- | 217 | ||
191 | 218 | Per vedere la lista dei breakpoints impostati, usare il comando "bl", |
|
192 | To see the list of set breakpoints use the command "bl", to obtain information |
219 | per ottenere informazioni su un particolare breakpoint, usare il |
193 | on concrete breakpoint use "bl |
220 | comando "bl |
194 | deleted with the command "bc |
221 | È possibile rimuovere i breakpoint con il comando "bc |
195 | disabled by the command "bd |
222 | disabilitati momentaneamente con il comando "bd |
196 | use the command "be |
- | |
197 | 223 | con "be |
|
198 | Remarks. |
224 | |
199 | 225 | Note. |
|
200 | 1. When debugging your own programs you can put in code instructions |
226 | 1. Quando si effettua il debug di un proprio programma, è possibile |
201 | int3 (pay attention to absence of space!). Such instruction causes |
227 | mettere nel codice istruzione int3. Queste istruzioni creano delle |
202 | exception at normal run, which leads to process termination, but |
228 | eccezioni durante la normale esecuzione, che porta alla terminazione |
203 | at work under debugger it is simply activated (with the message |
229 | del programma, ma durante l'attività di debug permette di non dover |
204 | "int3 command at xxx"). This feature allows to not think about addresses |
230 | pensare agli indirizzi di memoria da usare nei comandi g e bp. |
205 | to use in the commands g and/or bp. |
231 | 2. La notazione standard per l'output e input è quella esadecimale. |
206 | 2. All output and all input is oriented on hexadecimal scale of notation. |
232 | 3. Quando il programma viene eseguito, la finestra del registro e dei |
207 | 3. When program is executed, registers and data window shows information |
233 | dati mostrano delle informazioni prima dell'avvio. Non si possono |
Line 208... | Line 234... | ||
208 | regarding to moment before resume; you can not set registers value in this |
234 | impostare i valori di registro in questo mode. Tuttavia il |