Compare commits

...

11 Commits

Author SHA1 Message Date
aa619aa602 libc.obj: add copyright & delete _exit.h & fix tabs in crt0.asm 2026-03-07 21:51:58 +05:00
275401c06a libc.obj: add atexit test 2026-02-22 14:07:38 +05:00
f675fd31b7 libc.obj: add abort && add exit and _exit to stdlib.h and libc.def 2026-02-22 14:03:16 +05:00
ba8747e2ab libc.obj: add atexit and normal exit. add exit code save/read 2026-02-22 13:56:25 +05:00
0319a2d7cb libc.obj: add call exit after main && translate crt0.asm and convert it to UTF-8 2026-02-22 13:35:37 +05:00
Igor Shutrov
668fd4deeb ftpd: add ip to first message 2026-02-17 22:08:04 +05:00
dd9a7b92d8 libc.obj: Fixed build skip with TCC build enabled
Signed-off-by: Max Logaev <maxlogaev@proton.me>
2026-01-28 17:22:54 +03:00
Igor Shutrov
1173ca7b26 Cedit: Improve search panel (#313)
Улучшения для Cedit в Панели поиска:
- Добавлен поиск следующего фрагмента текста по нажатию Enter
- Добавлен обратный переход по полям ввода в Панели поиска по Shift-Tab

Co-authored-by: Igor Shutrov <igor@shutrov.ru>
Reviewed-on: KolibriOS/kolibrios#313
Reviewed-by: Burer <burer@noreply.localhost>
Co-authored-by: Igor Shutrov <kolibridev@inbox.ru>
Co-committed-by: Igor Shutrov <kolibridev@inbox.ru>
2026-01-18 16:28:46 +00:00
ccd0c183ec mtdbg: Backtrace implemented (#315)
Added support for backtrace/stacktrace output.
This is useful for high-level languages ​​like C and Oberon07.
If a debug file is provided, searches for the nearest debug symbol.

Reviewed-on: KolibriOS/kolibrios#315
Reviewed-by: Mikhail Frolov <mixa.frolov2003@gmail.com>
Reviewed-by: Burer <burer@noreply.localhost>
2026-01-18 13:08:02 +00:00
f065cc6e69 mtdbg: Fixed magic cmd flags
Signed-off-by: Max Logaev <maxlogaev@proton.me>
2026-01-11 13:35:58 +00:00
f1b99bad84 libc.obj: Added missing strpbrk() to EXPORTS (#310)
Reviewed-on: KolibriOS/kolibrios#310
Reviewed-by: Max Logaev <maxlogaev@proton.me>
Co-authored-by: Егор <velikiydolbayeb@gmail.com>
Co-committed-by: Егор <velikiydolbayeb@gmail.com>
2026-01-10 23:27:51 +00:00
19 changed files with 464 additions and 90 deletions

View File

@@ -722,6 +722,7 @@ tup.append_table(img_files, {
{"SHELL", VAR_PROGS .. "/system/shell/shell"},
{"GAMES/DINO", VAR_PROGS .. "/games/dino/dino"},
{"GAMES/FLPYBIRD", VAR_PROGS .. "/games/flpybird/flpybird"},
{"LIB/LIBC.OBJ", VAR_PROGS .. "/develop/ktcc/trunk/libc.obj/source/libc.obj"},
})
tup.append_table(extra_files, {
{"kolibrios/utils/thashview", VAR_PROGS .. "/other/TinyHashView/thashview"},
@@ -745,7 +746,6 @@ if tup.getconfig('NO_GCC') ~= 'full' then
tup.append_table(img_files, {
{"GAMES/REVERSI", VAR_PROGS .. "/games/reversi/reversi"},
{"LIB/BASE64.OBJ", VAR_PROGS .. "/develop/libraries/base64/base64.obj"},
{"LIB/LIBC.OBJ", VAR_PROGS .. "/develop/ktcc/trunk/libc.obj/source/libc.obj"},
{"LIB/ICONV.OBJ", VAR_PROGS .. "/develop/libraries/iconv/iconv.obj"},
-- {"LIB/MTAR.OBJ", VAR_PROGS .. "/develop/libraries/microtar/mtar.obj"},
})

View File

@@ -47,3 +47,9 @@
перемещение по тексту:
(ctrl+)Home, (ctrl+)End, (ctrl+)PageUp, (ctrl+)PageDown
ctrl+Left, ctrl+Right
перемещение в панели поиска:
Tab к следующему полю ввода
Shift-Tab к предыдущему полю ввода
Enter поиск следующего вхождения

View File

@@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST
HEADER = "CEdit (30-apr-2025)";
HEADER = "CEdit (11-jan-2026)";
ShellFilter = "";
EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json";
@@ -1750,7 +1750,15 @@ BEGIN
ELSE
IF EditBox_Focus(FindEdit) THEN
IF keyCode = 15 THEN (* Tab *)
SetFocus(ReplaceEdit, TRUE)
IF shift THEN
SetFocus(GotoEdit, TRUE)
ELSE
SetFocus(ReplaceEdit, TRUE)
END
ELSIF keyCode = 28 THEN (* Enter *)
IF searchOpened & (searchText # "") THEN
notFound := ~T.findNext(text, BKW.value)
END
ELSE
EB.key(FindEdit, key);
EditBox_Get(FindEdit, new_searchText);
@@ -1761,14 +1769,26 @@ BEGIN
END
ELSIF EditBox_Focus(ReplaceEdit) THEN
IF keyCode = 15 THEN (* Tab *)
SetFocus(GotoEdit, TRUE)
IF shift THEN
SetFocus(FindEdit, TRUE)
ELSE
SetFocus(GotoEdit, TRUE)
END
ELSIF keyCode = 28 THEN (* Enter *)
IF searchOpened & (searchText # "") THEN
notFound := ~T.findNext(text, BKW.value)
END
ELSE
EB.key(ReplaceEdit, key);
EditBox_Get(ReplaceEdit, replaceText)
END
ELSIF EditBox_Focus(GotoEdit) THEN
IF keyCode = 15 THEN (* Tab *)
SetFocus(FindEdit, TRUE)
IF shift THEN
SetFocus(ReplaceEdit, TRUE)
ELSE
SetFocus(FindEdit, TRUE)
END
ELSE
IF (key DIV 256) MOD 256 = 13 THEN
goto

View File

@@ -47,11 +47,13 @@ vsscanf
ungetc
;____STDLIB____
abs
abort
atoi
atol
atoll
atof
calloc
_exit
exit
free
itoa

View File

@@ -0,0 +1,4 @@
.tup
*.o
*.obj
*.kex

View File

@@ -48,7 +48,13 @@ DLLAPI void free(void* ptr);
DLLAPI long int strtol(const char* str, char** endptr, int base);
DLLAPI void _exit(int status);
#ifndef _Exit
#define _Exit(status) _exit(status);
#endif
DLLAPI void exit(int status);
DLLAPI void abort();
DLLAPI void srand(unsigned s);
DLLAPI int rand(void);

View File

@@ -27,7 +27,8 @@ BIN = \
libc_test.kex \
pipe.kex \
defgen.kex \
futex.kex
futex.kex \
atexit_test.kex
all: $(BIN)

View File

@@ -0,0 +1,18 @@
#include <stdlib.h>
#include <stdio.h>
void f()
{
static int c = 1;
printf("exit #%d\n", c);
c++;
}
int main()
{
atexit(&f);
atexit(&f);
atexit(&f);
return 0;
}

View File

@@ -23,5 +23,6 @@ cp clayer/logo.png /tmp0/1/tcc_samples/logo.png
../tcc defgen.c -o /tmp0/1/tcc_samples/defgen
../tcc pipe.c -o /tmp0/1/tcc_samples/pipe
../tcc futex.c -o /tmp0/1/tcc_samples/futex
../tcc atexit_test.c -o /tmp0/1/tcc_samples/atexit_test
"/sys/File managers/Eolite" /tmp0/1/tcc_samples
exit

View File

@@ -14,6 +14,7 @@ public start
public start as '_start'
extrn main
extrn exit
include '../../../../../../proc32.inc'
include '../../../../../../macros.inc'
@@ -38,36 +39,36 @@ start:
call push_param
; retrieving parameters
mov esi, params
xor edx, edx ; dl - èä¸ò ïàðàìåòð(1) èëè ðàçäåëèòåëè(0)
; dh - ñèìâîë ñ êîòîðîãî íà÷àëñÿ ïàðàìåòð (1 êàâû÷êè, 0 îñòàëüíîå)
xor edx, edx ; dl - is it a parameter (1) or delimiters (0)
; dh - character with which the parameter started (1 quotes, 0 everything else)
mov ecx, 1 ; cl = 1
; ch = 0 ïðîñòî íîëü
; ch = 0 just zero
.parse:
lodsb
test al, al
jz .run
test dl, dl
jnz .findendparam
;{åñëè áûë ðàçäåëèòåëü
;{if it was a delimiter
cmp al, ' '
jz .parse ;çàãðóæåí ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë
mov dl, cl ;íà÷èíàåòñÿ ïàðàìåòð
jz .parse ; space loaded, load next character
mov dl, cl ; parameter starts
cmp al, '"'
jz @f ;çàãðóæåíû êàâû÷êè
mov dh, ch ;ïàðàìåòð áåç êàâû÷åê
jz @f ; quotes loaded
mov dh, ch ; parameter without quotes
dec esi
call push_param
inc esi
jmp .parse
@@:
mov dh, cl ;ïàðàìåòð â êàâû÷åêàõ
call push_param ;åñëè íå ïðîáåë çíà÷èò íà÷èíàåòñÿ êàêîé òî ïàðàìåòð
jmp .parse ;åñëè áûë ðàçäåëèòåëü}
mov dh, cl ; parameter in quotes
call push_param ; if not a space, then some parameter starts
jmp .parse ; if it was a delimiter}
.findendparam:
test dh, dh
jz @f ; áåç êàâû÷åê
jz @f ; without quotes
cmp al, '"'
jz .clear
jmp .parse
@@ -86,10 +87,9 @@ start:
push [argc]
call main
.exit:
xor eax,eax
dec eax
int 0x40
dd -1
push eax
call dword [exit]
dd -1
.crash:
jmp .exit
;============================

View File

@@ -82,6 +82,7 @@
#include "string/strstr.c"
#include "string/strtok.c"
#include "string/strxfrm.c"
#include "stdlib/abs.c"
#include "stdlib/assert.c"
#include "stdlib/atof.c"
@@ -89,7 +90,9 @@
#include "stdlib/atol.c"
#include "stdlib/atoll.c"
#include "stdlib/calloc.c"
#include "stdlib/atexit.c"
#include "stdlib/exit.c"
#include "stdlib/_exit.c"
#include "stdlib/free.c"
#include "stdlib/itoa.c"
#include "stdlib/labs.c"
@@ -100,6 +103,7 @@
#include "stdlib/realloc.c"
#include "stdlib/strtod.c"
#include "stdlib/strtol.c"
#include "stdlib/abort.c"
#include "math/acosh.c"
#include "math/asinh.c"
@@ -170,7 +174,9 @@ ksys_dll_t EXPORTS[] = {
{ "atoll", &atoll },
{ "atof", &atof },
{ "calloc", &calloc },
{ "_exit", &_exit },
{ "exit", &exit },
{ "abort", &abort },
{ "free", &free },
{ "itoa", &itoa },
{ "labs", &labs },
@@ -204,6 +210,7 @@ ksys_dll_t EXPORTS[] = {
{ "strstr", &strstr },
{ "strtok", &strtok },
{ "strxfrm", &strxfrm },
{ "strpbrk", &strpbrk },
{ "__errno", &__errno },
{ "closedir", &closedir },
{ "opendir", &opendir },

View File

@@ -0,0 +1,26 @@
#include <conio.h>
#include <stdio.h>
#include <sys/ksys.h>
void _exit(int status)
{
__libc_exit(status, NULL);
}
void __libc_exit(int status, void (*before_exit)(int status))
{
// return error and this is not abort
if (status && status != 128) {
fprintf(stderr, "\nexit code: %d\n", status);
}
if (before_exit) {
before_exit(status);
}
if (__con_is_load) {
con_exit(0);
}
_ksys_exit();
}

View File

@@ -0,0 +1,17 @@
/*
* SPDX-License-Identifier: GPL-2.0-only
* Copyright (C) 2026 KolibriOS team
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/ksys.h>
void abort()
{
ksys_thread_t t;
_ksys_thread_info(&t, -1);
fprintf(stderr, "\nAbort in %d\n", t.pid);
_exit(128);
}

View File

@@ -0,0 +1,40 @@
/*
* SPDX-License-Identifier: GPL-2.0-only
* Copyright (C) 2026 KolibriOS team
*/
#include <stdlib.h>
struct atexit_n {
struct atexit_n* last;
void (*func)(void);
};
static struct atexit_n* __last_n = NULL;
int atexit(void (*func)(void))
{
struct atexit_n* n = malloc(sizeof(struct atexit_n));
if (n == NULL) {
return 1;
}
n->last = __last_n;
n->func = func;
__last_n = n;
return 0;
}
void __run_atexit()
{
struct atexit_n* n = __last_n;
while (n != NULL) {
n->func();
struct atexit_n* to_free = n;
n = n->last;
free(to_free);
}
}

View File

@@ -1,12 +1,32 @@
/* Copyright (C) 2021 Logaev Maxim (turbocat2001), GPLv2 */
/*
* SPDX-License-Identifier: GPL-2.0-only
* Copyright (C) 2021 Logaev Maxim
* Copyright (C) 2026 KolibriOS team
*/
#include <conio.h>
#include <stdlib.h>
#include <sys/ksys.h>
#include "_exit.h"
/*
TODO
static void __close_all()
{
}
static void __free_all_mem()
{
}
*/
void __normal_exit(int status)
{
__run_atexit();
__close_all();
__free_all_mem();
}
void exit(int status)
{
if (__con_is_load) {
con_exit(status);
}
_ksys_exit();
__libc_exit(status, &__normal_exit);
}

View File

@@ -122,7 +122,13 @@ struc fpcvt
.sizeof:
}
;-----------------------------------------------------------------------------
; Command flags
CMD_WITHOUT_PARAM = 1b ; command may be called without parameters
CMD_WITH_PARAM = 10b ; command may be called with parameters
CMD_WITHOUT_LOADED_APP = 100b ; command may be called without loaded program
CMD_WITH_LOADED_APP = 1000b ; command may be called with loaded program
;-----------------------------------------------------------------------------
; Entry point
@@ -449,63 +455,56 @@ z1:
mov esi, commands
call find_cmd
mov eax, aUnknownCommand
jc .x11
; check command requirements
; flags field:
; &1: command may be called without parameters
; &2: command may be called with parameters
; &4: command may be called without loaded program
; &8: command may be called with loaded program
jc .cmd_procg
mov eax, [esi+8]
mov ecx, [curarg]
cmp byte [ecx], 0
jz .noargs
test byte [esi+16], 2
jz .x11
test byte [esi+16], CMD_WITH_PARAM
jz .cmd_procg
jmp @f
.noargs:
test byte [esi+16], 1
jz .x11
test byte [esi+16], CMD_WITHOUT_PARAM
jz .cmd_procg
@@:
cmp [debuggee_pid], 0
jz .nodebuggee
mov eax, aAlreadyLoaded
test byte [esi+16], 8
jz .x11
jmp .x9
test byte [esi+16], CMD_WITH_LOADED_APP
jz .cmd_procg
jmp .run_cmd
.nodebuggee:
mov eax, need_debuggee
test byte [esi+16], 4
jnz .x9
test byte [esi+16], CMD_WITHOUT_LOADED_APP
jnz .run_cmd
.x11:
.cmd_procg:
xchg esi, eax
call put_message
; store cmdline for repeating
.x10:
.cmd_procg_no_put_msg:
mov esi, cmdline
mov ecx, [cmdline_len]
@@:
cmp ecx, 0
jle .we
jle .wait_event
mov al, [esi + ecx]
mov [cmdline_prev + ecx], al
dec ecx
jmp @b
.we:
.wait_event:
mov [cmdline_len], 0
jmp waitevent
.x9:
.run_cmd:
call dword [esi+4]
jmp .x10
jmp .cmd_procg_no_put_msg
;-----------------------------------------------------------------------------
; Cmdline handling

View File

@@ -2,7 +2,10 @@
COLOR_THEME fix MOVIEOS
format binary as ""
include '../../macros.inc'
include '../../KOSfuncs.inc'
use32
db 'MENUET01'
dd 1
@@ -1145,6 +1148,105 @@ OnDump:
.ret:
ret
;-----------------------------------------------------------------------------
; Print Backtrace
struct STACK_FRAME
prev_frame rd 1
ret_addr rd 1
ends
OnBacktrace:
push ebp
; Set max depth counter
xor eax, eax
dec eax
mov esi, [curarg]
cmp byte [esi], 0
jz .save_depth
call get_hex_number
mov esi, aParseError
jc .exit
; If depth 0
test eax, eax
jz .done
.save_depth:
mov [bt_depth], eax
; Get start frame addres
mov ebp, [_ebp]
test ebp, ebp
jz .done
mov edi, stack_frame_dump
.next:
mcall SF_DEBUG, SSF_READ_MEMORY, [debuggee_pid], sizeof.STACK_FRAME, ebp
cmp eax, -1
mov esi, read_mem_err
jz .exit
; The address of the previous frame must be less than the current one
mov eax, [edi + STACK_FRAME.prev_frame]
test eax, eax
jz .done
; Save stack_frame_dump
push edi
; Save previous frame
push ebp
; Save return address
mov eax, [edi + STACK_FRAME.ret_addr]
push eax
; Print frame address and return address
push eax ; pop in put_message_nodraw
push ebp ; pop in put_message_nodraw
mov esi, aBacktraceFmt
call put_message_nodraw
; Restore return address
pop eax
; Find symbol by return address
call find_near_symbol
test esi, esi
jnz .print_sym
mov esi, aBacktraceSymStub
.print_sym:
call put_message_nodraw
mov esi, newline
call put_message_nodraw
; Restore previous frame
pop ebp
; Restore stack_frame_dump
pop edi
; The address of the previous frame must be greater than the current one.
cmp [edi + STACK_FRAME.prev_frame], ebp
jna .done
; Set previous frame
mov ebp, [edi + STACK_FRAME.prev_frame]
dec [bt_depth]
jnz .next
.done:
mov esi, newline
.exit:
call put_message
pop ebp
ret
;-----------------------------------------------------------------------------
; Dissassemble block of executable event
@@ -1864,7 +1966,7 @@ include 'disasm.inc'
caption_str db 'Kolibri Debugger',0
begin_str db 'Kolibri Debugger, version 0.35',10
begin_str db 'Kolibri Debugger, version 0.36',10
db 'Hint: type "help" for help, "quit" to quit'
newline db 10,0
prompt db '> ',0
@@ -1880,66 +1982,88 @@ help_groups:
;-----------------------------------------------------------------------------
; Commands format definitions
; TODO: make it with macros
; flags field:
; &1: command may be called without parameters
; &2: command may be called with parameters
; &4: command may be called without loaded program
; &8: command may be called with loaded program
commands:
dd _aH, OnHelp, HelpSyntax, HelpHelp
db 0Fh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITHOUT_LOADED_APP or CMD_WITH_LOADED_APP
dd aHelp, OnHelp, HelpSyntax, HelpHelp
db 0Fh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITHOUT_LOADED_APP or CMD_WITH_LOADED_APP
dd aQuit, OnQuit, QuitSyntax, QuitHelp
db 0Dh
db CMD_WITHOUT_PARAM or CMD_WITHOUT_LOADED_APP or CMD_WITH_LOADED_APP
dd aLoad, OnLoad, LoadSyntax, LoadHelp
db 6
db CMD_WITH_PARAM or CMD_WITHOUT_LOADED_APP
dd aReload, OnReload, ReloadSyntax, ReloadHelp
db 0Dh
db CMD_WITHOUT_PARAM or CMD_WITHOUT_LOADED_APP or CMD_WITH_LOADED_APP
dd aTerminate, OnTerminate, TerminateSyntax, TerminateHelp
db 9
db CMD_WITHOUT_PARAM or CMD_WITH_LOADED_APP
dd aDetach, OnDetach, DetachSyntax, DetachHelp
db 9
db CMD_WITHOUT_PARAM or CMD_WITH_LOADED_APP
dd aSuspend, OnSuspend, SuspendSyntax, SuspendHelp
db 9
db CMD_WITHOUT_PARAM or CMD_WITH_LOADED_APP
dd aResume, OnResume, ResumeSyntax, ResumeHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aStep, OnStepMultiple, StepSyntax, StepHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aProceed, OnProceedMultiple, ProceedSyntax, ProceedHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aCalc, OnCalc, CalcSyntax, CalcHelp
db 0Eh
db CMD_WITH_PARAM or CMD_WITHOUT_LOADED_APP or CMD_WITH_LOADED_APP
dd aDump, OnDump, DumpSyntax, DumpHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBacktrace, OnBacktrace, BacktraceSyntax, BacktraceHelp
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBp, OnBp, BpSyntax, BpHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBpm, OnBpmb, BpmSyntax, BpmHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBpmb, OnBpmb, BpmSyntax, BpmHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBpmw, OnBpmw, BpmSyntax, BpmHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBpmd, OnBpmd, BpmSyntax, BpmHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBl, OnBl, BlSyntax, BlHelp
db 0Bh
db CMD_WITHOUT_PARAM or CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBc, OnBc, BcSyntax, BcHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBd, OnBd, BdSyntax, BdHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aBe, OnBe, BeSyntax, BeHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aReg, OnReg, RSyntax, RHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd aUnpack, OnUnpack, UnpackSyntax, UnpackHelp
db 9
db CMD_WITHOUT_PARAM or CMD_WITH_LOADED_APP
dd aLoadSymbols, OnLoadSymbols, LoadSymbolsSyntax, LoadSymbolsHelp
db 0Ah
db CMD_WITH_PARAM or CMD_WITH_LOADED_APP
dd 0
;-----------------------------------------------------------------------------
@@ -1980,7 +2104,8 @@ help_data_msg db 'List of data commands:',10
db 'd [<expression>] - dump data at given address',10
db 'u [<expression>] - unassemble instructions at given address',10
db 'r <register> <expression> or',10
db 'r <register>=<expression> - set register value',10,0
db 'r <register>=<expression> - set register value',10
db 'bt [<number>] - display backtrace / stacktrace',10,0
; Breakpoints commands group
@@ -2038,6 +2163,11 @@ DumpHelp db 'Dump data of debugged program',10
DumpSyntax db 'Usage: d <expression> - dump data at specified address',10
db ' or: d - continue current dump',10,0
aBacktrace db 3,'bt',0
BacktraceHelp db 'Display backtrace / stacktrace',10
BacktraceSyntax db 'Usage: bt <number> - display backtrace with depth',10
db ' or: bt display all backtrace',10,0
aCalc db 2,'?',0
CalcHelp db 'Calculate value of expression',10
CalcSyntax db 'Usage: ? <expression>',10,0
@@ -2102,6 +2232,11 @@ LoadSymbolsSyntax db 'Usage: load-symbols <symbols-file-name>',10,0
aUnknownCommand db 'Unknown command',10,0
;-----------------------------------------------------------------------------
; Info messages
aBacktraceSymStub db '??',0
aBacktraceFmt db '[0x%8X] 0x%8X in ',0
;-----------------------------------------------------------------------------
; Error messages
@@ -2474,11 +2609,13 @@ disasm_cur_pos dd ?
disasm_cur_str dd ?
disasm_string rb 256
thread_info process_information
stack_frame_dump rb sizeof.STACK_FRAME
bt_depth rd 1
;-----------------------------------------------------------------------------
; Coordinates and sizes for GUI
thread_info process_information
data_x_size_dd dd ?, ?
messages_x_size_dd dd ?, ?
registers_x_pos_dd dd ?, ?

View File

@@ -4,6 +4,11 @@
include 'sort.inc'
struct DEBUG_SYMBOL
addr rd 1
string rd 0
ends
; compare proc for sorter
compare:
cmpsd
@@ -459,4 +464,69 @@ find_symbol_name:
@@:
pop esi
ret
ret
;-----------------------------------------------------------------------------
;
; Find the nearest symol using binary search
;
; in: eax - target addres
; out: esi - symbol name
; destroys: ebx, ecx, edx, edi, ebp
;
find_near_symbol:
mov edi, [symbols]
xor esi, esi ; Result
mov ecx, esi ; Left
mov edx, [num_symbols] ; Right
dec edx
js .end
; If the first address is already greater than the target
mov ebp, [edi + ecx * sizeof.DEBUG_SYMBOL]
cmp [ebp + DEBUG_SYMBOL.addr], eax
ja .end
; If the last address is less than or equal to the target
mov ebp, [edi + edx * sizeof.DEBUG_SYMBOL]
cmp [ebp + DEBUG_SYMBOL.addr], eax
jbe .found
.loop:
cmp ecx, edx
ja .end
; Calc middle:
mov ebx, edx ; Middle
sub ebx, ecx ; (right - left)
shr ebx, 1 ; / 2
add ebx, ecx ; + left
; Equal
mov ebp, [edi + ebx * sizeof.DEBUG_SYMBOL]
cmp [ebp + DEBUG_SYMBOL.addr], eax
jz .found
jb .update_left
; Update right
mov edx, ebx
dec edx
jmp .loop
.update_left:
; Save potential result
mov esi, ebp
add esi, DEBUG_SYMBOL.string
; Update left
mov ecx, ebx
inc ecx
jmp .loop
.found:
mov esi, ebp
add esi, DEBUG_SYMBOL.string
.end:
ret

View File

@@ -135,7 +135,7 @@ start:
mov [sockaddr1.port], ax
xchg al, ah
invoke con_printf, str1, eax
invoke con_printf, str1, ini_buf, eax
add esp, 8
; open listening socket
@@ -341,7 +341,7 @@ thread_exit:
; initialized data
title db 'FTP daemon', 0
str1 db 'Starting FTP daemon on port %u.', 0
str1 db 'Starting FTP daemon on %s:%u', 0
str2 db '.', 0
str2b db ' OK!',10,0
str3 db 'Listen error',10,0