Commit in reactos/ntoskrnl/dbg on MAIN
kdb_stabs.c+18-161.18 -> 1.19
kdb_symbols.c+35-341.4 -> 1.5
+53-50
2 modified files
BUGFIX: stabs lookup ( particularly line # lookup )

reactos/ntoskrnl/dbg
kdb_stabs.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- kdb_stabs.c	15 Dec 2004 01:49:37 -0000	1.18
+++ kdb_stabs.c	17 Dec 2004 17:51:56 -0000	1.19
@@ -79,32 +79,35 @@
       StabEntry = StartEntry;
     }
 
-  for (; (ULONG_PTR)StabEntry < (ULONG_PTR)StabsEnd; StabEntry++)
+  if ( RelativeAddress != NULL )
+  {
+    for (; (ULONG_PTR)StabEntry < (ULONG_PTR)StabsEnd; StabEntry++)
     {
       ULONG_PTR SymbolRelativeAddress;
-      
+    
       if (StabEntry->n_type != Type)
         continue;
 
       if (RelativeAddress != NULL)
-        {
-          if (StabEntry->n_value >= SymbolInfo->ImageSize)
-            continue;
+      {
+        if (StabEntry->n_value >= SymbolInfo->ImageSize)
+          continue;
 
-          SymbolRelativeAddress = StabEntry->n_value;
-          if ((SymbolRelativeAddress <= (ULONG_PTR)RelativeAddress) &&
-              (SymbolRelativeAddress > AddrFound))
-            {
-	      AddrFound = SymbolRelativeAddress;
-	      BestStabEntry = StabEntry;
-            }
-        }
-      else
+        if (StabEntry->n_value > (ULONG_PTR)RelativeAddress )
+          break;
+
+        SymbolRelativeAddress = StabEntry->n_value;
+        if ((SymbolRelativeAddress <= (ULONG_PTR)RelativeAddress) &&
+            (SymbolRelativeAddress > AddrFound))
         {
+          AddrFound = SymbolRelativeAddress;
           BestStabEntry = StabEntry;
-          break;
         }
+      }
     }
+  }
+  else
+    BestStabEntry = StabEntry;
 
   if (BestStabEntry == NULL)
   {
@@ -117,4 +120,3 @@
 
   return BestStabEntry;
 }
-

reactos/ntoskrnl/dbg
kdb_symbols.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- kdb_symbols.c	13 Nov 2004 23:00:14 -0000	1.4
+++ kdb_symbols.c	17 Dec 2004 17:51:57 -0000	1.5
@@ -136,7 +136,7 @@
         }
       current_entry = current_entry->Flink;
     }
-    
+
   return FALSE;
 }
 
@@ -158,7 +158,7 @@
   INT Count = 0;
 
   current_entry = ModuleTextListHead.Flink;
-   
+
   while (current_entry != &ModuleTextListHead &&
          current_entry != NULL)
     {
@@ -178,7 +178,7 @@
         }
       current_entry = current_entry->Flink;
     }
-    
+
   return KdbpSymFindUserModule(Address, Name, Index-Count, pInfo);
 }
 
@@ -241,16 +241,16 @@
 
 /*! \brief Print address...
  *
- * Tries to lookup line number, file name and function name for the given 
+ * Tries to lookup line number, file name and function name for the given
  * address and prints it.
  * If no such information is found the address is printed in the format
- * <module: offset>, otherwise the format will be 
+ * <module: offset>, otherwise the format will be
  * <module: offset (filename:linenumber (functionname))>
  *
  * \retval TRUE  Module containing \a Address was found, \a Address was printed.
  * \retval FALSE  No module containing \a Address was found, nothing was printed.
  */
-BOOLEAN 
+BOOLEAN
 KdbSymPrintAddress(IN PVOID Address)
 {
   KDB_MODULE_INFO Info;
@@ -335,14 +335,14 @@
         {
           DPRINT("No function stab entry found. RelativeAddress %p\n", RelativeAddress);
         }
-        
+
       if (LineNumber != NULL && FunctionEntry != NULL)
         {
           /* find stab entry for line number */
-          ULONG_PTR FunctionRelativeAddress = FunctionEntry->n_value - (ULONG_PTR)SymbolInfo->ImageBase;
+          ULONG_PTR FunctionRelativeAddress = RelativeAddress - FunctionEntry->n_value;
           ULONG_PTR AddrFound = 0;
           PSTAB_ENTRY NextLineEntry;
-          
+
           LineEntry = NextLineEntry = FunctionEntry;
           while (NextLineEntry != NULL)
             {
@@ -353,9 +353,9 @@
                 break;
               if (NextLineEntry->n_type != N_SLINE)
                 continue;
-              
-              if (((NextLineEntry->n_value+FunctionRelativeAddress) <= RelativeAddress) &&
-                  (NextLineEntry->n_value > AddrFound))
+
+              if ( NextLineEntry->n_value <= FunctionRelativeAddress
+                && NextLineEntry->n_value >= AddrFound )
                 {
                   AddrFound = NextLineEntry->n_value;
                   LineEntry = NextLineEntry;
@@ -363,13 +363,13 @@
             }
         }
     }
-  
+
   if (FileName != NULL)
     {
       /* find stab entry for file name */
       PCHAR p;
       INT Length;
-      
+
       FileEntry = KdbpStabFindEntry(SymbolInfo, N_SO, (PVOID)RelativeAddress, NULL);
       if (FileEntry != NULL)
         {
@@ -383,7 +383,7 @@
           DPRINT("No filename stab entry found. RelativeAddress %p\n", RelativeAddress);
         }
     }
-  
+
   if (((LineNumber   != NULL && LineEntry     == NULL) || LineNumber   == NULL) &&
       ((FileName     != NULL && FileEntry     == NULL) || FileName     == NULL) &&
       ((FunctionName != NULL && FunctionEntry == NULL) || FunctionName == NULL))
@@ -443,10 +443,10 @@
   PCHAR SymbolName, p;
   CHAR Buffer[512] = "";
   INT Length, FileNameLength, FuncNameLength = 0;
-  
+
   if (FuncName == NULL && LineNumber < 1)
     return FALSE;
-  
+
   FileNameLength = strlen(FileName);
   FuncNameLength = strlen(FuncName);
   for (Entry = SymbolInfo->SymbolsBase;
@@ -467,7 +467,7 @@
         }
       strncat(Buffer, SymbolName, sizeof (Buffer) - 1);
       Buffer[sizeof (Buffer) - 1] = '\0';
-      
+
       Length = strlen(Buffer);
       if (strcmp(Buffer + Length - FileNameLength, FileName) != 0)
         continue;
@@ -513,7 +513,7 @@
         }
       break;
     }
-    
+
     return FALSE;
 }
 
@@ -574,7 +574,7 @@
 		     IN PIMAGE_SYMBOL_INFO SymbolInfo)
 {
   PIMAGE_SYMBOL_INFO_CACHE CacheEntry;
-  
+
   DPRINT("Adding symbol file: FileBuffer = %p, ImageBase = %p\n",
          SymbolInfo->FileBuffer, SymbolInfo->ImageBase);
 
@@ -664,7 +664,7 @@
   IO_STATUS_BLOCK IoStatusBlock;
   PSYMBOLFILE_HEADER SymbolFileHeader;
   PIMAGE_SYMBOL_INFO_CACHE CachedSymbolFile;
-  
+
   /*  Get the path to the symbol store  */
   wcscpy(TmpFileName, L"\\SystemRoot\\symbols\\");
 
@@ -747,7 +747,7 @@
       ZwClose(FileHandle);
       return;
     }
-   
+
   /*  Load file into memory chunk  */
   Status = ZwReadFile(FileHandle,
                       0, 0, 0,
@@ -779,7 +779,7 @@
 
   DPRINT("Installed stabs: %wZ (%08x-%08x,%08x)\n",
 	 FileName,
-	 SymbolInfo->SymbolsBase, 
+	 SymbolInfo->SymbolsBase,
 	 SymbolInfo->SymbolsLength + SymbolInfo->SymbolsBase,
 	 SymbolInfo->SymbolStringsBase);
 }
@@ -844,7 +844,7 @@
   ASSERT(Peb->Ldr);
 
   CurrentEntry = Peb->Ldr->InLoadOrderModuleList.Flink;
-  while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList && 
+  while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList &&
 	 CurrentEntry != NULL)
     {
       Current = CONTAINING_RECORD(CurrentEntry, LDR_MODULE, InLoadOrderModuleList);
@@ -871,11 +871,11 @@
 {
   /* Load symbols for the image if available */
   DPRINT("Loading driver %wZ symbols (driver @ %08x)\n", Filename, Module->Base);
-  
+
   RtlZeroMemory(&Module->TextSection->SymbolInfo, sizeof (Module->TextSection->SymbolInfo));
   Module->TextSection->SymbolInfo.ImageBase = Module->TextSection->Base;
   Module->TextSection->SymbolInfo.ImageSize = Module->TextSection->Length;
-  
+
   KdbpSymLoadModuleSymbols(Filename, &Module->TextSection->SymbolInfo);
 }
 
@@ -893,7 +893,7 @@
 /*! \brief Called when a symbol file is loaded by the loader?
  *
  * Tries to find a driver (.sys) or executable (.exe) with the same base name
- * as the symbol file and sets the drivers/exes symbol info to the loaded 
+ * as the symbol file and sets the drivers/exes symbol info to the loaded
  * module.
  * Used to load ntoskrnl and hal symbols before the SystemRoot is available to us.
  *
@@ -925,13 +925,13 @@
     {
       *Extension = 0;
     }
-  
+
   DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
-  
+
   strcpy(TmpFileName, TmpBaseName);
   strcat(TmpFileName, ".sys");
   RtlInitAnsiString(&AnsiString, TmpFileName);
-  
+
   RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
   ModuleObject = LdrGetModuleObject(&ModuleName);
   RtlFreeUnicodeString(&ModuleName);
@@ -951,7 +951,7 @@
         {
           KdbpSymRemoveCachedFile(SymbolInfo);
         }
-      
+
       SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
       SymbolInfo->FileBuffer = ModuleLoadBase;
       SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
@@ -960,11 +960,12 @@
       SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
       DPRINT("Installed stabs: %s@%08x-%08x (%08x-%08x,%08x)\n",
 	       FileName,
-	       ModuleObject->Base, ModuleObject->Length + ModuleObject->Base,
-	       SymbolInfo->SymbolsBase, 
+	       ModuleObject->Base,
+	       ModuleObject->Length + ModuleObject->Base,
+	       SymbolInfo->SymbolsBase,
 	       SymbolInfo->SymbolsLength + SymbolInfo->SymbolsBase,
 	       SymbolInfo->SymbolStringsBase);
-    } 
+    }
 }
 
 /*! \brief Initializes the KDB symbols implementation.
CVSspam 0.2.8