Skip to contentSkip to conversation

kgdb internet/ethernet support and {gcc or gdb} bug on test addresses on ia64 port

Linux-ia64 Keith Owens 1 participant 1 message Jan 3, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines · Piet/Pete Delaney

#include <stdio.h>

typedef struct disassemble_info {
       void (*fprintf_func)();
} disassemble_info_t;

disassemble_info_t disinfo;

void my_printf(void)

{
       (void) printf("Hello World\n");
}
Quoted 7 lines

main(void)

{
       disinfo.fprintf_func = my_printf;
       printf("my_printf is at 0x%llx.\n", my_printf);
       printf("disinfo is at 0x%llx.\n", &disinfo);
       disinfo.fprintf_func();
}

You are printing the address of the ia64 function descriptor, not the function itself.

        printf("&my_printf is at 0x%llx.\n", &my_printf);
	printf("my_printf is at 0x%llx.\n", ((unsigned long *)(&my_printf))[0]);

&my_printf is at 0x40000000000009f0.
my_printf is at 0x4000000000000690.
disinfo is at 0x6000000000000dd8.
Hello World

(gdb) disassemble my_printf
Dump of assembler code for function my_printf:
0x4000000000000690 <my_printf>: [MII] alloc r34=ar.pfs,5,4,0
0x4000000000000691 <my_printf+1>: mov r35=r12
0x4000000000000692 <my_printf+2>: mov r33°

(gdb) disassemble 0x4000000000000690
Dump of assembler code for function my_printf:
0x4000000000000690 <my_printf>: [MII] alloc r34=ar.pfs,5,4,0
0x4000000000000691 <my_printf+1>: mov r35=r12
0x4000000000000692 <my_printf+2>: mov r33°