[Lldb-commits] [lldb] r341482 - Hold GIL while allocating memory for PythonString.
Tatyana Krasnukha via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 5 10:07:29 PDT 2018
Author: tkrasnukha
Date: Wed Sep 5 10:07:29 2018
New Revision: 341482
URL: http://llvm.org/viewvc/llvm-project?rev=341482&view=rev
Log:
Hold GIL while allocating memory for PythonString.
Summary:
Swig wraps C++ code into SWIG_PYTHON_THREAD_BEGIN_ALLOW; ... SWIG_PYTHON_THREAD_END_ALLOW;
Thus, LLDB crashes with "Fatal Python error: Python memory allocator called without holding the GIL" when calls an lldb_SB***___str__ function.
Reviewers: clayborg
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D51569
Modified:
lldb/trunk/scripts/Python/python-extensions.swig
Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=341482&r1=341481&r2=341482&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep 5 10:07:29 2018
@@ -1,5 +1,6 @@
%extend lldb::SBAddress {
+ %nothreadallow;
PyObject *lldb::SBAddress::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -12,8 +13,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBBlock {
+ %nothreadallow;
PyObject *lldb::SBBlock::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -26,8 +29,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBBreakpoint {
+ %nothreadallow;
PyObject *lldb::SBBreakpoint::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -40,6 +45,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -57,6 +63,7 @@
}
%extend lldb::SBBreakpointLocation {
+ %nothreadallow;
PyObject *lldb::SBBreakpointLocation::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelFull);
@@ -69,9 +76,11 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBBreakpointName {
+ %nothreadallow;
PyObject *lldb::SBBreakpointName::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -84,6 +93,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBBroadcaster {
@@ -103,6 +113,7 @@
}
%extend lldb::SBCommandReturnObject {
+ %nothreadallow;
PyObject *lldb::SBCommandReturnObject::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -115,6 +126,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
/* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort
@@ -130,6 +142,7 @@
{}
}
%extend lldb::SBCompileUnit {
+ %nothreadallow;
PyObject *lldb::SBCompileUnit::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -142,6 +155,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -157,6 +171,7 @@
%}
}
%extend lldb::SBData {
+ %nothreadallow;
PyObject *lldb::SBData::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -169,8 +184,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBDebugger {
+ %nothreadallow;
PyObject *lldb::SBDebugger::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -183,8 +200,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBDeclaration {
+ %nothreadallow;
PyObject *lldb::SBDeclaration::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -197,6 +216,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -214,6 +234,7 @@
}
%extend lldb::SBError {
+ %nothreadallow;
PyObject *lldb::SBError::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -226,8 +247,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBFileSpec {
+ %nothreadallow;
PyObject *lldb::SBFileSpec::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -240,8 +263,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBFrame {
+ %nothreadallow;
PyObject *lldb::SBFrame::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -254,8 +279,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBFunction {
+ %nothreadallow;
PyObject *lldb::SBFunction::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -268,6 +295,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -285,6 +313,7 @@
}
%extend lldb::SBInstruction {
+ %nothreadallow;
PyObject *lldb::SBInstruction::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -297,8 +326,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBInstructionList {
+ %nothreadallow;
PyObject *lldb::SBInstructionList::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -311,8 +342,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBLineEntry {
+ %nothreadallow;
PyObject *lldb::SBLineEntry::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -325,6 +358,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -342,6 +376,7 @@
}
%extend lldb::SBMemoryRegionInfo {
+ %nothreadallow;
PyObject *lldb::SBMemoryRegionInfo::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -354,9 +389,11 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBModule {
+ %nothreadallow;
PyObject *lldb::SBModule::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -369,6 +406,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -386,6 +424,7 @@
}
%extend lldb::SBModuleSpec {
+ %nothreadallow;
PyObject *lldb::SBModuleSpec::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -398,9 +437,11 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBModuleSpecList {
+ %nothreadallow;
PyObject *lldb::SBModuleSpecList::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -413,9 +454,11 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBProcess {
+ %nothreadallow;
PyObject *lldb::SBProcess::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -428,8 +471,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBSection {
+ %nothreadallow;
PyObject *lldb::SBSection::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -442,6 +487,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -472,6 +518,7 @@
{}
}
%extend lldb::SBSymbol {
+ %nothreadallow;
PyObject *lldb::SBSymbol::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -484,6 +531,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -499,6 +547,7 @@
%}
}
%extend lldb::SBSymbolContext {
+ %nothreadallow;
PyObject *lldb::SBSymbolContext::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -511,8 +560,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBSymbolContextList {
+ %nothreadallow;
PyObject *lldb::SBSymbolContextList::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -525,9 +576,11 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTarget {
+ %nothreadallow;
PyObject *lldb::SBTarget::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -540,6 +593,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
@@ -557,6 +611,7 @@
}
%extend lldb::SBType {
+ %nothreadallow;
PyObject *lldb::SBType::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -569,8 +624,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeCategory {
+ %nothreadallow;
PyObject *lldb::SBTypeCategory::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -583,8 +640,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeFilter {
+ %nothreadallow;
PyObject *lldb::SBTypeFilter::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -597,6 +656,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -612,6 +672,7 @@
%}
}
%extend lldb::SBTypeFormat {
+ %nothreadallow;
PyObject *lldb::SBTypeFormat::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -624,8 +685,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeMember {
+ %nothreadallow;
PyObject *lldb::SBTypeMember::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -638,8 +701,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeMemberFunction {
+ %nothreadallow;
PyObject *lldb::SBTypeMemberFunction::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -652,8 +717,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeEnumMember {
+ %nothreadallow;
PyObject *lldb::SBTypeEnumMember::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -666,8 +733,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBTypeNameSpecifier {
+ %nothreadallow;
PyObject *lldb::SBTypeNameSpecifier::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -680,6 +749,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -695,6 +765,7 @@
%}
}
%extend lldb::SBTypeSummary {
+ %nothreadallow;
PyObject *lldb::SBTypeSummary::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -707,6 +778,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -722,6 +794,7 @@
%}
}
%extend lldb::SBTypeSynthetic {
+ %nothreadallow;
PyObject *lldb::SBTypeSynthetic::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
@@ -734,6 +807,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -749,6 +823,7 @@
%}
}
%extend lldb::SBThread {
+ %nothreadallow;
PyObject *lldb::SBThread::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -761,6 +836,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -776,6 +852,7 @@
%}
}
%extend lldb::SBValue {
+ %nothreadallow;
PyObject *lldb::SBValue::__str__ (){
lldb::SBStream description;
$self->GetDescription (description);
@@ -788,8 +865,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBValueList {
+ %nothreadallow;
PyObject *lldb::SBValueList::__str__ (){
lldb::SBStream description;
const size_t n = $self->GetSize();
@@ -811,8 +890,10 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
%extend lldb::SBWatchpoint {
+ %nothreadallow;
PyObject *lldb::SBWatchpoint::__str__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelVerbose);
@@ -825,6 +906,7 @@
else
return lldb_private::PythonString("").release();
}
+ %clearnothreadallow;
}
More information about the lldb-commits
mailing list