| File: | jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c |
| Warning: | line 50, column 19 Dereference of null pointer (loaded from variable 'tagPtr') |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* | |||
| 2 | * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. | |||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||
| 4 | * | |||
| 5 | * This code is free software; you can redistribute it and/or modify it | |||
| 6 | * under the terms of the GNU General Public License version 2 only, as | |||
| 7 | * published by the Free Software Foundation. Oracle designates this | |||
| 8 | * particular file as subject to the "Classpath" exception as provided | |||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | |||
| 10 | * | |||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | |||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | |||
| 15 | * accompanied this code). | |||
| 16 | * | |||
| 17 | * You should have received a copy of the GNU General Public License version | |||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | |||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |||
| 20 | * | |||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |||
| 22 | * or visit www.oracle.com if you need additional information or have any | |||
| 23 | * questions. | |||
| 24 | */ | |||
| 25 | ||||
| 26 | #include "util.h" | |||
| 27 | #include "signature.h" | |||
| 28 | ||||
| 29 | ||||
| 30 | /* | |||
| 31 | * JNI signature constants, beyond those defined in JVM_TYPE(*) | |||
| 32 | */ | |||
| 33 | #define SIGNATURE_BEGIN_ARGS'(' '(' | |||
| 34 | #define SIGNATURE_END_ARGS')' ')' | |||
| 35 | #define SIGNATURE_END_CLASS';' ';' | |||
| 36 | ||||
| 37 | char* componentTypeSignature(const char *signature) { | |||
| 38 | jbyte typeKey = jdwpTag(signature); | |||
| 39 | JDI_ASSERT(isArrayTag(typeKey))do { if (gdata && gdata->assertOn && !(isArrayTag (typeKey))) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 39, "isArrayTag(typeKey)"); } } while (0); | |||
| 40 | JVM_TYPE_ASSERT(signature[1])do { if (gdata && gdata->assertOn && !(76 == signature[1] || 91 == signature[1] || 90 == signature[1] || 66 == signature[1] || 67 == signature[1] || 68 == signature[1] || 70 == signature[1] || 73 == signature[1] || 74 == signature[ 1] || 83 == signature[1] || 86 == signature[1])) { jdiAssertionFailed ("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 40, "Tag is not a JVM basic type"); } } while (0); | |||
| 41 | return (char*)&signature[1]; | |||
| 42 | } | |||
| 43 | ||||
| 44 | jbyte methodSignature_returnTag(char *signature) | |||
| 45 | { | |||
| 46 | char *tagPtr = strchr(signature, SIGNATURE_END_ARGS')'); | |||
| 47 | JDI_ASSERT(tagPtr)do { if (gdata && gdata->assertOn && !(tagPtr )) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 47, "tagPtr"); } } while (0); | |||
| ||||
| 48 | tagPtr++; /* 1st character after the end of args */ | |||
| 49 | JVM_TYPE_ASSERT((jbyte)*tagPtr)do { if (gdata && gdata->assertOn && !(76 == (jbyte)*tagPtr || 91 == (jbyte)*tagPtr || 90 == (jbyte)*tagPtr || 66 == (jbyte)*tagPtr || 67 == (jbyte)*tagPtr || 68 == (jbyte )*tagPtr || 70 == (jbyte)*tagPtr || 73 == (jbyte)*tagPtr || 74 == (jbyte)*tagPtr || 83 == (jbyte)*tagPtr || 86 == (jbyte)*tagPtr )) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 49, "Tag is not a JVM basic type"); } } while (0); | |||
| 50 | return (jbyte)*tagPtr; | |||
| ||||
| 51 | } | |||
| 52 | ||||
| 53 | void methodSignature_init(char *signature, void **cursor) | |||
| 54 | { | |||
| 55 | JDI_ASSERT(signature[0] == SIGNATURE_BEGIN_ARGS)do { if (gdata && gdata->assertOn && !(signature [0] == '(')) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 55, "signature[0] == SIGNATURE_BEGIN_ARGS"); } } while (0); | |||
| 56 | *cursor = signature + 1; /* skip to the first arg */ | |||
| 57 | } | |||
| 58 | ||||
| 59 | ||||
| 60 | jboolean methodSignature_nextArgumentExists(void **cursor, jbyte *argumentTag) | |||
| 61 | { | |||
| 62 | char *tagPtr = *cursor; | |||
| 63 | jbyte nextType = (jbyte)*tagPtr; | |||
| 64 | ||||
| 65 | if (*tagPtr != SIGNATURE_END_ARGS')') { | |||
| 66 | /* Skip any array modifiers */ | |||
| 67 | while (*tagPtr == JDWP_TAG(ARRAY)91) { | |||
| 68 | tagPtr++; | |||
| 69 | } | |||
| 70 | /* Skip class name */ | |||
| 71 | if (*tagPtr == JDWP_TAG(OBJECT)76) { | |||
| 72 | tagPtr = strchr(tagPtr, SIGNATURE_END_CLASS';') + 1; | |||
| 73 | JDI_ASSERT(tagPtr)do { if (gdata && gdata->assertOn && !(tagPtr )) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 73, "tagPtr"); } } while (0); | |||
| 74 | } else { | |||
| 75 | /* Skip primitive sig */ | |||
| 76 | tagPtr++; | |||
| 77 | } | |||
| 78 | } | |||
| 79 | *cursor = tagPtr; | |||
| 80 | if (nextType != SIGNATURE_END_ARGS')') { | |||
| 81 | JVM_TYPE_ASSERT(nextType)do { if (gdata && gdata->assertOn && !(76 == nextType || 91 == nextType || 90 == nextType || 66 == nextType || 67 == nextType || 68 == nextType || 70 == nextType || 73 == nextType || 74 == nextType || 83 == nextType || 86 == nextType )) { jdiAssertionFailed("/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/signature.c" , 81, "Tag is not a JVM basic type"); } } while (0); | |||
| 82 | *argumentTag = nextType; | |||
| 83 | return JNI_TRUE1; | |||
| 84 | } | |||
| 85 | return JNI_FALSE0; | |||
| 86 | } | |||
| 87 | ||||
| 88 | /* | |||
| 89 | * Convert the signature "Ljava/lang/Foo;" to a | |||
| 90 | * classname "java.lang.Foo" compatible with the pattern. | |||
| 91 | * Signature is overwritten in-place. | |||
| 92 | */ | |||
| 93 | void convertSignatureToClassname(char *convert) | |||
| 94 | { | |||
| 95 | char *p; | |||
| 96 | ||||
| 97 | p = convert + 1; | |||
| 98 | while ((*p != ';') && (*p != '\0')) { | |||
| 99 | char c = *p; | |||
| 100 | if (c == '/') { | |||
| 101 | *(p-1) = '.'; | |||
| 102 | } else if (c == '.') { | |||
| 103 | // class signature of a hidden class is "Ljava/lang/Foo.1234;" | |||
| 104 | // map to "java.lang.Foo/1234" | |||
| 105 | *(p-1) = '/'; | |||
| 106 | } else { | |||
| 107 | *(p-1) = c; | |||
| 108 | } | |||
| 109 | p++; | |||
| 110 | } | |||
| 111 | *(p-1) = '\0'; | |||
| 112 | } |