summaryrefslogtreecommitdiffstats
path: root/src/btparser/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btparser/thread.c')
-rw-r--r--src/btparser/thread.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/src/btparser/thread.c b/src/btparser/thread.c
index 4d52a9d4..05f154d6 100644
--- a/src/btparser/thread.c
+++ b/src/btparser/thread.c
@@ -293,7 +293,7 @@ btp_thread_parse(char **input,
return NULL;
}
- /* Skip spaces after the thread number and before the parenthesis. */
+ /* Skip spaces after the thread number and before parentheses. */
spaces = btp_skip_char_sequence(&local_input, ' ');
location->column += spaces;
if (0 == spaces)
@@ -303,60 +303,49 @@ btp_thread_parse(char **input,
return NULL;
}
- /* Read the Thread keyword in parenthesis, which is mandatory. */
+ /* Read the LWP section in parentheses, optional. */
+ location->column += btp_thread_skip_lwp(&local_input);
+
+ /* Read the Thread keyword in parentheses, optional. */
chars = btp_skip_string(&local_input, "(Thread ");
location->column += chars;
- if (0 == chars)
- {
- location->message = "Thread keyword in the parenthesis expected in the form '(Thread '.";
- btp_thread_free(imthread);
- return NULL;
- }
-
- /* Read the thread identification number. It can be either in
- * decimal or hexadecimal form.
- * Examples:
- * "Thread 10 (Thread 2476):"
- * "Thread 8 (Thread 0xb07fdb70 (LWP 6357)):"
- */
- digits = btp_skip_hexadecimal_number(&local_input);
- if (0 == digits)
- digits = btp_skip_unsigned_integer(&local_input);
- location->column += digits;
- if (0 == digits)
+ if (0 != chars)
{
- location->message = "The thread identification number expected.";
- btp_thread_free(imthread);
- return NULL;
- }
-
- /* Handle the optional " (LWP [0-9]+)" section. */
- chars = btp_skip_string(&local_input, " (LWP ");
- if (0 < chars)
- {
- location->column += chars;
- digits = btp_skip_unsigned_integer(&local_input);
+ /* Read the thread identification number. It can be either in
+ * decimal or hexadecimal form.
+ * Examples:
+ * "Thread 10 (Thread 2476):"
+ * "Thread 8 (Thread 0xb07fdb70 (LWP 6357)):"
+ */
+ digits = btp_skip_hexadecimal_number(&local_input);
+ if (0 == digits)
+ digits = btp_skip_unsigned_integer(&local_input);
+ location->column += digits;
if (0 == digits)
{
- location->message = "The LWP number expected.";
+ location->message = "The thread identification number expected.";
btp_thread_free(imthread);
return NULL;
}
- location->column += digits;
+
+ /* Handle the optional " (LWP [0-9]+)" section. */
+ location->column += btp_skip_char_sequence(&local_input, ' ');
+ location->column += btp_thread_skip_lwp(&local_input);
+
+ /* Read the end of the parenthesis. */
if (!btp_skip_char(&local_input, ')'))
{
- location->message = "Closing parenthesis for LWP expected.";
+ location->message = "Closing parenthesis for Thread expected.";
btp_thread_free(imthread);
return NULL;
}
- location->column += 1;
}
- /* Read the end of the parenthesis. */
- chars = btp_skip_string(&local_input, "):\n");
+ /* Read the end of the header line. */
+ chars = btp_skip_string(&local_input, ":\n");
if (0 == chars)
{
- location->message = "The end of the parenthesis expected in the form of '):\\n'.";
+ location->message = "Expected a colon followed by a newline ':\\n'.";
btp_thread_free(imthread);
return NULL;
}
@@ -391,3 +380,20 @@ btp_thread_parse(char **input,
*input = local_input;
return imthread;
}
+
+int
+btp_thread_skip_lwp(char **input)
+{
+ char *local_input = *input;
+ int count = btp_skip_string(&local_input, "(LWP ");
+ if (0 == count)
+ return 0;
+ int digits = btp_skip_unsigned_integer(&local_input);
+ if (0 == digits)
+ return 0;
+ count += digits;
+ if (!btp_skip_char(&local_input, ')'))
+ return 0;
+ *input = local_input;
+ return count + 1;
+}