- Rebase on libpfm-4.10.0.
- Use Python 3.
This commit is contained in:
		
							parent
							
								
									75e5fed5de
								
							
						
					
					
						commit
						360481a7b3
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -8,3 +8,4 @@
 | 
			
		||||
/libpfm-4.7.0.tar.gz
 | 
			
		||||
/libpfm-4.8.0.tar.gz
 | 
			
		||||
/libpfm-4.9.0.tar.gz
 | 
			
		||||
/libpfm-4.10.0.tar.gz
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								libpfm-cavium-tx2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								libpfm-cavium-tx2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
diff --git a/lib/Makefile b/lib/Makefile
 | 
			
		||||
index 129db90..f1241ad 100644
 | 
			
		||||
--- a/lib/Makefile
 | 
			
		||||
+++ b/lib/Makefile
 | 
			
		||||
@@ -360,7 +360,7 @@ INC_ARM=pfmlib_arm_priv.h			\
 | 
			
		||||
 	events/arm_cortex_a15_events.h		\
 | 
			
		||||
 	events/arm_cortex_a57_events.h		\
 | 
			
		||||
 	events/arm_cortex_a53_events.h		\
 | 
			
		||||
-	events/arm_thunderx2_events.h
 | 
			
		||||
+	events/arm_cavium_tx2_events.h
 | 
			
		||||
 
 | 
			
		||||
 INC_ARM64=events/arm_cortex_a57_events.h	\
 | 
			
		||||
 	  events/arm_cortex_a53_events.h
 | 
			
		||||
							
								
								
									
										10
									
								
								libpfm-python3-setup.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								libpfm-python3-setup.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
diff --git a/python/setup.py b/python/setup.py
 | 
			
		||||
index eda8fa5..dff0f27 100755
 | 
			
		||||
--- a/python/setup.py
 | 
			
		||||
+++ b/python/setup.py
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
-#!/usr/bin/env python
 | 
			
		||||
+#!/usr/bin/env python3
 | 
			
		||||
 
 | 
			
		||||
 from distutils.core import setup, Extension
 | 
			
		||||
 from distutils.command.install_data import install_data
 | 
			
		||||
@ -1,85 +0,0 @@
 | 
			
		||||
diff --git a/lib/pfmlib_perf_event_pmu.c b/lib/pfmlib_perf_event_pmu.c
 | 
			
		||||
index 86ff824..ca371d8 100644
 | 
			
		||||
--- a/lib/pfmlib_perf_event_pmu.c
 | 
			
		||||
+++ b/lib/pfmlib_perf_event_pmu.c
 | 
			
		||||
@@ -344,6 +344,7 @@ gen_tracepoint_table(void)
 | 
			
		||||
 
 | 
			
		||||
 	err = 0;
 | 
			
		||||
 	while((d1 = readdir(dir1)) && err >= 0) {
 | 
			
		||||
+		int retlen;
 | 
			
		||||
 
 | 
			
		||||
 		if (!strcmp(d1->d_name, "."))
 | 
			
		||||
 			continue;
 | 
			
		||||
@@ -351,7 +352,10 @@ gen_tracepoint_table(void)
 | 
			
		||||
 		if (!strcmp(d1->d_name, ".."))
 | 
			
		||||
 			continue;
 | 
			
		||||
 
 | 
			
		||||
-		snprintf(d2path, MAXPATHLEN, "%s/%s", debugfs_mnt, d1->d_name);
 | 
			
		||||
+		retlen = snprintf(d2path, MAXPATHLEN, "%s/%s", debugfs_mnt, d1->d_name);
 | 
			
		||||
+		/* if string truncated do not try to open the corrupted path */
 | 
			
		||||
+		if (retlen < 0 || retlen >= MAXPATHLEN)
 | 
			
		||||
+			continue;
 | 
			
		||||
 
 | 
			
		||||
 		/* fails if d2path is not a directory */
 | 
			
		||||
 		dir2 = opendir(d2path);
 | 
			
		||||
@@ -398,10 +402,16 @@ gen_tracepoint_table(void)
 | 
			
		||||
 				continue;
 | 
			
		||||
 
 | 
			
		||||
 #ifdef HAS_OPENAT
 | 
			
		||||
-                        snprintf(idpath, MAXPATHLEN, "%s/id", d2->d_name);
 | 
			
		||||
+			retlen = snprintf(idpath, MAXPATHLEN, "%s/id", d2->d_name);
 | 
			
		||||
+			/* if string truncated do not try to open the corrupted path */
 | 
			
		||||
+			if (retlen < 0 || retlen >= MAXPATHLEN)
 | 
			
		||||
+				continue;
 | 
			
		||||
                         fd = openat(dir2_fd, idpath, O_RDONLY);
 | 
			
		||||
 #else
 | 
			
		||||
-                        snprintf(idpath, MAXPATHLEN, "%s/%s/id", d2path, d2->d_name);
 | 
			
		||||
+			retlen = snprintf(idpath, MAXPATHLEN, "%s/%s/id", d2path, d2->d_name);
 | 
			
		||||
+			/* if string truncated do not try to open the corrupted path */
 | 
			
		||||
+			if (retlen < 0 || retlen >= MAXPATHLEN)
 | 
			
		||||
+				continue;
 | 
			
		||||
                         fd = open(idpath, O_RDONLY);
 | 
			
		||||
 #endif
 | 
			
		||||
 			if (fd == -1)
 | 
			
		||||
diff --git a/perf_examples/syst_count.c b/perf_examples/syst_count.c
 | 
			
		||||
index e0fa42e..7841d01 100644
 | 
			
		||||
--- a/perf_examples/syst_count.c
 | 
			
		||||
+++ b/perf_examples/syst_count.c
 | 
			
		||||
@@ -112,12 +112,14 @@ open_cgroup(char *name)
 | 
			
		||||
 {
 | 
			
		||||
         char path[MAX_PATH+1];
 | 
			
		||||
         char mnt[MAX_PATH+1];
 | 
			
		||||
-        int cfd;
 | 
			
		||||
+        int cfd, retlen;
 | 
			
		||||
 
 | 
			
		||||
         if (cgroupfs_find_mountpoint(mnt, MAX_PATH+1))
 | 
			
		||||
                 errx(1, "cannot find cgroup fs mount point");
 | 
			
		||||
 
 | 
			
		||||
-        snprintf(path, MAX_PATH, "%s/%s", mnt, name);
 | 
			
		||||
+        retlen = snprintf(path, MAX_PATH, "%s/%s", mnt, name);
 | 
			
		||||
+	if (retlen < 0 || retlen >= MAX_PATH)
 | 
			
		||||
+                warn("path truncated %s/%s\n", mnt, name);
 | 
			
		||||
 
 | 
			
		||||
         cfd = open(path, O_RDONLY);
 | 
			
		||||
         if (cfd == -1)
 | 
			
		||||
diff --git a/perf_examples/syst_smpl.c b/perf_examples/syst_smpl.c
 | 
			
		||||
index 6b70e0e..a8b00df 100755
 | 
			
		||||
--- a/perf_examples/syst_smpl.c
 | 
			
		||||
+++ b/perf_examples/syst_smpl.c
 | 
			
		||||
@@ -278,12 +278,14 @@ open_cgroup(char *name)
 | 
			
		||||
 {
 | 
			
		||||
         char path[MAX_PATH+1];
 | 
			
		||||
         char mnt[MAX_PATH+1];
 | 
			
		||||
-        int cfd;
 | 
			
		||||
+        int cfd, retlen;
 | 
			
		||||
 
 | 
			
		||||
         if (cgroupfs_find_mountpoint(mnt, MAX_PATH+1))
 | 
			
		||||
                 errx(1, "cannot find cgroup fs mount point");
 | 
			
		||||
 
 | 
			
		||||
-        snprintf(path, MAX_PATH, "%s/%s", mnt, name);
 | 
			
		||||
+        retlen = snprintf(path, MAX_PATH, "%s/%s", mnt, name);
 | 
			
		||||
+	if (retlen < 0 || retlen >= MAX_PATH)
 | 
			
		||||
+                warn("path truncated %s/%s\n", mnt, name);
 | 
			
		||||
 
 | 
			
		||||
         cfd = open(path, O_RDONLY);
 | 
			
		||||
         if (cfd == -1)
 | 
			
		||||
							
								
								
									
										31
									
								
								libpfm.spec
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								libpfm.spec
									
									
									
									
									
								
							@ -1,7 +1,7 @@
 | 
			
		||||
%bcond_without python
 | 
			
		||||
%if %{with python}
 | 
			
		||||
%define python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")
 | 
			
		||||
%define python_prefix %(python -c "import sys; print sys.prefix")
 | 
			
		||||
%define python_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))")
 | 
			
		||||
%define python_prefix %(python3 -c "import sys; print (sys.prefix)")
 | 
			
		||||
%{?filter_setup:
 | 
			
		||||
%filter_provides_in %{python_sitearch}/perfmon/.*\.so$
 | 
			
		||||
%filter_setup
 | 
			
		||||
@ -9,8 +9,8 @@
 | 
			
		||||
%endif
 | 
			
		||||
 | 
			
		||||
Name:		libpfm
 | 
			
		||||
Version:	4.9.0
 | 
			
		||||
Release:	6%{?dist}
 | 
			
		||||
Version:	4.10.0
 | 
			
		||||
Release:	1%{?dist}
 | 
			
		||||
 | 
			
		||||
Summary:	Library to encode performance events for use by perf tool
 | 
			
		||||
 | 
			
		||||
@ -18,11 +18,13 @@ Group:		System Environment/Libraries
 | 
			
		||||
License:	MIT
 | 
			
		||||
URL:		http://perfmon2.sourceforge.net/
 | 
			
		||||
Source0:	http://sourceforge.net/projects/perfmon2/files/libpfm4/%{name}-%{version}.tar.gz
 | 
			
		||||
Patch1:		libpfm-truncation.patch
 | 
			
		||||
Patch1:		libpfm-cavium-tx2.patch
 | 
			
		||||
Patch2:		libpfm-python3-setup.patch
 | 
			
		||||
 | 
			
		||||
%if %{with python}
 | 
			
		||||
BuildRequires:	python2-devel
 | 
			
		||||
BuildRequires:	python2-setuptools
 | 
			
		||||
BuildRequires:	python3
 | 
			
		||||
BuildRequires:	python3-devel
 | 
			
		||||
BuildRequires:	python3-setuptools
 | 
			
		||||
BuildRequires:	swig
 | 
			
		||||
%endif
 | 
			
		||||
 | 
			
		||||
@ -51,8 +53,8 @@ Static version of the libpfm library for performance monitoring
 | 
			
		||||
applications for the perf_events interface.
 | 
			
		||||
 | 
			
		||||
%if %{with python}
 | 
			
		||||
%package -n python2-libpfm
 | 
			
		||||
%{?python_provide:%python_provide python2-libpfm}
 | 
			
		||||
%package -n python3-libpfm
 | 
			
		||||
%{?python_provide:%python_provide python3-libpfm}
 | 
			
		||||
# Remove before F30
 | 
			
		||||
Provides: %{name}-python = %{version}-%{release}
 | 
			
		||||
Provides: %{name}-python%{?_isa} = %{version}-%{release}
 | 
			
		||||
@ -61,13 +63,14 @@ Summary:	Python bindings for libpfm and perf_event_open system call
 | 
			
		||||
Group:		Development/Languages
 | 
			
		||||
Requires:	%{name}%{?_isa} = %{version}-%{release}
 | 
			
		||||
 | 
			
		||||
%description -n python2-libpfm
 | 
			
		||||
%description -n python3-libpfm
 | 
			
		||||
Python bindings for libpfm4 and perf_event_open system call.
 | 
			
		||||
%endif
 | 
			
		||||
 | 
			
		||||
%prep
 | 
			
		||||
%setup -q
 | 
			
		||||
%patch1 -p1 -b .trun
 | 
			
		||||
%patch1 -p1 -b .cavium
 | 
			
		||||
%patch2 -p1 -b .python3
 | 
			
		||||
 | 
			
		||||
%build
 | 
			
		||||
%if %{with python}
 | 
			
		||||
@ -111,11 +114,15 @@ make \
 | 
			
		||||
%{_libdir}/lib*.a
 | 
			
		||||
 | 
			
		||||
%if %{with python}
 | 
			
		||||
%files -n python2-libpfm
 | 
			
		||||
%files -n python3-libpfm
 | 
			
		||||
%{python_sitearch}/*
 | 
			
		||||
%endif
 | 
			
		||||
 | 
			
		||||
%changelog
 | 
			
		||||
* Fri Jun 8 2018 William Cohen <wcohen@redhat.com> - 4.10.0-1
 | 
			
		||||
- Rebase on libpfm-4.10.0.
 | 
			
		||||
- Use Python 3.
 | 
			
		||||
 | 
			
		||||
* Mon Feb 26 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.9.0-6
 | 
			
		||||
- Pass in LDFLAGS for build.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								sources
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								sources
									
									
									
									
									
								
							@ -1 +1 @@
 | 
			
		||||
SHA512 (libpfm-4.9.0.tar.gz) = 9e62556a5e8029b94383bd54176c5171fec7f919b6826d5d348837540922874c922eb0e01d7835c388ae28809c798f4b3da8ba751777767ce4a0e47ddab2b645
 | 
			
		||||
SHA512 (libpfm-4.10.0.tar.gz) = c2e1a7d389efebc27a32dd3a5a6f3e8e8d624347616e06daf7bf06c0d5b8ca39cee5821ad5cf23330d47ed987697fcc05aa54660b8f6899f62aad9cd05e908f9
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user