| |   |
| 32 | 32 | |
| 33 | 33 | typedef struct breakpoint_object breakpoint_object; |
| 34 | 34 | |
| 35 | | static PyObject *bppy_is_valid (breakpoint_object *); |
| 36 | | static PyObject *bppy_is_enabled (breakpoint_object *); |
| 37 | | static PyObject *bppy_is_silent (breakpoint_object *); |
| 38 | | static PyObject *bppy_set_enabled (breakpoint_object *, PyObject *); |
| 39 | | static PyObject *bppy_set_silent (breakpoint_object *, PyObject *); |
| 40 | | static PyObject *bppy_get_location (breakpoint_object *); |
| 41 | | static PyObject *bppy_get_condition (breakpoint_object *); |
| 42 | | static PyObject *bppy_get_commands (breakpoint_object *); |
| 35 | static PyObject *bppy_is_valid (PyObject *, PyObject *); |
| 36 | static PyObject *bppy_is_enabled (PyObject *, PyObject *); |
| 37 | static PyObject *bppy_is_silent (PyObject *, PyObject *); |
| 38 | static PyObject *bppy_set_enabled (PyObject *, PyObject *); |
| 39 | static PyObject *bppy_set_silent (PyObject *, PyObject *); |
| 40 | static PyObject *bppy_get_location (PyObject *, PyObject *); |
| 41 | static PyObject *bppy_get_condition (PyObject *, PyObject *); |
| 42 | static PyObject *bppy_get_commands (PyObject *, PyObject *); |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | /* A dynamically allocated vector of breakpoint objects. Each |
| … | … | |
| 86 | 86 | |
| 87 | 87 | static PyMethodDef breakpoint_object_methods[] = |
| 88 | 88 | { |
| 89 | | { "is_valid", (PyCFunction) bppy_is_valid, METH_NOARGS, |
| 89 | { "is_valid", bppy_is_valid, METH_NOARGS, |
| 90 | 90 | "Return true if this breakpoint is valid, false if not." }, |
| 91 | | { "is_enabled", (PyCFunction) bppy_is_enabled, METH_NOARGS, |
| 91 | { "is_enabled", bppy_is_enabled, METH_NOARGS, |
| 92 | 92 | "Return true if this breakpoint is enabled, false if disabled." }, |
| 93 | | { "is_silent", (PyCFunction) bppy_is_silent, METH_NOARGS, |
| 93 | { "is_silent", bppy_is_silent, METH_NOARGS, |
| 94 | 94 | "Return true if this breakpoint is silent, false if verbose." }, |
| 95 | 95 | |
| 96 | | { "set_enabled", (PyCFunction) bppy_set_enabled, METH_O, |
| 96 | { "set_enabled", bppy_set_enabled, METH_O, |
| 97 | 97 | "Enable or disable this breakpoint" }, |
| 98 | | { "set_silent", (PyCFunction) bppy_set_silent, METH_O, |
| 98 | { "set_silent", bppy_set_silent, METH_O, |
| 99 | 99 | "Make this breakpoint quiet or verbose" }, |
| 100 | 100 | |
| 101 | | { "get_location", (PyCFunction) bppy_get_location, METH_NOARGS, |
| 101 | { "get_location", bppy_get_location, METH_NOARGS, |
| 102 | 102 | "Return the location of this breakpoint, as specified by the user"}, |
| 103 | | { "get_condition", (PyCFunction) bppy_get_condition, METH_NOARGS, |
| 103 | { "get_condition", bppy_get_condition, METH_NOARGS, |
| 104 | 104 | "Return the condition of this breakpoint, as specified by the user.\n\ |
| 105 | 105 | Returns None if no condition set."}, |
| 106 | | { "get_commands", (PyCFunction) bppy_get_commands, METH_NOARGS, |
| 106 | { "get_commands", bppy_get_commands, METH_NOARGS, |
| 107 | 107 | "Return the commands of this breakpoint, as specified by the user"}, |
| 108 | 108 | |
| 109 | 109 | { 0 } |
| … | … | |
| 143 | 143 | }; |
| 144 | 144 | |
| 145 | 145 | static PyObject * |
| 146 | | bppy_is_valid (breakpoint_object *self) |
| 146 | bppy_is_valid (PyObject *self, PyObject *args) |
| 147 | 147 | { |
| 148 | | if (self->bp) |
| 148 | if (((breakpoint_object *) self)->bp) |
| 149 | 149 | Py_RETURN_TRUE; |
| 150 | 150 | Py_RETURN_FALSE; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | static PyObject * |
| 154 | | bppy_is_enabled (breakpoint_object *self) |
| 154 | bppy_is_enabled (PyObject *self, PyObject *args) |
| 155 | 155 | { |
| 156 | | if (! self->bp) |
| 156 | if (! ((breakpoint_object *) self)->bp) |
| 157 | 157 | Py_RETURN_FALSE; |
| 158 | 158 | /* Not clear what we really want here. */ |
| 159 | | if (self->bp->enable_state == bp_enabled) |
| 159 | if (((breakpoint_object *) self)->bp->enable_state == bp_enabled) |
| 160 | 160 | Py_RETURN_TRUE; |
| 161 | 161 | Py_RETURN_FALSE; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | static PyObject * |
| 165 | | bppy_is_silent (breakpoint_object *self) |
| 165 | bppy_is_silent (PyObject *self, PyObject *args) |
| 166 | 166 | { |
| 167 | | BPPY_REQUIRE_VALID (self); |
| 168 | | if (self->bp->silent) |
| 167 | BPPY_REQUIRE_VALID ((breakpoint_object *) self); |
| 168 | if (((breakpoint_object *) self)->bp->silent) |
| 169 | 169 | Py_RETURN_TRUE; |
| 170 | 170 | Py_RETURN_FALSE; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | static PyObject * |
| 174 | | bppy_set_enabled (breakpoint_object *self, PyObject *newvalue) |
| 174 | bppy_set_enabled (PyObject *self, PyObject *newvalue) |
| 175 | 175 | { |
| 176 | | BPPY_REQUIRE_VALID (self); |
| 176 | breakpoint_object *self_bp = (breakpoint_object *) self; |
| 177 | |
| 178 | BPPY_REQUIRE_VALID (self_bp); |
| 177 | 179 | if (! PyBool_Check (newvalue)) |
| 178 | 180 | return PyErr_Format (PyExc_RuntimeError, "argument must be boolean"); |
| 179 | 181 | |
| 180 | 182 | if (newvalue == Py_True) |
| 181 | | enable_breakpoint (self->bp); |
| 183 | enable_breakpoint (self_bp->bp); |
| 182 | 184 | else |
| 183 | | disable_breakpoint (self->bp); |
| 185 | disable_breakpoint (self_bp->bp); |
| 184 | 186 | |
| 185 | 187 | Py_RETURN_NONE; |
| 186 | 188 | } |
| 187 | 189 | |
| 188 | 190 | static PyObject * |
| 189 | | bppy_set_silent (breakpoint_object *self, PyObject *newvalue) |
| 191 | bppy_set_silent (PyObject *self, PyObject *newvalue) |
| 190 | 192 | { |
| 191 | | BPPY_REQUIRE_VALID (self); |
| 193 | breakpoint_object *self_bp = (breakpoint_object *) self; |
| 194 | |
| 195 | BPPY_REQUIRE_VALID (self_bp); |
| 192 | 196 | if (! PyBool_Check (newvalue)) |
| 193 | 197 | return PyErr_Format (PyExc_RuntimeError, "argument must be boolean"); |
| 194 | 198 | |
| 195 | | self->bp->silent = (newvalue == Py_True); |
| 199 | self_bp->bp->silent = (newvalue == Py_True); |
| 196 | 200 | |
| 197 | 201 | Py_RETURN_NONE; |
| 198 | 202 | } |
| 199 | 203 | |
| 200 | 204 | static PyObject * |
| 201 | | bppy_get_location (breakpoint_object *self) |
| 205 | bppy_get_location (PyObject *self, PyObject *args) |
| 202 | 206 | { |
| 203 | 207 | char *str; |
| 204 | | BPPY_REQUIRE_VALID (self); |
| 205 | | str = self->bp->addr_string; |
| 208 | |
| 209 | BPPY_REQUIRE_VALID ((breakpoint_object *) self); |
| 210 | str = ((breakpoint_object *) self)->bp->addr_string; |
| 206 | 211 | /* FIXME: watchpoints? tracepoints? */ |
| 207 | 212 | if (! str) |
| 208 | 213 | str = ""; |
| … | … | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | static PyObject * |
| 219 | | bppy_get_condition (breakpoint_object *self) |
| 219 | bppy_get_condition (PyObject *self, PyObject *args) |
| 220 | 220 | { |
| 221 | 221 | char *str; |
| 222 | | BPPY_REQUIRE_VALID (self); |
| 222 | BPPY_REQUIRE_VALID ((breakpoint_object *) self); |
| 223 | 223 | |
| 224 | | str = self->bp->cond_string; |
| 224 | str = ((breakpoint_object *) self)->bp->cond_string; |
| 225 | 225 | if (! str) |
| 226 | 226 | Py_RETURN_NONE; |
| 227 | 227 | return PyString_Decode (str, strlen (str), host_charset (), |
| … | … | |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | static PyObject * |
| 232 | | bppy_get_commands (breakpoint_object *self) |
| 232 | bppy_get_commands (PyObject *self, PyObject *args) |
| 233 | 233 | { |
| 234 | breakpoint_object *self_bp = (breakpoint_object *) self; |
| 234 | 235 | long length; |
| 235 | 236 | volatile struct gdb_exception except; |
| 236 | 237 | struct ui_file *string_file; |
| … | … | |
| 239 | 239 | PyObject *result; |
| 240 | 240 | char *cmdstr; |
| 241 | 241 | |
| 242 | | BPPY_REQUIRE_VALID (self); |
| 242 | BPPY_REQUIRE_VALID (self_bp); |
| 243 | 243 | |
| 244 | | if (! self->bp->commands) |
| 244 | if (! self_bp->bp->commands) |
| 245 | 245 | Py_RETURN_NONE; |
| 246 | 246 | |
| 247 | 247 | string_file = mem_fileopen (); |
| … | … | |
| 252 | 252 | /* FIXME: this can fail. Maybe we need to be making a new |
| 253 | 253 | ui_out object here? */ |
| 254 | 254 | ui_out_redirect (uiout, string_file); |
| 255 | | print_command_lines (uiout, self->bp->commands, 0); |
| 255 | print_command_lines (uiout, self_bp->bp->commands, 0); |
| 256 | 256 | ui_out_redirect (uiout, NULL); |
| 257 | 257 | } |
| 258 | 258 | cmdstr = ui_file_xstrdup (string_file, &length); |
| toggle raw diff |
--- a/gdb/python/breakpoint.c
+++ b/gdb/python/breakpoint.c
@@ -32,14 +32,14 @@ extern struct breakpoint *breakpoint_chain;
typedef struct breakpoint_object breakpoint_object;
-static PyObject *bppy_is_valid (breakpoint_object *);
-static PyObject *bppy_is_enabled (breakpoint_object *);
-static PyObject *bppy_is_silent (breakpoint_object *);
-static PyObject *bppy_set_enabled (breakpoint_object *, PyObject *);
-static PyObject *bppy_set_silent (breakpoint_object *, PyObject *);
-static PyObject *bppy_get_location (breakpoint_object *);
-static PyObject *bppy_get_condition (breakpoint_object *);
-static PyObject *bppy_get_commands (breakpoint_object *);
+static PyObject *bppy_is_valid (PyObject *, PyObject *);
+static PyObject *bppy_is_enabled (PyObject *, PyObject *);
+static PyObject *bppy_is_silent (PyObject *, PyObject *);
+static PyObject *bppy_set_enabled (PyObject *, PyObject *);
+static PyObject *bppy_set_silent (PyObject *, PyObject *);
+static PyObject *bppy_get_location (PyObject *, PyObject *);
+static PyObject *bppy_get_condition (PyObject *, PyObject *);
+static PyObject *bppy_get_commands (PyObject *, PyObject *);
/* A dynamically allocated vector of breakpoint objects. Each
@@ -86,24 +86,24 @@ struct breakpoint_object
static PyMethodDef breakpoint_object_methods[] =
{
- { "is_valid", (PyCFunction) bppy_is_valid, METH_NOARGS,
+ { "is_valid", bppy_is_valid, METH_NOARGS,
"Return true if this breakpoint is valid, false if not." },
- { "is_enabled", (PyCFunction) bppy_is_enabled, METH_NOARGS,
+ { "is_enabled", bppy_is_enabled, METH_NOARGS,
"Return true if this breakpoint is enabled, false if disabled." },
- { "is_silent", (PyCFunction) bppy_is_silent, METH_NOARGS,
+ { "is_silent", bppy_is_silent, METH_NOARGS,
"Return true if this breakpoint is silent, false if verbose." },
- { "set_enabled", (PyCFunction) bppy_set_enabled, METH_O,
+ { "set_enabled", bppy_set_enabled, METH_O,
"Enable or disable this breakpoint" },
- { "set_silent", (PyCFunction) bppy_set_silent, METH_O,
+ { "set_silent", bppy_set_silent, METH_O,
"Make this breakpoint quiet or verbose" },
- { "get_location", (PyCFunction) bppy_get_location, METH_NOARGS,
+ { "get_location", bppy_get_location, METH_NOARGS,
"Return the location of this breakpoint, as specified by the user"},
- { "get_condition", (PyCFunction) bppy_get_condition, METH_NOARGS,
+ { "get_condition", bppy_get_condition, METH_NOARGS,
"Return the condition of this breakpoint, as specified by the user.\n\
Returns None if no condition set."},
- { "get_commands", (PyCFunction) bppy_get_commands, METH_NOARGS,
+ { "get_commands", bppy_get_commands, METH_NOARGS,
"Return the commands of this breakpoint, as specified by the user"},
{ 0 }
@@ -143,66 +143,71 @@ static PyTypeObject breakpoint_object_type =
};
static PyObject *
-bppy_is_valid (breakpoint_object *self)
+bppy_is_valid (PyObject *self, PyObject *args)
{
- if (self->bp)
+ if (((breakpoint_object *) self)->bp)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject *
-bppy_is_enabled (breakpoint_object *self)
+bppy_is_enabled (PyObject *self, PyObject *args)
{
- if (! self->bp)
+ if (! ((breakpoint_object *) self)->bp)
Py_RETURN_FALSE;
/* Not clear what we really want here. */
- if (self->bp->enable_state == bp_enabled)
+ if (((breakpoint_object *) self)->bp->enable_state == bp_enabled)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject *
-bppy_is_silent (breakpoint_object *self)
+bppy_is_silent (PyObject *self, PyObject *args)
{
- BPPY_REQUIRE_VALID (self);
- if (self->bp->silent)
+ BPPY_REQUIRE_VALID ((breakpoint_object *) self);
+ if (((breakpoint_object *) self)->bp->silent)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject *
-bppy_set_enabled (breakpoint_object *self, PyObject *newvalue)
+bppy_set_enabled (PyObject *self, PyObject *newvalue)
{
- BPPY_REQUIRE_VALID (self);
+ breakpoint_object *self_bp = (breakpoint_object *) self;
+
+ BPPY_REQUIRE_VALID (self_bp);
if (! PyBool_Check (newvalue))
return PyErr_Format (PyExc_RuntimeError, "argument must be boolean");
if (newvalue == Py_True)
- enable_breakpoint (self->bp);
+ enable_breakpoint (self_bp->bp);
else
- disable_breakpoint (self->bp);
+ disable_breakpoint (self_bp->bp);
Py_RETURN_NONE;
}
static PyObject *
-bppy_set_silent (breakpoint_object *self, PyObject *newvalue)
+bppy_set_silent (PyObject *self, PyObject *newvalue)
{
- BPPY_REQUIRE_VALID (self);
+ breakpoint_object *self_bp = (breakpoint_object *) self;
+
+ BPPY_REQUIRE_VALID (self_bp);
if (! PyBool_Check (newvalue))
return PyErr_Format (PyExc_RuntimeError, "argument must be boolean");
- self->bp->silent = (newvalue == Py_True);
+ self_bp->bp->silent = (newvalue == Py_True);
Py_RETURN_NONE;
}
static PyObject *
-bppy_get_location (breakpoint_object *self)
+bppy_get_location (PyObject *self, PyObject *args)
{
char *str;
- BPPY_REQUIRE_VALID (self);
- str = self->bp->addr_string;
+
+ BPPY_REQUIRE_VALID ((breakpoint_object *) self);
+ str = ((breakpoint_object *) self)->bp->addr_string;
/* FIXME: watchpoints? tracepoints? */
if (! str)
str = "";
@@ -211,12 +216,12 @@ bppy_get_location (breakpoint_object *self)
}
static PyObject *
-bppy_get_condition (breakpoint_object *self)
+bppy_get_condition (PyObject *self, PyObject *args)
{
char *str;
- BPPY_REQUIRE_VALID (self);
+ BPPY_REQUIRE_VALID ((breakpoint_object *) self);
- str = self->bp->cond_string;
+ str = ((breakpoint_object *) self)->bp->cond_string;
if (! str)
Py_RETURN_NONE;
return PyString_Decode (str, strlen (str), host_charset (),
@@ -224,8 +229,9 @@ bppy_get_condition (breakpoint_object *self)
}
static PyObject *
-bppy_get_commands (breakpoint_object *self)
+bppy_get_commands (PyObject *self, PyObject *args)
{
+ breakpoint_object *self_bp = (breakpoint_object *) self;
long length;
volatile struct gdb_exception except;
struct ui_file *string_file;
@@ -233,9 +239,9 @@ bppy_get_commands (breakpoint_object *self)
PyObject *result;
char *cmdstr;
- BPPY_REQUIRE_VALID (self);
+ BPPY_REQUIRE_VALID (self_bp);
- if (! self->bp->commands)
+ if (! self_bp->bp->commands)
Py_RETURN_NONE;
string_file = mem_fileopen ();
@@ -246,7 +252,7 @@ bppy_get_commands (breakpoint_object *self)
/* FIXME: this can fail. Maybe we need to be making a new
ui_out object here? */
ui_out_redirect (uiout, string_file);
- print_command_lines (uiout, self->bp->commands, 0);
+ print_command_lines (uiout, self_bp->bp->commands, 0);
ui_out_redirect (uiout, NULL);
}
cmdstr = ui_file_xstrdup (string_file, &length); |
| |   |
| 45 | 45 | static struct frame_info *frame_object_to_frame_info (frame_object *frame_obj); |
| 46 | 46 | |
| 47 | 47 | static PyObject *frapy_str (PyObject *self); |
| 48 | | static PyObject *frapy_equal_p (frame_object *self, PyObject *args); |
| 49 | | static PyObject *frapy_inner_p (frame_object *self, PyObject *args); |
| 50 | | static PyObject *frapy_is_valid (frame_object *self); |
| 51 | | static PyObject *frapy_get_name (frame_object *self); |
| 52 | | static PyObject *frapy_get_type (frame_object *self); |
| 53 | | static PyObject *frapy_get_unwind_stop_reason (frame_object *self); |
| 54 | | static PyObject *frapy_get_pc (frame_object *self); |
| 48 | static PyObject *frapy_equal_p (PyObject *self, PyObject *args); |
| 49 | static PyObject *frapy_inner_p (PyObject *self, PyObject *args); |
| 50 | static PyObject *frapy_is_valid (PyObject *self, PyObject *args); |
| 51 | static PyObject *frapy_get_name (PyObject *self, PyObject *args); |
| 52 | static PyObject *frapy_get_type (PyObject *self, PyObject *args); |
| 53 | static PyObject *frapy_get_unwind_stop_reason (PyObject *self, PyObject *args); |
| 54 | static PyObject *frapy_get_pc (PyObject *self, PyObject *args); |
| 55 | 55 | static PyObject *frapy_get_address_in_block (PyObject *self, PyObject *args); |
| 56 | | static PyObject *frapy_get_prev (frame_object *self); |
| 57 | | static PyObject *frapy_get_next (frame_object *self); |
| 58 | | static PyObject *frapy_find_sal (frame_object *self); |
| 56 | static PyObject *frapy_get_prev (PyObject *self, PyObject *args); |
| 57 | static PyObject *frapy_get_next (PyObject *self, PyObject *args); |
| 58 | static PyObject *frapy_find_sal (PyObject *self, PyObject *args); |
| 59 | 59 | |
| 60 | 60 | #define FRAPY_REQUIRE_VALID(frame_obj, frame) \ |
| 61 | 61 | do { \ |
| … | … | |
| 68 | 68 | } while (0) |
| 69 | 69 | |
| 70 | 70 | static PyMethodDef frame_object_methods[] = { |
| 71 | | { "equals", (PyCFunction) frapy_equal_p, METH_VARARGS, |
| 72 | | "Compare frames." }, |
| 73 | | { "is_inner_than", (PyCFunction) frapy_inner_p, METH_VARARGS, |
| 71 | { "equals", frapy_equal_p, METH_VARARGS, "Compare frames." }, |
| 72 | { "is_inner_than", frapy_inner_p, METH_VARARGS, |
| 74 | 73 | "Return true if this frame is strictly inner than the other frame." }, |
| 75 | | { "is_valid.", (PyCFunction) frapy_is_valid, METH_NOARGS, |
| 74 | { "is_valid.", frapy_is_valid, METH_NOARGS, |
| 76 | 75 | "Return true if this frame is valid, false if not." }, |
| 77 | | { "get_name", (PyCFunction) frapy_get_name, METH_NOARGS, |
| 76 | { "get_name", frapy_get_name, METH_NOARGS, |
| 78 | 77 | "Return the function name of the frame." }, |
| 79 | | { "get_type", (PyCFunction) frapy_get_type, METH_NOARGS, |
| 80 | | "Return the type of the frame." }, |
| 81 | | { "get_unwind_stop_reason", (PyCFunction) frapy_get_unwind_stop_reason, |
| 78 | { "get_type", frapy_get_type, METH_NOARGS, "Return the type of the frame." }, |
| 79 | { "get_unwind_stop_reason", frapy_get_unwind_stop_reason, |
| 82 | 80 | METH_NOARGS, "Return the function name of the frame." }, |
| 83 | | { "get_pc", (PyCFunction) frapy_get_pc, METH_NOARGS, |
| 84 | | "Return the frame's resume address." }, |
| 81 | { "get_pc", frapy_get_pc, METH_NOARGS, "Return the frame's resume address." }, |
| 85 | 82 | { "get_address_in_block", frapy_get_address_in_block, METH_NOARGS, |
| 86 | 83 | "Return an address which falls within the frame's code block." }, |
| 87 | | { "get_prev", (PyCFunction) frapy_get_prev, METH_NOARGS, |
| 84 | { "get_prev", frapy_get_prev, METH_NOARGS, |
| 88 | 85 | "Return the previous (outer) frame." }, |
| 89 | | { "get_next", (PyCFunction) frapy_get_next, METH_NOARGS, |
| 90 | | "Return the next (inner) frame." }, |
| 91 | | { "find_sal", (PyCFunction) frapy_find_sal, METH_NOARGS, |
| 86 | { "get_next", frapy_get_next, METH_NOARGS, "Return the next (inner) frame." }, |
| 87 | { "find_sal", frapy_find_sal, METH_NOARGS, |
| 92 | 88 | "Return the frame's symtab and line." }, |
| 93 | 89 | {NULL} /* Sentinel */ |
| 94 | 90 | }; |
| … | … | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | static PyObject * |
| 126 | | frapy_is_valid (frame_object *self) |
| 127 | | { |
| 128 | | struct frame_info *frame; |
| 129 | | |
| 130 | | frame = frame_object_to_frame_info (self); |
| 131 | | if (frame == NULL) |
| 132 | | Py_RETURN_FALSE; |
| 133 | | |
| 134 | | Py_RETURN_TRUE; |
| 135 | | } |
| 136 | | |
| 137 | | static PyObject * |
| 138 | 126 | frapy_str (PyObject *self) |
| 139 | 127 | { |
| 140 | 128 | char *s; |
| … | … | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | static PyObject * |
| 143 | | frapy_equal_p (frame_object *self, PyObject *args) |
| 143 | frapy_is_valid (PyObject *self, PyObject *args) |
| 144 | { |
| 145 | struct frame_info *frame; |
| 146 | |
| 147 | frame = frame_object_to_frame_info ((frame_object *) self); |
| 148 | if (frame == NULL) |
| 149 | Py_RETURN_FALSE; |
| 150 | |
| 151 | Py_RETURN_TRUE; |
| 152 | } |
| 153 | |
| 154 | static PyObject * |
| 155 | frapy_equal_p (PyObject *self, PyObject *args) |
| 144 | 156 | { |
| 145 | 157 | int equalp = 0; /* Initialize to appease gcc warning. */ |
| 158 | frame_object *self_frame = (frame_object *) self; |
| 146 | 159 | frame_object *other; |
| 147 | 160 | volatile struct gdb_exception except; |
| 148 | 161 | |
| … | … | |
| 164 | 164 | |
| 165 | 165 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 166 | 166 | { |
| 167 | | equalp = frame_id_eq (self->frame_id, other->frame_id); |
| 167 | equalp = frame_id_eq (self_frame->frame_id, other->frame_id); |
| 168 | 168 | } |
| 169 | 169 | GDB_PY_HANDLE_EXCEPTION (except); |
| 170 | 170 | |
| … | … | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | static PyObject * |
| 178 | | frapy_inner_p (frame_object *self, PyObject *args) |
| 178 | frapy_inner_p (PyObject *self, PyObject *args) |
| 179 | 179 | { |
| 180 | 180 | int innerp = 0; /* Initialize to appease gcc warning. */ |
| 181 | frame_object *self_frame = (frame_object *) self; |
| 181 | 182 | frame_object *other; |
| 182 | 183 | volatile struct gdb_exception except; |
| 183 | 184 | |
| … | … | |
| 188 | 188 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 189 | 189 | { |
| 190 | 190 | /* It doesn't make sense to compare frames from different arches. */ |
| 191 | | if (self->gdbarch != other->gdbarch) |
| 191 | if (self_frame->gdbarch != other->gdbarch) |
| 192 | 192 | { |
| 193 | 193 | PyErr_SetString (PyExc_ValueError, |
| 194 | 194 | "Frames are from different architectures."); |
| 195 | 195 | return NULL; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | | innerp = frame_id_inner (self->gdbarch, self->frame_id, other->frame_id); |
| 198 | innerp = frame_id_inner (self_frame->gdbarch, |
| 199 | self_frame->frame_id, other->frame_id); |
| 199 | 200 | } |
| 200 | 201 | GDB_PY_HANDLE_EXCEPTION (except); |
| 201 | 202 | |
| … | … | |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | static PyObject * |
| 210 | | frapy_get_name (frame_object *self) |
| 210 | frapy_get_name (PyObject *self, PyObject *args) |
| 211 | 211 | { |
| 212 | 212 | struct frame_info *frame; |
| 213 | 213 | char *name; |
| … | … | |
| 217 | 217 | |
| 218 | 218 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 219 | 219 | { |
| 220 | | FRAPY_REQUIRE_VALID (self, frame); |
| 220 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 221 | 221 | |
| 222 | 222 | find_frame_funname (frame, &name, &lang); |
| 223 | 223 | } |
| … | … | |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | static PyObject * |
| 239 | | frapy_get_type (frame_object *self) |
| 239 | frapy_get_type (PyObject *self, PyObject *args) |
| 240 | 240 | { |
| 241 | 241 | struct frame_info *frame; |
| 242 | 242 | enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */ |
| … | … | |
| 244 | 244 | |
| 245 | 245 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 246 | 246 | { |
| 247 | | FRAPY_REQUIRE_VALID (self, frame); |
| 247 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 248 | 248 | |
| 249 | 249 | type = get_frame_type (frame); |
| 250 | 250 | } |
| … | … | |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | static PyObject * |
| 257 | | frapy_get_unwind_stop_reason (frame_object *self) |
| 257 | frapy_get_unwind_stop_reason (PyObject *self, PyObject *args) |
| 258 | 258 | { |
| 259 | 259 | struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ |
| 260 | 260 | volatile struct gdb_exception except; |
| … | … | |
| 262 | 262 | |
| 263 | 263 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 264 | 264 | { |
| 265 | | FRAPY_REQUIRE_VALID (self, frame); |
| 265 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 266 | 266 | } |
| 267 | 267 | GDB_PY_HANDLE_EXCEPTION (except); |
| 268 | 268 | |
| … | … | |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | static PyObject * |
| 275 | | frapy_get_pc (frame_object *self) |
| 275 | frapy_get_pc (PyObject *self, PyObject *args) |
| 276 | 276 | { |
| 277 | 277 | CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ |
| 278 | 278 | struct frame_info *frame; |
| … | … | |
| 280 | 280 | |
| 281 | 281 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 282 | 282 | { |
| 283 | | FRAPY_REQUIRE_VALID (self, frame); |
| 283 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 284 | 284 | |
| 285 | 285 | pc = get_frame_pc (frame); |
| 286 | 286 | } |
| … | … | |
| 292 | 292 | static PyObject * |
| 293 | 293 | frapy_get_address_in_block (PyObject *self, PyObject *args) |
| 294 | 294 | { |
| 295 | | frame_object *frame_obj = (frame_object *) self; |
| 296 | 295 | CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ |
| 297 | 296 | struct frame_info *frame; |
| 298 | 297 | volatile struct gdb_exception except; |
| 299 | 298 | |
| 300 | 299 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 301 | 300 | { |
| 302 | | FRAPY_REQUIRE_VALID (frame_obj, frame); |
| 301 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 303 | 302 | |
| 304 | 303 | pc = get_frame_address_in_block (frame); |
| 305 | 304 | } |
| … | … | |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | static PyObject * |
| 359 | | frapy_get_prev (frame_object *self) |
| 359 | frapy_get_prev (PyObject *self, PyObject *args) |
| 360 | 360 | { |
| 361 | 361 | struct frame_info *frame, *prev; |
| 362 | 362 | volatile struct gdb_exception except; |
| … | … | |
| 364 | 364 | |
| 365 | 365 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 366 | 366 | { |
| 367 | | FRAPY_REQUIRE_VALID (self, frame); |
| 367 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 368 | 368 | |
| 369 | 369 | prev = get_prev_frame (frame); |
| 370 | 370 | if (prev) |
| … | … | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | static PyObject * |
| 384 | | frapy_get_next (frame_object *self) |
| 384 | frapy_get_next (PyObject *self, PyObject *args) |
| 385 | 385 | { |
| 386 | 386 | struct frame_info *frame, *next; |
| 387 | 387 | volatile struct gdb_exception except; |
| … | … | |
| 389 | 389 | |
| 390 | 390 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 391 | 391 | { |
| 392 | | FRAPY_REQUIRE_VALID (self, frame); |
| 392 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 393 | 393 | |
| 394 | 394 | next = get_next_frame (frame); |
| 395 | 395 | if (next) |
| … | … | |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | static PyObject * |
| 409 | | frapy_find_sal (frame_object *self) |
| 409 | frapy_find_sal (PyObject *self, PyObject *args) |
| 410 | 410 | { |
| 411 | 411 | struct frame_info *frame; |
| 412 | 412 | struct symtab_and_line sal; |
| … | … | |
| 415 | 415 | |
| 416 | 416 | TRY_CATCH (except, RETURN_MASK_ALL) |
| 417 | 417 | { |
| 418 | | FRAPY_REQUIRE_VALID (self, frame); |
| 418 | FRAPY_REQUIRE_VALID ((frame_object *) self, frame); |
| 419 | 419 | |
| 420 | 420 | find_frame_sal (frame, &sal); |
| 421 | 421 | sal_obj = symtab_and_line_to_sal_object (sal); |
| toggle raw diff |
--- a/gdb/python/frame.c
+++ b/gdb/python/frame.c
@@ -45,17 +45,17 @@ static frame_object *frame_info_to_frame_object (struct frame_info *frame);
static struct frame_info *frame_object_to_frame_info (frame_object *frame_obj);
static PyObject *frapy_str (PyObject *self);
-static PyObject *frapy_equal_p (frame_object *self, PyObject *args);
-static PyObject *frapy_inner_p (frame_object *self, PyObject *args);
-static PyObject *frapy_is_valid (frame_object *self);
-static PyObject *frapy_get_name (frame_object *self);
-static PyObject *frapy_get_type (frame_object *self);
-static PyObject *frapy_get_unwind_stop_reason (frame_object *self);
-static PyObject *frapy_get_pc (frame_object *self);
+static PyObject *frapy_equal_p (PyObject *self, PyObject *args);
+static PyObject *frapy_inner_p (PyObject *self, PyObject *args);
+static PyObject *frapy_is_valid (PyObject *self, PyObject *args);
+static PyObject *frapy_get_name (PyObject *self, PyObject *args);
+static PyObject *frapy_get_type (PyObject *self, PyObject *args);
+static PyObject *frapy_get_unwind_stop_reason (PyObject *self, PyObject *args);
+static PyObject *frapy_get_pc (PyObject *self, PyObject *args);
static PyObject *frapy_get_address_in_block (PyObject *self, PyObject *args);
-static PyObject *frapy_get_prev (frame_object *self);
-static PyObject *frapy_get_next (frame_object *self);
-static PyObject *frapy_find_sal (frame_object *self);
+static PyObject *frapy_get_prev (PyObject *self, PyObject *args);
+static PyObject *frapy_get_next (PyObject *self, PyObject *args);
+static PyObject *frapy_find_sal (PyObject *self, PyObject *args);
#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
do { \
@@ -68,27 +68,23 @@ static PyObject *frapy_find_sal (frame_object *self);
} while (0)
static PyMethodDef frame_object_methods[] = {
- { "equals", (PyCFunction) frapy_equal_p, METH_VARARGS,
- "Compare frames." },
- { "is_inner_than", (PyCFunction) frapy_inner_p, METH_VARARGS,
+ { "equals", frapy_equal_p, METH_VARARGS, "Compare frames." },
+ { "is_inner_than", frapy_inner_p, METH_VARARGS,
"Return true if this frame is strictly inner than the other frame." },
- { "is_valid.", (PyCFunction) frapy_is_valid, METH_NOARGS,
+ { "is_valid.", frapy_is_valid, METH_NOARGS,
"Return true if this frame is valid, false if not." },
- { "get_name", (PyCFunction) frapy_get_name, METH_NOARGS,
+ { "get_name", frapy_get_name, METH_NOARGS,
"Return the function name of the frame." },
- { "get_type", (PyCFunction) frapy_get_type, METH_NOARGS,
- "Return the type of the frame." },
- { "get_unwind_stop_reason", (PyCFunction) frapy_get_unwind_stop_reason,
+ { "get_type", frapy_get_type, METH_NOARGS, "Return the type of the frame." },
+ { "get_unwind_stop_reason", frapy_get_unwind_stop_reason,
METH_NOARGS, "Return the function name of the frame." },
- { "get_pc", (PyCFunction) frapy_get_pc, METH_NOARGS,
- "Return the frame's resume address." },
+ { "get_pc", frapy_get_pc, METH_NOARGS, "Return the frame's resume address." },
{ "get_address_in_block", frapy_get_address_in_block, METH_NOARGS,
"Return an address which falls within the frame's code block." },
- { "get_prev", (PyCFunction) frapy_get_prev, METH_NOARGS,
+ { "get_prev", frapy_get_prev, METH_NOARGS,
"Return the previous (outer) frame." },
- { "get_next", (PyCFunction) frapy_get_next, METH_NOARGS,
- "Return the next (inner) frame." },
- { "find_sal", (PyCFunction) frapy_find_sal, METH_NOARGS,
+ { "get_next", frapy_get_next, METH_NOARGS, "Return the next (inner) frame." },
+ { "find_sal", frapy_find_sal, METH_NOARGS,
"Return the frame's symtab and line." },
{NULL} /* Sentinel */
};
@@ -127,18 +123,6 @@ static PyTypeObject frame_object_type = {
static PyObject *
-frapy_is_valid (frame_object *self)
-{
- struct frame_info *frame;
-
- frame = frame_object_to_frame_info (self);
- if (frame == NULL)
- Py_RETURN_FALSE;
-
- Py_RETURN_TRUE;
-}
-
-static PyObject *
frapy_str (PyObject *self)
{
char *s;
@@ -156,9 +140,22 @@ frapy_str (PyObject *self)
}
static PyObject *
-frapy_equal_p (frame_object *self, PyObject *args)
+frapy_is_valid (PyObject *self, PyObject *args)
+{
+ struct frame_info *frame;
+
+ frame = frame_object_to_frame_info ((frame_object *) self);
+ if (frame == NULL)
+ Py_RETURN_FALSE;
+
+ Py_RETURN_TRUE;
+}
+
+static PyObject *
+frapy_equal_p (PyObject *self, PyObject *args)
{
int equalp = 0; /* Initialize to appease gcc warning. */
+ frame_object *self_frame = (frame_object *) self;
frame_object *other;
volatile struct gdb_exception except;
@@ -167,7 +164,7 @@ frapy_equal_p (frame_object *self, PyObject *args)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- equalp = frame_id_eq (self->frame_id, other->frame_id);
+ equalp = frame_id_eq (self_frame->frame_id, other->frame_id);
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -178,9 +175,10 @@ frapy_equal_p (frame_object *self, PyObject *args)
}
static PyObject *
-frapy_inner_p (frame_object *self, PyObject *args)
+frapy_inner_p (PyObject *self, PyObject *args)
{
int innerp = 0; /* Initialize to appease gcc warning. */
+ frame_object *self_frame = (frame_object *) self;
frame_object *other;
volatile struct gdb_exception except;
@@ -190,14 +188,15 @@ frapy_inner_p (frame_object *self, PyObject *args)
TRY_CATCH (except, RETURN_MASK_ALL)
{
/* It doesn't make sense to compare frames from different arches. */
- if (self->gdbarch != other->gdbarch)
+ if (self_frame->gdbarch != other->gdbarch)
{
PyErr_SetString (PyExc_ValueError,
"Frames are from different architectures.");
return NULL;
}
- innerp = frame_id_inner (self->gdbarch, self->frame_id, other->frame_id);
+ innerp = frame_id_inner (self_frame->gdbarch,
+ self_frame->frame_id, other->frame_id);
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -208,7 +207,7 @@ frapy_inner_p (frame_object *self, PyObject *args)
}
static PyObject *
-frapy_get_name (frame_object *self)
+frapy_get_name (PyObject *self, PyObject *args)
{
struct frame_info *frame;
char *name;
@@ -218,7 +217,7 @@ frapy_get_name (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
find_frame_funname (frame, &name, &lang);
}
@@ -237,7 +236,7 @@ frapy_get_name (frame_object *self)
}
static PyObject *
-frapy_get_type (frame_object *self)
+frapy_get_type (PyObject *self, PyObject *args)
{
struct frame_info *frame;
enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */
@@ -245,7 +244,7 @@ frapy_get_type (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
type = get_frame_type (frame);
}
@@ -255,7 +254,7 @@ frapy_get_type (frame_object *self)
}
static PyObject *
-frapy_get_unwind_stop_reason (frame_object *self)
+frapy_get_unwind_stop_reason (PyObject *self, PyObject *args)
{
struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */
volatile struct gdb_exception except;
@@ -263,7 +262,7 @@ frapy_get_unwind_stop_reason (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -273,7 +272,7 @@ frapy_get_unwind_stop_reason (frame_object *self)
}
static PyObject *
-frapy_get_pc (frame_object *self)
+frapy_get_pc (PyObject *self, PyObject *args)
{
CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
struct frame_info *frame;
@@ -281,7 +280,7 @@ frapy_get_pc (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
pc = get_frame_pc (frame);
}
@@ -293,14 +292,13 @@ frapy_get_pc (frame_object *self)
static PyObject *
frapy_get_address_in_block (PyObject *self, PyObject *args)
{
- frame_object *frame_obj = (frame_object *) self;
CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
struct frame_info *frame;
volatile struct gdb_exception except;
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (frame_obj, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
pc = get_frame_address_in_block (frame);
}
@@ -358,7 +356,7 @@ frame_object_to_frame_info (frame_object *frame_obj)
}
static PyObject *
-frapy_get_prev (frame_object *self)
+frapy_get_prev (PyObject *self, PyObject *args)
{
struct frame_info *frame, *prev;
volatile struct gdb_exception except;
@@ -366,7 +364,7 @@ frapy_get_prev (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
prev = get_prev_frame (frame);
if (prev)
@@ -383,7 +381,7 @@ frapy_get_prev (frame_object *self)
}
static PyObject *
-frapy_get_next (frame_object *self)
+frapy_get_next (PyObject *self, PyObject *args)
{
struct frame_info *frame, *next;
volatile struct gdb_exception except;
@@ -391,7 +389,7 @@ frapy_get_next (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
next = get_next_frame (frame);
if (next)
@@ -408,7 +406,7 @@ frapy_get_next (frame_object *self)
}
static PyObject *
-frapy_find_sal (frame_object *self)
+frapy_find_sal (PyObject *self, PyObject *args)
{
struct frame_info *frame;
struct symtab_and_line sal;
@@ -417,7 +415,7 @@ frapy_find_sal (frame_object *self)
TRY_CATCH (except, RETURN_MASK_ALL)
{
- FRAPY_REQUIRE_VALID (self, frame);
+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
find_frame_sal (frame, &sal);
sal_obj = symtab_and_line_to_sal_object (sal); |
| |   |
| 29 | 29 | } symtab_object; |
| 30 | 30 | |
| 31 | 31 | static PyObject *stpy_str (PyObject *self); |
| 32 | | static PyObject *stpy_filename (symtab_object *self); |
| 33 | | static PyObject *stpy_to_fullname (symtab_object *self); |
| 32 | static PyObject *stpy_filename (PyObject *self, PyObject *args); |
| 33 | static PyObject *stpy_to_fullname (PyObject *self, PyObject *args); |
| 34 | 34 | |
| 35 | 35 | static PyMethodDef symtab_object_methods[] = { |
| 36 | | { "get_filename", (PyCFunction) stpy_filename, METH_NOARGS, |
| 36 | { "get_filename", stpy_filename, METH_NOARGS, |
| 37 | 37 | "Return the symtab's source filename." }, |
| 38 | | { "to_fullname", (PyCFunction) stpy_to_fullname, METH_NOARGS, |
| 38 | { "to_fullname", stpy_to_fullname, METH_NOARGS, |
| 39 | 39 | "Return the symtab's full source filename." }, |
| 40 | 40 | {NULL} /* Sentinel */ |
| 41 | 41 | }; |
| … | … | |
| 78 | 78 | struct symtab_and_line *sal; |
| 79 | 79 | } sal_object; |
| 80 | 80 | |
| 81 | | static void salpy_dealloc (sal_object *self); |
| 82 | | static int salpy_setsymtab (sal_object *self, void *closure); |
| 81 | static void salpy_dealloc (PyObject *self); |
| 82 | static int salpy_setsymtab (PyObject *self, PyObject *value, void *closure); |
| 83 | 83 | static PyObject *salpy_str (PyObject *self); |
| 84 | | static PyObject *salpy_getsymtab (sal_object *self, void *closure); |
| 85 | | static PyObject *salpy_pc (sal_object *self); |
| 86 | | static PyObject *salpy_line (sal_object *self); |
| 84 | static PyObject *salpy_getsymtab (PyObject *self, void *closure); |
| 85 | static PyObject *salpy_pc (PyObject *self, PyObject *args); |
| 86 | static PyObject *salpy_line (PyObject *self, PyObject *args); |
| 87 | 87 | |
| 88 | 88 | static PyGetSetDef sal_object_getseters[] = { |
| 89 | | { "symtab", (getter) salpy_getsymtab, (setter) salpy_setsymtab, |
| 90 | | "Symtab object.", NULL }, |
| 89 | { "symtab", salpy_getsymtab, salpy_setsymtab, "Symtab object.", NULL }, |
| 91 | 90 | {NULL} /* Sentinel */ |
| 92 | 91 | }; |
| 93 | 92 | |
| 94 | 93 | static PyMethodDef sal_object_methods[] = { |
| 95 | | { "get_pc", (PyCFunction) salpy_pc, METH_NOARGS, |
| 94 | { "get_pc", salpy_pc, METH_NOARGS, |
| 96 | 95 | "Return the symtab_and_line's pc." }, |
| 97 | | { "get_line", (PyCFunction) salpy_line, METH_NOARGS, |
| 96 | { "get_line", salpy_line, METH_NOARGS, |
| 98 | 97 | "Return the symtab_and_line's line." }, |
| 99 | 98 | {NULL} /* Sentinel */ |
| 100 | 99 | }; |
| … | … | |
| 104 | 104 | "gdb.Symtab_and_line", /*tp_name*/ |
| 105 | 105 | sizeof (sal_object), /*tp_basicsize*/ |
| 106 | 106 | 0, /*tp_itemsize*/ |
| 107 | | (destructor) salpy_dealloc, /*tp_dealloc*/ |
| 107 | salpy_dealloc, /*tp_dealloc*/ |
| 108 | 108 | 0, /*tp_print*/ |
| 109 | 109 | 0, /*tp_getattr*/ |
| 110 | 110 | 0, /*tp_setattr*/ |
| … | … | |
| 140 | 140 | char *s; |
| 141 | 141 | PyObject *result; |
| 142 | 142 | |
| 143 | | ret = asprintf(&s, "symbol table for %s", |
| 144 | | ((symtab_object *) self)->symtab->filename); |
| 143 | ret = asprintf (&s, "symbol table for %s", |
| 144 | ((symtab_object *) self)->symtab->filename); |
| 145 | 145 | if (ret < 0) |
| 146 | 146 | Py_RETURN_NONE; |
| 147 | 147 | |
| … | … | |
| 153 | 153 | |
| 154 | 154 | /* FIXME: maybe this should be an attribute instead of a method? */ |
| 155 | 155 | static PyObject * |
| 156 | | stpy_filename (symtab_object *self) |
| 156 | stpy_filename (PyObject *self, PyObject *args) |
| 157 | 157 | { |
| 158 | symtab_object *self_symtab = (symtab_object *) self; |
| 158 | 159 | PyObject *str_obj; |
| 159 | 160 | |
| 160 | 161 | /* FIXME: Can symtab->filename really be NULL? */ |
| 161 | | if (self->symtab->filename) |
| 162 | | str_obj = PyString_Decode (self->symtab->filename, |
| 163 | | strlen (self->symtab->filename), host_charset (), |
| 164 | | NULL /* FIXME */); |
| 162 | if (self_symtab->symtab->filename) |
| 163 | str_obj = PyString_Decode (self_symtab->symtab->filename, |
| 164 | strlen (self_symtab->symtab->filename), |
| 165 | host_charset (), NULL /* FIXME */); |
| 165 | 166 | else |
| 166 | 167 | { |
| 167 | 168 | str_obj = Py_None; |
| … | … | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | static PyObject * |
| 176 | | stpy_to_fullname (symtab_object *self) |
| 176 | stpy_to_fullname (PyObject *self, PyObject *args) |
| 177 | 177 | { |
| 178 | 178 | char *fullname; |
| 179 | 179 | |
| 180 | | fullname = symtab_to_fullname (self->symtab); |
| 180 | fullname = symtab_to_fullname (((symtab_object *) self)->symtab); |
| 181 | 181 | if (fullname) |
| 182 | 182 | return PyString_Decode (fullname, strlen (fullname), host_charset (), |
| 183 | 183 | NULL /* FIXME */); |
| … | … | |
| 196 | 196 | sal_obj = (sal_object *) self; |
| 197 | 197 | filename = (sal_obj->symtab == (symtab_object *) Py_None)? "<unknown>" : |
| 198 | 198 | sal_obj->symtab->symtab->filename; |
| 199 | | ret = asprintf(&s, "symbol and line for %s, line %d", filename, |
| 200 | | sal_obj->sal->line); |
| 199 | ret = asprintf (&s, "symbol and line for %s, line %d", filename, |
| 200 | sal_obj->sal->line); |
| 201 | 201 | if (ret < 0) |
| 202 | 202 | Py_RETURN_NONE; |
| 203 | 203 | |
| … | … | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | static PyObject * |
| 211 | | salpy_pc (sal_object *self) |
| 211 | salpy_pc (PyObject *self, PyObject *args) |
| 212 | 212 | { |
| 213 | | return PyLong_FromUnsignedLongLong (self->sal->pc); |
| 213 | return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->pc); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | static PyObject * |
| 217 | | salpy_line (sal_object *self) |
| 217 | salpy_line (PyObject *self, PyObject *args) |
| 218 | 218 | { |
| 219 | | return PyLong_FromUnsignedLongLong (self->sal->line); |
| 219 | return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->line); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | static PyObject * |
| 223 | | salpy_getsymtab (sal_object *self, void *closure) |
| 223 | salpy_getsymtab (PyObject *self, void *closure) |
| 224 | 224 | { |
| 225 | | Py_INCREF (self->symtab); |
| 225 | sal_object *self_sal = (sal_object *) self; |
| 226 | 226 | |
| 227 | | return (PyObject *) self->symtab; |
| 227 | Py_INCREF (self_sal->symtab); |
| 228 | |
| 229 | return (PyObject *) self_sal->symtab; |
| 228 | 230 | } |
| 229 | 231 | |
| 230 | 232 | static int |
| 231 | | salpy_setsymtab (sal_object *self, void *closure) |
| 233 | salpy_setsymtab (PyObject *self, PyObject *value, void *closure) |
| 232 | 234 | { |
| 233 | | PyErr_SetString(PyExc_TypeError, "The symtab attribute can't be modified."); |
| 235 | PyErr_SetString (PyExc_TypeError, "The symtab attribute can't be modified."); |
| 234 | 236 | |
| 235 | 237 | return -1; |
| 236 | 238 | } |
| 237 | 239 | |
| 238 | 240 | static void |
| 239 | | salpy_dealloc (sal_object *self) |
| 241 | salpy_dealloc (PyObject *self) |
| 240 | 242 | { |
| 241 | | Py_DECREF (self->symtab); |
| 242 | | xfree (self->sal); |
| 243 | | self->ob_type->tp_free((PyObject*)self); |
| 243 | sal_object *self_sal = (sal_object *) self; |
| 244 | |
| 245 | Py_DECREF (self_sal->symtab); |
| 246 | xfree (self_sal->sal); |
| 247 | self_sal->ob_type->tp_free (self); |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | 250 | PyObject * |
| … | … | |
| 317 | 317 | return; |
| 318 | 318 | |
| 319 | 319 | P |