Debugging Kernel, in Source Mode

Hi,

I am trying to get WinDbg to work in source mode while debugging a driver.
I have explicitly set a break point in the source code using DbgBreakPoint()
and WinDbg breaks fine.
My problem is I cannot get my source code to appear. Also, If I explicitly
open my source in WinDbg I cannot set a break point on a line (say with F9),
it gives me an error saying ‘Symbol info for current source line could not
be located in the currently loaded symbols.’. However, I have my source path
set to the correct directory and if I do a ‘lm’ command it shows that the
correct pdb is loaded for my driver.

So, what am I missing here?

Thanks, Chris

P.S. I do have source mode on.

Here are a couple of suggestions…:

  1. use the latest windbg 6.0.0007.0
  2. add MSC_OPTIMIZATION=/Od to your sources file (the w2k ddk did not turn
    off code optimizations in the checked build, if you are debugging w2k).
  3. add the following line to your symbol file path:
    srv*e:\websymbols*http:\msdl.microsoft.com\downloads\symbols
    this will allow windbg to use the symbol server at Microsoft to get
    all
    the os symbols (e:\websymbols is a local directory you create on your
    machine to use as a local symbol cache). Make sure you append the path to
    where your symbols are for the driver that you are debugging…

“Chris Dore” wrote in message news:xxxxx@windbg…
>
> Hi,
>
> I am trying to get WinDbg to work in source mode while debugging a driver.
> I have explicitly set a break point in the source code using
DbgBreakPoint()
> and WinDbg breaks fine.
> My problem is I cannot get my source code to appear. Also, If I explicitly
> open my source in WinDbg I cannot set a break point on a line (say with
F9),
> it gives me an error saying ‘Symbol info for current source line could not
> be located in the currently loaded symbols.’. However, I have my source
path
> set to the correct directory and if I do a ‘lm’ command it shows that the
> correct pdb is loaded for my driver.
>
> So, what am I missing here?
>
> Thanks, Chris
>
> P.S. I do have source mode on.
>
>
>
>

Did you read the section in the docs called “Debugging in Source Mode”?

Other things to try:

  1. verify that .srcpath points to your source directory or one
    of it’s parent directories
  2. verify your pdb has source info (you can do this by doing a
    debug break in your driver, then open the call stack window and clicking
    the button to show source line info. If a file&line number appear next
    to your driver functions then you are set. If not then either source
    mode is off or your PDB doesn’t have the info)

-----Original Message-----
From: Chris Dore [mailto:xxxxx@connecttech.com]
Sent: Friday, May 10, 2002 8:18 AM
To: Kernel Debugging Interest List
Subject: [windbg] Debugging Kernel, in Source Mode

Hi,

I am trying to get WinDbg to work in source mode while debugging a
driver. I have explicitly set a break point in the source code using
DbgBreakPoint() and WinDbg breaks fine. My problem is I cannot get my
source code to appear. Also, If I explicitly open my source in WinDbg I
cannot set a break point on a line (say with F9), it gives me an error
saying ‘Symbol info for current source line could not be located in the
currently loaded symbols.’. However, I have my source path set to the
correct directory and if I do a ‘lm’ command it shows that the correct
pdb is loaded for my driver.

So, what am I missing here?

Thanks, Chris

P.S. I do have source mode on.


You are currently subscribed to windbg as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

Thanks for all your suggestions. It was sorta working the whole time. When
I hit the break point I starting hittin’ step over and after about 2-3 times
it jumped into my source on the line following the DbgBreakPoint. This makes
sense now that I think about it…DbgBP I’m guessing does something like and
int 3 and the Debugger takes over from there, but DbgBP is a function so I
probably was stepping over the last few assembly lines of it. When it
returned the debugger picked up on that fact and jumped into my source. Does
this explanation make sense or am I way off?

Anyways, that gets one problem out of the way, now for the next.
I would like to set some breakpoints (from a source window, I don’t want to
hard code DbgBreakPoint’s everywhere) before my driver starts, however
WinDbg complains that the symbol file is not loaded. How can I set these
points up? Do I have to load the symbol file before the driver starts
somehow? I am debugging a USB driver so I can set things up after the system
boots without having to worry about breaking before it loads the driver.

Thanks, Chris

----- Original Message -----
From: “Nathan Nesbit”
To: “Kernel Debugging Interest List”
Sent: Friday, May 10, 2002 12:05 PM
Subject: [windbg] RE: Debugging Kernel, in Source Mode

Did you read the section in the docs called “Debugging in Source Mode”?

Other things to try:
1) verify that .srcpath points to your source directory or one
of it’s parent directories
2) verify your pdb has source info (you can do this by doing a
debug break in your driver, then open the call stack window and clicking
the button to show source line info. If a file&line number appear next
to your driver functions then you are set. If not then either source
mode is off or your PDB doesn’t have the info)

-----Original Message-----
From: Chris Dore [mailto:xxxxx@connecttech.com]
Sent: Friday, May 10, 2002 8:18 AM
To: Kernel Debugging Interest List
Subject: [windbg] Debugging Kernel, in Source Mode

Hi,

I am trying to get WinDbg to work in source mode while debugging a
driver. I have explicitly set a break point in the source code using
DbgBreakPoint() and WinDbg breaks fine. My problem is I cannot get my
source code to appear. Also, If I explicitly open my source in WinDbg I
cannot set a break point on a line (say with F9), it gives me an error
saying ‘Symbol info for current source line could not be located in the
currently loaded symbols.’. However, I have my source path set to the
correct directory and if I do a ‘lm’ command it shows that the correct
pdb is loaded for my driver.

So, what am I missing here?

Thanks, Chris

P.S. I do have source mode on.


You are currently subscribed to windbg as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to windbg as: xxxxx@connecttech.com
To unsubscribe send a blank email to %%email.unsub%%

Typically all you need to do is “BU MyDriver!DriverEnter”. I have never
found a need to set a hard coded breakpoint in the source. If I need to step
into the DE function I use Ctl+Alt+K, which then forces a BP at the next
boot, after driver load but before any DE is called. I can then use the
above command to get into my drivers DE function.

I have found that somehow, no matter how hard I try, eventually a customer
will get the driver with the hard-coded BP in it and I then have to grovel
and profusely apologize as I remove the little bugger, re-compile and then
reship.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Chris Dore” wrote in message news:xxxxx@windbg…
>
> Thanks for all your suggestions. It was sorta working the whole time.
When
> I hit the break point I starting hittin’ step over and after about 2-3
times
> it jumped into my source on the line following the DbgBreakPoint. This
makes
> sense now that I think about it…DbgBP I’m guessing does something like
and
> int 3 and the Debugger takes over from there, but DbgBP is a function so I
> probably was stepping over the last few assembly lines of it. When it
> returned the debugger picked up on that fact and jumped into my source.
Does
> this explanation make sense or am I way off?
>
> Anyways, that gets one problem out of the way, now for the next.
> I would like to set some breakpoints (from a source window, I don’t want
to
> hard code DbgBreakPoint’s everywhere) before my driver starts, however
> WinDbg complains that the symbol file is not loaded. How can I set these
> points up? Do I have to load the symbol file before the driver starts
> somehow? I am debugging a USB driver so I can set things up after the
system
> boots without having to worry about breaking before it loads the driver.
>
> Thanks, Chris
>
> ----- Original Message -----
> From: “Nathan Nesbit”
> To: “Kernel Debugging Interest List”
> Sent: Friday, May 10, 2002 12:05 PM
> Subject: [windbg] RE: Debugging Kernel, in Source Mode
>
>
> Did you read the section in the docs called “Debugging in Source Mode”?
>
> Other things to try:
> 1) verify that .srcpath points to your source directory or one
> of it’s parent directories
> 2) verify your pdb has source info (you can do this by doing a
> debug break in your driver, then open the call stack window and clicking
> the button to show source line info. If a file&line number appear next
> to your driver functions then you are set. If not then either source
> mode is off or your PDB doesn’t have the info)
>
> -----Original Message-----
> From: Chris Dore [mailto:xxxxx@connecttech.com]
> Sent: Friday, May 10, 2002 8:18 AM
> To: Kernel Debugging Interest List
> Subject: [windbg] Debugging Kernel, in Source Mode
>
>
> Hi,
>
> I am trying to get WinDbg to work in source mode while debugging a
> driver. I have explicitly set a break point in the source code using
> DbgBreakPoint() and WinDbg breaks fine. My problem is I cannot get my
> source code to appear. Also, If I explicitly open my source in WinDbg I
> cannot set a break point on a line (say with F9), it gives me an error
> saying ‘Symbol info for current source line could not be located in the
> currently loaded symbols.’. However, I have my source path set to the
> correct directory and if I do a ‘lm’ command it shows that the correct
> pdb is loaded for my driver.
>
> So, what am I missing here?
>
> Thanks, Chris
>
> P.S. I do have source mode on.
>
>
>
> —
> You are currently subscribed to windbg as: xxxxx@microsoft.com To
> unsubscribe send a blank email to %%email.unsub%%
>
> —
> You are currently subscribed to windbg as: xxxxx@connecttech.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
>