summaryrefslogtreecommitdiffstats
path: root/recipes-devtools
diff options
context:
space:
mode:
authorJan-Simon Möller <dl9pf@gmx.de>2021-05-25 20:23:37 +0200
committerKhem Raj <raj.khem@gmail.com>2021-05-25 14:14:48 -0700
commit94cceaf952b72b6b02a117ef35fed3928e7dd7b3 (patch)
treeb52b263f30c3a983a97b27c6b6f3f3bd6bef776c /recipes-devtools
parentaf99c02a85c264ab181b3cdeaf156de373de8b70 (diff)
downloadmeta-clang-94cceaf952b72b6b02a117ef35fed3928e7dd7b3.tar.gz
Import missing patch for Reporter.py
Upstream removed Reporter.py and added it back later. Backport the patch. Create 0033-Import-upstream-patch-to-re-add-Reporter.py.patch Upstream status: Backport of https://github.com/llvm/llvm-project/commit/3263c81589eca689341ab5084723bdb7fe4a1286 Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Diffstat (limited to 'recipes-devtools')
-rw-r--r--recipes-devtools/clang/clang/0033-Import-upstream-patch-to-re-add-Reporter.py.patch222
-rw-r--r--recipes-devtools/clang/common.inc1
2 files changed, 223 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0033-Import-upstream-patch-to-re-add-Reporter.py.patch b/recipes-devtools/clang/clang/0033-Import-upstream-patch-to-re-add-Reporter.py.patch
new file mode 100644
index 0000000..3086786
--- /dev/null
+++ b/recipes-devtools/clang/clang/0033-Import-upstream-patch-to-re-add-Reporter.py.patch
@@ -0,0 +1,222 @@
1From fde8a18b21e3e4d6fe72e0b73016cd780b08d023 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= <jsmoeller@linuxfoundation.org>
3Date: Tue, 25 May 2021 10:34:21 +0000
4Subject: [PATCH] Add Reporter.py back
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This was accidentially removed.
10
11Upstream-Status: backport from https://github.com/llvm/llvm-project/commit/e3cd3a3c91524c957e06bb0170343548f02b6842
12Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
13---
14 clang/tools/scan-view/CMakeLists.txt | 1 +
15 clang/tools/scan-view/share/Reporter.py | 183 ++++++++++++++++++++++++
16 2 files changed, 184 insertions(+)
17 create mode 100644 clang/tools/scan-view/share/Reporter.py
18
19diff --git a/clang/tools/scan-view/CMakeLists.txt b/clang/tools/scan-view/CMakeLists.txt
20index dd3d33439299..eccc6b83195b 100644
21--- a/clang/tools/scan-view/CMakeLists.txt
22+++ b/clang/tools/scan-view/CMakeLists.txt
23@@ -5,6 +5,7 @@ set(BinFiles
24
25 set(ShareFiles
26 ScanView.py
27+ Reporter.py
28 startfile.py
29 bugcatcher.ico)
30
31diff --git a/clang/tools/scan-view/share/Reporter.py b/clang/tools/scan-view/share/Reporter.py
32new file mode 100644
33index 000000000000..31a14fb0cf74
34--- /dev/null
35+++ b/clang/tools/scan-view/share/Reporter.py
36@@ -0,0 +1,183 @@
37+#!/usr/bin/env python
38+# -*- coding: utf-8 -*-
39+
40+"""Methods for reporting bugs."""
41+
42+import subprocess, sys, os
43+
44+__all__ = ['ReportFailure', 'BugReport', 'getReporters']
45+
46+#
47+
48+class ReportFailure(Exception):
49+ """Generic exception for failures in bug reporting."""
50+ def __init__(self, value):
51+ self.value = value
52+
53+# Collect information about a bug.
54+
55+class BugReport(object):
56+ def __init__(self, title, description, files):
57+ self.title = title
58+ self.description = description
59+ self.files = files
60+
61+# Reporter interfaces.
62+
63+import os
64+
65+import email, mimetypes, smtplib
66+from email import encoders
67+from email.message import Message
68+from email.mime.base import MIMEBase
69+from email.mime.multipart import MIMEMultipart
70+from email.mime.text import MIMEText
71+
72+#===------------------------------------------------------------------------===#
73+# ReporterParameter
74+#===------------------------------------------------------------------------===#
75+
76+class ReporterParameter(object):
77+ def __init__(self, n):
78+ self.name = n
79+ def getName(self):
80+ return self.name
81+ def getValue(self,r,bugtype,getConfigOption):
82+ return getConfigOption(r.getName(),self.getName())
83+ def saveConfigValue(self):
84+ return True
85+
86+class TextParameter (ReporterParameter):
87+ def getHTML(self,r,bugtype,getConfigOption):
88+ return """\
89+<tr>
90+<td class="form_clabel">%s:</td>
91+<td class="form_value"><input type="text" name="%s_%s" value="%s"></td>
92+</tr>"""%(self.getName(),r.getName(),self.getName(),self.getValue(r,bugtype,getConfigOption))
93+
94+class SelectionParameter (ReporterParameter):
95+ def __init__(self, n, values):
96+ ReporterParameter.__init__(self,n)
97+ self.values = values
98+
99+ def getHTML(self,r,bugtype,getConfigOption):
100+ default = self.getValue(r,bugtype,getConfigOption)
101+ return """\
102+<tr>
103+<td class="form_clabel">%s:</td><td class="form_value"><select name="%s_%s">
104+%s
105+</select></td>"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\
106+<option value="%s"%s>%s</option>"""%(o[0],
107+ o[0] == default and ' selected="selected"' or '',
108+ o[1]) for o in self.values]))
109+
110+#===------------------------------------------------------------------------===#
111+# Reporters
112+#===------------------------------------------------------------------------===#
113+
114+class EmailReporter(object):
115+ def getName(self):
116+ return 'Email'
117+
118+ def getParameters(self):
119+ return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']]
120+
121+ # Lifted from python email module examples.
122+ def attachFile(self, outer, path):
123+ # Guess the content type based on the file's extension. Encoding
124+ # will be ignored, although we should check for simple things like
125+ # gzip'd or compressed files.
126+ ctype, encoding = mimetypes.guess_type(path)
127+ if ctype is None or encoding is not None:
128+ # No guess could be made, or the file is encoded (compressed), so
129+ # use a generic bag-of-bits type.
130+ ctype = 'application/octet-stream'
131+ maintype, subtype = ctype.split('/', 1)
132+ if maintype == 'text':
133+ fp = open(path)
134+ # Note: we should handle calculating the charset
135+ msg = MIMEText(fp.read(), _subtype=subtype)
136+ fp.close()
137+ else:
138+ fp = open(path, 'rb')
139+ msg = MIMEBase(maintype, subtype)
140+ msg.set_payload(fp.read())
141+ fp.close()
142+ # Encode the payload using Base64
143+ encoders.encode_base64(msg)
144+ # Set the filename parameter
145+ msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(path))
146+ outer.attach(msg)
147+
148+ def fileReport(self, report, parameters):
149+ mainMsg = """\
150+BUG REPORT
151+---
152+Title: %s
153+Description: %s
154+"""%(report.title, report.description)
155+
156+ if not parameters.get('To'):
157+ raise ReportFailure('No "To" address specified.')
158+ if not parameters.get('From'):
159+ raise ReportFailure('No "From" address specified.')
160+
161+ msg = MIMEMultipart()
162+ msg['Subject'] = 'BUG REPORT: %s'%(report.title)
163+ # FIXME: Get config parameters
164+ msg['To'] = parameters.get('To')
165+ msg['From'] = parameters.get('From')
166+ msg.preamble = mainMsg
167+
168+ msg.attach(MIMEText(mainMsg, _subtype='text/plain'))
169+ for file in report.files:
170+ self.attachFile(msg, file)
171+
172+ try:
173+ s = smtplib.SMTP(host=parameters.get('SMTP Server'),
174+ port=parameters.get('SMTP Port'))
175+ s.sendmail(msg['From'], msg['To'], msg.as_string())
176+ s.close()
177+ except:
178+ raise ReportFailure('Unable to send message via SMTP.')
179+
180+ return "Message sent!"
181+
182+class BugzillaReporter(object):
183+ def getName(self):
184+ return 'Bugzilla'
185+
186+ def getParameters(self):
187+ return [TextParameter(x) for x in ['URL','Product']]
188+
189+ def fileReport(self, report, parameters):
190+ raise NotImplementedError
191+
192+
193+class RadarClassificationParameter(SelectionParameter):
194+ def __init__(self):
195+ SelectionParameter.__init__(self,"Classification",
196+ [['1', 'Security'], ['2', 'Crash/Hang/Data Loss'],
197+ ['3', 'Performance'], ['4', 'UI/Usability'],
198+ ['6', 'Serious Bug'], ['7', 'Other']])
199+
200+ def saveConfigValue(self):
201+ return False
202+
203+ def getValue(self,r,bugtype,getConfigOption):
204+ if bugtype.find("leak") != -1:
205+ return '3'
206+ elif bugtype.find("dereference") != -1:
207+ return '2'
208+ elif bugtype.find("missing ivar release") != -1:
209+ return '3'
210+ else:
211+ return '7'
212+
213+###
214+
215+def getReporters():
216+ reporters = []
217+ reporters.append(EmailReporter())
218+ return reporters
219+
220--
2212.31.1
222
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index e211258..68b9b0d 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -41,6 +41,7 @@ SRC_URI = "\
41 file://0030-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \ 41 file://0030-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
42 file://0031-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \ 42 file://0031-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \
43 file://0032-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \ 43 file://0032-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \
44 file://0033-Import-upstream-patch-to-re-add-Reporter.py.patch \
44" 45"
45# Fallback to no-PIE if not set 46# Fallback to no-PIE if not set
46GCCPIE ??= "" 47GCCPIE ??= ""