ReactOS 0.4.15-dev-7958-gcd0bb1a
find.c File Reference
#include <ntdef.h>
#include <reactos/rossym.h>
#include "rossympriv.h"
#include <debug.h>
Include dependency graph for find.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static PROSSYM_ENTRY FindEntry (IN PROSSYM_INFO RosSymInfo, IN ULONG_PTR RelativeAddress)
 
BOOLEAN RosSymGetAddressInformation (PROSSYM_INFO RosSymInfo, ULONG_PTR RelativeAddress, ULONG *LineNumber, char *FileName, char *FunctionName)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 42 of file find.c.

Function Documentation

◆ FindEntry()

static PROSSYM_ENTRY FindEntry ( IN PROSSYM_INFO  RosSymInfo,
IN ULONG_PTR  RelativeAddress 
)
static

Definition at line 46 of file find.c.

47{
48 /*
49 * Perform a binary search.
50 *
51 * The code below is a bit sneaky. After a comparison fails, we
52 * divide the work in half by moving either left or right. If lim
53 * is odd, moving left simply involves halving lim: e.g., when lim
54 * is 5 we look at item 2, so we change lim to 2 so that we will
55 * look at items 0 & 1. If lim is even, the same applies. If lim
56 * is odd, moving right again involes halving lim, this time moving
57 * the base up one item past p: e.g., when lim is 5 we change base
58 * to item 3 and make lim 2 so that we will look at items 3 and 4.
59 * If lim is even, however, we have to shrink it by one before
60 * halving: e.g., when lim is 4, we still looked at item 2, so we
61 * have to make lim 3, then halve, obtaining 1, so that we will only
62 * look at item 3.
63 */
64 PROSSYM_ENTRY Base = RosSymInfo->Symbols;
65 ULONG Lim;
66 PROSSYM_ENTRY Mid, Low;
67
68 if (RelativeAddress < Base->Address)
69 {
70 return NULL;
71 }
72
73 Low = Base;
74 for (Lim = RosSymInfo->SymbolsCount; Lim != 0; Lim >>= 1)
75 {
76 Mid = Base + (Lim >> 1);
77 if (RelativeAddress == Mid->Address)
78 {
79 return Mid;
80 }
81 if (Mid->Address < RelativeAddress) /* key > mid: move right */
82 {
83 Low = Mid;
84 Base = Mid + 1;
85 Lim--;
86 } /* else move left */
87 }
88
89 return Low;
90}
#define NULL
Definition: types.h:112
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
static WCHAR Address[46]
Definition: ping.c:68
@ Low
Definition: strmini.h:380
Definition: rossym.h:26
ULONG_PTR Address
Definition: rossym.h:27
uint32_t ULONG
Definition: typedefs.h:59

Referenced by RosSymGetAddressInformation().

◆ RosSymGetAddressInformation()

BOOLEAN RosSymGetAddressInformation ( PROSSYM_INFO  RosSymInfo,
ULONG_PTR  RelativeAddress,
ULONG LineNumber,
char FileName,
char FunctionName 
)

Definition at line 94 of file find.c.

99{
100 PROSSYM_ENTRY RosSymEntry;
101
102 DPRINT("RelativeAddress = 0x%08x\n", RelativeAddress);
103
104 if (RosSymInfo->Symbols == NULL || RosSymInfo->SymbolsCount == 0 ||
105 RosSymInfo->Strings == NULL || RosSymInfo->StringsLength == 0)
106 {
107 DPRINT1("Uninitialized RosSymInfo\n");
108 return FALSE;
109 }
110
112
113 /* find symbol entry for function */
114 RosSymEntry = FindEntry(RosSymInfo, RelativeAddress);
115
116 if (NULL == RosSymEntry)
117 {
118 DPRINT("None of the requested information was found!\n");
119 return FALSE;
120 }
121
122 if (LineNumber != NULL)
123 {
124 *LineNumber = RosSymEntry->SourceLine;
125 }
126 if (FileName != NULL)
127 {
128 PCSTR Name = "";
129 if (RosSymEntry->FileOffset != 0)
130 {
131 Name = (PCHAR) RosSymInfo->Strings + RosSymEntry->FileOffset;
132 }
134 }
135 if (FunctionName != NULL)
136 {
137 PCSTR Name = "";
138 if (RosSymEntry->FunctionOffset != 0)
139 {
140 Name = (PCHAR) RosSymInfo->Strings + RosSymEntry->FunctionOffset;
141 }
143 }
144
145 return TRUE;
146}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1220
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
static PROSSYM_ENTRY FindEntry(IN PROSSYM_INFO RosSymInfo, IN ULONG_PTR RelativeAddress)
Definition: find.c:46
#define DPRINT
Definition: sndvol32.h:71
ULONG SourceLine
Definition: rossym.h:30
ULONG FileOffset
Definition: rossym.h:29
ULONG FunctionOffset
Definition: rossym.h:28
ULONG SymbolsCount
Definition: rossym.h:124
ULONG StringsLength
Definition: rossym.h:126
PROSSYM_ENTRY Symbols
Definition: rossym.h:123
PCHAR Strings
Definition: rossym.h:125
const char * PCSTR
Definition: typedefs.h:52

Referenced by KdbSymPrintAddress().