Groups > Microsoft > WinDbg > Re: Beheld and SymGetLineFromAddr64 (Source file of variable)




DbgHelp and SymGetLineFromAddr64 (Source file of variable)

DbgHelp and SymGetLineFromAddr64 (Source file of variable)
Fri, 21 Mar 2008 10:28:39 -070
Hi All,

I'm using DbgHelp to aide in a program similar to a profiler (not a
debugger assistant). When I call SymGetLineFromAddr64 on a global
variable, the function fails with 0x01e7 (Attempt to access invalid
address). Other globals (such as argc and argv) fails also.

I understand that some variable (such as 'int i') may show up in
different lines of the source code. The logic flow is as follows. If
the tag is not SymTagBaseType, I bail out.

SymEnumSymbols( ... )
SymGetTypeInfo( ..., TI_GET_SYMTAG )
SymGetTypeInfo( ..., TI_GET_ADDRESS )
SymGetLineFromAddr64( ... )

I suspect I am using the wrong API, or am going about determining the
source file name incorrectly. Any ideas?

Jeff
Post Reply
Re: DbgHelp and SymGetLineFromAddr64 (Source file of variable)
Sat, 22 Mar 2008 14:28:37 -070
I guess you misunderstood the intent of the API.

The intent of the API is to take an address, such as 77c43f5c
and get information that the address is `close` to line 2490
of this file d:\nt\windows\core\ntuser\client\clmsg.c.

The concept of `close` is related to line-mapping to generated assembly,
that is a detail of the compiler, the linker, and how they produce the PDB.

Getting the line of code of a Global Variable, or a stack variable is kind
of pointless.

-- 

-- 
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jeffrey Walton" <noloader@gmail.com> wrote in message 
news:53458669-4f38-4d81-a7b1-524093c51a50@b64g2000hsa.googlegroups.com...
> Hi All,
>
> I'm using DbgHelp to aide in a program similar to a profiler (not a
> debugger assistant). When I call SymGetLineFromAddr64 on a global
> variable, the function fails with 0x01e7 (Attempt to access invalid
> address). Other globals (such as argc and argv) fails also.
>
> I understand that some variable (such as 'int i') may show up in
> different lines of the source code. The logic flow is as follows. If
> the tag is not SymTagBaseType, I bail out.
>
> SymEnumSymbols( ... )
> SymGetTypeInfo( ..., TI_GET_SYMTAG )
> SymGetTypeInfo( ..., TI_GET_ADDRESS )
> SymGetLineFromAddr64( ... )
>
> I suspect I am using the wrong API, or am going about determining the
> source file name incorrectly. Any ideas?
>
> Jeff
> Jeffrey Walton 

Post Reply
Re: DbgHelp and SymGetLineFromAddr64 (Source file of variable)
Sat, 22 Mar 2008 17:10:51 -070
Hi Ivan,

Thanks. I was concluding it was not possible.

> I guess you misunderstood the intent of the API.
Perhaps (or attemting to use the API in a way the authors did not
accomodate).

> Getting the line of code of a Global Variable, or a stack variable
> is kind of pointless.
I suppose it depends on the context of the problem.

DbgHelp is a pretty awesome library. I see why John Robbins talks so
highly about it. There's no sense in me reinventing the wheel if the
OS team has already rolled it.

Jeff

On Mar 22, 5:28 pm, "Ivan Brugiolo [MSFT]"
<ivanb...@online.microsoft.com> wrote:
> I guess you misunderstood the intent of the API.
>
> The intent of the API is to take an address, such as 77c43f5c
> and get information that the address is `close` to line 2490
> of this file d:\nt\windows\core\ntuser\client\clmsg.c.
>
> The concept of `close` is related to line-mapping to generated assembly,
> that is a detail of the compiler, the linker, and how they produce the
PDB.
>
> Getting the line of code of a Global Variable, or a stack variable is kind
> of pointless.
>
> --
> This posting is provided "AS IS" with no warranties, and confers
no rights.
> Use of any included script samples are subject to the terms specified
athttp://www.microsoft.com/info/cpyright.htm
>
> "Jeffrey Walton" <noloa...@gmail.com> wrote in message
>
> news:53458669-4f38-4d81-a7b1-524093c51a50@b64g2000hsa.googlegroups.com...
>
>
>
> > Hi All,
>
> > I'm using DbgHelp to aide in a program similar to a profiler (not a
> > debugger assistant). When I call SymGetLineFromAddr64 on a global
> > variable, the function fails with 0x01e7 (Attempt to access invalid
> > address). Other globals (such as argc and argv) fails also.
>
> > I understand that some variable (such as 'int i') may show up in
> > different lines of the source code. The logic flow is as follows. If
> > the tag is not SymTagBaseType, I bail out.
>
> > SymEnumSymbols( ... )
> > SymGetTypeInfo( ..., TI_GET_SYMTAG )
> > SymGetTypeInfo( ..., TI_GET_ADDRESS )
> > SymGetLineFromAddr64( ... )
>
> > I suspect I am using the wrong API, or am going about determining the
> > source file name incorrectly. Any ideas?
>
> > Jeff
> > Jeffrey Walton- Hide quoted text -
>
> - Show quoted text -
Post Reply
Re: Beheld and SymGetLineFromAddr64 (Source file of variable)
Wed, 26 Mar 2008 13:27:47 +080
Hello Jeffrey.

Don't you mean to call SymGetSymFromName64() on the global variable you are 
looking for?  That will give you the address of the variable everything you 
need to call the type API stuff on it.  But better yet, can you tell me what 
you are trying to achieve?  This program flow does not seem to be useful to 
me...

SymEnumSymbols( ... )
SymGetTypeInfo( ..., TI_GET_SYMTAG )
SymGetTypeInfo( ..., TI_GET_ADDRESS )
SymGetLineFromAddr64( ... )

.p



"Jeffrey Walton" <noloader@gmail.com> wrote in message 
news:53458669-4f38-4d81-a7b1-524093c51a50@b64g2000hsa.googlegroups.com...
Hi All,

I'm using DbgHelp to aide in a program similar to a profiler (not a
debugger assistant). When I call SymGetLineFromAddr64 on a global
variable, the function fails with 0x01e7 (Attempt to access invalid
address). Other globals (such as argc and argv) fails also.

I understand that some variable (such as 'int i') may show up in
different lines of the source code. The logic flow is as follows. If
the tag is not SymTagBaseType, I bail out.

SymEnumSymbols( ... )
SymGetTypeInfo( ..., TI_GET_SYMTAG )
SymGetTypeInfo( ..., TI_GET_ADDRESS )
SymGetLineFromAddr64( ... )

I suspect I am using the wrong API, or am going about determining the
source file name incorrectly. Any ideas?

Jeff
Jeffrey Walton 
Post Reply
about | contact