https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b86c4bd522bb82de5bea0…
commit b86c4bd522bb82de5bea068086653186f019d4b5
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Oct 14 20:29:46 2024 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 14 22:51:52 2024 +0200
[NTOS:KDBG] Small improvements for KdbpCliMainLoop() and KdbpDoCommand() (#4917)
- Move the printing pager state reset code (setting the number of
printed rows and columns to zero, and the output aborted flag)
to KdbpDoCommand(). This allows to keep the original behaviour,
while also inheriting it whenever KdbpDoCommand() is invoked
elsewhere (for example, from KdbpCliInterpretInitFile()).
- Use KdbPuts/Printf() instead of KdbpPrint() for the entry banners,
so that they aren't subject to the current printing pager state.
Do the same for the "command unknown" error in KdbpDoCommand().
- Add a "Type 'help' for a list of commands" banner, for the users.
- Replace the do-while-loop with a simple while-loop.
---
ntoskrnl/kdbg/kdb_cli.c | 59 ++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index e6a23fc5321..08c33d8afb8 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -2910,7 +2910,7 @@ KdbpPagerInternal(
KdpInitTerminal();
}
- /* Refresh terminal size each time when number of rows printed is 0 */
+ /* Refresh terminal size each time when number of printed rows is 0 */
if (KdbNumberOfRowsPrinted == 0)
{
KdpUpdateTerminalSize(&KdTermSize);
@@ -3030,7 +3030,7 @@ KdbpPagerInternal(
p[i + 1] = c;
/* Set p to the start of the next line and
- * remember the number of rows/cols printed */
+ * remember the number of printed rows/cols */
p += i;
if (p[0] == '\n')
{
@@ -3205,6 +3205,7 @@ static BOOLEAN
KdbpDoCommand(
IN PCHAR Command)
{
+ BOOLEAN Continue = TRUE;
SIZE_T i;
PCHAR p;
ULONG Argc;
@@ -3238,6 +3239,10 @@ KdbpDoCommand(
if (Argc < 1)
return TRUE;
+ /* Reset the pager state: number of printed rows/cols and aborted output flag */
+ KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0;
+ KdbOutputAborted = FALSE;
+
for (i = 0; i < RTL_NUMBER_OF(KdbDebuggerCommands); i++)
{
if (!KdbDebuggerCommands[i].Name)
@@ -3245,18 +3250,20 @@ KdbpDoCommand(
if (strcmp(KdbDebuggerCommands[i].Name, Argv[0]) == 0)
{
- return KdbDebuggerCommands[i].Fn(Argc, Argv);
+ Continue = KdbDebuggerCommands[i].Fn(Argc, Argv);
+ goto Done;
}
}
/* Now invoke the registered callbacks */
if (KdbpInvokeCliCallbacks(Command, Argc, Argv))
- {
- return TRUE;
- }
+ goto Done;
- KdbpPrint("Command '%s' is unknown.\n", OrigCommand);
- return TRUE;
+ KdbPrintf("Command '%s' is unknown.\n", OrigCommand);
+
+Done:
+ KdbOutputAborted = FALSE;
+ return Continue;
}
/*!\brief KDB Main Loop.
@@ -3267,39 +3274,37 @@ VOID
KdbpCliMainLoop(
IN BOOLEAN EnteredOnSingleStep)
{
- BOOLEAN Continue;
- SIZE_T CmdLen;
+ BOOLEAN Continue = TRUE;
static CHAR Command[1024];
static CHAR LastCommand[1024] = "";
if (EnteredOnSingleStep)
{
if (!KdbSymPrintAddress((PVOID)KeGetContextPc(KdbCurrentTrapFrame), KdbCurrentTrapFrame))
- {
- KdbpPrint("<%p>", KeGetContextPc(KdbCurrentTrapFrame));
- }
+ KdbPrintf("<%p>", KeGetContextPc(KdbCurrentTrapFrame));
- KdbpPrint(": ");
+ KdbPuts(": ");
if (KdbpDisassemble(KeGetContextPc(KdbCurrentTrapFrame), KdbUseIntelSyntax) < 0)
- {
- KdbpPrint("<INVALID>");
- }
- KdbpPrint("\n");
+ KdbPuts("<INVALID>");
+ KdbPuts("\n");
+ }
+ else
+ {
+ /* Preceding this message is one of the "Entered debugger..." banners */
+ // KdbPuts("\nEntered debugger\n");
+ KdbPuts("\nType \"help\" for a list of commands.\n");
}
/* Main loop */
- do
+ while (Continue)
{
- /* Reset the number of rows/cols printed */
- KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0;
-
/*
* Print the prompt and read a command.
* Repeat the last one if the user pressed Enter.
* This reduces the risk of RSI when single-stepping!
*/
// TEMP HACK! Issue an empty string instead of duplicating "kdb:>"
- CmdLen = KdbPrompt(/*KdbPromptStr.Buffer*/"", Command, sizeof(Command));
+ SIZE_T CmdLen = KdbPrompt(/*KdbPromptStr.Buffer*/"", Command, sizeof(Command));
if (CmdLen == 0)
{
/* Nothing received but the user didn't press Enter, retry */
@@ -3320,15 +3325,9 @@ KdbpCliMainLoop(
RtlStringCbCopyA(Command, sizeof(Command), LastCommand);
}
- /* Reset the number of rows/cols printed and output aborted state */
- KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0;
- KdbOutputAborted = FALSE;
-
- /* Call the command */
+ /* Invoke the command */
Continue = KdbpDoCommand(Command);
- KdbOutputAborted = FALSE;
}
- while (Continue);
}
/*!\brief This function is called by KdbEnterDebuggerException...
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=842e40d7cdc508b76b514…
commit 842e40d7cdc508b76b514bd790f6249cf2faaee7
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Oct 14 20:27:38 2024 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 14 22:51:51 2024 +0200
[NTOS:KDBG] Minor code style for the following commits
---
ntoskrnl/kd64/kdtrap.c | 2 +-
ntoskrnl/kdbg/kdb.c | 5 ++---
ntoskrnl/kdbg/kdb_cli.c | 7 ++-----
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/ntoskrnl/kd64/kdtrap.c b/ntoskrnl/kd64/kdtrap.c
index dc78b11891e..4cfac2b04b0 100644
--- a/ntoskrnl/kd64/kdtrap.c
+++ b/ntoskrnl/kd64/kdtrap.c
@@ -147,7 +147,7 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame,
/*
* Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
- * Load/Unload symbols. Make sure it isn't a software breakpoints as those
+ * Load/Unload symbols. Make sure it isn't a software breakpoint as those
* are handled by KdpReport.
*/
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
diff --git a/ntoskrnl/kdbg/kdb.c b/ntoskrnl/kdbg/kdb.c
index 15175d5ca93..bb5b3afe0af 100644
--- a/ntoskrnl/kdbg/kdb.c
+++ b/ntoskrnl/kdbg/kdb.c
@@ -1176,7 +1176,8 @@ KdbpInternalEnter(VOID)
Thread->Tcb.StackLimit = (ULONG_PTR)KdbStack;
Thread->Tcb.KernelStack = (char*)KdbStack + KDB_STACK_SIZE;
- // KdbPrintf("Switching to KDB stack 0x%08x-0x%08x (Current Stack is 0x%08x)\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase, Esp);
+ // KdbPrintf("Switching to KDB stack 0x%08x-0x%08x (Current Stack is 0x%08x)\n",
+ // Thread->Tcb.StackLimit, Thread->Tcb.StackBase, Esp);
KdbpStackSwitchAndCall(KdbStack + KDB_STACK_SIZE - KDB_STACK_RESERVE, KdbpCallMainLoop);
@@ -1333,7 +1334,6 @@ KdbEnterDebuggerException(
{
Resume = TRUE; /* Set the resume flag when continuing execution */
}
-
/*
* When a temporary breakpoint is hit we have to make sure that we are
* in the same context in which it was set, otherwise it could happen
@@ -1360,7 +1360,6 @@ KdbEnterDebuggerException(
KdbEnteredOnSingleStep = TRUE;
}
-
/*
* If we hit a breakpoint set by the debugger we set the single step flag,
* ignore the next single step and reenable the breakpoint.
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index a8ce312f918..e6a23fc5321 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -3341,23 +3341,20 @@ VOID
KdbpCliInterpretInitFile(VOID)
{
PCHAR p1, p2;
- INT_PTR i;
- CHAR c;
/* Execute the commands in the init file */
DPRINT("KDB: Executing KDBinit file...\n");
p1 = KdbInitFileBuffer;
while (p1[0] != '\0')
{
- i = strcspn(p1, "\r\n");
+ size_t i = strcspn(p1, "\r\n");
if (i > 0)
{
- c = p1[i];
+ CHAR c = p1[i];
p1[i] = '\0';
/* Look for "break" command and comments */
p2 = p1;
-
while (isspace(p2[0]))
p2++;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=798ea907848cc8adf4eb2…
commit 798ea907848cc8adf4eb284f192ce2b58c4faba2
Author: Joachim Henze <joachim.henze(a)reactos.org>
AuthorDate: Sun Oct 13 19:23:38 2024 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Oct 13 19:23:38 2024 +0200
[FREELDR] Less outdated version-hardcodes (#7384)
Those haven't been groomed anymore for more than 10 years. We had many thousands of
different freeldr builds with different behavior and bugs each, but nobody ever
did have the slightest motivation to update those hardcoded
FREELOADER_MAJOR_VERSION, FREELOADER_MINOR_VERSION, FREELOADER_PATCH_VERSION
from ver.h. And that is logical, because touching other modules will change the behavior
of freeldr as well, so it is absolutely impossible to groom anything like that correctly.
Instead we should simply do what we started to do in PR7383, which will at least give
some information (the actual sources it was built from) instead of some misleading voodoo-version.
This might slightly shrink the size of freeldr as well, but I was too lazy to measure by how much.
---
boot/freeldr/freeldr/freeldr.c | 10 ----------
boot/freeldr/freeldr/include/ver.h | 17 +++--------------
boot/freeldr/freeldr/ui/tui.c | 2 +-
3 files changed, 4 insertions(+), 25 deletions(-)
diff --git a/boot/freeldr/freeldr/freeldr.c b/boot/freeldr/freeldr/freeldr.c
index c7bac46d93f..bbed7a4139a 100644
--- a/boot/freeldr/freeldr/freeldr.c
+++ b/boot/freeldr/freeldr/freeldr.c
@@ -26,16 +26,6 @@ DBG_DEFAULT_CHANNEL(WARNING);
/* GLOBALS ********************************************************************/
-#define TOSTRING_(X) #X
-#define TOSTRING(X) TOSTRING_(X)
-
-const PCSTR FrLdrVersionString =
-#if (FREELOADER_PATCH_VERSION == 0)
- "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION);
-#else
- "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION) "." TOSTRING(FREELOADER_PATCH_VERSION);
-#endif
-
CCHAR FrLdrBootPath[MAX_PATH] = "";
/* FUNCTIONS ******************************************************************/
diff --git a/boot/freeldr/freeldr/include/ver.h b/boot/freeldr/freeldr/include/ver.h
index 26cbb1195d9..dcffdc1aec4 100644
--- a/boot/freeldr/freeldr/include/ver.h
+++ b/boot/freeldr/freeldr/include/ver.h
@@ -19,21 +19,10 @@
#pragma once
-/* Just some stuff */
+// FreeLoader version defines
+// If you add features then you increment the minor version
+// If you add major functionality then you increment the major version and zero the minor version
#define VERSION "FreeLoader v3.2"
#define COPYRIGHT "Copyright (C) 1996-" COPYRIGHT_YEAR " ReactOS Project"
#define AUTHOR_EMAIL "<www.reactos.org>"
#define BY_AUTHOR "by ReactOS Project"
-
-// FreeLoader version defines
-//
-// NOTE:
-// If you fix bugs then you increment the patch version
-// If you add features then you increment the minor version and zero the patch version
-// If you add major functionality then you increment the major version and zero the minor & patch versions
-//
-#define FREELOADER_MAJOR_VERSION 3
-#define FREELOADER_MINOR_VERSION 2
-#define FREELOADER_PATCH_VERSION 0
-
-extern const PCSTR FrLdrVersionString;
diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c
index b712820b60a..5960dcd5d44 100644
--- a/boot/freeldr/freeldr/ui/tui.c
+++ b/boot/freeldr/freeldr/ui/tui.c
@@ -293,7 +293,7 @@ VOID TuiDrawBackdrop(VOID)
/* Draw version text */
TuiDrawText(2,
1,
- FrLdrVersionString,
+ VERSION,
ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
/* Draw copyright */