Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2795)

Side by Side Diff: gdb/python/py-symbol.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/python/py-stopevent.c ('k') | gdb/python/py-symtab.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* Python interface to symbols. 1 /* Python interface to symbols.
2 2
3 Copyright (C) 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2008-2012 Free Software Foundation, Inc.
4 4
5 This file is part of GDB. 5 This file is part of GDB.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 SYMPY_REQUIRE_VALID (self, symbol); 176 SYMPY_REQUIRE_VALID (self, symbol);
177 177
178 class = SYMBOL_CLASS (symbol); 178 class = SYMBOL_CLASS (symbol);
179 179
180 return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (symbol) 180 return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (symbol)
181 && (class == LOC_LOCAL || class == LOC_REGISTER 181 && (class == LOC_LOCAL || class == LOC_REGISTER
182 || class == LOC_STATIC || class == LOC_COMPUTED 182 || class == LOC_STATIC || class == LOC_COMPUTED
183 || class == LOC_OPTIMIZED_OUT)); 183 || class == LOC_OPTIMIZED_OUT));
184 } 184 }
185 185
186 /* Implementation of gdb.Symbol.needs_frame -> Boolean.
187 Returns true iff the symbol needs a frame for evaluation. */
188
189 static PyObject *
190 sympy_needs_frame (PyObject *self, void *closure)
191 {
192 struct symbol *symbol = NULL;
193 volatile struct gdb_exception except;
194 int result = 0;
195
196 SYMPY_REQUIRE_VALID (self, symbol);
197
198 TRY_CATCH (except, RETURN_MASK_ALL)
199 {
200 result = symbol_read_needs_frame (symbol);
201 }
202 GDB_PY_HANDLE_EXCEPTION (except);
203
204 if (result)
205 Py_RETURN_TRUE;
206 Py_RETURN_FALSE;
207 }
208
209 /* Implementation of gdb.Symbol.line -> int.
210 Returns the line number at which the symbol was defined. */
211
212 static PyObject *
213 sympy_line (PyObject *self, void *closure)
214 {
215 struct symbol *symbol = NULL;
216
217 SYMPY_REQUIRE_VALID (self, symbol);
218
219 return PyInt_FromLong (SYMBOL_LINE (symbol));
220 }
221
186 /* Implementation of gdb.Symbol.is_valid (self) -> Boolean. 222 /* Implementation of gdb.Symbol.is_valid (self) -> Boolean.
187 Returns True if this Symbol still exists in GDB. */ 223 Returns True if this Symbol still exists in GDB. */
188 224
189 static PyObject * 225 static PyObject *
190 sympy_is_valid (PyObject *self, PyObject *args) 226 sympy_is_valid (PyObject *self, PyObject *args)
191 { 227 {
192 struct symbol *symbol = NULL; 228 struct symbol *symbol = NULL;
193 229
194 symbol = symbol_object_to_symbol (self); 230 symbol = symbol_object_to_symbol (self);
195 if (symbol == NULL) 231 if (symbol == NULL)
196 Py_RETURN_FALSE; 232 Py_RETURN_FALSE;
197 233
198 Py_RETURN_TRUE; 234 Py_RETURN_TRUE;
199 } 235 }
200 236
237 /* Implementation of gdb.Symbol.value (self[, frame]) -> gdb.Value. Returns
238 the value of the symbol, or an error in various circumstances. */
239
240 static PyObject *
241 sympy_value (PyObject *self, PyObject *args)
242 {
243 struct symbol *symbol = NULL;
244 struct frame_info *frame_info = NULL;
245 PyObject *frame_obj = NULL;
246 struct value *value = NULL;
247 volatile struct gdb_exception except;
248
249 if (!PyArg_ParseTuple (args, "|O", &frame_obj))
250 return NULL;
251
252 if (frame_obj != NULL && !PyObject_TypeCheck (frame_obj, &frame_object_type))
253 {
254 PyErr_SetString (PyExc_TypeError, "argument is not a frame");
255 return NULL;
256 }
257
258 SYMPY_REQUIRE_VALID (self, symbol);
259 if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
260 {
261 PyErr_SetString (PyExc_TypeError, "cannot get the value of a typedef");
262 return NULL;
263 }
264
265 TRY_CATCH (except, RETURN_MASK_ALL)
266 {
267 if (frame_obj != NULL)
268 {
269 frame_info = frame_object_to_frame_info (frame_obj);
270 if (frame_info == NULL)
271 error (_("invalid frame"));
272 }
273
274 if (symbol_read_needs_frame (symbol) && frame_info == NULL)
275 error (_("symbol requires a frame to compute its value"));
276
277 value = read_var_value (symbol, frame_info);
278 }
279 GDB_PY_HANDLE_EXCEPTION (except);
280
281 return value_to_value_object (value);
282 }
283
201 /* Given a symbol, and a symbol_object that has previously been 284 /* Given a symbol, and a symbol_object that has previously been
202 allocated and initialized, populate the symbol_object with the 285 allocated and initialized, populate the symbol_object with the
203 struct symbol data. Also, register the symbol_object life-cycle 286 struct symbol data. Also, register the symbol_object life-cycle
204 with the life-cycle of the object file associated with this 287 with the life-cycle of the object file associated with this
205 symbol, if needed. */ 288 symbol, if needed. */
206 static void 289 static void
207 set_symbol (symbol_object *obj, struct symbol *symbol) 290 set_symbol (symbol_object *obj, struct symbol *symbol)
208 { 291 {
209 obj->symbol = symbol; 292 obj->symbol = symbol;
210 obj->prev = NULL; 293 obj->prev = NULL;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 NULL }, 533 NULL },
451 { "print_name", sympy_get_print_name, NULL, 534 { "print_name", sympy_get_print_name, NULL,
452 "Name of the symbol in a form suitable for output.\n\ 535 "Name of the symbol in a form suitable for output.\n\
453 This is either name or linkage_name, depending on whether the user asked GDB\n\ 536 This is either name or linkage_name, depending on whether the user asked GDB\n\
454 to display demangled or mangled names.", NULL }, 537 to display demangled or mangled names.", NULL },
455 { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." }, 538 { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
456 { "is_argument", sympy_is_argument, NULL, 539 { "is_argument", sympy_is_argument, NULL,
457 "True if the symbol is an argument of a function." }, 540 "True if the symbol is an argument of a function." },
458 { "is_constant", sympy_is_constant, NULL, 541 { "is_constant", sympy_is_constant, NULL,
459 "True if the symbol is a constant." }, 542 "True if the symbol is a constant." },

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/python/py-stopevent.c ('k') | gdb/python/py-symtab.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698