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

Side by Side Diff: gdb/python/py-utils.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-type.c ('k') | gdb/python/py-value.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* General utility routines for GDB/Python. 1 /* General utility routines for GDB/Python.
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 unicode_to_target_string (PyObject *unicode_str) 132 unicode_to_target_string (PyObject *unicode_str)
133 { 133 {
134 return unicode_to_encoded_string (unicode_str, 134 return unicode_to_encoded_string (unicode_str,
135 target_charset (python_gdbarch)); 135 target_charset (python_gdbarch));
136 } 136 }
137 137
138 /* Returns a PyObject with the contents of the given unicode string 138 /* Returns a PyObject with the contents of the given unicode string
139 object converted to the target's charset. If an error occurs 139 object converted to the target's charset. If an error occurs
140 during the conversion, NULL will be returned and a python exception 140 during the conversion, NULL will be returned and a python exception
141 will be set. */ 141 will be set. */
142 PyObject * 142 static PyObject *
143 unicode_to_target_python_string (PyObject *unicode_str) 143 unicode_to_target_python_string (PyObject *unicode_str)
144 { 144 {
145 return unicode_to_encoded_python_string (unicode_str, 145 return unicode_to_encoded_python_string (unicode_str,
146 target_charset (python_gdbarch)); 146 target_charset (python_gdbarch));
147 } 147 }
148 148
149 /* Converts a python string (8-bit or unicode) to a target string in 149 /* Converts a python string (8-bit or unicode) to a target string in
150 the target's charset. Returns NULL on error, with a python exception set. 150 the target's charset. Returns NULL on error, with a python exception set.
151 151
152 The caller is responsible for xfree'ing the string. */ 152 The caller is responsible for xfree'ing the string. */
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 366
367 /* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts 367 /* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts
368 the value into an out parameter. */ 368 the value into an out parameter. */
369 369
370 int 370 int
371 gdb_py_int_as_long (PyObject *obj, long *result) 371 gdb_py_int_as_long (PyObject *obj, long *result)
372 { 372 {
373 *result = PyInt_AsLong (obj); 373 *result = PyInt_AsLong (obj);
374 return ! (*result == -1 && PyErr_Occurred ()); 374 return ! (*result == -1 && PyErr_Occurred ());
375 } 375 }
376
377
378
379 /* Generic implementation of the __dict__ attribute for objects that
380 have a dictionary. The CLOSURE argument should be the type object.
381 This only handles positive values for tp_dictoffset. */
382
383 PyObject *
384 gdb_py_generic_dict (PyObject *self, void *closure)
385 {
386 PyObject *result;
387 PyTypeObject *type_obj = closure;
388 char *raw_ptr;
389
390 raw_ptr = (char *) self + type_obj->tp_dictoffset;
391 result = * (PyObject **) raw_ptr;
392
393 Py_INCREF (result);
394 return result;
395 }
OLDNEW
« no previous file with comments | « gdb/python/py-type.c ('k') | gdb/python/py-value.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698