This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Still on ethernet configuration


On Wed, 2002-10-16 at 12:33, Cristiano Pereira wrote:
> Done. Now I'm using the latest CVS version. The problem persists unchanged. 
> How will the "bt" command tell me whether the stack is corrupted or not?
> 
> Sometimes I have the impression that things are getting executed twice when 
> I'm debugging. Look at this example:
> 
> Breakpoint 1, i82559_configure (p_i82559=0xc006994c, promisc=0, oversized=1,
>     multicast_all=0)
>     at
> /opt/ecoscvs.10-13-2002/ecos/packages/devs/eth/intel/i82559/current/src/if_i82559.c:3180
> 3180        OUTL(VIRT_TO_BUS(p_i82559->rx_ring[0]), ioaddr + SCBPointer);
> (gdb) n
> 340         HAL_WRITE_UINT16( io_address, (((value & 0xff) << 8) | ((value & 
> 0xff00) >> 8)) );
> (gdb) n
> 3183        return 0;
> (gdb) s
> 3180        OUTL(VIRT_TO_BUS(p_i82559->rx_ring[0]), ioaddr + SCBPointer);
> (gdb) s
> 345         HAL_WRITE_UINT32( io_address,
> (gdb) s
> 340         HAL_WRITE_UINT16( io_address, (((value & 0xff) << 8) | ((value & 
> 0xff00) >> 8)) );
> (gdb) s
> 3183        return 0;
> (gdb) bt
> #0  i82559_configure (p_i82559=0xc006994c, promisc=393216, oversized=1,
>     multicast_all=0)
>     at 
> /opt/ecoscvs.10-13-2002/ecos/packages/devs/eth/intel/i82559/current/src/if_i82559.c:3183
> #1  0xc0021594 in i82559_start (sc=0xc0069fd4, enaddr=0xc50600 "",
>     flags=-1073298004)
>     at 
> /opt/ecoscvs.10-13-2002/ecos/packages/devs/eth/intel/i82559/current/src/if_i82559.c:1619
> #2  0xc011baf8 in stack ()
> (gdb) s
> 

This is simply an artifact of debugging optimized code.

> I set a breakpoint in the function i82559_configure at line 3180. When
> I step through it it seems to execute statements 3180 and 3183 twice.
> Am I missing something silly or this is some sort of weird behavior
> (I'm not very used to debug things using GDB so the question might be
> silly)?
> 
> I'm also issuing the "bt" command but honestly I don't see how it tells me 
> whether the stack is good or not. After the last "s" command
> the program never returns.
> 

Why not try making the stack bigger?  If that changes things, then
you definitely had a stack size problem.  If nothing changes, then 
you've at least reduced the possibilities.

Alternatively, you could use the stack monitoring stuff in the file 
".../kernel/current/include/test/stackmon.h"  (just copy it to the
directory which contains your code).  I've attached my test code 
based on your program which shows how to use it.

-- 
------------------------------------------------------------
Gary Thomas                  |
eCosCentric, Ltd.            |  
+1 (970) 229-1963            |  eCos & RedBoot experts
gthomas@ecoscentric.com      |
http://www.ecoscentric.com/  |
------------------------------------------------------------
#include <stdio.h>
#include <cyg/kernel/kapi.h>
#include <pkgconf/net.h>
#include <network.h>
#include "stackmon.h"

#define STACK_SIZE 4096


cyg_thread thread_s; /* space for two thread objects */
char stack[STACK_SIZE];

/* now the handler for the threads */
cyg_handle_t thread_handle;

/* and now variables for the procedure which is the thread */

void
net_test(cyg_addrword_t p);

static struct bootp bootp_info;

void cyg_start(void)
{
    diag_printf("creating thread\n");
    cyg_thread_create(10,
                      net_test,          // entry
                      0,                 // entry parameter
                      "Network test",    // Name
                      &stack,            // Stack
                      STACK_SIZE,        // Size
                      &thread_handle,    // Handle
                      &thread_s          // Thread data structure
            );
    cyg_thread_resume(thread_handle);  // Start it
    cyg_scheduler_start();
}

void
net_test(cyg_addrword_t p)
{
  diag_printf("net_test created\n");

  cyg_thread_delay(5);

  build_bootp_record(&bootp_info,
                     "eth0",
                     "192.128.1.31",
                     "255.255.255.0",
                     "192.168.1.255",
//                     "192.168.1.101"
//                     "192.168.1.101",
                     "0.0.0.0",
                     "0.0.0.0"
                     );

  show_bootp("eth0", &bootp_info);
  diag_printf("called init_net\n");
  init_net("eth0", &bootp_info);
  diag_printf("returned from init_net\n");
  cyg_test_dump_thread_stack_stats("main", thread_handle);
  while (1) ;
}

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]