summaryrefslogtreecommitdiff
path: root/gdb/mi/mi-events.c
blob: 1d942a4d2656fd556b11e6499dc45f5705213ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* MI Event Handlers
   Copyright 2002 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#include "defs.h"
#include "ui-out.h"
#include "interps.h"
#include "gdb.h"
#include "breakpoint.h"

#include "mi.h"

void 
mi_interp_stack_changed_hook (void)
{
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "stack_changed");
  ui_out_list_end (uiout);
  uiout = saved_ui_out;
}

void 
mi_interp_frame_changed_hook (int new_frame_number)
{
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "frame_changed");
  ui_out_field_int (uiout, "frame", new_frame_number);
  ui_out_list_end (uiout);
  uiout = saved_ui_out;

}

void
mi_interp_context_hook (int thread_id)
{
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "thread_changed");
  ui_out_field_int (uiout, "thread", thread_id);
  ui_out_list_end (uiout);
  uiout = saved_ui_out;
}

void
mi_interp_create_breakpoint_hook (struct breakpoint *bpt)
{
  CORE_ADDR unusued_addr;
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  /* This is a little inefficient, but it probably isn't worth adding
     a gdb_breakpoint_query that takes a bpt structure... */

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "breakpoint_create");
  gdb_breakpoint_query (uiout, bpt->number);
  ui_out_list_end (uiout);
  uiout = saved_ui_out; 
}

void
mi_interp_modify_breakpoint_hook (struct breakpoint *bpt)
{

  CORE_ADDR unusued_addr;
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  /* This is a little inefficient, but it probably isn't worth adding
     a gdb_breakpoint_query that takes a bpt structure... */

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "breakpoint_modify");
  gdb_breakpoint_query (uiout, bpt->number);
  ui_out_list_end (uiout);
  uiout = saved_ui_out; 
}

void
mi_interp_delete_breakpoint_hook (struct breakpoint *bpt)
{
  CORE_ADDR unusued_addr;
  struct ui_out *saved_ui_out = uiout;
  struct mi_out *tmp_mi_out;

  if (gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0))
    uiout = gdb_interpreter_ui_out (mi0_interp);
  else
    uiout = gdb_interpreter_ui_out (mi_interp);

  /* This is a little inefficient, but it probably isn't worth adding
     a gdb_breakpoint_query that takes a bpt structure... */

  ui_out_list_begin (uiout, "MI_HOOK_RESULT");
  ui_out_field_string (uiout, "HOOK_TYPE", "breakpoint_delete");
  ui_out_field_int (uiout, "bkptno", bpt->number);
  ui_out_list_end (uiout);
  uiout = saved_ui_out; 
}