Project

General

Profile

7824b_14976.patch

Sergey Ivanovskiy, 02/08/2024 07:01 AM

Download (3.11 KB)

View differences:

src/com/goldencode/p2j/main/ClientBuilderOptions.java 2024-02-08 11:56:40 +0000
31 31
**                  parseDebuggerPort and parseJMXPort
32 32
** 015 GBB 20240102 Adding fwd-slf4j.jar to client process classpath.
33 33
** 016 EVL 20240118 Adding method to check if we need native logger for spawn.
34
** 017 SBI 20240208 Added suspend option support.
34 35
*/
35 36
/*
36 37
** This program is free software: you can redistribute it and/or modify
......
116 117
   private final static String defaultPath = getDefaultPath();
117 118

  
118 119
   /** The template for the transport part of the java debugger agent connection string */
119
   private final static String DEBUGGER_TRANSPORT = "dt_socket,server=y,suspend=n,address=%d";
120
   private final static String DEBUGGER_TRANSPORT = "dt_socket,server=y,suspend=%s,address=%d";
120 121
   
121 122
   /** The search pattern for the debugger port */
122 123
   private final static Pattern DEBUGGER_ADDRESS_PATTERN = Pattern.compile("address=(\\d+)");
123 124
   
125
   /** The search pattern for the debugger suspend option */
126
   private final static Pattern DEBUGGER_SUSPEND_PATTERN = Pattern.compile("suspend=([ny])");
127
   
124 128
   /** The search pattern for the jmx agent port */
125 129
   private final static Pattern JMX_PORT_PATTERN = Pattern.compile("-Dcom\\.sun\\.management\\.jmxremote\\.port=(\\d+)");
126 130
   
......
157 161
   /** Storage for overridden options */
158 162
   private final Map<String, String> overriddenOptions = new HashMap<>();
159 163

  
164
   private String suspendOption;
160 165
   /**
161 166
    * All the subject IDs associated with this builder or <code>null</code> to use the 
162 167
    * context's subject IDs.
......
333 338
   {
334 339
      if (debuggerPort > 0)
335 340
      {
336
         updateJvmArgument("-Xrunjdwp:transport", String.format(DEBUGGER_TRANSPORT, debuggerPort));
341
         updateJvmArgument("-Xrunjdwp:transport", String.format(DEBUGGER_TRANSPORT, suspendOption, debuggerPort));
337 342
         applyDebugProfile();
338 343
      }
339 344
   }
......
456 461
      
457 462
      return -1;
458 463
   }
464
   
465
   /**
466
    * Get the debugger suspend option from the jvm arguments string, otherwise return null.
467
    * 
468
    * @param    jvmArgs
469
    *           The jvm arguments string
470
    * 
471
    * @return   The debugger suspend option or null value.
472
    */
473
   public static String parseDebuggerSuspendOption(String jvmArgs)
474
   {
475
      Matcher m = DEBUGGER_SUSPEND_PATTERN.matcher(jvmArgs);
476
      if (m.find())
477
      {
478
         return m.group(1);
479
      }
480
      
481
      return null;
482
   }
459 483

  
460 484
   /**
461 485
    * Get the jmx agent port from the jvm arguments string, otherwise return -1.
......
667 691
      // JVM arguments
668 692
      String jvm = getNode(DIRECTORY_NODE_ID, "jvmArgs", "");
669 693
      
694
      suspendOption = parseDebuggerSuspendOption(jvm);
695
      if (suspendOption == null)
696
      {
697
         suspendOption = "n"; // if the option is missed, then its default value is set to "suspend=n"
698
      }
699
      
670 700
      // we always must pass headless mode
671 701
      if (jvm.indexOf("-Djava.awt.headless=true") == -1)
672 702
      {