Ejemplo n.º 1
0
int main (int argc, char **argv) {
   print_uname ();
   int main_local;
   xprintf ("\n");
   PRINT (NULL, "null pointer");

   xprintf ("\nAddresses of some local variables:\n");
   stack (1);
   PRINT (&main_local, "address of a local variable in main");
   PRINT (&argc, "address of argc");
   PRINT (&argv, "address of argv");
   PRINT (argv, "address of arg vector");
   PRINT (environ, "address of environ vector");
   PRINT (stack_bottom (environ), "byte at bottom of stack");

   xprintf ("\nAddresses of some static variables:\n");
   PRINT (printf, "(text) address of the printf() function");
   PRINT (&_start, "start of program text");
   PRINT (main, "(text) address of the main() function");
   PRINT (&_etext, "end of program text");
   PRINT (&init_var, "address of an init static variable");
   PRINT (&_edata, "end of init data segment");
   PRINT (&uninit_var1, "address of an uninit static variable1");
   PRINT (&uninit_var2, "address of an uninit static variable2");
   PRINT (&_end, "end of uninit data segment");

   xprintf ("\nAddresses of some heap variables:\n");
   for (int heap_count = 0; heap_count < 10; ++heap_count) {
      void *heap_variable = calloc (1000, sizeof (int));
      assert (heap_variable != NULL);
      char *message = fmt ("heap variable ", heap_count);
      PRINT (heap_variable, message);
      free (message);
   }

   return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
void tw2_stack_review (void)
{
	unsigned int i=0;
	char *ps;
	NODE2* sb;

	sb = StackTW->bottom;
	if (!sb) {
		printf ("** 번역된 문장이 없습니다.\n");
		return;
	}

	while (true) {
		if (!StackTW->bottom) StackTW->bottom = sb;	//계속 반복

		ps = (char*)stack_bottom (StackTW, FLAG_VIEW);
		printf ("%s\n", ps);

		time_sleep (str_len (ps) / 10);	//문장길이에 따라서 대기

		if (!(++i%8) && tw1_qn_answer ("* Would you like to see more? [Y/n] ", FLAG_YES) == FLAG_NO) break;
	}
	StackTW->bottom = sb;
}
Ejemplo n.º 3
0
 intptr_t data_offset() const {
   if(status_ != eOnHeap) return 0;
   return (intptr_t)heap_ - (intptr_t)stack_bottom();
 }