From f34ab2ba641e6e7f81e1a372d62f278e2a58df69 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 6 Apr 2016 20:20:04 -0400 Subject: [PATCH] Use java ID for local thread --- Makefile | 10 +- frysk-0.4-per-thread-java-id.patch | 201 +++++++++++++++++++++++++++++ frysk.spec | 7 +- 3 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 frysk-0.4-per-thread-java-id.patch diff --git a/Makefile b/Makefile index 68a0acd..b920ecf 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,12 @@ # Somewhat superseeded by fedpkg -BRANCH := $(shell git branch | sed -e 's/^\* f*//' -e 's/master/rawhide/' ) +BRANCH := $(shell fedpkg switch-branch | sed -n -e 's/ f/ /' -e 's/master/rawhide/' -e 's/^\* //p') SPEC_FILE = $(shell fedpkg gimmespec) # VERREL is very slow -VERREL = $(shell fedpkg verrel) -VERREL_WORDS = $(shell fedpkg verrel | sed -e 's/^\(.*\)\-\([^-]*\)\.\([^.]*\)$$/\1 \2 \3/') +VERREL := $(shell fedpkg verrel) +VERREL_WORDS := $(shell fedpkg verrel | sed -e 's/^\(.*\)\-\([^-]*\)\.\([^.]*\)$$/\1 \2 \3/') DIST = $(word 1, $(VERREL_WORDS)) SPEC_VERSION = $(word 2, $(VERREL_WORDS)) SPEC_RELEASE = $(word 3, $(VERREL_WORDS)) @@ -29,8 +29,8 @@ ORDER = \ libglade-java \ frysk -MOCKCFG = fedora-$(BRANCH)-i386 -#MOCKCFG = fedora-$(BRANCH)-x86_64 +#MOCKCFG = fedora-$(BRANCH)-i386 +MOCKCFG = fedora-$(BRANCH)-x86_64 MOCK_WORDS := $(subst -, , $(MOCKCFG)) MOCK_OS := $(word 1,$(MOCK_WORDS)) MOCK_RELEASE := $(word 2,$(MOCK_WORDS)) diff --git a/frysk-0.4-per-thread-java-id.patch b/frysk-0.4-per-thread-java-id.patch new file mode 100644 index 0000000..2d7bf49 --- /dev/null +++ b/frysk-0.4-per-thread-java-id.patch @@ -0,0 +1,201 @@ +--- frysk-0.4/frysk-sys/jnixx/PrintHxxDefinitions.java.jmethodid 2016-04-06 16:06:04.482142069 -0400 ++++ frysk-0.4/frysk-sys/jnixx/PrintHxxDefinitions.java 2016-04-06 16:12:30.247740400 -0400 +@@ -1,5 +1,6 @@ + // This file is part of the program FRYSK. + // ++// Copyright 2016, Andrew Cagney + // Copyright 2008, Red Hat Inc. + // + // FRYSK is free software; you can redistribute it and/or modify it +@@ -75,27 +76,20 @@ + if (isStatic) { + p.println("jclass _class = _class_(_env);"); + } else { +- p.print("if (_class == NULL)"); +- while (p.dent(1, "{", "}")) { +- p.println("_class = _class_(_env);"); +- } ++ p.println("jclass _class = _env.GetObjectClass(_object);"); + } +- p.print("if ("); ++ p.print("jfieldID "); + p.printID(field); +- p.print(" == NULL)"); +- while (p.dent(1, "{", "}")) { +- p.printID(field); +- p.print(" = _env.Get"); +- if (isStatic) { +- p.print("Static"); +- } +- p.print("FieldID(_class, \""); +- p.print(field.getName()); +- p.print("\", \""); +- p.printJniSignature(type); +- p.print("\""); +- p.println(");"); ++ p.print(" = _env.Get"); ++ if (isStatic) { ++ p.print("Static"); + } ++ p.print("FieldID(_class, \""); ++ p.print(field.getName()); ++ p.print("\", \""); ++ p.printJniSignature(type); ++ p.print("\""); ++ p.println(");"); + if (get) { + p.printJniType(type); + p.print(" ret = "); +@@ -135,33 +129,22 @@ + p.printFormalCxxParameters(method, true); + p.print(")"); + while (p.dent(0, "{", "}")) { +- p.print("static jmethodID "); +- p.printID(method); +- p.println(";"); + if (isStatic) { + p.println("jclass _class = _class_(_env);"); ++ } else { ++ p.println("jclass _class = _env.GetObjectClass(_object);"); + } +- p.print("if ("); ++ p.print("jmethodID "); + p.printID(method); +- p.print(" == NULL)"); +- while (p.dent(1, "{", "}")) { +- if (!isStatic) { +- p.print("if (_class == NULL)"); +- while (p.dent(2, "{", "}")) { +- p.println("_class = _class_(_env);"); +- } +- } +- p.printID(method); +- p.print(" = _env.Get"); +- if (isStatic) { +- p.print("Static"); +- } +- p.print("MethodID(_class, \""); +- p.print(method.getName()); +- p.print("\", \""); +- p.printJniSignature(method); +- p.println("\");"); ++ p.print(" = _env.Get"); ++ if (isStatic) { ++ p.print("Static"); + } ++ p.print("MethodID(_class, \""); ++ p.print(method.getName()); ++ p.print("\", \""); ++ p.printJniSignature(method); ++ p.println("\");"); + if (returnType != Void.TYPE) { + if (returnType.isPrimitive()) { + p.printJniType(returnType); +@@ -201,18 +184,11 @@ + p.print(")"); + while (p.dent(0, "{", "}")) { + p.println("jclass _class = _class_(_env);"); +- p.print("static jmethodID "); +- p.printID(constructor); +- p.println(";"); +- p.print("if ("); ++ p.print("jmethodID "); + p.printID(constructor); +- p.print(" == NULL)"); +- while (p.dent(1, "{", "}")) { +- p.printID(constructor); +- p.print(" = _env.GetMethodID(_class, \"\", \"("); +- p.printJniSignature(constructor.getParameterTypes()); +- p.println(")V\");"); +- } ++ p.print(" = _env.GetMethodID(_class, \"\", \"("); ++ p.printJniSignature(constructor.getParameterTypes()); ++ p.println(")V\");"); + p.print("jobject object = _env.NewObject("); + p.printActualJniParameters(constructor); + p.println(");"); +--- frysk-0.4/frysk-sys/jnixx/PrintDeclarations.java.jmethodid 2016-04-06 16:22:40.595194032 -0400 ++++ frysk-0.4/frysk-sys/jnixx/PrintDeclarations.java 2016-04-06 16:25:16.964016994 -0400 +@@ -88,9 +88,6 @@ + } + public void acceptField(Field field) { + p.println(); +- p.print("private: static jfieldID "); +- p.printID(field); +- p.println("; public:"); + printCxxFieldAccessorDeclaration(field, true); + if (!Modifier.isFinal(field.getModifiers())) { + printCxxFieldAccessorDeclaration(field, false); +@@ -143,8 +140,6 @@ + p.printGlobalCxxName(parent); + p.println("() { }"); + } +- // cached per-instance copy - a local-ref +- p.println("private: jclass _class = NULL;"); + // Static get-class method - a class knows its own class. + p.println("public: static inline jclass _class_(::jnixx::env _env);"); + JniBindings.printDeclarations(p, klass); +--- frysk-0.4/frysk-sys/jnixx/PrintCxxDefinitions.java.jmethodid 2016-04-06 16:32:15.056208875 -0400 ++++ frysk-0.4/frysk-sys/jnixx/PrintCxxDefinitions.java 2016-04-06 16:33:01.466564144 -0400 +@@ -137,12 +137,6 @@ + void acceptConstructor(Constructor constructor) { + } + void acceptField(Field field) { +- p.println(); +- p.print("jfieldID "); +- p.printGlobalCxxName(field.getDeclaringClass()); +- p.print("::"); +- p.printID(field); +- p.println(";"); + } + void acceptClass(Class klass) { + } +--- frysk-0.4/frysk-sys/lib/unwind/jni/UnwindH.hxx.jmethodid 2016-04-06 17:23:28.883437146 -0400 ++++ frysk-0.4/frysk-sys/lib/unwind/jni/UnwindH.hxx 2016-04-06 17:30:54.360172075 -0400 +@@ -236,7 +236,7 @@ + // XXX: Need to zero out the cursor, as unw_init_remote doesn't seem + // to do it. + memset(UNW_CURSOR, 0, sizeof(*UNW_CURSOR)); +- unw_init_remote(UNW_CURSOR, UNW_ADDRESS_SPACE, addressSpace._object); ++ unw_init_remote(UNW_CURSOR, UNW_ADDRESS_SPACE, env.NewGlobalRef(addressSpace._object)); + logf(FINE, "createCursor at %lx", (long) UNW_CURSOR); + return (jlong) UNW_CURSOR; + } +@@ -244,6 +244,7 @@ + void + TARGET::destroyCursor(jnixx::env env, jlong unwCursor) { + logf(FINE, "destroyCursor at %lx", (long) UNW_CURSOR); ++ env.DeleteGlobalRef((jobject) unw_get_as_arg(UNW_CURSOR)); + ::free(UNW_CURSOR); + } + +--- frysk-0.4/frysk-imports/libunwind/include/libunwind-common.h.in.unw-get-as-arg 2016-04-06 19:35:50.139996162 -0400 ++++ frysk-0.4/frysk-imports/libunwind/include/libunwind-common.h.in 2016-04-06 19:36:43.594234850 -0400 +@@ -213,6 +213,7 @@ + #define unw_init_remote UNW_OBJ(init_remote) + #define unw_step UNW_OBJ(step) + #define unw_resume UNW_OBJ(resume) ++#define unw_get_as_arg UNW_OBJ(get_as_arg) + #define unw_get_proc_info UNW_OBJ(get_proc_info) + #define unw_get_proc_info_by_ip UNW_OBJ(get_proc_info_by_ip) + #define unw_get_reg UNW_OBJ(get_reg) +@@ -239,6 +240,7 @@ + extern int unw_init_remote (unw_cursor_t *, unw_addr_space_t, void *); + extern int unw_step (unw_cursor_t *); + extern int unw_resume (unw_cursor_t *); ++extern void *unw_get_as_arg (unw_cursor_t *); + extern int unw_get_proc_info (unw_cursor_t *, unw_proc_info_t *); + extern int unw_get_proc_info_by_ip (unw_addr_space_t, unw_word_t, + unw_proc_info_t *, void *); +--- frysk-0.4/frysk-imports/libunwind/src/mi/strerror.c.unw-get-as-arg 2016-04-06 19:44:17.529769760 -0400 ++++ frysk-0.4/frysk-imports/libunwind/src/mi/strerror.c 2016-04-06 19:46:09.822170457 -0400 +@@ -49,3 +49,9 @@ + } + return cp; + } ++ ++void * ++unw_get_as_arg(unw_cursor_t *c) ++{ ++ return tdep_get_as_arg((struct cursor*) c); ++} diff --git a/frysk.spec b/frysk.spec index 2e2ebcd..64b87a4 100644 --- a/frysk.spec +++ b/frysk.spec @@ -1,7 +1,7 @@ Summary: Execution analysis and debugging tool-suite. Name: frysk Version: 0.4 -Release: 45%{?dist} +Release: 47%{?dist} # Fedora 17+ doesn't have libvte et.al. %define enable_gnome %{fedora}0 < 170 @@ -50,6 +50,7 @@ Patch23: frysk-0.4-missing-javah-cni-built.patch Patch24: frysk-0.4-jni.patch Patch25: frysk-0.4-awk-gensub.patch Patch26: frysk-0.4-pic-asm.patch +Patch27: frysk-0.4-per-thread-java-id.patch Patch100: frysk-0.4-aclocaljavac.patch Patch101: frysk-0.4-cxx-scope.patch @@ -261,6 +262,7 @@ rm -rf frysk-core/frysk/rt/LineXXX.java %patch24 -p1 -z .jni %patch25 -p1 -z .awk-gensub %patch26 -p1 -z .pic-asm +%patch27 -p1 -z .per-thread-java-id echo "%{version}-%{release}" > frysk-common/version.in @@ -458,6 +460,9 @@ rm -rf %{buildroot} %endif %changelog +* Wed Apr 06 2016 Andrew Cagney - 0.4-47 +- Use java ID for local thread + * Mon Aug 17 2015 Andrew Cagney - 0.4.45 - Fix AWK gensub parameter 3; new warning about it is being printed to STDOUT instead of STDERR and, hence, ends up in generated Java files