• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂4794efbfdc4b1497c1f47397b2a2c43382e3de78 (tree)
時間2018-12-14 04:36:42
作者John Baldwin <jhb@Free...>
CommiterJohn Baldwin

Log Message

Change get_syscalls_by_group to append to an existing vector of integers.

This removes the need for the caller to explicitly manage the memory
for the returned system call list. The sole caller only needed the
system call numbers rather than the full syscall structures.

get_syscalls_by_group now uses a boolean return value to indicate if
the requested group exists.

gdb/ChangeLog:

* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
to get_syscalls_by_group.
* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_group): Return
false.
[HAVE_LIBEXPAT] (xml_list_syscalls_by_group): Append syscall
numbers to an existing vector of integers and return a bool.
(get_syscalls_by_group): Accept pointer to vector of integers
and change return type to bool.
* xml-syscall.h (get_syscalls_by_group): Likewise.

Change Summary

差異

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
1+2018-12-13 John Baldwin <jhb@FreeBSD.org>
2+
3+ * break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
4+ to get_syscalls_by_group.
5+ * xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_group): Return
6+ false.
7+ [HAVE_LIBEXPAT] (xml_list_syscalls_by_group): Append syscall
8+ numbers to an existing vector of integers and return a bool.
9+ (get_syscalls_by_group): Accept pointer to vector of integers
10+ and change return type to bool.
11+ * xml-syscall.h (get_syscalls_by_group): Likewise.
12+
113 2018-12-13 Jim Wilson <jimw@sifive.com>
214
315 * riscv-tdep.c (riscv_print_one_register_info): For MSTATUS, add
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -409,25 +409,13 @@ catch_syscall_split_args (const char *arg)
409409 {
410410 /* We have a syscall group. Let's expand it into a syscall
411411 list before inserting. */
412- struct syscall *syscall_list;
413412 const char *group_name;
414413
415414 /* Skip over "g:" and "group:" prefix strings. */
416415 group_name = strchr (cur_name, ':') + 1;
417416
418- syscall_list = get_syscalls_by_group (gdbarch, group_name);
419-
420- if (syscall_list == NULL)
417+ if (!get_syscalls_by_group (gdbarch, group_name, &result))
421418 error (_("Unknown syscall group '%s'."), group_name);
422-
423- for (i = 0; syscall_list[i].name != NULL; i++)
424- {
425- /* Insert each syscall that are part of the group. No
426- need to check if it is valid. */
427- result.push_back (syscall_list[i].number);
428- }
429-
430- xfree (syscall_list);
431419 }
432420 else
433421 {
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -77,11 +77,12 @@ get_syscall_names (struct gdbarch *gdbarch)
7777 return NULL;
7878 }
7979
80-struct syscall *
81-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
80+bool
81+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
82+ std::vector<int> *syscall_numbers)
8283 {
8384 syscall_warn_user ();
84- return NULL;
85+ return false;
8586 }
8687
8788 const char **
@@ -444,40 +445,27 @@ xml_list_of_syscalls (struct gdbarch *gdbarch)
444445 }
445446
446447 /* Iterate over the syscall_group_desc element to return a list of
447- syscalls that are part of the given group, terminated by an empty
448- element. If the syscall group doesn't exist, return NULL. */
448+ syscalls that are part of the given group. If the syscall group
449+ doesn't exist, return false. */
449450
450-static struct syscall *
451-xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
451+static bool
452+xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
453+ std::vector<int> *syscalls)
452454 {
453455 struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch);
454456 struct syscall_group_desc *groupdesc;
455- struct syscall *syscalls = NULL;
456- int nsyscalls;
457- int i;
458457
459- if (syscalls_info == NULL)
460- return NULL;
458+ if (syscalls_info == NULL || syscalls == NULL)
459+ return false;
461460
462461 groupdesc = syscall_group_get_group_by_name (syscalls_info, group);
463462 if (groupdesc == NULL)
464- return NULL;
465-
466- nsyscalls = groupdesc->syscalls.size ();
467- syscalls = (struct syscall*) xmalloc ((nsyscalls + 1)
468- * sizeof (struct syscall));
469-
470- for (i = 0; i < groupdesc->syscalls.size (); i++)
471- {
472- syscalls[i].name = groupdesc->syscalls[i]->name.c_str ();
473- syscalls[i].number = groupdesc->syscalls[i]->number;
474- }
463+ return false;
475464
476- /* Add final element marker. */
477- syscalls[i].name = NULL;
478- syscalls[i].number = 0;
465+ for (const struct syscall_desc *sysdesc : groupdesc->syscalls)
466+ syscalls->push_back (sysdesc->number);
479467
480- return syscalls;
468+ return true;
481469 }
482470
483471 /* Return a NULL terminated list of syscall groups or an empty list, if
@@ -542,12 +530,13 @@ get_syscall_names (struct gdbarch *gdbarch)
542530
543531 /* See comment in xml-syscall.h. */
544532
545-struct syscall *
546-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
533+bool
534+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
535+ std::vector<int> *syscall_numbers)
547536 {
548537 init_syscalls_info (gdbarch);
549538
550- return xml_list_syscalls_by_group (gdbarch, group);
539+ return xml_list_syscalls_by_group (gdbarch, group, syscall_numbers);
551540 }
552541
553542 /* See comment in xml-syscall.h. */
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -51,13 +51,11 @@ void get_syscall_by_name (struct gdbarch *gdbarch,
5151 const char **get_syscall_names (struct gdbarch *gdbarch);
5252
5353 /* Function used to retrieve the list of syscalls of a given group in
54- the system. Return a list of syscalls that are element of the
55- group, terminated by an empty element. The list is malloc'ed
56- and must be freed by the caller. If group doesn't exist, return
57- NULL. */
54+ the system. The syscall numbers are appended to SYSCALL_NUMBERS.
55+ If the group doesn't exist, return false. */
5856
59-struct syscall *get_syscalls_by_group (struct gdbarch *gdbarch,
60- const char *group);
57+bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
58+ std::vector<int> *syscall_numbers);
6159
6260 /* Function used to retrieve the list of syscall groups in the system.
6361 Return an array of strings terminated by a NULL element. The list