- return frame_base - (u->Total_frame_size << 3);
- }
- }
-
- /* The value in %r3 was never saved into the stack (thus %r3 still
- holds the value of the previous frame pointer). */
- return deprecated_read_fp ();
- }
-}
-\f
-
-/* To see if a frame chain is valid, see if the caller looks like it
- was compiled with gcc. */
-
-int
-hppa_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
-{
- struct minimal_symbol *msym_us;
- struct minimal_symbol *msym_start;
- struct unwind_table_entry *u, *next_u = NULL;
- struct frame_info *next;
-
- u = find_unwind_entry (get_frame_pc (thisframe));
-
- if (u == NULL)
- return 1;
-
- /* We can't just check that the same of msym_us is "_start", because
- someone idiotically decided that they were going to make a Ltext_end
- symbol with the same address. This Ltext_end symbol is totally
- indistinguishable (as nearly as I can tell) from the symbol for a function
- which is (legitimately, since it is in the user's namespace)
- named Ltext_end, so we can't just ignore it. */
- msym_us = lookup_minimal_symbol_by_pc (DEPRECATED_FRAME_SAVED_PC (thisframe));
- msym_start = lookup_minimal_symbol ("_start", NULL, NULL);
- if (msym_us
- && msym_start
- && SYMBOL_VALUE_ADDRESS (msym_us) == SYMBOL_VALUE_ADDRESS (msym_start))
- return 0;
-
- /* Grrrr. Some new idiot decided that they don't want _start for the
- PRO configurations; $START$ calls main directly.... Deal with it. */
- msym_start = lookup_minimal_symbol ("$START$", NULL, NULL);
- if (msym_us
- && msym_start
- && SYMBOL_VALUE_ADDRESS (msym_us) == SYMBOL_VALUE_ADDRESS (msym_start))
- return 0;
-
- next = get_next_frame (thisframe);
- if (next)
- next_u = find_unwind_entry (get_frame_pc (next));
-
- /* If this frame does not save SP, has no stack, isn't a stub,
- and doesn't "call" an interrupt routine or signal handler caller,
- then its not valid. */
- if (u->Save_SP || u->Total_frame_size || u->stub_unwind.stub_type != 0
- || (get_next_frame (thisframe) && (get_frame_type (get_next_frame (thisframe)) == SIGTRAMP_FRAME))
- || (next_u && next_u->HP_UX_interrupt_marker))
- return 1;
-
- if (pc_in_linker_stub (get_frame_pc (thisframe)))
- return 1;
-
- return 0;
-}
-
-/* These functions deal with saving and restoring register state
- around a function call in the inferior. They keep the stack
- double-word aligned; eventually, on an hp700, the stack will have
- to be aligned to a 64-byte boundary. */
-
-void
-hppa_push_dummy_frame (void)
-{
- CORE_ADDR sp, pc, pcspace;
- int regnum;
- CORE_ADDR int_buffer;
- double freg_buffer;
-
- pc = hppa_target_read_pc (inferior_ptid);
- int_buffer = read_register (FLAGS_REGNUM);
- if (int_buffer & 0x2)
- {
- const unsigned int sid = (pc >> 30) & 0x3;
- if (sid == 0)
- pcspace = read_register (SR4_REGNUM);
- else
- pcspace = read_register (SR4_REGNUM + 4 + sid);
- }
- else
- pcspace = read_register (PCSQ_HEAD_REGNUM);
-
- /* Space for "arguments"; the RP goes in here. */
- sp = read_register (SP_REGNUM) + 48;
- int_buffer = read_register (RP_REGNUM) | 0x3;
-
- /* The 32bit and 64bit ABIs save the return pointer into different
- stack slots. */
- if (DEPRECATED_REGISTER_SIZE == 8)
- write_memory (sp - 16, (char *) &int_buffer, DEPRECATED_REGISTER_SIZE);
- else
- write_memory (sp - 20, (char *) &int_buffer, DEPRECATED_REGISTER_SIZE);
-
- int_buffer = deprecated_read_fp ();
- write_memory (sp, (char *) &int_buffer, DEPRECATED_REGISTER_SIZE);
-
- write_register (DEPRECATED_FP_REGNUM, sp);
-
- sp += 2 * DEPRECATED_REGISTER_SIZE;
-
- for (regnum = 1; regnum < 32; regnum++)
- if (regnum != RP_REGNUM && regnum != DEPRECATED_FP_REGNUM)
- sp = push_word (sp, read_register (regnum));
-
- /* This is not necessary for the 64bit ABI. In fact it is dangerous. */
- if (DEPRECATED_REGISTER_SIZE != 8)
- sp += 4;
-
- for (regnum = FP0_REGNUM; regnum < NUM_REGS; regnum++)
- {
- deprecated_read_register_bytes (DEPRECATED_REGISTER_BYTE (regnum),
- (char *) &freg_buffer, 8);
- sp = push_bytes (sp, (char *) &freg_buffer, 8);
- }
- sp = push_word (sp, read_register (IPSW_REGNUM));
- sp = push_word (sp, read_register (SAR_REGNUM));
- sp = push_word (sp, pc);
- sp = push_word (sp, pcspace);
- sp = push_word (sp, pc + 4);
- sp = push_word (sp, pcspace);
- write_register (SP_REGNUM, sp);
-}
-
-static void
-find_dummy_frame_regs (struct frame_info *frame,
- CORE_ADDR frame_saved_regs[])
-{
- CORE_ADDR fp = get_frame_base (frame);
- int i;
-
- /* The 32bit and 64bit ABIs save RP into different locations. */
- if (DEPRECATED_REGISTER_SIZE == 8)
- frame_saved_regs[RP_REGNUM] = (fp - 16) & ~0x3;
- else
- frame_saved_regs[RP_REGNUM] = (fp - 20) & ~0x3;
-
- frame_saved_regs[DEPRECATED_FP_REGNUM] = fp;
-
- frame_saved_regs[1] = fp + (2 * DEPRECATED_REGISTER_SIZE);
-
- for (fp += 3 * DEPRECATED_REGISTER_SIZE, i = 3; i < 32; i++)
- {
- if (i != DEPRECATED_FP_REGNUM)
- {
- frame_saved_regs[i] = fp;
- fp += DEPRECATED_REGISTER_SIZE;
- }
- }
-
- /* This is not necessary or desirable for the 64bit ABI. */
- if (DEPRECATED_REGISTER_SIZE != 8)
- fp += 4;
-
- for (i = FP0_REGNUM; i < NUM_REGS; i++, fp += 8)
- frame_saved_regs[i] = fp;
-
- frame_saved_regs[IPSW_REGNUM] = fp;
- frame_saved_regs[SAR_REGNUM] = fp + DEPRECATED_REGISTER_SIZE;
- frame_saved_regs[PCOQ_HEAD_REGNUM] = fp + 2 * DEPRECATED_REGISTER_SIZE;
- frame_saved_regs[PCSQ_HEAD_REGNUM] = fp + 3 * DEPRECATED_REGISTER_SIZE;
- frame_saved_regs[PCOQ_TAIL_REGNUM] = fp + 4 * DEPRECATED_REGISTER_SIZE;
- frame_saved_regs[PCSQ_TAIL_REGNUM] = fp + 5 * DEPRECATED_REGISTER_SIZE;
-}
-
-void
-hppa_pop_frame (void)
-{
- struct frame_info *frame = get_current_frame ();
- CORE_ADDR fp, npc, target_pc;
- int regnum;
- CORE_ADDR *fsr;
- double freg_buffer;
-
- fp = get_frame_base (frame);
- hppa_frame_init_saved_regs (frame);
- fsr = deprecated_get_frame_saved_regs (frame);
-
-#ifndef NO_PC_SPACE_QUEUE_RESTORE
- if (fsr[IPSW_REGNUM]) /* Restoring a call dummy frame */
- restore_pc_queue (fsr);
-#endif
-
- for (regnum = 31; regnum > 0; regnum--)
- if (fsr[regnum])
- write_register (regnum, read_memory_integer (fsr[regnum],
- DEPRECATED_REGISTER_SIZE));
-
- for (regnum = NUM_REGS - 1; regnum >= FP0_REGNUM; regnum--)
- if (fsr[regnum])
- {
- read_memory (fsr[regnum], (char *) &freg_buffer, 8);
- deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (regnum),
- (char *) &freg_buffer, 8);
- }
-
- if (fsr[IPSW_REGNUM])
- write_register (IPSW_REGNUM,
- read_memory_integer (fsr[IPSW_REGNUM],
- DEPRECATED_REGISTER_SIZE));
-
- if (fsr[SAR_REGNUM])
- write_register (SAR_REGNUM,
- read_memory_integer (fsr[SAR_REGNUM],
- DEPRECATED_REGISTER_SIZE));
-
- /* If the PC was explicitly saved, then just restore it. */
- if (fsr[PCOQ_TAIL_REGNUM])
- {
- npc = read_memory_integer (fsr[PCOQ_TAIL_REGNUM],
- DEPRECATED_REGISTER_SIZE);
- write_register (PCOQ_TAIL_REGNUM, npc);
- }
- /* Else use the value in %rp to set the new PC. */
- else
- {
- npc = read_register (RP_REGNUM);
- write_pc (npc);
- }
-
- write_register (DEPRECATED_FP_REGNUM, read_memory_integer (fp, DEPRECATED_REGISTER_SIZE));
-
- if (fsr[IPSW_REGNUM]) /* call dummy */
- write_register (SP_REGNUM, fp - 48);
- else
- write_register (SP_REGNUM, fp);
-
- /* The PC we just restored may be inside a return trampoline. If so
- we want to restart the inferior and run it through the trampoline.
-
- Do this by setting a momentary breakpoint at the location the
- trampoline returns to.
-
- Don't skip through the trampoline if we're popping a dummy frame. */
- target_pc = SKIP_TRAMPOLINE_CODE (npc & ~0x3) & ~0x3;
- if (target_pc && !fsr[IPSW_REGNUM])
- {
- struct symtab_and_line sal;
- struct breakpoint *breakpoint;
- struct cleanup *old_chain;
-
- /* Set up our breakpoint. Set it to be silent as the MI code
- for "return_command" will print the frame we returned to. */
- sal = find_pc_line (target_pc, 0);
- sal.pc = target_pc;
- breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_finish);
- breakpoint->silent = 1;
-
- /* So we can clean things up. */
- old_chain = make_cleanup_delete_breakpoint (breakpoint);
-
- /* Start up the inferior. */
- clear_proceed_status ();
- proceed_to_finish = 1;
- proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
-
- /* Perform our cleanups. */
- do_cleanups (old_chain);
- }
- flush_cached_frames ();
-}
-
-/* After returning to a dummy on the stack, restore the instruction
- queue space registers. */
-
-static int
-restore_pc_queue (CORE_ADDR *fsr)
-{
- CORE_ADDR pc = read_pc ();
- CORE_ADDR new_pc = read_memory_integer (fsr[PCOQ_HEAD_REGNUM],
- TARGET_PTR_BIT / 8);
- struct target_waitstatus w;
- int insn_count;
-
- /* Advance past break instruction in the call dummy. */
- write_register (PCOQ_HEAD_REGNUM, pc + 4);
- write_register (PCOQ_TAIL_REGNUM, pc + 8);
-
- /* HPUX doesn't let us set the space registers or the space
- registers of the PC queue through ptrace. Boo, hiss.
- Conveniently, the call dummy has this sequence of instructions
- after the break:
- mtsp r21, sr0
- ble,n 0(sr0, r22)
-
- So, load up the registers and single step until we are in the
- right place. */
-
- write_register (21, read_memory_integer (fsr[PCSQ_HEAD_REGNUM],
- DEPRECATED_REGISTER_SIZE));
- write_register (22, new_pc);
-
- for (insn_count = 0; insn_count < 3; insn_count++)
- {
- /* FIXME: What if the inferior gets a signal right now? Want to
- merge this into wait_for_inferior (as a special kind of
- watchpoint? By setting a breakpoint at the end? Is there
- any other choice? Is there *any* way to do this stuff with
- ptrace() or some equivalent?). */
- resume (1, 0);
- target_wait (inferior_ptid, &w);
-
- if (w.kind == TARGET_WAITKIND_SIGNALLED)
- {
- stop_signal = w.value.sig;
- terminal_ours_for_output ();
- printf_unfiltered ("\nProgram terminated with signal %s, %s.\n",
- target_signal_to_name (stop_signal),
- target_signal_to_string (stop_signal));
- gdb_flush (gdb_stdout);
- return 0;
- }
- }
- target_terminal_ours ();
- target_fetch_registers (-1);
- return 1;
-}
-
-
-#ifdef PA20W_CALLING_CONVENTIONS
-
-/* This function pushes a stack frame with arguments as part of the
- inferior function calling mechanism.
-
- This is the version for the PA64, in which later arguments appear
- at higher addresses. (The stack always grows towards higher
- addresses.)
-
- We simply allocate the appropriate amount of stack space and put
- arguments into their proper slots. The call dummy code will copy
- arguments into registers as needed by the ABI.
-
- This ABI also requires that the caller provide an argument pointer
- to the callee, so we do that too. */
-
-CORE_ADDR
-hppa_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
-{
- /* array of arguments' offsets */
- int *offset = (int *) alloca (nargs * sizeof (int));
-
- /* array of arguments' lengths: real lengths in bytes, not aligned to
- word size */
- int *lengths = (int *) alloca (nargs * sizeof (int));
-
- /* The value of SP as it was passed into this function after
- aligning. */
- CORE_ADDR orig_sp = DEPRECATED_STACK_ALIGN (sp);
-
- /* The number of stack bytes occupied by the current argument. */
- int bytes_reserved;
-
- /* The total number of bytes reserved for the arguments. */
- int cum_bytes_reserved = 0;
-
- /* Similarly, but aligned. */
- int cum_bytes_aligned = 0;
- int i;
-
- /* Iterate over each argument provided by the user. */
- for (i = 0; i < nargs; i++)
- {
- struct type *arg_type = VALUE_TYPE (args[i]);
-
- /* Integral scalar values smaller than a register are padded on
- the left. We do this by promoting them to full-width,
- although the ABI says to pad them with garbage. */
- if (is_integral_type (arg_type)
- && TYPE_LENGTH (arg_type) < DEPRECATED_REGISTER_SIZE)
- {
- args[i] = value_cast ((TYPE_UNSIGNED (arg_type)
- ? builtin_type_unsigned_long
- : builtin_type_long),
- args[i]);
- arg_type = VALUE_TYPE (args[i]);
- }
-
- lengths[i] = TYPE_LENGTH (arg_type);
-
- /* Align the size of the argument to the word size for this
- target. */
- bytes_reserved = (lengths[i] + DEPRECATED_REGISTER_SIZE - 1) & -DEPRECATED_REGISTER_SIZE;
-
- offset[i] = cum_bytes_reserved;
-
- /* Aggregates larger than eight bytes (the only types larger
- than eight bytes we have) are aligned on a 16-byte boundary,
- possibly padded on the right with garbage. This may leave an
- empty word on the stack, and thus an unused register, as per
- the ABI. */
- if (bytes_reserved > 8)
- {
- /* Round up the offset to a multiple of two slots. */
- int new_offset = ((offset[i] + 2*DEPRECATED_REGISTER_SIZE-1)
- & -(2*DEPRECATED_REGISTER_SIZE));
-
- /* Note the space we've wasted, if any. */
- bytes_reserved += new_offset - offset[i];
- offset[i] = new_offset;
- }
-
- cum_bytes_reserved += bytes_reserved;
- }
-
- /* CUM_BYTES_RESERVED already accounts for all the arguments
- passed by the user. However, the ABIs mandate minimum stack space
- allocations for outgoing arguments.
-
- The ABIs also mandate minimum stack alignments which we must
- preserve. */
- cum_bytes_aligned = DEPRECATED_STACK_ALIGN (cum_bytes_reserved);
- sp += max (cum_bytes_aligned, REG_PARM_STACK_SPACE);
-
- /* Now write each of the args at the proper offset down the stack. */
- for (i = 0; i < nargs; i++)
- write_memory (orig_sp + offset[i], VALUE_CONTENTS (args[i]), lengths[i]);
-
- /* If a structure has to be returned, set up register 28 to hold its
- address */
- if (struct_return)
- write_register (28, struct_addr);
-
- /* For the PA64 we must pass a pointer to the outgoing argument list.
- The ABI mandates that the pointer should point to the first byte of
- storage beyond the register flushback area.
-
- However, the call dummy expects the outgoing argument pointer to
- be passed in register %r4. */
- write_register (4, orig_sp + REG_PARM_STACK_SPACE);
-
- /* ?!? This needs further work. We need to set up the global data
- pointer for this procedure. This assumes the same global pointer
- for every procedure. The call dummy expects the dp value to
- be passed in register %r6. */
- write_register (6, read_register (27));
-
- /* The stack will have 64 bytes of additional space for a frame marker. */
- return sp + 64;
-}
-
-#else
-
-/* This function pushes a stack frame with arguments as part of the
- inferior function calling mechanism.
-
- This is the version of the function for the 32-bit PA machines, in
- which later arguments appear at lower addresses. (The stack always
- grows towards higher addresses.)
-
- We simply allocate the appropriate amount of stack space and put
- arguments into their proper slots. The call dummy code will copy
- arguments into registers as needed by the ABI. */
-
-CORE_ADDR
-hppa_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
-{
- /* array of arguments' offsets */
- int *offset = (int *) alloca (nargs * sizeof (int));
-
- /* array of arguments' lengths: real lengths in bytes, not aligned to
- word size */
- int *lengths = (int *) alloca (nargs * sizeof (int));
-
- /* The number of stack bytes occupied by the current argument. */
- int bytes_reserved;
-
- /* The total number of bytes reserved for the arguments. */
- int cum_bytes_reserved = 0;
-
- /* Similarly, but aligned. */
- int cum_bytes_aligned = 0;
- int i;
-
- /* Iterate over each argument provided by the user. */
- for (i = 0; i < nargs; i++)
- {
- lengths[i] = TYPE_LENGTH (VALUE_TYPE (args[i]));
-
- /* Align the size of the argument to the word size for this
- target. */
- bytes_reserved = (lengths[i] + DEPRECATED_REGISTER_SIZE - 1) & -DEPRECATED_REGISTER_SIZE;
-
- offset[i] = (cum_bytes_reserved
- + (lengths[i] > 4 ? bytes_reserved : lengths[i]));
-
- /* If the argument is a double word argument, then it needs to be
- double word aligned. */
- if ((bytes_reserved == 2 * DEPRECATED_REGISTER_SIZE)
- && (offset[i] % 2 * DEPRECATED_REGISTER_SIZE))
- {
- int new_offset = 0;
- /* BYTES_RESERVED is already aligned to the word, so we put
- the argument at one word more down the stack.
-
- This will leave one empty word on the stack, and one unused
- register as mandated by the ABI. */
- new_offset = ((offset[i] + 2 * DEPRECATED_REGISTER_SIZE - 1)
- & -(2 * DEPRECATED_REGISTER_SIZE));
-
- if ((new_offset - offset[i]) >= 2 * DEPRECATED_REGISTER_SIZE)
- {
- bytes_reserved += DEPRECATED_REGISTER_SIZE;
- offset[i] += DEPRECATED_REGISTER_SIZE;
- }
- }
-
- cum_bytes_reserved += bytes_reserved;
-
- }
-
- /* CUM_BYTES_RESERVED already accounts for all the arguments passed
- by the user. However, the ABI mandates minimum stack space
- allocations for outgoing arguments.
-
- The ABI also mandates minimum stack alignments which we must
- preserve. */
- cum_bytes_aligned = DEPRECATED_STACK_ALIGN (cum_bytes_reserved);
- sp += max (cum_bytes_aligned, REG_PARM_STACK_SPACE);
-
- /* Now write each of the args at the proper offset down the stack.
- ?!? We need to promote values to a full register instead of skipping
- words in the stack. */
- for (i = 0; i < nargs; i++)
- write_memory (sp - offset[i], VALUE_CONTENTS (args[i]), lengths[i]);
-
- /* If a structure has to be returned, set up register 28 to hold its
- address */
- if (struct_return)
- write_register (28, struct_addr);
-
- /* The stack will have 32 bytes of additional space for a frame marker. */
- return sp + 32;
-}
-
-#endif
-
-/* This function pushes a stack frame with arguments as part of the
- inferior function calling mechanism.
-
- This is the version of the function for the 32-bit PA machines, in
- which later arguments appear at lower addresses. (The stack always
- grows towards higher addresses.)
-
- We simply allocate the appropriate amount of stack space and put
- arguments into their proper slots. */
-
-CORE_ADDR
-hppa32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
- struct regcache *regcache, CORE_ADDR bp_addr,
- int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
-{
- /* NOTE: cagney/2004-02-27: This is a guess - its implemented by
- reverse engineering testsuite failures. */
-
- /* Stack base address at which any pass-by-reference parameters are
- stored. */
- CORE_ADDR struct_end = 0;
- /* Stack base address at which the first parameter is stored. */
- CORE_ADDR param_end = 0;
-
- /* The inner most end of the stack after all the parameters have
- been pushed. */
- CORE_ADDR new_sp = 0;
-
- /* Two passes. First pass computes the location of everything,
- second pass writes the bytes out. */
- int write_pass;
- for (write_pass = 0; write_pass < 2; write_pass++)
- {
- CORE_ADDR struct_ptr = 0;
- CORE_ADDR param_ptr = 0;
- int reg = 27; /* NOTE: Registers go down. */
- int i;
- for (i = 0; i < nargs; i++)
- {
- struct value *arg = args[i];
- struct type *type = check_typedef (VALUE_TYPE (arg));
- /* The corresponding parameter that is pushed onto the
- stack, and [possibly] passed in a register. */
- char param_val[8];
- int param_len;
- memset (param_val, 0, sizeof param_val);
- if (TYPE_LENGTH (type) > 8)
- {
- /* Large parameter, pass by reference. Store the value
- in "struct" area and then pass its address. */
- param_len = 4;
- struct_ptr += align_up (TYPE_LENGTH (type), 8);
- if (write_pass)
- write_memory (struct_end - struct_ptr, VALUE_CONTENTS (arg),
- TYPE_LENGTH (type));
- store_unsigned_integer (param_val, 4, struct_end - struct_ptr);
- }
- else if (TYPE_CODE (type) == TYPE_CODE_INT
- || TYPE_CODE (type) == TYPE_CODE_ENUM)
- {
- /* Integer value store, right aligned. "unpack_long"
- takes care of any sign-extension problems. */
- param_len = align_up (TYPE_LENGTH (type), 4);
- store_unsigned_integer (param_val, param_len,
- unpack_long (type,
- VALUE_CONTENTS (arg)));
- }
- else
- {
- /* Small struct value, store right aligned? */
- param_len = align_up (TYPE_LENGTH (type), 4);
- memcpy (param_val + param_len - TYPE_LENGTH (type),
- VALUE_CONTENTS (arg), TYPE_LENGTH (type));
- }
- param_ptr += param_len;
- reg -= param_len / 4;
- if (write_pass)
- {
- write_memory (param_end - param_ptr, param_val, param_len);
- if (reg >= 23)
- {
- regcache_cooked_write (regcache, reg, param_val);
- if (param_len > 4)
- regcache_cooked_write (regcache, reg + 1, param_val + 4);
- }
- }
- }
-
- /* Update the various stack pointers. */
- if (!write_pass)
- {
- struct_end = sp + struct_ptr;
- /* PARAM_PTR already accounts for all the arguments passed
- by the user. However, the ABI mandates minimum stack
- space allocations for outgoing arguments. The ABI also
- mandates minimum stack alignments which we must
- preserve. */
- param_end = struct_end + max (align_up (param_ptr, 8),
- REG_PARM_STACK_SPACE);
- }
- }
-
- /* If a structure has to be returned, set up register 28 to hold its
- address */
- if (struct_return)
- write_register (28, struct_addr);
-
- /* Set the return address. */
- regcache_cooked_write_unsigned (regcache, RP_REGNUM, bp_addr);
-
- /* The stack will have 32 bytes of additional space for a frame marker. */
- return param_end + 32;
-}
-
-/* This function pushes a stack frame with arguments as part of the
- inferior function calling mechanism.
-
- This is the version for the PA64, in which later arguments appear
- at higher addresses. (The stack always grows towards higher
- addresses.)
-
- We simply allocate the appropriate amount of stack space and put
- arguments into their proper slots.
-
- This ABI also requires that the caller provide an argument pointer
- to the callee, so we do that too. */
-
-CORE_ADDR
-hppa64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
- struct regcache *regcache, CORE_ADDR bp_addr,
- int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
-{
- /* Array of arguments' offsets. */
- int *offset = (int *) alloca (nargs * sizeof (int));
-
- /* Array of arguments' lengths: real lengths in bytes, not aligned
- to word size. */
- int *lengths = (int *) alloca (nargs * sizeof (int));
-
- /* The value of SP as it was passed into this function. */
- CORE_ADDR orig_sp = sp;
-
- /* The number of stack bytes occupied by the current argument. */
- int bytes_reserved;
-
- /* The total number of bytes reserved for the arguments. */
- int cum_bytes_reserved = 0;
-
- /* Similarly, but aligned. */
- int cum_bytes_aligned = 0;
- int i;
-
- /* Iterate over each argument provided by the user. */
- for (i = 0; i < nargs; i++)
- {
- struct type *arg_type = VALUE_TYPE (args[i]);
-
- /* Integral scalar values smaller than a register are padded on
- the left. We do this by promoting them to full-width,
- although the ABI says to pad them with garbage. */
- if (is_integral_type (arg_type)
- && TYPE_LENGTH (arg_type) < DEPRECATED_REGISTER_SIZE)
- {
- args[i] = value_cast ((TYPE_UNSIGNED (arg_type)
- ? builtin_type_unsigned_long
- : builtin_type_long),
- args[i]);
- arg_type = VALUE_TYPE (args[i]);
- }
-
- lengths[i] = TYPE_LENGTH (arg_type);
-
- /* Align the size of the argument to the word size for this
- target. */
- bytes_reserved = (lengths[i] + DEPRECATED_REGISTER_SIZE - 1) & -DEPRECATED_REGISTER_SIZE;
-
- offset[i] = cum_bytes_reserved;
-
- /* Aggregates larger than eight bytes (the only types larger
- than eight bytes we have) are aligned on a 16-byte boundary,
- possibly padded on the right with garbage. This may leave an
- empty word on the stack, and thus an unused register, as per
- the ABI. */
- if (bytes_reserved > 8)
- {
- /* Round up the offset to a multiple of two slots. */
- int new_offset = ((offset[i] + 2*DEPRECATED_REGISTER_SIZE-1)
- & -(2*DEPRECATED_REGISTER_SIZE));
-
- /* Note the space we've wasted, if any. */
- bytes_reserved += new_offset - offset[i];
- offset[i] = new_offset;
- }
-
- cum_bytes_reserved += bytes_reserved;
- }
-
- /* CUM_BYTES_RESERVED already accounts for all the arguments passed
- by the user. However, the ABIs mandate minimum stack space
- allocations for outgoing arguments.
-
- The ABIs also mandate minimum stack alignments which we must
- preserve. */
- cum_bytes_aligned = align_up (cum_bytes_reserved, 16);
- sp += max (cum_bytes_aligned, REG_PARM_STACK_SPACE);
-
- /* Now write each of the args at the proper offset down the
- stack. */
- for (i = 0; i < nargs; i++)
- write_memory (orig_sp + offset[i], VALUE_CONTENTS (args[i]), lengths[i]);
-
- /* If a structure has to be returned, set up register 28 to hold its
- address */
- if (struct_return)
- write_register (28, struct_addr);
-
- /* For the PA64 we must pass a pointer to the outgoing argument
- list. The ABI mandates that the pointer should point to the
- first byte of storage beyond the register flushback area.
-
- However, the call dummy expects the outgoing argument pointer to
- be passed in register %r4. */
- write_register (4, orig_sp + REG_PARM_STACK_SPACE);
-
- /* ?!? This needs further work. We need to set up the global data
- pointer for this procedure. This assumes the same global pointer
- for every procedure. The call dummy expects the dp value to be
- passed in register %r6. */
- write_register (6, read_register (27));
-
- /* Set the return address. */
- regcache_cooked_write_unsigned (regcache, RP_REGNUM, bp_addr);
-
- /* The stack will have 64 bytes of additional space for a frame
- marker. */
- return sp + 64;
-
-}
-
-static CORE_ADDR
-hppa32_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
-{
- /* HP frames are 64-byte (or cache line) aligned (yes that's _byte_
- and not _bit_)! */
- return align_up (addr, 64);
-}
-
-/* Force all frames to 16-byte alignment. Better safe than sorry. */
-
-static CORE_ADDR
-hppa64_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
-{
- /* Just always 16-byte align. */
- return align_up (addr, 16);
-}
-
-
-/* elz: Used to lookup a symbol in the shared libraries.
- This function calls shl_findsym, indirectly through a
- call to __d_shl_get. __d_shl_get is in end.c, which is always
- linked in by the hp compilers/linkers.
- The call to shl_findsym cannot be made directly because it needs
- to be active in target address space.
- inputs: - minimal symbol pointer for the function we want to look up
- - address in target space of the descriptor for the library
- where we want to look the symbol up.
- This address is retrieved using the
- som_solib_get_solib_by_pc function (somsolib.c).
- output: - real address in the library of the function.
- note: the handle can be null, in which case shl_findsym will look for
- the symbol in all the loaded shared libraries.
- files to look at if you need reference on this stuff:
- dld.c, dld_shl_findsym.c
- end.c
- man entry for shl_findsym */
-
-CORE_ADDR
-find_stub_with_shl_get (struct minimal_symbol *function, CORE_ADDR handle)
-{
- struct symbol *get_sym, *symbol2;
- struct minimal_symbol *buff_minsym, *msymbol;
- struct type *ftype;
- struct value **args;
- struct value *funcval;
- struct value *val;
-
- int x, namelen, err_value, tmp = -1;
- CORE_ADDR endo_buff_addr, value_return_addr, errno_return_addr;
- CORE_ADDR stub_addr;
-
-
- args = alloca (sizeof (struct value *) * 8); /* 6 for the arguments and one null one??? */
- funcval = find_function_in_inferior ("__d_shl_get");
- get_sym = lookup_symbol ("__d_shl_get", NULL, VAR_DOMAIN, NULL, NULL);
- buff_minsym = lookup_minimal_symbol ("__buffer", NULL, NULL);
- msymbol = lookup_minimal_symbol ("__shldp", NULL, NULL);
- symbol2 = lookup_symbol ("__shldp", NULL, VAR_DOMAIN, NULL, NULL);
- endo_buff_addr = SYMBOL_VALUE_ADDRESS (buff_minsym);
- namelen = strlen (DEPRECATED_SYMBOL_NAME (function));
- value_return_addr = endo_buff_addr + namelen;
- ftype = check_typedef (SYMBOL_TYPE (get_sym));
-
- /* do alignment */
- if ((x = value_return_addr % 64) != 0)
- value_return_addr = value_return_addr + 64 - x;
-
- errno_return_addr = value_return_addr + 64;
-
-
- /* set up stuff needed by __d_shl_get in buffer in end.o */
-
- target_write_memory (endo_buff_addr, DEPRECATED_SYMBOL_NAME (function), namelen);
-
- target_write_memory (value_return_addr, (char *) &tmp, 4);
-
- target_write_memory (errno_return_addr, (char *) &tmp, 4);
-
- target_write_memory (SYMBOL_VALUE_ADDRESS (msymbol),
- (char *) &handle, 4);
-
- /* now prepare the arguments for the call */
-
- args[0] = value_from_longest (TYPE_FIELD_TYPE (ftype, 0), 12);
- args[1] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 1), SYMBOL_VALUE_ADDRESS (msymbol));
- args[2] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 2), endo_buff_addr);
- args[3] = value_from_longest (TYPE_FIELD_TYPE (ftype, 3), TYPE_PROCEDURE);
- args[4] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 4), value_return_addr);
- args[5] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 5), errno_return_addr);
-
- /* now call the function */
-
- val = call_function_by_hand (funcval, 6, args);
-
- /* now get the results */
-
- target_read_memory (errno_return_addr, (char *) &err_value, sizeof (err_value));
-
- target_read_memory (value_return_addr, (char *) &stub_addr, sizeof (stub_addr));
- if (stub_addr <= 0)
- error ("call to __d_shl_get failed, error code is %d", err_value);
-
- return (stub_addr);
-}
-
-/* Cover routine for find_stub_with_shl_get to pass to catch_errors */
-static int
-cover_find_stub_with_shl_get (void *args_untyped)
-{
- args_for_find_stub *args = args_untyped;
- args->return_val = find_stub_with_shl_get (args->msym, args->solib_handle);
- return 0;
-}
-
-/* Insert the specified number of args and function address
- into a call sequence of the above form stored at DUMMYNAME.
-
- On the hppa we need to call the stack dummy through $$dyncall.
- Therefore our version of DEPRECATED_FIX_CALL_DUMMY takes an extra
- argument, real_pc, which is the location where gdb should start up
- the inferior to do the function call.
-
- This has to work across several versions of hpux, bsd, osf1. It has to
- work regardless of what compiler was used to build the inferior program.
- It should work regardless of whether or not end.o is available. It has
- to work even if gdb can not call into the dynamic loader in the inferior
- to query it for symbol names and addresses.
-
- Yes, all those cases should work. Luckily code exists to handle most
- of them. The complexity is in selecting exactly what scheme should
- be used to perform the inferior call.
-
- At the current time this routine is known not to handle cases where
- the program was linked with HP's compiler without including end.o.
-
- Please contact Jeff Law (law@cygnus.com) before changing this code. */
-
-CORE_ADDR
-hppa_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
- struct value **args, struct type *type, int gcc_p)
-{
- CORE_ADDR dyncall_addr;
- struct minimal_symbol *msymbol;
- struct minimal_symbol *trampoline;
- int flags = read_register (FLAGS_REGNUM);
- struct unwind_table_entry *u = NULL;
- CORE_ADDR new_stub = 0;
- CORE_ADDR solib_handle = 0;
-
- /* Nonzero if we will use GCC's PLT call routine. This routine must be
- passed an import stub, not a PLABEL. It is also necessary to set %r19
- (the PIC register) before performing the call.
-
- If zero, then we are using __d_plt_call (HP's PLT call routine) or we
- are calling the target directly. When using __d_plt_call we want to
- use a PLABEL instead of an import stub. */
- int using_gcc_plt_call = 1;
-
-#ifdef GDB_TARGET_IS_HPPA_20W
- /* We currently use completely different code for the PA2.0W inferior
- function call sequences. This needs to be cleaned up. */
- {
- CORE_ADDR pcsqh, pcsqt, pcoqh, pcoqt, sr5;
- struct target_waitstatus w;
- int inst1, inst2;
- char buf[4];
- int status;
- struct objfile *objfile;
-
- /* We can not modify the PC space queues directly, so we start
- up the inferior and execute a couple instructions to set the
- space queues so that they point to the call dummy in the stack. */
- pcsqh = read_register (PCSQ_HEAD_REGNUM);
- sr5 = read_register (SR5_REGNUM);
- if (1)
- {
- pcoqh = read_register (PCOQ_HEAD_REGNUM);
- pcoqt = read_register (PCOQ_TAIL_REGNUM);
- if (target_read_memory (pcoqh, buf, 4) != 0)
- error ("Couldn't modify space queue\n");
- inst1 = extract_unsigned_integer (buf, 4);
-
- if (target_read_memory (pcoqt, buf, 4) != 0)
- error ("Couldn't modify space queue\n");
- inst2 = extract_unsigned_integer (buf, 4);
-
- /* BVE (r1) */
- *((int *) buf) = 0xe820d000;
- if (target_write_memory (pcoqh, buf, 4) != 0)
- error ("Couldn't modify space queue\n");
-
- /* NOP */
- *((int *) buf) = 0x08000240;
- if (target_write_memory (pcoqt, buf, 4) != 0)
- {
- *((int *) buf) = inst1;
- target_write_memory (pcoqh, buf, 4);
- error ("Couldn't modify space queue\n");
- }
-
- write_register (1, pc);
-
- /* Single step twice, the BVE instruction will set the space queue
- such that it points to the PC value written immediately above
- (ie the call dummy). */
- resume (1, 0);
- target_wait (inferior_ptid, &w);
- resume (1, 0);
- target_wait (inferior_ptid, &w);
-
- /* Restore the two instructions at the old PC locations. */
- *((int *) buf) = inst1;
- target_write_memory (pcoqh, buf, 4);
- *((int *) buf) = inst2;
- target_write_memory (pcoqt, buf, 4);
- }
-
- /* The call dummy wants the ultimate destination address initially
- in register %r5. */
- write_register (5, fun);
-
- /* We need to see if this objfile has a different DP value than our
- own (it could be a shared library for example). */
- ALL_OBJFILES (objfile)
- {
- struct obj_section *s;
- obj_private_data_t *obj_private;
-
- /* See if FUN is in any section within this shared library. */
- for (s = objfile->sections; s < objfile->sections_end; s++)
- if (s->addr <= fun && fun < s->endaddr)
- break;
-
- if (s >= objfile->sections_end)
- continue;
-
- obj_private = (obj_private_data_t *) objfile->obj_private;
-
- /* The DP value may be different for each objfile. But within an
- objfile each function uses the same dp value. Thus we do not need
- to grope around the opd section looking for dp values.
-
- ?!? This is not strictly correct since we may be in a shared library
- and want to call back into the main program. To make that case
- work correctly we need to set obj_private->dp for the main program's
- objfile, then remove this conditional. */
- if (obj_private->dp)
- write_register (27, obj_private->dp);
- break;
- }
- return pc;
- }
-#endif
-
-#ifndef GDB_TARGET_IS_HPPA_20W
- /* Prefer __gcc_plt_call over the HP supplied routine because
- __gcc_plt_call works for any number of arguments. */
- trampoline = NULL;
- if (lookup_minimal_symbol ("__gcc_plt_call", NULL, NULL) == NULL)
- using_gcc_plt_call = 0;
-
- msymbol = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
- if (msymbol == NULL)
- error ("Can't find an address for $$dyncall trampoline");
-
- dyncall_addr = SYMBOL_VALUE_ADDRESS (msymbol);
-
- /* FUN could be a procedure label, in which case we have to get
- its real address and the value of its GOT/DP if we plan to
- call the routine via gcc_plt_call. */
- if ((fun & 0x2) && using_gcc_plt_call)
- {
- /* Get the GOT/DP value for the target function. It's
- at *(fun+4). Note the call dummy is *NOT* allowed to
- trash %r19 before calling the target function. */
- write_register (19, read_memory_integer ((fun & ~0x3) + 4,
- DEPRECATED_REGISTER_SIZE));
-
- /* Now get the real address for the function we are calling, it's
- at *fun. */
- fun = (CORE_ADDR) read_memory_integer (fun & ~0x3,
- TARGET_PTR_BIT / 8);
- }
- else
- {
-
-#ifndef GDB_TARGET_IS_PA_ELF
- /* FUN could be an export stub, the real address of a function, or
- a PLABEL. When using gcc's PLT call routine we must call an import
- stub rather than the export stub or real function for lazy binding
- to work correctly
-
- If we are using the gcc PLT call routine, then we need to
- get the import stub for the target function. */
- if (using_gcc_plt_call && som_solib_get_got_by_pc (fun))
- {
- struct objfile *objfile;
- struct minimal_symbol *funsymbol, *stub_symbol;
- CORE_ADDR newfun = 0;
-
- funsymbol = lookup_minimal_symbol_by_pc (fun);
- if (!funsymbol)
- error ("Unable to find minimal symbol for target function.\n");
-
- /* Search all the object files for an import symbol with the
- right name. */
- ALL_OBJFILES (objfile)
- {
- stub_symbol
- = lookup_minimal_symbol_solib_trampoline
- (DEPRECATED_SYMBOL_NAME (funsymbol), objfile);
-
- if (!stub_symbol)
- stub_symbol = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (funsymbol),
- NULL, objfile);
-
- /* Found a symbol with the right name. */
- if (stub_symbol)
- {
- struct unwind_table_entry *u;
- /* It must be a shared library trampoline. */
- if (MSYMBOL_TYPE (stub_symbol) != mst_solib_trampoline)
- continue;
-
- /* It must also be an import stub. */
- u = find_unwind_entry (SYMBOL_VALUE (stub_symbol));
- if (u == NULL
- || (u->stub_unwind.stub_type != IMPORT
-#ifdef GDB_NATIVE_HPUX_11
- /* Sigh. The hpux 10.20 dynamic linker will blow
- chunks if we perform a call to an unbound function
- via the IMPORT_SHLIB stub. The hpux 11.00 dynamic
- linker will blow chunks if we do not call the
- unbound function via the IMPORT_SHLIB stub.
-
- We currently have no way to select bevahior on just
- the target. However, we only support HPUX/SOM in
- native mode. So we conditinalize on a native
- #ifdef. Ugly. Ugly. Ugly */
- && u->stub_unwind.stub_type != IMPORT_SHLIB
-#endif
- ))
- continue;
-
- /* OK. Looks like the correct import stub. */
- newfun = SYMBOL_VALUE (stub_symbol);
- fun = newfun;
-
- /* If we found an IMPORT stub, then we want to stop
- searching now. If we found an IMPORT_SHLIB, we want
- to continue the search in the hopes that we will find
- an IMPORT stub. */
- if (u->stub_unwind.stub_type == IMPORT)
- break;
- }
- }
-
- /* Ouch. We did not find an import stub. Make an attempt to
- do the right thing instead of just croaking. Most of the
- time this will actually work. */
- if (newfun == 0)
- write_register (19, som_solib_get_got_by_pc (fun));
-
- u = find_unwind_entry (fun);
- if (u
- && (u->stub_unwind.stub_type == IMPORT
- || u->stub_unwind.stub_type == IMPORT_SHLIB))
- trampoline = lookup_minimal_symbol ("__gcc_plt_call", NULL, NULL);
-
- /* If we found the import stub in the shared library, then we have
- to set %r19 before we call the stub. */
- if (u && u->stub_unwind.stub_type == IMPORT_SHLIB)
- write_register (19, som_solib_get_got_by_pc (fun));
- }
-#endif
- }
-
- /* If we are calling into another load module then have sr4export call the
- magic __d_plt_call routine which is linked in from end.o.
-
- You can't use _sr4export to make the call as the value in sp-24 will get
- fried and you end up returning to the wrong location. You can't call the
- target as the code to bind the PLT entry to a function can't return to a
- stack address.
-
- Also, query the dynamic linker in the inferior to provide a suitable
- PLABEL for the target function. */
- if (!using_gcc_plt_call)
- {
- CORE_ADDR new_fun;
-
- /* Get a handle for the shared library containing FUN. Given the
- handle we can query the shared library for a PLABEL. */
- solib_handle = som_solib_get_solib_by_pc (fun);
-
- if (solib_handle)
- {
- struct minimal_symbol *fmsymbol = lookup_minimal_symbol_by_pc (fun);
-
- trampoline = lookup_minimal_symbol ("__d_plt_call", NULL, NULL);
-
- if (trampoline == NULL)
- {
- error ("Can't find an address for __d_plt_call or __gcc_plt_call trampoline\nSuggest linking executable with -g or compiling with gcc.");
- }
-
- /* This is where sr4export will jump to. */
- new_fun = SYMBOL_VALUE_ADDRESS (trampoline);
-
- /* If the function is in a shared library, then call __d_shl_get to
- get a PLABEL for the target function. */
- new_stub = find_stub_with_shl_get (fmsymbol, solib_handle);
-
- if (new_stub == 0)
- error ("Can't find an import stub for %s", DEPRECATED_SYMBOL_NAME (fmsymbol));
-
- /* We have to store the address of the stub in __shlib_funcptr. */
- msymbol = lookup_minimal_symbol ("__shlib_funcptr", NULL,
- (struct objfile *) NULL);
-
- if (msymbol == NULL)
- error ("Can't find an address for __shlib_funcptr");
- target_write_memory (SYMBOL_VALUE_ADDRESS (msymbol),
- (char *) &new_stub, 4);
-
- /* We want sr4export to call __d_plt_call, so we claim it is
- the final target. Clear trampoline. */
- fun = new_fun;
- trampoline = NULL;
- }
- }
-
- /* Store upper 21 bits of function address into ldil. fun will either be
- the final target (most cases) or __d_plt_call when calling into a shared
- library and __gcc_plt_call is not available. */
- store_unsigned_integer
- (&dummy[FUNC_LDIL_OFFSET],
- INSTRUCTION_SIZE,
- deposit_21 (fun >> 11,
- extract_unsigned_integer (&dummy[FUNC_LDIL_OFFSET],
- INSTRUCTION_SIZE)));
-
- /* Store lower 11 bits of function address into ldo */
- store_unsigned_integer
- (&dummy[FUNC_LDO_OFFSET],
- INSTRUCTION_SIZE,
- deposit_14 (fun & MASK_11,
- extract_unsigned_integer (&dummy[FUNC_LDO_OFFSET],
- INSTRUCTION_SIZE)));
-#ifdef SR4EXPORT_LDIL_OFFSET
-
- {
- CORE_ADDR trampoline_addr;
-
- /* We may still need sr4export's address too. */
-
- if (trampoline == NULL)
- {
- msymbol = lookup_minimal_symbol ("_sr4export", NULL, NULL);
- if (msymbol == NULL)
- error ("Can't find an address for _sr4export trampoline");
-
- trampoline_addr = SYMBOL_VALUE_ADDRESS (msymbol);
- }
- else
- trampoline_addr = SYMBOL_VALUE_ADDRESS (trampoline);
-
-
- /* Store upper 21 bits of trampoline's address into ldil */
- store_unsigned_integer
- (&dummy[SR4EXPORT_LDIL_OFFSET],
- INSTRUCTION_SIZE,
- deposit_21 (trampoline_addr >> 11,
- extract_unsigned_integer (&dummy[SR4EXPORT_LDIL_OFFSET],
- INSTRUCTION_SIZE)));
-
- /* Store lower 11 bits of trampoline's address into ldo */
- store_unsigned_integer
- (&dummy[SR4EXPORT_LDO_OFFSET],
- INSTRUCTION_SIZE,
- deposit_14 (trampoline_addr & MASK_11,
- extract_unsigned_integer (&dummy[SR4EXPORT_LDO_OFFSET],
- INSTRUCTION_SIZE)));
- }
-#endif
-
- write_register (22, pc);
-
- /* If we are in a syscall, then we should call the stack dummy
- directly. $$dyncall is not needed as the kernel sets up the
- space id registers properly based on the value in %r31. In
- fact calling $$dyncall will not work because the value in %r22
- will be clobbered on the syscall exit path.
-
- Similarly if the current PC is in a shared library. Note however,
- this scheme won't work if the shared library isn't mapped into
- the same space as the stack. */
- if (flags & 2)
- return pc;
-#ifndef GDB_TARGET_IS_PA_ELF
- else if (som_solib_get_got_by_pc (hppa_target_read_pc (inferior_ptid)))
- return pc;
-#endif
- else
- return dyncall_addr;
-#endif
-}
-
-/* If the pid is in a syscall, then the FP register is not readable.
- We'll return zero in that case, rather than attempting to read it
- and cause a warning. */
-
-CORE_ADDR
-hppa_read_fp (int pid)
-{
- int flags = read_register (FLAGS_REGNUM);
-
- if (flags & 2)
- {
- return (CORE_ADDR) 0;
- }
-
- /* This is the only site that may directly read_register () the FP
- register. All others must use deprecated_read_fp (). */
- return read_register (DEPRECATED_FP_REGNUM);
-}
-
-CORE_ADDR
-hppa_target_read_fp (void)
-{
- return hppa_read_fp (PIDGET (inferior_ptid));
-}
-
-/* Get the PC from %r31 if currently in a syscall. Also mask out privilege
- bits. */
-
-CORE_ADDR
-hppa_target_read_pc (ptid_t ptid)
-{
- int flags = read_register_pid (FLAGS_REGNUM, ptid);
-
- /* The following test does not belong here. It is OS-specific, and belongs
- in native code. */
- /* Test SS_INSYSCALL */
- if (flags & 2)
- return read_register_pid (31, ptid) & ~0x3;
-
- return read_register_pid (PC_REGNUM, ptid) & ~0x3;
-}
-
-/* Write out the PC. If currently in a syscall, then also write the new
- PC value into %r31. */
-
-void
-hppa_target_write_pc (CORE_ADDR v, ptid_t ptid)
-{
- int flags = read_register_pid (FLAGS_REGNUM, ptid);
-
- /* The following test does not belong here. It is OS-specific, and belongs
- in native code. */
- /* If in a syscall, then set %r31. Also make sure to get the
- privilege bits set correctly. */
- /* Test SS_INSYSCALL */
- if (flags & 2)
- write_register_pid (31, v | 0x3, ptid);
-
- write_register_pid (PC_REGNUM, v, ptid);
- write_register_pid (PCOQ_TAIL_REGNUM, v + 4, ptid);
-}
-
-/* return the alignment of a type in bytes. Structures have the maximum
- alignment required by their fields. */
-
-static int
-hppa_alignof (struct type *type)
-{
- int max_align, align, i;
- CHECK_TYPEDEF (type);
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_PTR:
- case TYPE_CODE_INT:
- case TYPE_CODE_FLT:
- return TYPE_LENGTH (type);
- case TYPE_CODE_ARRAY:
- return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
- case TYPE_CODE_STRUCT:
- case TYPE_CODE_UNION:
- max_align = 1;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
- {
- /* Bit fields have no real alignment. */
- /* if (!TYPE_FIELD_BITPOS (type, i)) */
- if (!TYPE_FIELD_BITSIZE (type, i)) /* elz: this should be bitsize */
- {
- align = hppa_alignof (TYPE_FIELD_TYPE (type, i));
- max_align = max (max_align, align);
- }
- }
- return max_align;
- default:
- return 4;
- }
-}
-
-/* Print the register regnum, or all registers if regnum is -1 */
-
-void
-pa_do_registers_info (int regnum, int fpregs)
-{
- char *raw_regs = alloca (DEPRECATED_REGISTER_BYTES);
- int i;
-
- /* Make a copy of gdb's save area (may cause actual
- reads from the target). */
- for (i = 0; i < NUM_REGS; i++)
- frame_register_read (deprecated_selected_frame, i,
- raw_regs + DEPRECATED_REGISTER_BYTE (i));
-
- if (regnum == -1)
- pa_print_registers (raw_regs, regnum, fpregs);
- else if (regnum < FP4_REGNUM)
- {
- long reg_val[2];
-
- /* Why is the value not passed through "extract_signed_integer"
- as in "pa_print_registers" below? */
- pa_register_look_aside (raw_regs, regnum, ®_val[0]);
-
- if (!is_pa_2)
- {
- printf_unfiltered ("%s %lx\n", REGISTER_NAME (regnum), reg_val[1]);
- }
- else
- {
- /* Fancy % formats to prevent leading zeros. */
- if (reg_val[0] == 0)
- printf_unfiltered ("%s %lx\n", REGISTER_NAME (regnum), reg_val[1]);
- else
- printf_unfiltered ("%s %lx%8.8lx\n", REGISTER_NAME (regnum),
- reg_val[0], reg_val[1]);
- }
- }
- else
- /* Note that real floating point values only start at
- FP4_REGNUM. FP0 and up are just status and error
- registers, which have integral (bit) values. */
- pa_print_fp_reg (regnum);
-}
-
-/********** new function ********************/
-void
-pa_do_strcat_registers_info (int regnum, int fpregs, struct ui_file *stream,
- enum precision_type precision)
-{
- char *raw_regs = alloca (DEPRECATED_REGISTER_BYTES);
- int i;
-
- /* Make a copy of gdb's save area (may cause actual
- reads from the target). */
- for (i = 0; i < NUM_REGS; i++)
- frame_register_read (deprecated_selected_frame, i,
- raw_regs + DEPRECATED_REGISTER_BYTE (i));
-
- if (regnum == -1)
- pa_strcat_registers (raw_regs, regnum, fpregs, stream);
-
- else if (regnum < FP4_REGNUM)
- {
- long reg_val[2];