public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB hardware watchpoint information on i386
@ 2010-08-02  4:10 Shrikanth Kamath
  2010-08-02  5:53 ` paawan oza
  2010-08-02  6:58 ` Jan Kratochvil
  0 siblings, 2 replies; 6+ messages in thread
From: Shrikanth Kamath @ 2010-08-02  4:10 UTC (permalink / raw)
  To: gdb

Is there information on how a GDB hardware watchpoint works on a i386.
More like internals of its working,
right from when the hardware watchpoint triggers a trap from processor
perspective(i386 processor supporting
hardware watchpoint).
Which function gets called in GDB to handle this? I am specifically
looking for information about "hooking" my
own handler to service the watchpoint interrupt rather than needing to
invoke a GDB session and press 'c'.

--
Shrikanth R K

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB hardware watchpoint information on i386
  2010-08-02  4:10 GDB hardware watchpoint information on i386 Shrikanth Kamath
@ 2010-08-02  5:53 ` paawan oza
  2010-08-02  6:58 ` Jan Kratochvil
  1 sibling, 0 replies; 6+ messages in thread
From: paawan oza @ 2010-08-02  5:53 UTC (permalink / raw)
  To: Shrikanth Kamath, gdb

Hi,

basically sigtrap is generated and gdb comes out of my_waitpid function.
so do you want to hook handler on every watchpoint trap or you want to just hook 
if at all watchpoint expression match ?

Regards,
Oza.



----- Original Message ----
From: Shrikanth Kamath <shrikanth07@gmail.com>
To: gdb@sourceware.org
Sent: Mon, August 2, 2010 9:40:31 AM
Subject: GDB hardware watchpoint information on i386

Is there information on how a GDB hardware watchpoint works on a i386.
More like internals of its working,
right from when the hardware watchpoint triggers a trap from processor
perspective(i386 processor supporting
hardware watchpoint).
Which function gets called in GDB to handle this? I am specifically
looking for information about "hooking" my
own handler to service the watchpoint interrupt rather than needing to
invoke a GDB session and press 'c'.

--
Shrikanth R K



      

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB hardware watchpoint information on i386
  2010-08-02  4:10 GDB hardware watchpoint information on i386 Shrikanth Kamath
  2010-08-02  5:53 ` paawan oza
@ 2010-08-02  6:58 ` Jan Kratochvil
  2010-08-02  7:55   ` Shrikanth Kamath
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2010-08-02  6:58 UTC (permalink / raw)
  To: Shrikanth Kamath; +Cc: gdb

On Mon, 02 Aug 2010 06:10:31 +0200, Shrikanth Kamath wrote:
> I am specifically looking for information about "hooking" my own handler to
> service the watchpoint interrupt rather than needing to invoke a GDB session
> and press 'c'.

Besides GDB hacking isn't it enough for you to use `commands' with `continue'
and associate arbitrary commands (`backtrace' here) in the GDB CLI interface?

Regards,
Jan


(gdb) watch v
Hardware watchpoint 1: v
(gdb) commands
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>backtrace
>continue 
>end
(gdb) run
Starting program: var 
Hardware watchpoint 1: v

Old value = 0
New value = 1
f () at var.c:7
7	}
#0  f () at var.c:7
#1  0x00000000004004a7 in main () at var.c:20
Hardware watchpoint 1: v

Old value = 1
New value = 0
g () at var.c:13
13	}
#0  g () at var.c:13
#1  0x00000000004004ac in main () at var.c:21
Hardware watchpoint 1: v

Old value = 0
New value = 1
f () at var.c:7
7	}
#0  f () at var.c:7
#1  0x00000000004004a7 in main () at var.c:20
Hardware watchpoint 1: v

[...]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB hardware watchpoint information on i386
  2010-08-02  6:58 ` Jan Kratochvil
@ 2010-08-02  7:55   ` Shrikanth Kamath
  2010-08-02  8:09     ` Jan Kratochvil
  2010-08-02  8:16     ` paawan oza
  0 siblings, 2 replies; 6+ messages in thread
From: Shrikanth Kamath @ 2010-08-02  7:55 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb

Decent enough Jan. Okay, from internals perspective, say I have
written the "commands" to be executed when the watchpoint is hit,
which function
inside GDB maps this action(s) to the watchpoint trap?

I mean there would be
foo_service_watchpoint()
{
   /* map actions to this watchpoint */
}

which is this function?

--
Shrikanth R K

On Mon, Aug 2, 2010 at 12:28 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Mon, 02 Aug 2010 06:10:31 +0200, Shrikanth Kamath wrote:
>> I am specifically looking for information about "hooking" my own handler to
>> service the watchpoint interrupt rather than needing to invoke a GDB session
>> and press 'c'.
>
> Besides GDB hacking isn't it enough for you to use `commands' with `continue'
> and associate arbitrary commands (`backtrace' here) in the GDB CLI interface?
>
> Regards,
> Jan
>
>
> (gdb) watch v
> Hardware watchpoint 1: v
> (gdb) commands
> Type commands for when breakpoint 1 is hit, one per line.
> End with a line saying just "end".
>>backtrace
>>continue
>>end
> (gdb) run
> Starting program: var
> Hardware watchpoint 1: v
>
> Old value = 0
> New value = 1
> f () at var.c:7
> 7       }
> #0  f () at var.c:7
> #1  0x00000000004004a7 in main () at var.c:20
> Hardware watchpoint 1: v
>
> Old value = 1
> New value = 0
> g () at var.c:13
> 13      }
> #0  g () at var.c:13
> #1  0x00000000004004ac in main () at var.c:21
> Hardware watchpoint 1: v
>
> Old value = 0
> New value = 1
> f () at var.c:7
> 7       }
> #0  f () at var.c:7
> #1  0x00000000004004a7 in main () at var.c:20
> Hardware watchpoint 1: v
>
> [...]
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB hardware watchpoint information on i386
  2010-08-02  7:55   ` Shrikanth Kamath
@ 2010-08-02  8:09     ` Jan Kratochvil
  2010-08-02  8:16     ` paawan oza
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2010-08-02  8:09 UTC (permalink / raw)
  To: Shrikanth Kamath; +Cc: gdb

On Mon, 02 Aug 2010 09:55:02 +0200, Shrikanth Kamath wrote:
> I mean there would be
> foo_service_watchpoint()
> {
>    /* map actions to this watchpoint */
> }
> 
> which is this function?

It is caught by bpstat_stop_status but you should not touch the existing
breakpoint list there.  Otherwise print_it_typical but I am not completely
sure you cannot miss the watchpoint in some cases of multiple events at once
(but the same applies for normal watchpoints themselves).

Anyway I do not much understand why don't you connect externally.


Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB hardware watchpoint information on i386
  2010-08-02  7:55   ` Shrikanth Kamath
  2010-08-02  8:09     ` Jan Kratochvil
@ 2010-08-02  8:16     ` paawan oza
  1 sibling, 0 replies; 6+ messages in thread
From: paawan oza @ 2010-08-02  8:16 UTC (permalink / raw)
  To: Shrikanth Kamath, Jan Kratochvil; +Cc: gdb

Hi,
If you look at functions 
'bpstat_stop_status' and 'bpstat_do_actions', they find out why the process was 
stooped and how to execute the associated command.
Regards,
Oza.



----- Original Message ----
From: Shrikanth Kamath <shrikanth07@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb@sourceware.org
Sent: Mon, August 2, 2010 1:25:02 PM
Subject: Re: GDB hardware watchpoint information on i386

Decent enough Jan. Okay, from internals perspective, say I have
written the "commands" to be executed when the watchpoint is hit,
which function
inside GDB maps this action(s) to the watchpoint trap?

I mean there would be
foo_service_watchpoint()
{
   /* map actions to this watchpoint */
}

which is this function?

--
Shrikanth R K

On Mon, Aug 2, 2010 at 12:28 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Mon, 02 Aug 2010 06:10:31 +0200, Shrikanth Kamath wrote:
>> I am specifically looking for information about "hooking" my own handler to
>> service the watchpoint interrupt rather than needing to invoke a GDB session
>> and press 'c'.
>
> Besides GDB hacking isn't it enough for you to use `commands' with `continue'
> and associate arbitrary commands (`backtrace' here) in the GDB CLI interface?
>
> Regards,
> Jan
>
>
> (gdb) watch v
> Hardware watchpoint 1: v
> (gdb) commands
> Type commands for when breakpoint 1 is hit, one per line.
> End with a line saying just "end".
>>backtrace
>>continue
>>end
> (gdb) run
> Starting program: var
> Hardware watchpoint 1: v
>
> Old value = 0
> New value = 1
> f () at var.c:7
> 7       }
> #0  f () at var.c:7
> #1  0x00000000004004a7 in main () at var.c:20
> Hardware watchpoint 1: v
>
> Old value = 1
> New value = 0
> g () at var.c:13
> 13      }
> #0  g () at var.c:13
> #1  0x00000000004004ac in main () at var.c:21
> Hardware watchpoint 1: v
>
> Old value = 0
> New value = 1
> f () at var.c:7
> 7       }
> #0  f () at var.c:7
> #1  0x00000000004004a7 in main () at var.c:20
> Hardware watchpoint 1: v
>
> [...]
>



      

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-02  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-02  4:10 GDB hardware watchpoint information on i386 Shrikanth Kamath
2010-08-02  5:53 ` paawan oza
2010-08-02  6:58 ` Jan Kratochvil
2010-08-02  7:55   ` Shrikanth Kamath
2010-08-02  8:09     ` Jan Kratochvil
2010-08-02  8:16     ` paawan oza

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).