Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2742 → Rev 3139

/data/it/docs/MTDBG.TXT
1,135 → 1,154
Introduction.
Introduzione.
 
mtdbg is a debugger for Kolibri operating system. This documentation describes
debugger features and work with it. Feel free to ask on our board (mostly
in Russian, but has an English forum) -- board.kolibrios.org.
mtdbg è un debugger per il sistema operativo KolibriOS. Questo documento
descrive come utilizzare tale programma. Per eventuali domande conviene
scrivere sul forum (in russo, ma esiste anche una sezione inglese)
-- board.kolibrios.org.
 
General description.
Descrizione generica.
 
In each moment of time mtdbg can debug only one program. I will call it
loaded program. If no program is loaded, overwhelming majority of debugging
actions is disabled.
mtdbg è in grado di fare il debug di un solo programma alla volta, se non
viene caricato nessun programma, il debug viene disabilitato.
 
mtdbg is controlled by command line, entering from keyboard. Command line
is drawn in the bottom part of debugger window. Debugger handles standard
input keys Backspace,Delete,Home,End,left/right arrows.
Commands are case-insensitive. Delimiter is arbitrary nonzero number of spaces.
Il programma è a linea di comando, e accetta in input comandi da tastiera
La linea di comando è posizionata in basso, e accetta in input tasti
Backspace,Delete,Home,End,frecce sinistra/destra.
I comandi non sono case-sensitive e il delimitatore è un numero arbitrario
non nullo di spazi.
 
At any moment mtdbg can be terminated by command "quit" (without arguments).
You can also simply press to close button in the right upper corner of window.
Per chiudere il debugger è sufficiente usare il comando "quit" senza
nessun argomento, altrimenti da interfaccia cliccando sul pulsante di
chiusura come per le altre applicazioni.
 
When debugger is started without command string parameters, no program is
loaded. Also mtdbg can be started with command string, in this case it tries
to load program with the name pointed to in first parameter in command string
and parameters pointed to following (if present).
Quando il debugger viene avviato senza argomenti, non viene caricato
nessun programma. Se invece viene avviato con degli argomenti, mtdbg
cercherà di caricare il programma indicato come primo argomento e con
eventuali parametri per il programma passati come argomenti successivi.
 
If no program is loaded, you can load a program with the command
load <full name of executable file> [<parameters>]
Examples:
È possibile caricare un qualsiasi programma in un secondo
momento con il comando
load <percorso all'eseguibile> [<parametri>]
ad esempio:
load /rd/1/example
LOAD /rd/1/aclock w200 h200
LoaD /hd0/1/menuetos/dosbox/dosbox
All that stays after first space after executable file name, is exactly passed
to program as command string.
The command "load" reports result in the messages window (a little higher
than command line window). If program was loaded successfully, there will
be the appropriate message; otherwise the message will contain error reason.
Most probable error is "file not found" if wrong file name is given.
negli esempi, mtdbg caricherà il programma passato come primo argomenti,
un eventuale secondo argomento è il parametro da passare al programma
che si vuole caricare.
Il comando "load" restituisce in output nel "messages window", poco più
in alto della linea di comando, se il programma è stato caricato con
successo o meno. In caso di errore, verra mostrata la causa.
L'errore più comune è del tipo, "file not found", probabilmente perché
si è digitato in modo errato il percorso o il nome del programma da
caricare.
 
The debugger can load files with information on symbols in the program
(labels, global variables) - text files, each line of which has format
Il debugger è in grado di caricare file con simboli relativi al
programma di cui si vuole effetuare il debug.
Si tratta di file di testo, dei quali ogni riga inizia con
0x<hex_value_of_addr> <name>
(lines, which do not have such format, are ignored). Such file can be created
by hand or generated automatically by fasm. Evident load can be done by command
load-symbols <full name of symbols file>
Furthermore, when the debugger executes the command "load", it checks for
presence of file with name as of loading binary and extension '.dbg'
(/rd/1/example.dbg in the first of examples above), and if such file exists,
the debugger loads it automatically (with the message "Symbols loaded", if
all is OK).
(righe che non iniziano in questo modo vengono ignorate). Tali file si
possono creare a mano o tramite fasm. È possibile caricare questi file
esplicitamente con il comando
load-symbols <percorso al file>
Inoltre, quando viene eseguito il comando "load", mtdbg controllerà
la presenza di un file contenente simboli relativi al programma e di
estensione .dbg (nel primo esempio controlla la presenza del file
/rd/1/example.dbg). Se tale file esiste, questo viene caricato
automaticamente and if such file exists, e verrà notificato tramite il
messaggio "Symbols loaded", se il caricamento viene eseguito con
successo.
 
It can happen so that loaded program is packed. General principle of
program packing is following: at first input file is packed (by some
pack algorithm), then is appended small code which gets control at program
start, unpacks input code in the memory and then passes control to it.
If program is packed, it "real" code is not visible and for debugging it is
needed previously to pass through unpacker code.
mtdbg determines most of existing packers (mxp,mxp_lzo,mxp_nrv,mtappack)
and in this case suggests to automatically go to "real" code. It is recommended
to accept (press 'y' or <Enter>), but you can refuse too. At refusal and if
program is packed by something unknown the command "unpack" (without arguments)
can be used. Call it only in the case when you are sure that program is packed
and control has not already went to main code! [Starting from Kolibri 0.6.5.0,
this paragraph is no more actual, because one can pack applications as all
binary files with kpack and the unpacker code in this case is located in the
kernel and is transparent for debug.]
Può succedere che un programma che si vuole caricare è stato
compresso. La compressione funziona, in linea generale, nel
seguente modo: il file di input viene compresso (da qualche
programma apposito), successivamente viene aggiunto un pezzo di codice
che all'avvio del programma effettua una decompressione in memoria.
Se un programma è stato compresso, il suo codice non è visibile al
debugger, e deve venir prima decompresso.
mtdbg è in grado di determinare la maggior parte di compressori
(mxp,mxp_lzo,mxp_nrv,mtappack) e in questi casi suggerisce in automatico
di effettuare la decompressione per vedere il codice del programma.
È sufficiente pigiare 'y' e enter per accettare l'opzione, altrimenti
rifiutarla. Se non viene riconosciuto il metodo di compressione, è
sempre possibile usare il comando unpack (senza argomenti).
Tale comando è da usare solamente se si è sicuro che il programma sia
compresso e che non sia già stato decompresso dal debugger.
[A partire da Kolibri 0.6.5.0, questo paragrafo non è più attuale poiché
è possibile comprimere le applicazioni con kpack e il decompressore è
implementato a livello kernel, in modo da rendere il debug trasparente]
 
Loaded program can be terminated by the command "terminate" (without
arguments). The command "detach" (without arguments) detaches from program,
after that program continues execution normally, as if there was no debugger.
After both this commands program stops to be debugged.
Un programma caricato può essere terminato tramite il comando
"terminate" senza argomenti. Il comando "detach", senza parametri
aggiuntivi "stacca" il programma dal debugger, nel senso che questo
continuerà la sua normale esecuzione senza il debugger, come se questo
non vi fosse mai stato.
Dato uno di questi due comandi, l'attività di debug viene terminata.
 
It is possible to anew load program for debugging by the command "reload"
(without arguments). If there is already loaded program, it is terminated
and new instance is started (from the beginning) (with the same command
string), in this case the command is similar to the commands
È possibile ricaricare il programma precedente con il comando "reload",
senza parametri. Se nel frattempo è stato caricato un altro programma,
questo viene terminato e viene ricaricato il programma precedente con
gli argomenti passati precedentemente, come se fossero stati dati i
comandi
terminate
load <last program name> <last program arguments>
Otherwise is loaded anew latest program, which was debugged (in the current
seance of work with mtdbg) (with the same command string), i.e. is similar to
load <last program name> <last program arguments>,
but the command "reload" in both cases is shorter and more convenient;
moreover, "load" thinks that new program is loaded and moves data window
(see below) to zero address, and "reload" keeps current address.
load <vecchio programma> <vecchi parametri>
Il vantaggio di reload sta nel fatto di essere più immediato e che viene
mantenuto l'indirizzo di memoria, mentre con il comando load questo
viene spostato all'indirizzo 0. (vedi sotto)
 
The command "help", which can be shorten to "h", is always available.
All commands are divided on groups.
"help" without arguments displays the list of command groups.
"help" with group name displays the list of commands in this group with short
comments.
"help" with command name displays information about given command.
Examples:
Il comando "help", oppure "h", è sempre disponibile.
Tutti i comandi sono divisi in gruppi
"help" senza argomenti mostra l'elenco dei comandi disponibili
"help" con il nome di un gruppo mostra i comandi relativi al gruppo
"help" con il nome di un comando mostra informazioni sull'uso di tale
comando
esempi:
help
help control
h LoaD
 
The debugger window consists from the following items enumerated from up
to down:
- status string. If there is loaded program, shows its name and state
("Running/Paused"), otherwise reports "No program loaded".
- registers window - shows values of general-purpose registers, register eip
and states of single flags: CF,PF,AF,ZF,SF,DF,OF: if flag is cleared, then
is displayed lower-case letter, if flag is set, then upper-case one.
Registers which are changed from previous moment are highlighted in green.
- data window (dump window) - shows memory contains of loaded program
- code window (disassembler window) - shows program code as disassembled
instructions
La finestra del debugger è composta dai seguenti elementi enumerati
dall'alto al basso:
- status string. Se è stato caricato un programma, mostra il suo nome e
stato ("Running/Paused"), altrimenti "No program
loaded".
- registers window - Mostra valori di caratteri generico, valori di
registro e stato delle singole flag:
CF,PF,AF,ZF,SF,DF,OF: se una flag viene rimossa,
allora è contrassegnata da lettere minuscole, se
creata allora da lettere maiuscole. I valori di
registro che vengono modificati sono contrassegnati
in verde.
- data window (dump window) - mostra la porzione di memoria contenente
il programma caricato
- code window (disassembler window) - mostra il codice del programma come
"disassembled instructions"
- messages window
- command line window
 
Dump window can display data starting from any address, to this serves
the command
d <expression>
The command "d" without arguments flicks dump window down.
The same is for code window and the command
u <expression>
or simply "u".
Examples:
d esi - displays data at address esi (e.g. is useful before execution of
instruction rep movsb)
d esp - displays stack
u eip - disassembles instruction starting from the current
Nella "Dump window" è possibile osservare i dati a partire da ogni
indirizzo, usare il comando
d <espressione>
Il comando "d", senza parametri mostra la "dump window".
In modo analogo funziona il seguente comando per la "code window"
u <espressione>
oppure "u".
Esempi:
d esi - mostra i dati all'indirizzo esi (e.g. utile prima di eseguire
una istruzione rep movsb)
d esp - mostra lo stack
u eip - disassembla le istruzioni a partire dall'attuale indirizzo
 
Expressions in mtdbg can include
- hexadecimal constants
- names of all general-purpose registers (8 32-bits, 8 16-bits and
8 8-bits) and register eip; values of 16- and 8-bits registers are padded
with zeroes to 32 bits
- four arithmetic operations +,-,*,/ (with standard priorities) and
brackets
- [if symbols information was loaded] names, loaded from dbg-file
All calculations are realized modulo 2^32.
Examples of expressions:
Le espressioni in mtdbg possono includere
- costanti esadecimali
- nomi generici dei registri degli indirizzi (8 32-bits, 8 16-bits e
8 8-bits) e registri eip; valori di 16- e 8-bits sono riempiti nel
registro di 0 fino a raggiungere i 32 bit.
- quattro operatori aritmetici +,-,*,/ (con le priorità standard) e le
parentesi
- [se sono stati caricati i simboli del programma] nomi, caricati dal
file dbg
Tutti i calcoli sono effettuati modulo 2^32.
Esempi di espressioni:
eax
eip+2
ecx-esi-1F
136,77 → 155,84
al+AH*bl
ax + 2* bH*(eip+a73)
3*esi*di/EAX
The command
? <expression>
calculates value of specified expression.
Il comando
? <espressione>
calcola il valore della espressione passata come argomento.
 
Values of registers in loaded program can be changed by the command "r", which
has two absolutely equivalent forms:
r <register> <expression>
r <register>=<expression>
(in both cases you can place spaces as you want). Register can be any of
above-mentioned - 24 general-purpose registers and eip.
I valori del registro caricato nel programma può essere modificato con
il comando "r" in uno dei seguenti modi (sono equivalenti)
r <registro> <espressione>
r <registro>=<espressione>
 
Supponendo che sia stato caricato un programma con successo per il
debug, subito dopo il programma verrà sospeso e non più eseguito.
Premendo Ctrl+F7 (oppure dalla linea di comando "s") è possibile far
effettuare una azione al programma, dopodiché questo verrà sospeso
immediatamente, e il debugger mostrerà i nuovi valori nel registro e in
memoria.
la chiamata di sistema "int 40h" è considerata una azione.
Premendo Ctrl+F8 (oppure dalla linea di comando "p") permette di
eseguire il programma, e chiamate a procedure esterne, cicli e altre
strutture di controllo oppure operazioni con prefisso rep/repz/repnz
verranno interpretate come una singola azione.
Solitamente si chiede di eseguire azioni singole su sezioni di
programmi, ad esempio per tenere traccia dei valori in memoria e nel
registro.
Il comando
g <espressione>
riprende l'esecuzione del programma e attende che il controllo vada a
eip=indirizzo dato, e in quel momento sospende il programma.
Se il comando "g" viene dato senza argomenti, viene semplicemente
ripresa l'esecuzione del programma.
 
Let us assume that the command "load" was successfully load program for
debugging.
Immediately after loading program is suspended and does not execute.
Press Ctrl+F7 (command-line analog is the command "s") to make one step
in loaded program, after that control returns to debugger which displays
new contains of registers and memory. The system call "int 40h" is considered
as one step.
Pressing Ctrl+F8 (command-line analog is the command "p") also makes step in
loaded program, but procedure calls, string operations with prefix
rep/repz/repnz and 'loop' cycles are executed as one step.
The one-step commands are used usually on single program sections,
when it is needed, for example, to regularly trace registers value and/or
some variables in memory.
The command
g <expression>
resumes program execution and waits until control goes to eip=given address,
and in this moment suspends program. The command "g" without arguments
simply resumes execution.
Per sospendere l'esecuzione del programma è sufficiente usare il comando
"stop", senza parametri o argomenti.
 
To suspend program use the command "stop" (without arguments).
In una situazione standard il programma viene eseguito normalmente,
quando sono soddisfatte alcune condizioni, il programma viene sospeso e
invia un segnale al debugger. Tali condizioni sono chiamate
"breakpoints" o "breaks".
L'utilizzo principale dei breakpoints è quello di interrompere
l'esecuzione del programma in determinati punti. I breakpoint si
impostano con il comando
bp <espressione>
Si noti che se è presente un solo breakpoint, allora è più conveniente
usare il comando "g" con parametri.
 
In the typical situation it is required that program is executed normally,
but when some conditions are satisfied, program suspends and debugger receives
control. The corresponding conditions are called breakpoints or simply breaks.
Primary type of breakpoints is to concrete address, i.e. stop execution at
eip=<given value>. Such breakpoints are set by the command
bp <expression>
Note that if there is only one such breakpoint, there is more convenient to use
the command "g" with argument instead.
Vi sono altri tipi di breakpoint che permettono di accedera ad una data
area di memoria. Il numero massimo di breakpoint di questo tipo sono 4,
causa limitazioni hardware.
bpm <espressione> - interrompe ad ogni accesso ad ogni byte ad un
indirizzo dato
bpm w <espressione> - interrompe alla scrittura di ogni byte ad un
indirizzo dato
bpmb,bpmw,bpmd <espressione> - interrompe all'accesso di ogni byte, o
dword all'indirizzo dato. bpm e bpmb sono
sinonimi. Quando viene usato bpmw o bpmd,
gli indirizzi devono essere del tipo
corrispondenti al tipo di dato, quindi
per i word è dispari, per i dword è
divisibile per 4.
bpmb,bpmw,bpmd w <espressione> - simile al break in scrittura.
 
Other type of breakpoints is on access to given memory area. Maximum
numbers of such breakpoints is 4 (because hardware features of x86 processors
are used and they allows only 4).
bpm <expression> - breaks at any access to byte at given address
bpm w <expression> - breaks at write to byte at given address
bpmb,bpmw,bpmd <expression> - breaks to access correspondingly to byte, word
or dword at given address. bpm ¨ bpmb are synonyms. When bpmw,bpmd are used,
address must be aligned according to correspondingly word bound (i.e. be even)
or dword bound (i.e. be divisible by 4).
bpmb,bpmw,bpmd w <expression> - similar to break on write.
Per vedere la lista dei breakpoints impostati, usare il comando "bl",
per ottenere informazioni su un particolare breakpoint, usare il
comando "bl <numero>".
È possibile rimuovere i breakpoint con il comando "bc <numero>", oppure
disabilitati momentaneamente con il comando "bd <numero>" e riabilitati
con "be <numero>"
 
To see the list of set breakpoints use the command "bl", to obtain information
on concrete breakpoint use "bl <number>". Unnecessary breakpoints can be
deleted with the command "bc <number>", temporarily unnecessary can be
disabled by the command "bd <number>", when they will be needed again,
use the command "be <number>".
Note.
1. Quando si effettua il debug di un proprio programma, è possibile
mettere nel codice istruzione int3. Queste istruzioni creano delle
eccezioni durante la normale esecuzione, che porta alla terminazione
del programma, ma durante l'attività di debug permette di non dover
pensare agli indirizzi di memoria da usare nei comandi g e bp.
2. La notazione standard per l'output e input è quella esadecimale.
3. Quando il programma viene eseguito, la finestra del registro e dei
dati mostrano delle informazioni prima dell'avvio. Non si possono
impostare i valori di registro in questo mode. Tuttavia il
comando "d" in questo modo mostra informazioni che erano vere nel
momento in cui si è immesso il comando.
 
Remarks.
 
1. When debugging your own programs you can put in code instructions
int3 (pay attention to absence of space!). Such instruction causes
exception at normal run, which leads to process termination, but
at work under debugger it is simply activated (with the message
"int3 command at xxx"). This feature allows to not think about addresses
to use in the commands g and/or bp.
2. All output and all input is oriented on hexadecimal scale of notation.
3. When program is executed, registers and data window shows information
regarding to moment before resume; you can not set registers value in this
mode. Nevertheless the command "d" in this mode shows information that
was true in the moment of command delivery.
 
diamond