1 /* QNX Neutrino specific low level interface, for the remote server
3 Copyright (C) 2009-2020 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "gdbthread.h"
30 #include <sys/procfs.h>
32 #include <sys/iomgr.h>
33 #include <sys/neutrino.h>
36 int using_threads
= 1;
38 const struct target_desc
*nto_tdesc
;
41 nto_trace (const char *fmt
, ...)
45 if (debug_threads
== 0)
47 fprintf (stderr
, "nto:");
48 va_start (arg_list
, fmt
);
49 vfprintf (stderr
, fmt
, arg_list
);
53 #define TRACE nto_trace
55 /* Structure holding neutrino specific information about
60 char nto_procfs_path
[PATH_MAX
];
63 int exit_signo
; /* For tracking exit status. */
66 static struct nto_inferior nto_inferior
;
69 init_nto_inferior (struct nto_inferior
*nto_inferior
)
71 memset (nto_inferior
, 0, sizeof (struct nto_inferior
));
72 nto_inferior
->ctl_fd
= -1;
73 nto_inferior
->pid
= -1;
79 if (nto_inferior
.ctl_fd
!= -1)
81 nto_trace ("Closing fd\n");
82 close (nto_inferior
.ctl_fd
);
83 init_nto_inferior (&nto_inferior
);
87 /* Set current thread. Return 1 on success, 0 otherwise. */
90 nto_set_thread (ptid_t ptid
)
94 TRACE ("%s pid: %d tid: %ld\n", __func__
, ptid
.pid (),
96 if (nto_inferior
.ctl_fd
!= -1
98 && ptid
!= minus_one_ptid
)
100 pthread_t tid
= ptid
.lwp ();
102 if (EOK
== devctl (nto_inferior
.ctl_fd
, DCMD_PROC_CURTHREAD
, &tid
,
106 TRACE ("%s: Error: failed to set current thread\n", __func__
);
111 /* This function will determine all alive threads. Note that we do not list
112 dead but unjoined threads even though they are still in the process' thread
115 NTO_INFERIOR must not be NULL. */
118 nto_find_new_threads (struct nto_inferior
*nto_inferior
)
122 TRACE ("%s pid:%d\n", __func__
, nto_inferior
->pid
);
124 if (nto_inferior
->ctl_fd
== -1)
127 for (tid
= 1;; ++tid
)
129 procfs_status status
;
134 err
= devctl (nto_inferior
->ctl_fd
, DCMD_PROC_TIDSTATUS
, &status
,
137 if (err
!= EOK
|| status
.tid
== 0)
140 /* All threads in between are gone. */
141 while (tid
!= status
.tid
|| status
.state
== STATE_DEAD
)
143 struct thread_info
*ti
;
145 ptid
= ptid_t (nto_inferior
->pid
, tid
, 0);
146 ti
= find_thread_ptid (ptid
);
149 TRACE ("Removing thread %d\n", tid
);
152 if (tid
== status
.tid
)
157 if (status
.state
!= STATE_DEAD
)
159 TRACE ("Adding thread %d\n", tid
);
160 ptid
= ptid_t (nto_inferior
->pid
, tid
, 0);
161 if (!find_thread_ptid (ptid
))
162 add_thread (ptid
, NULL
);
167 /* Given pid, open procfs path. */
170 do_attach (pid_t pid
)
172 procfs_status status
;
173 struct sigevent event
;
175 if (nto_inferior
.ctl_fd
!= -1)
177 close (nto_inferior
.ctl_fd
);
178 init_nto_inferior (&nto_inferior
);
180 xsnprintf (nto_inferior
.nto_procfs_path
, PATH_MAX
- 1, "/proc/%d/as", pid
);
181 nto_inferior
.ctl_fd
= open (nto_inferior
.nto_procfs_path
, O_RDWR
);
182 if (nto_inferior
.ctl_fd
== -1)
184 TRACE ("Failed to open %s\n", nto_inferior
.nto_procfs_path
);
185 init_nto_inferior (&nto_inferior
);
188 if (devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STOP
, &status
, sizeof (status
), 0)
194 nto_inferior
.pid
= pid
;
195 /* Define a sigevent for process stopped notification. */
196 event
.sigev_notify
= SIGEV_SIGNAL_THREAD
;
197 event
.sigev_signo
= SIGUSR1
;
198 event
.sigev_code
= 0;
199 event
.sigev_value
.sival_ptr
= NULL
;
200 event
.sigev_priority
= -1;
201 devctl (nto_inferior
.ctl_fd
, DCMD_PROC_EVENT
, &event
, sizeof (event
), 0);
203 if (devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
, sizeof (status
),
205 && (status
.flags
& _DEBUG_FLAG_STOPPED
))
208 struct process_info
*proc
;
211 ptid
= ptid_t (status
.pid
, status
.tid
, 0);
212 the_low_target
.arch_setup ();
213 proc
= add_process (status
.pid
, 1);
214 proc
->tdesc
= nto_tdesc
;
215 TRACE ("Adding thread: pid=%d tid=%ld\n", status
.pid
,
217 nto_find_new_threads (&nto_inferior
);
228 /* Read or write LEN bytes from/to inferior's MEMADDR memory address
229 into gdbservers's MYADDR buffer. Return number of bytes actually
233 nto_xfer_memory (off_t memaddr
, unsigned char *myaddr
, int len
,
238 if (lseek (nto_inferior
.ctl_fd
, memaddr
, SEEK_SET
) == memaddr
)
241 nbytes
= write (nto_inferior
.ctl_fd
, myaddr
, len
);
243 nbytes
= read (nto_inferior
.ctl_fd
, myaddr
, len
);
250 TRACE ("Error in %s : errno=%d (%s)\n", __func__
, e
, safe_strerror (e
));
255 /* Insert or remove breakpoint or watchpoint at address ADDR.
256 TYPE can be one of Neutrino breakpoint types. SIZE must be 0 for
257 inserting the point, -1 for removing it.
259 Return 0 on success, 1 otherwise. */
262 nto_breakpoint (CORE_ADDR addr
, int type
, int size
)
269 if (devctl (nto_inferior
.ctl_fd
, DCMD_PROC_BREAK
, &brk
, sizeof (brk
), 0)
275 /* Read auxiliary vector from inferior's initial stack into gdbserver's
276 MYADDR buffer, up to LEN bytes.
278 Return number of bytes read. */
281 nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack
,
282 unsigned char *myaddr
,
287 unsigned int len_read
= 0;
289 /* Skip over argc, argv and envp... Comment from ldd.c:
291 The startup frame is set-up so that we have:
296 envp1 <----- void *frame + (argc + 2) * sizeof(char *)
301 argc <------ void * frame
303 On entry to ldd, frame gives the address of argc on the stack. */
304 if (nto_xfer_memory (initial_stack
, (unsigned char *)&anint
,
305 sizeof (anint
), 0) != sizeof (anint
))
308 /* Size of pointer is assumed to be 4 bytes (32 bit arch. ) */
309 data_ofs
+= (anint
+ 2) * sizeof (void *); /* + 2 comes from argc itself and
310 NULL terminating pointer in
313 /* Now loop over env table: */
314 while (nto_xfer_memory (initial_stack
+ data_ofs
,
315 (unsigned char *)&anint
, sizeof (anint
), 0)
318 data_ofs
+= sizeof (anint
);
322 initial_stack
+= data_ofs
;
324 memset (myaddr
, 0, len
);
325 while (len_read
<= len
- sizeof (auxv_t
))
327 auxv_t
*auxv
= (auxv_t
*)myaddr
;
329 /* Search backwards until we have read AT_PHDR (num. 3),
330 AT_PHENT (num 4), AT_PHNUM (num 5) */
331 if (nto_xfer_memory (initial_stack
, (unsigned char *)auxv
,
332 sizeof (auxv_t
), 0) == sizeof (auxv_t
))
334 if (auxv
->a_type
!= AT_NULL
)
337 len_read
+= sizeof (auxv_t
);
339 if (auxv
->a_type
== AT_PHNUM
) /* That's all we need. */
341 initial_stack
+= sizeof (auxv_t
);
346 TRACE ("auxv: len_read: %d\n", len_read
);
350 /* Start inferior specified by PROGRAM, using PROGRAM_ARGS as its
354 nto_process_target::create_inferior (const char *program
,
355 const std::vector
<char *> &program_args
)
357 struct inheritance inherit
;
360 std::string str_program_args
= stringify_argv (program_args
);
362 TRACE ("%s %s\n", __func__
, program
);
363 /* Clear any pending SIGUSR1's but keep the behavior the same. */
364 signal (SIGUSR1
, signal (SIGUSR1
, SIG_IGN
));
367 sigaddset (&set
, SIGUSR1
);
368 sigprocmask (SIG_UNBLOCK
, &set
, NULL
);
370 memset (&inherit
, 0, sizeof (inherit
));
371 inherit
.flags
|= SPAWN_SETGROUP
| SPAWN_HOLD
;
372 inherit
.pgroup
= SPAWN_NEWPGROUP
;
373 pid
= spawnp (program
, 0, NULL
, &inherit
,
374 (char *) str_program_args
.c_str (), 0);
375 sigprocmask (SIG_BLOCK
, &set
, NULL
);
380 if (do_attach (pid
) != pid
)
386 /* Attach to process PID. */
389 nto_process_target::attach (unsigned long pid
)
391 TRACE ("%s %ld\n", __func__
, pid
);
392 if (do_attach (pid
) != pid
)
393 error ("Unable to attach to %ld\n", pid
);
397 /* Send signal to process PID. */
400 nto_process_target::kill (process_info
*proc
)
404 TRACE ("%s %d\n", __func__
, pid
);
410 /* Detach from process PID. */
413 nto_detach (process_info
*proc
)
415 TRACE ("%s %d\n", __func__
, proc
->pid
);
421 nto_mourn (struct process_info
*process
)
423 remove_process (process
);
426 /* Check if the given thread is alive.
428 Return 1 if alive, 0 otherwise. */
431 nto_thread_alive (ptid_t ptid
)
435 TRACE ("%s pid:%d tid:%d\n", __func__
, ptid
.pid (),
437 if (SignalKill (0, ptid
.pid (), ptid
.lwp (),
442 TRACE ("%s: %s\n", __func__
, res
? "yes" : "no");
446 /* Resume inferior's execution. */
449 nto_resume (struct thread_resume
*resume_info
, size_t n
)
451 /* We can only work in all-stop mode. */
452 procfs_status status
;
456 TRACE ("%s\n", __func__
);
457 /* Workaround for aliasing rules violation. */
458 sigset_t
*run_fault
= (sigset_t
*) (void *) &run
.fault
;
460 nto_set_thread (resume_info
->thread
);
462 run
.flags
= _DEBUG_RUN_FAULT
| _DEBUG_RUN_TRACE
;
463 if (resume_info
->kind
== resume_step
)
464 run
.flags
|= _DEBUG_RUN_STEP
;
465 run
.flags
|= _DEBUG_RUN_ARM
;
467 sigemptyset (run_fault
);
468 sigaddset (run_fault
, FLTBPT
);
469 sigaddset (run_fault
, FLTTRACE
);
470 sigaddset (run_fault
, FLTILL
);
471 sigaddset (run_fault
, FLTPRIV
);
472 sigaddset (run_fault
, FLTBOUNDS
);
473 sigaddset (run_fault
, FLTIOVF
);
474 sigaddset (run_fault
, FLTIZDIV
);
475 sigaddset (run_fault
, FLTFPE
);
476 sigaddset (run_fault
, FLTPAGE
);
477 sigaddset (run_fault
, FLTSTACK
);
478 sigaddset (run_fault
, FLTACCESS
);
480 sigemptyset (&run
.trace
);
481 if (resume_info
->sig
)
485 devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
, sizeof (status
),
487 signal_to_pass
= resume_info
->sig
;
488 if (status
.why
& (_DEBUG_WHY_SIGNALLED
| _DEBUG_WHY_FAULTED
))
490 if (signal_to_pass
!= status
.info
.si_signo
)
492 kill (status
.pid
, signal_to_pass
);
493 run
.flags
|= _DEBUG_RUN_CLRFLT
| _DEBUG_RUN_CLRSIG
;
495 else /* Let it kill the program without telling us. */
496 sigdelset (&run
.trace
, signal_to_pass
);
500 run
.flags
|= _DEBUG_RUN_CLRSIG
| _DEBUG_RUN_CLRFLT
;
502 sigfillset (&run
.trace
);
504 regcache_invalidate ();
506 err
= devctl (nto_inferior
.ctl_fd
, DCMD_PROC_RUN
, &run
, sizeof (run
), 0);
508 TRACE ("Error: %d \"%s\"\n", err
, safe_strerror (err
));
511 /* Wait for inferior's event.
513 Return ptid of thread that caused the event. */
516 nto_wait (ptid_t ptid
,
517 struct target_waitstatus
*ourstatus
, int target_options
)
521 procfs_status status
;
522 const int trace_mask
= (_DEBUG_FLAG_TRACE_EXEC
| _DEBUG_FLAG_TRACE_RD
523 | _DEBUG_FLAG_TRACE_WR
| _DEBUG_FLAG_TRACE_MODIFY
);
525 TRACE ("%s\n", __func__
);
527 ourstatus
->kind
= TARGET_WAITKIND_SPURIOUS
;
530 sigaddset (&set
, SIGUSR1
);
532 devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
, sizeof (status
), 0);
533 while (!(status
.flags
& _DEBUG_FLAG_ISTOP
))
535 sigwaitinfo (&set
, &info
);
536 devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
, sizeof (status
),
539 nto_find_new_threads (&nto_inferior
);
541 if (status
.flags
& _DEBUG_FLAG_SSTEP
)
544 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
545 ourstatus
->value
.sig
= GDB_SIGNAL_TRAP
;
547 /* Was it a breakpoint? */
548 else if (status
.flags
& trace_mask
)
551 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
552 ourstatus
->value
.sig
= GDB_SIGNAL_TRAP
;
554 else if (status
.flags
& _DEBUG_FLAG_ISTOP
)
559 case _DEBUG_WHY_SIGNALLED
:
560 TRACE (" SIGNALLED\n");
561 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
562 ourstatus
->value
.sig
=
563 gdb_signal_from_host (status
.info
.si_signo
);
564 nto_inferior
.exit_signo
= ourstatus
->value
.sig
;
566 case _DEBUG_WHY_FAULTED
:
567 TRACE (" FAULTED\n");
568 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
569 if (status
.info
.si_signo
== SIGTRAP
)
571 ourstatus
->value
.sig
= 0;
572 nto_inferior
.exit_signo
= 0;
576 ourstatus
->value
.sig
=
577 gdb_signal_from_host (status
.info
.si_signo
);
578 nto_inferior
.exit_signo
= ourstatus
->value
.sig
;
582 case _DEBUG_WHY_TERMINATED
:
586 TRACE (" TERMINATED\n");
587 waitpid (ptid
.pid (), &waitval
, WNOHANG
);
588 if (nto_inferior
.exit_signo
)
590 /* Abnormal death. */
591 ourstatus
->kind
= TARGET_WAITKIND_SIGNALLED
;
592 ourstatus
->value
.sig
= nto_inferior
.exit_signo
;
597 ourstatus
->kind
= TARGET_WAITKIND_EXITED
;
598 ourstatus
->value
.integer
= WEXITSTATUS (waitval
);
600 nto_inferior
.exit_signo
= 0;
604 case _DEBUG_WHY_REQUESTED
:
605 TRACE ("REQUESTED\n");
606 /* We are assuming a requested stop is due to a SIGINT. */
607 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
608 ourstatus
->value
.sig
= GDB_SIGNAL_INT
;
609 nto_inferior
.exit_signo
= 0;
614 return ptid_t (status
.pid
, status
.tid
, 0);
617 /* Fetch inferior's registers for currently selected thread (CURRENT_INFERIOR).
618 If REGNO is -1, fetch all registers, or REGNO register only otherwise. */
621 nto_fetch_registers (struct regcache
*regcache
, int regno
)
626 TRACE ("%s (regno=%d)\n", __func__
, regno
);
627 if (regno
>= the_low_target
.num_regs
)
630 if (current_thread
== NULL
)
632 TRACE ("current_thread is NULL\n");
635 ptid_t ptid
= ptid_of (current_thread
);
636 if (!nto_set_thread (ptid
))
639 if (devctl (nto_inferior
.ctl_fd
, DCMD_PROC_GETGREG
, &greg
, sizeof (greg
),
642 if (regno
== -1) /* All registers. */
644 for (regno
= 0; regno
!= the_low_target
.num_regs
; ++regno
)
646 const unsigned int registeroffset
647 = the_low_target
.register_offset (regno
);
648 supply_register (regcache
, regno
,
649 ((char *)&greg
) + registeroffset
);
654 const unsigned int registeroffset
655 = the_low_target
.register_offset (regno
);
656 if (registeroffset
== -1)
658 supply_register (regcache
, regno
, ((char *)&greg
) + registeroffset
);
662 TRACE ("ERROR reading registers from inferior.\n");
665 /* Store registers for currently selected thread (CURRENT_INFERIOR).
666 We always store all registers, regardless of REGNO. */
669 nto_store_registers (struct regcache
*regcache
, int regno
)
674 TRACE ("%s (regno:%d)\n", __func__
, regno
);
676 if (current_thread
== NULL
)
678 TRACE ("current_thread is NULL\n");
681 ptid_t ptid
= ptid_of (current_thread
);
682 if (!nto_set_thread (ptid
))
685 memset (&greg
, 0, sizeof (greg
));
686 for (regno
= 0; regno
!= the_low_target
.num_regs
; ++regno
)
688 const unsigned int regoffset
689 = the_low_target
.register_offset (regno
);
690 collect_register (regcache
, regno
, ((char *)&greg
) + regoffset
);
692 err
= devctl (nto_inferior
.ctl_fd
, DCMD_PROC_SETGREG
, &greg
, sizeof (greg
),
695 TRACE ("Error: setting registers.\n");
698 /* Read LEN bytes from inferior's memory address MEMADDR into
699 gdbserver's MYADDR buffer.
701 Return 0 on success -1 otherwise. */
704 nto_read_memory (CORE_ADDR memaddr
, unsigned char *myaddr
, int len
)
706 TRACE ("%s memaddr:0x%08lx, len:%d\n", __func__
, memaddr
, len
);
708 if (nto_xfer_memory (memaddr
, myaddr
, len
, 0) != len
)
710 TRACE ("Failed to read memory\n");
717 /* Write LEN bytes from gdbserver's buffer MYADDR into inferior's
718 memory at address MEMADDR.
720 Return 0 on success -1 otherwise. */
723 nto_write_memory (CORE_ADDR memaddr
, const unsigned char *myaddr
, int len
)
727 TRACE ("%s memaddr: 0x%08llx len: %d\n", __func__
, memaddr
, len
);
728 if ((len_written
= nto_xfer_memory (memaddr
, (unsigned char *)myaddr
, len
,
732 TRACE ("Wanted to write: %d but written: %d\n", len
, len_written
);
739 /* Stop inferior. We always stop all threads. */
742 nto_request_interrupt (void)
744 TRACE ("%s\n", __func__
);
745 nto_set_thread (ptid_t (nto_inferior
.pid
, 1, 0));
746 if (EOK
!= devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STOP
, NULL
, 0, 0))
747 TRACE ("Error stopping inferior.\n");
750 /* Read auxiliary vector from inferior's memory into gdbserver's buffer
751 MYADDR. We always read whole auxv.
753 Return number of bytes stored in MYADDR buffer, 0 if OFFSET > 0
757 nto_read_auxv (CORE_ADDR offset
, unsigned char *myaddr
, unsigned int len
)
760 CORE_ADDR initial_stack
;
761 procfs_info procinfo
;
763 TRACE ("%s\n", __func__
);
767 err
= devctl (nto_inferior
.ctl_fd
, DCMD_PROC_INFO
, &procinfo
,
772 initial_stack
= procinfo
.initial_stack
;
774 return nto_read_auxv_from_initial_stack (initial_stack
, myaddr
, len
);
778 nto_supports_z_point_type (char z_type
)
784 case Z_PACKET_WRITE_WP
:
785 case Z_PACKET_READ_WP
:
786 case Z_PACKET_ACCESS_WP
:
793 /* Insert {break/watch}point at address ADDR. SIZE is not used. */
796 nto_insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
797 int size
, struct raw_breakpoint
*bp
)
799 int wtype
= _DEBUG_BREAK_HW
; /* Always request HW. */
801 TRACE ("%s type:%c addr: 0x%08lx len:%d\n", __func__
, (int)type
, addr
, size
);
804 case raw_bkpt_type_sw
:
805 wtype
= _DEBUG_BREAK_EXEC
;
807 case raw_bkpt_type_hw
:
808 wtype
|= _DEBUG_BREAK_EXEC
;
810 case raw_bkpt_type_write_wp
:
811 wtype
|= _DEBUG_BREAK_RW
;
813 case raw_bkpt_type_read_wp
:
814 wtype
|= _DEBUG_BREAK_RD
;
816 case raw_bkpt_type_access_wp
:
817 wtype
|= _DEBUG_BREAK_RW
;
820 return 1; /* Not supported. */
822 return nto_breakpoint (addr
, wtype
, 0);
825 /* Remove {break/watch}point at address ADDR. SIZE is not used. */
828 nto_remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
829 int size
, struct raw_breakpoint
*bp
)
831 int wtype
= _DEBUG_BREAK_HW
; /* Always request HW. */
833 TRACE ("%s type:%c addr: 0x%08lx len:%d\n", __func__
, (int)type
, addr
, size
);
836 case raw_bkpt_type_sw
:
837 wtype
= _DEBUG_BREAK_EXEC
;
839 case raw_bkpt_type_hw
:
840 wtype
|= _DEBUG_BREAK_EXEC
;
842 case raw_bkpt_type_write_wp
:
843 wtype
|= _DEBUG_BREAK_RW
;
845 case raw_bkpt_type_read_wp
:
846 wtype
|= _DEBUG_BREAK_RD
;
848 case raw_bkpt_type_access_wp
:
849 wtype
|= _DEBUG_BREAK_RW
;
852 return 1; /* Not supported. */
854 return nto_breakpoint (addr
, wtype
, -1);
857 /* Check if the reason of stop for current thread (CURRENT_INFERIOR) is
860 Return 1 if stopped by watchpoint, 0 otherwise. */
863 nto_stopped_by_watchpoint (void)
867 TRACE ("%s\n", __func__
);
868 if (nto_inferior
.ctl_fd
!= -1 && current_thread
!= NULL
)
870 ptid_t ptid
= ptid_of (current_thread
);
871 if (nto_set_thread (ptid
))
873 const int watchmask
= _DEBUG_FLAG_TRACE_RD
| _DEBUG_FLAG_TRACE_WR
874 | _DEBUG_FLAG_TRACE_MODIFY
;
875 procfs_status status
;
878 err
= devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
,
880 if (err
== EOK
&& (status
.flags
& watchmask
))
884 TRACE ("%s: %s\n", __func__
, ret
? "yes" : "no");
888 /* Get instruction pointer for CURRENT_INFERIOR thread.
890 Return inferior's instruction pointer value, or 0 on error. */
893 nto_stopped_data_address (void)
895 CORE_ADDR ret
= (CORE_ADDR
)0;
897 TRACE ("%s\n", __func__
);
898 if (nto_inferior
.ctl_fd
!= -1 && current_thread
!= NULL
)
900 ptid_t ptid
= ptid_of (current_thread
);
902 if (nto_set_thread (ptid
))
904 procfs_status status
;
906 if (devctl (nto_inferior
.ctl_fd
, DCMD_PROC_STATUS
, &status
,
907 sizeof (status
), 0) == EOK
)
911 TRACE ("%s: 0x%08lx\n", __func__
, ret
);
915 /* We do not currently support non-stop. */
918 nto_supports_non_stop (void)
920 TRACE ("%s\n", __func__
);
924 /* Implementation of the target_ops method "sw_breakpoint_from_kind". */
926 static const gdb_byte
*
927 nto_sw_breakpoint_from_kind (int kind
, int *size
)
929 *size
= the_low_target
.breakpoint_len
;
930 return the_low_target
.breakpoint
;
933 /* The QNX Neutrino target ops object. */
935 static nto_process_target the_nto_target
;
937 static process_stratum_target nto_target_ops
= {
946 NULL
, /* prepare_to_access_memory */
947 NULL
, /* done_accessing_memory */
950 NULL
, /* nto_look_up_symbols */
951 nto_request_interrupt
,
953 nto_supports_z_point_type
,
956 NULL
, /* stopped_by_sw_breakpoint */
957 NULL
, /* supports_stopped_by_sw_breakpoint */
958 NULL
, /* stopped_by_hw_breakpoint */
959 NULL
, /* supports_stopped_by_hw_breakpoint */
960 target_can_do_hardware_single_step
,
961 nto_stopped_by_watchpoint
,
962 nto_stopped_data_address
,
963 NULL
, /* nto_read_offsets */
964 NULL
, /* thread_db_set_tls_address */
965 hostio_last_error_from_errno
,
966 NULL
, /* nto_qxfer_osdata */
967 NULL
, /* xfer_siginfo */
968 nto_supports_non_stop
,
970 NULL
, /* start_non_stop */
971 NULL
, /* supports_multi_process */
972 NULL
, /* supports_fork_events */
973 NULL
, /* supports_vfork_events */
974 NULL
, /* supports_exec_events */
975 NULL
, /* handle_new_gdb_connection */
976 NULL
, /* handle_monitor_command */
977 NULL
, /* core_of_thread */
978 NULL
, /* read_loadmap */
979 NULL
, /* process_qsupported */
980 NULL
, /* supports_tracepoints */
983 NULL
, /* thread_stopped */
984 NULL
, /* get_tib_address */
985 NULL
, /* pause_all */
986 NULL
, /* unpause_all */
987 NULL
, /* stabilize_threads */
988 NULL
, /* install_fast_tracepoint_jump_pad */
990 NULL
, /* supports_disable_randomization */
991 NULL
, /* get_min_fast_tracepoint_insn_len */
992 NULL
, /* qxfer_libraries_svr4 */
993 NULL
, /* support_agent */
994 NULL
, /* enable_btrace */
995 NULL
, /* disable_btrace */
996 NULL
, /* read_btrace */
997 NULL
, /* read_btrace_conf */
998 NULL
, /* supports_range_stepping */
999 NULL
, /* pid_to_exec_file */
1000 NULL
, /* multifs_open */
1001 NULL
, /* multifs_unlink */
1002 NULL
, /* multifs_readlink */
1003 NULL
, /* breakpoint_kind_from_pc */
1004 nto_sw_breakpoint_from_kind
,
1005 NULL
, /* thread_name */
1006 NULL
, /* breakpoint_kind_from_current_state */
1007 NULL
, /* supports_software_single_step */
1008 NULL
, /* supports_catch_syscall */
1009 NULL
, /* get_ipa_tdesc_idx */
1010 NULL
, /* thread_handle */
1015 /* Global function called by server.c. Initializes QNX Neutrino
1019 initialize_low (void)
1023 TRACE ("%s\n", __func__
);
1024 set_target_ops (&nto_target_ops
);
1026 /* We use SIGUSR1 to gain control after we block waiting for a process.
1027 We use sigwaitevent to wait. */
1029 sigaddset (&set
, SIGUSR1
);
1030 sigprocmask (SIG_BLOCK
, &set
, NULL
);